ref: 260d1eaaa73a377fb7b0cfc00707ddba35a54ccd
parent: 15a32f06839819cbbf6f40dccc5189c66379bcc0
author: Ori Bernstein <ori@eigenstate.org>
date: Sun Apr 19 07:26:31 EDT 2020
Make priority array max size explicit. we were implicitly depending on UMINUS being the last entry in the operator table -- that's fragile.
--- a/sys/src/cmd/cpp/cpp.h
+++ b/sys/src/cmd/cpp/cpp.h
@@ -17,7 +17,7 @@
COLON, ASGN, COMMA, XCOMMA, SHARP, SEMIC, CBRA, CKET,
ASPLUS, ASMINUS, ASSTAR, ASSLASH, ASPCT, ASCIRC, ASLSH,
ASRSH, ASOR, ASAND, ELLIPS,
- DSHARP1, NAME1, DEFINED, UMINUS };
+ DSHARP1, NAME1, DEFINED, UMINUS, MAXTOK};
enum kwtype { KIF, KIFDEF, KIFNDEF, KELIF, KELSE, KENDIF, KINCLUDE, KDEFINE,
KUNDEF, KLINE, KERROR, KWARNING, KPRAGMA, KDEFINED,
--- a/sys/src/cmd/cpp/eval.c
+++ b/sys/src/cmd/cpp/eval.c
@@ -31,7 +31,7 @@
char assoc;
char arity;
char ctype;
-} priority[] = {
+} priority[MAXTOK] = {
[END] { 0, 0, 0, 0 },
[EQ] { 11, 0, 2, RELAT },
[NEQ] { 11, 0, 2, RELAT },