scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit b390c994ee75e9c45616cfc91bf89d869d228310
parent 9097ba1b790c0387f2d6fc6d3a99ec2b98f97679
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Fri, 22 Sep 2017 12:16:17 +0100

[as] Fix +1 problems in parser

Diffstat:
Mas/expr.c | 7+++----
Mas/parser.c | 3++-
2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/as/expr.c b/as/expr.c @@ -175,7 +175,7 @@ iden(void) int c; char *p; - for (endp = textp; isalnum(c = *endp) || c == '_' || c == '.'; ++endp) + for (endp = textp+1; isalnum(c = *endp) || c == '_' || c == '.'; ++endp) /* nothing */; tok2str(); yylval.sym = lookup(yytext); @@ -189,7 +189,7 @@ number(void) int c; char *p; - for (endp = textp; isxdigit(*endp); ++endp) + for (endp = textp+1; isxdigit(*endp); ++endp) /* nothing */; tok2str(); yylval.sym = tmpsym(atoi(yytext)); /* TODO: parse the string */ @@ -239,9 +239,8 @@ next(void) c = character(); else if (c == '\"') c = string(); - tok2str(); - return c; + return yytoken = c; } static void diff --git a/as/parser.c b/as/parser.c @@ -53,8 +53,9 @@ getargs(char *s) for (t = s; *s && *s != ','; s++) /* nothing */; - *s++ = '\0'; len = t - s; + if (*s != '\0') + *s++ = '\0'; if (len == 0) error("wrong operand '%s'", t); }