From b1576e2c7737d55340fb64bac3df04dce35bbd12 Mon Sep 17 00:00:00 2001 From: David Given Date: Sat, 31 Dec 2016 19:43:03 +0000 Subject: [PATCH] Add support for negative constants in external initialisers. --- lang/b/compiler/b0.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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))