diff options
| author | 2025-10-15 13:20:11 +0200 | |
|---|---|---|
| committer | 2025-10-15 13:20:11 +0200 | |
| commit | f36fab3c7b730e0226cf91f040bfc58e61cb4825 (patch) | |
| tree | 393676bbac9a184fbfe87a36bf63964a01a5fef0 | |
| parent | 41483dda42f6eb2ce45b0f8580fc46eacf6390b8 (diff) | |
sanity checks
| -rw-r--r-- | c.c | 13 | ||||
| -rw-r--r-- | lex.c | 1 |
2 files changed, 10 insertions, 4 deletions
@@ -29,11 +29,16 @@ lexc(struct comp *cm, struct token *tk) vec_of(char) rest = VINIT(buf, sizeof buf); do { lex(&cm->lx, &tk2); - vpushn(&rest, tk2.s, tk2.len); + if (tk) { + joinspan(&tk->span.ex, tk2.span.ex); + vpushn(&rest, tk2.s, tk2.len); + } } while (peek(cm, NULL) == TKSTRLIT); - tk->s = memcpy(alloc(&cm->exarena, tk->len + rest.n, 0), tk->s, tk->len); - memcpy((char *)tk->s + tk->len, rest.p, rest.n); - tk->len += rest.n; + if (tk) { + tk->s = memcpy(alloc(&cm->exarena, tk->len + rest.n, 0), tk->s, tk->len); + memcpy((char *)tk->s + tk->len, rest.p, rest.n); + tk->len += rest.n; + } vfree(&rest); } return t; @@ -647,6 +647,7 @@ putmac(struct macro *mac) uint h, i, n = arraylength(macroht); struct macro *slot; + assert(mac->name); i = h = ptrhash(mac->name); for (;; ++i) { i &= arraylength(macroht) - 1; |