aboutsummaryrefslogtreecommitdiffstats
path: root/parser.cpp
diff options
context:
space:
mode:
authorClyne Sullivan <clyne@bitgloo.com>2023-02-17 11:14:40 -0500
committerClyne Sullivan <clyne@bitgloo.com>2023-02-17 11:14:40 -0500
commit12cb6b9e5607e9db2255afd977814cbb0e3fceae (patch)
treecd39976a2dda02d2e7d65e785dfb32e82449fd85 /parser.cpp
parent24a61f3c99125c97ca79ea173c959d7bd89f1a48 (diff)
fix bad word detection
Diffstat (limited to 'parser.cpp')
-rw-r--r--parser.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/parser.cpp b/parser.cpp
index b4c2d1c..b44547f 100644
--- a/parser.cpp
+++ b/parser.cpp
@@ -74,15 +74,16 @@ ParseStatus Parser::parseWord(State& state, Word word)
state.execute(e);
}
} else {
- char buf[word.size()];
+ char buf[word.size() + 1];
for (unsigned i = 0; i < word.size(); ++i)
buf[i] = state.dict.readbyte(word.start + i);
+ buf[word.size()] = '\0';
char *p;
const auto base = state.dict.read(0);
const Cell l = std::strtol(buf, &p, base);
- if (p != buf) {
+ if (std::distance(buf, p) == word.size()) {
if (state.compiling()) {
state.dict.add(CoreWords::HiddenWordLiteral);
state.dict.add(l);