aboutsummaryrefslogtreecommitdiffstats
path: root/source/parse.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/parse.cpp')
-rw-r--r--source/parse.cpp31
1 files changed, 20 insertions, 11 deletions
diff --git a/source/parse.cpp b/source/parse.cpp
index 74f7e6a..cebf702 100644
--- a/source/parse.cpp
+++ b/source/parse.cpp
@@ -42,25 +42,34 @@ static void parseword(const char *start, const char *end)
void parseSource()
{
- auto start = (char *)DICT[DIdxSource];
- auto end = start;
+ char *start = nullptr;
+ char *end;
+ char *s;
- // Try to build words while we have input available.
while (haskey()) {
- end = (char *)++DICT[DIdxSource];
+ s = (char *)DICT[DIdxSource];
+
+ ++DICT[DIdxSource];
--DICT[DIdxSrcLen];
- if (isspace(*end)) {
- // May have collected a word.
- // parseword() will check if start != end.
- parseword(start, end);
- start = (char *)(DICT[DIdxSource] + 1);
+ if (isspace(*s)) {
+ if (start) {
+ parseword(start, end + 1);
+ start = nullptr;
+ }
+ } else {
+ if (!start) {
+ start = s;
+ end = start;
+ } else {
+ ++end;
+ }
}
}
// Parse the final word if it is non-empty.
- if (start != end)
- parseword(start, end);
+ if (start)
+ parseword(start, s + 1);
}
void parse()