diff options
| author | 2025-11-22 10:22:37 +0100 | |
|---|---|---|
| committer | 2025-11-22 10:22:37 +0100 | |
| commit | 654dde3b3f2fafddb9139cc53af0633689b1d2b7 (patch) | |
| tree | bea64af651eaf9e730bde8bea4e8b3effd197293 | |
| parent | 79272697e025663d7a4e7972019f318fea8d18bf (diff) | |
lex: move token data from tmp to glob arena when used in a macro body
maybe introduce per-macro arenas to tie their lifetimes to that. but
most macros have global lifetime (i.e. aren't #undef'd) so there
probably wouldn't be much benefit to that
| -rw-r--r-- | c/lex.c | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -561,8 +561,11 @@ Begin: } tmp[n] = 0; tk->len = n; - if (n == lx->chridx - idx) tk->s = (char *)&lx->dat[idx]; - else { + if (n == lx->chridx - idx) { + tk->litlit = 1; + tk->s = (char *)&lx->dat[idx]; + } else { + tk->litlit = 0; tk->s = alloccopy(lx->tmparena, tmp, n, 1); } RET(TKNUMLIT); @@ -890,6 +893,8 @@ ppdefine(struct lexer *lx) continue; } } + if (in_range(tk.t, TKNUMLIT, TKSTRLIT) && !tk.litlit) + tk.s = alloccopy(&globarena, tk.s, tk.len << tk.wide, 1); vpush(&rlist, tk); Next:; } |