diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2020-04-25 22:16:44 +0200 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2020-04-25 22:16:44 +0200 |
commit | 7feab4dc5913c8d072d57e9cc7cc7b3815037fe8 (patch) | |
tree | 62b834b7657d63cdd85d984d15474c20101148ef /sys/src/cmd/cc/lex.c | |
parent | 4adb1d68d1a958c2ee3c5cfe2e26968e13dcfc1b (diff) |
cc: simplify macexpand() and off-by-one error
the caller of macexpand() needs one more byte in
the buffer to append peekc.
make macexpand() actually check for buffer overflow.
just use strdup() to duplicate include file name
instead of the hunk dance.
move GETC() macro in cc.h
Diffstat (limited to 'sys/src/cmd/cc/lex.c')
-rw-r--r-- | sys/src/cmd/cc/lex.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/sys/src/cmd/cc/lex.c b/sys/src/cmd/cc/lex.c index 73d994968..7c22cb464 100644 --- a/sys/src/cmd/cc/lex.c +++ b/sys/src/cmd/cc/lex.c @@ -430,7 +430,6 @@ syminit(Sym *s) #define EOF (-1) #define IGN (-2) #define ESC (1<<20) -#define GETC() ((--fi.c < 0)? filbuf(): (*fi.p++ & 0xff)) enum { @@ -756,7 +755,7 @@ talph: if(s->macro) { newio(); cp = ionext->b; - macexpand(s, cp, sizeof(ionext->b)); + macexpand(s, cp, sizeof(ionext->b)-1); pushio(); ionext->link = iostack; iostack = ionext; |