ref: f06e3c5b844503328f6f214c522a77c9dc737074
parent: c348854f6e02bc13f11245582bbd05ea2597fd9b
author: aiju <devnull@localhost>
date: Sat Dec 8 13:04:25 EST 2018
dtracy: fix lexer bug
--- a/sys/src/cmd/dtracy/lex.c
+++ b/sys/src/cmd/dtracy/lex.c
@@ -7,7 +7,7 @@
#include "fns.h"
#include "y.tab.h"
-char *str, *strp;
+char *str, *strp, *stre;
int lineno = 1;
int errors;
@@ -60,6 +60,7 @@
lexstring(char *s)
{str = strp = s;
+ stre = str + strlen(str);
}
void
@@ -88,7 +89,10 @@
static int
getch(void)
{- if(*strp == 0) return -1;
+ if(strp >= stre){+ strp++;
+ return -1;
+ }
return *strp++;
}
@@ -96,8 +100,7 @@
ungetch(void)
{assert(strp > str);
- if(*strp != 0)
- strp--;
+ strp--;
}
int
--
⑨