Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f0a338f164 |
+19
-9
@@ -139,7 +139,8 @@ struct Parser3 {
|
||||
stackPtr = stack();
|
||||
std::ignore = push({N_VALUE, N_WHITESPACE, T_EOF});
|
||||
inKey = false;
|
||||
terminalStatus = WeaselJson_OK;
|
||||
rejected = false;
|
||||
overflowed = false;
|
||||
utf8Codepoint = 0;
|
||||
utf16Surrogate = 0;
|
||||
minCodepoint = 0;
|
||||
@@ -162,7 +163,8 @@ struct Parser3 {
|
||||
NumDfa numDfa;
|
||||
Utf8Dfa strDfa;
|
||||
bool inKey = false;
|
||||
WeaselJsonStatus terminalStatus = WeaselJson_OK;
|
||||
bool rejected = false;
|
||||
bool overflowed = false;
|
||||
|
||||
#ifndef HAS_MUSTTAIL
|
||||
char *stashBufForTrampoline;
|
||||
@@ -1070,12 +1072,16 @@ constexpr inline struct ContinuationTable {
|
||||
inline WeaselJsonStatus Parser3::parse(char *buf, int len) {
|
||||
this->dataBegin = this->writeBuf = buf;
|
||||
|
||||
if (this->terminalStatus != WeaselJson_OK) [[unlikely]] {
|
||||
return this->terminalStatus;
|
||||
if (this->rejected) [[unlikely]] {
|
||||
return WeaselJson_REJECT;
|
||||
}
|
||||
|
||||
if (this->overflowed) [[unlikely]] {
|
||||
return WeaselJson_OVERFLOW;
|
||||
}
|
||||
|
||||
if (len < 0) [[unlikely]] {
|
||||
this->terminalStatus = WeaselJson_REJECT;
|
||||
this->rejected = true;
|
||||
return WeaselJson_REJECT;
|
||||
}
|
||||
|
||||
@@ -1085,8 +1091,10 @@ inline WeaselJsonStatus Parser3::parse(char *buf, int len) {
|
||||
// range.
|
||||
ContinuationStatus status =
|
||||
symbolTables.continuations[top()](this, buf, buf + len);
|
||||
if (status == WeaselJson_REJECT || status == WeaselJson_OVERFLOW) {
|
||||
this->terminalStatus = WeaselJsonStatus(status);
|
||||
if (status == WeaselJson_REJECT) {
|
||||
this->rejected = true;
|
||||
} else if (status == WeaselJson_OVERFLOW) {
|
||||
this->overflowed = true;
|
||||
}
|
||||
return WeaselJsonStatus(status);
|
||||
#else
|
||||
@@ -1095,8 +1103,10 @@ inline WeaselJsonStatus Parser3::parse(char *buf, int len) {
|
||||
while ((result = symbolTables.continuations[top()](
|
||||
this, stashBufForTrampoline, buf + len)) == kBounce)
|
||||
;
|
||||
if (result == WeaselJson_REJECT || result == WeaselJson_OVERFLOW) {
|
||||
this->terminalStatus = WeaselJsonStatus(result);
|
||||
if (result == WeaselJson_REJECT) {
|
||||
this->rejected = true;
|
||||
} else if (result == WeaselJson_OVERFLOW) {
|
||||
this->overflowed = true;
|
||||
}
|
||||
return WeaselJsonStatus(result);
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user