ref: 44d7ee0f42a108bf8304cade628bb37fbbe806ef
parent: 4ed832ac9312fdfae3dec4fceb3eb657b2687567
author: Roberto E. Vargas Caballero <[email protected]>
date: Fri Sep 22 08:16:17 EDT 2017
[as] Fix +1 problems in parser
--- a/as/expr.c
+++ b/as/expr.c
@@ -175,7 +175,7 @@
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 @@
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 @@
c = character();
else if (c == '\"')
c = string();
- tok2str();
- return c;
+ return yytoken = c;
}
static void
--- a/as/parser.c
+++ b/as/parser.c
@@ -53,8 +53,9 @@
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);
}