summaryrefslogtreecommitdiff
path: root/sys/src/cmd/dtracy
diff options
context:
space:
mode:
authoraiju <devnull@localhost>2018-12-08 18:04:25 +0000
committeraiju <devnull@localhost>2018-12-08 18:04:25 +0000
commitb96be173766c58ccfcc3abc84bd751ba000be838 (patch)
tree2e2c92d7572e3219ce9d1c14f853b36570a56c5f /sys/src/cmd/dtracy
parent722a1a33347c759c797da9f889ceaed304092aff (diff)
dtracy: fix lexer bug
Diffstat (limited to 'sys/src/cmd/dtracy')
-rw-r--r--sys/src/cmd/dtracy/lex.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/sys/src/cmd/dtracy/lex.c b/sys/src/cmd/dtracy/lex.c
index 15a959ffa..c820f145c 100644
--- 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 @@ void
lexstring(char *s)
{
str = strp = s;
+ stre = str + strlen(str);
}
void
@@ -88,7 +89,10 @@ yyerror(char *msg)
static int
getch(void)
{
- if(*strp == 0) return -1;
+ if(strp >= stre){
+ strp++;
+ return -1;
+ }
return *strp++;
}
@@ -96,8 +100,7 @@ static void
ungetch(void)
{
assert(strp > str);
- if(*strp != 0)
- strp--;
+ strp--;
}
int