diff options
| author | Nakidai <nakidai@disroot.org> | 2026-04-22 15:49:57 +0300 |
|---|---|---|
| committer | Nakidai <nakidai@disroot.org> | 2026-04-22 15:49:57 +0300 |
| commit | 956b50a00167ed073375e0213e022ea0fb177309 (patch) | |
| tree | cee4e73d77cb28558c8fe021c21e5b5fba4cbf32 | |
| parent | 9a7cce615632e47d2ba4e6be3a4ffdb4266ab602 (diff) | |
| download | thac-956b50a00167ed073375e0213e022ea0fb177309.tar.gz thac-956b50a00167ed073375e0213e022ea0fb177309.zip | |
Remove storage from lex.c
There's no point in holding curtok somewhere as the maximum supported amount of ungettok() calls is 1
| -rw-r--r-- | lex.c | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/lex.c b/lex.c index 29b56f0..7c17b33 100644 --- a/lex.c +++ b/lex.c @@ -23,7 +23,6 @@ #include <string.h> -static struct tok storage; struct tok curtok; static int isunget; ulong curline; @@ -220,16 +219,14 @@ gettok(void) { int ch; - curtok.info = (struct tinfo){NULL, 0, 0}; - if (isunget) { isunget = 0; - curtok = storage; - /*say("reread %s(`%s')", tokname(curtok.type), curtok.info.p)*/; return curtok.type; } + curtok.info = (struct tinfo){NULL, 0, 0}; + for (; (ch = get()) != EOF; curtok.info.len = 0) if (!isspace(ch)) goto found; @@ -242,14 +239,12 @@ found: else oper(); - /*say("read %s(`%s')", tokname(curtok.type), curtok.info.p)*/; return curtok.type; } void ungettok() { - storage = curtok; isunget = 1; } |