From: David Given Date: Sat, 31 Dec 2016 19:43:03 +0000 (+0000) Subject: Add support for negative constants in external initialisers. X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=b1576e2c7737d55340fb64bac3df04dce35bbd12;p=ack.git Add support for negative constants in external initialisers. --- diff --git a/lang/b/compiler/b0.c b/lang/b/compiler/b0.c index 03123ecdd..e6845bea0 100644 --- a/lang/b/compiler/b0.c +++ b/lang/b/compiler/b0.c @@ -373,7 +373,15 @@ loop: return subseq(c,PLUS,INCBEF); case MINUS: - return subseq(c,MINUS,DECBEF); + /* avoid peeking a name, which could overwrite + * an already set bsym. */ + if (ctab[peekc = spnextchar()] == DIGIT) { + getnum(); + cval = -cval; + return CON; + } else { + return subseq(c,MINUS,DECBEF); + } case LESS: if (subseq(c,0,1))