ref: e4a2c5ccce08cc186506cfbd6a7597b10ac957a8
parent: 1652b5cdb44fafba4c8343b993b0c5fd54923e16
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Sun Sep 24 04:33:17 EDT 2017
[as] Fix end of string test in expr()
--- a/as/expr.c
+++ b/as/expr.c
@@ -11,6 +11,7 @@
#define NNODES 10
enum tokens {
+ EOS = -1,
IDEN = 1,
NUMBER,
REG,
@@ -244,21 +245,20 @@
endp = textp;
if ((c = *textp) == '\0') {
- strcpy(yytext, "EOF");
+ strcpy(yytext, "EOS");
yylen = 3;
- return EOF;
- }
-
- if (isalpha(c) || c == '_' || c == '.')
+ c = EOS;
+ } else if (isalpha(c) || c == '_' || c == '.') {
c = iden();
- else if (isdigit(c))
+ } else if (isdigit(c)) {
c = number();
- else if (c == '\"')
+ } else if (c == '\"') {
c = string();
- else if (c == '\'')
+ } else if (c == '\'') {
c = character();
- else
+ } else {
c = operator();
+ }
return yytoken = c;
}
@@ -422,15 +422,15 @@
{
Node *np;
- if (*s == '\0')
+ textp = *s;
+ if (*textp == '\0')
return NULL;
- textp = *s;
next();
np = or();
- if (yytoken != ',' && yytoken != EOF)
- error("trailing characters in expression '%s:%s'", *s, textp);
+ if (yytoken != ',' && yytoken != EOS)
+ error("trailing characters in expression '%s'", textp);
*s = endp;
return np;