Remove use of wuffs_base__token__link_prev

This commit is contained in:
Nigel Tao committed 2020-04-09 17:24:39 +10:00
1 parent 478d1b817c
commit 2ef3999d6d
2 files changed
+12 -16

No files matched your search

+8 -5
View File
@@ -838,7 +838,7 @@ handle_unicode_code_point(uint32_t ucp) {
}
const char* //
handle_token(wuffs_base__token t) {
handle_token(wuffs_base__token t, bool start_of_token_chain) {
do {
int64_t vbc = t.value_base_category();
uint64_t vbd = t.value_base_detail();
@@ -888,7 +888,7 @@ handle_token(wuffs_base__token t) {
// Write preceding whitespace and punctuation, if it wasn't ']', '}' or a
// continuation of a multi-token chain.
if (!t.link_prev()) {
if (start_of_token_chain) {
if (g_ctx == context::in_dict_after_key) {
TRY(write_dst(": ", g_flags.compact_output ? 1 : 2));
} else if (g_ctx != context::none) {
@@ -962,7 +962,7 @@ handle_token(wuffs_base__token t) {
return nullptr;
case WUFFS_BASE__TOKEN__VBC__STRING:
if (!t.link_prev()) {
if (start_of_token_chain) {
TRY(write_dst("\"", 1));
g_query.restart_fragment(in_dict_before_key() &&
g_query.is_at(g_depth));
@@ -986,7 +986,7 @@ handle_token(wuffs_base__token t) {
goto after_value;
case WUFFS_BASE__TOKEN__VBC__UNICODE_CODE_POINT:
if (!t.link_prev() || !t.link_next()) {
if (!t.link_next()) {
return "main: internal error: unexpected unlinked token";
}
TRY(handle_unicode_code_point(vbd));
@@ -1033,6 +1033,7 @@ const char* //
main1(int argc, char** argv) {
TRY(initialize_globals(argc, argv));
bool start_of_token_chain = false;
while (true) {
wuffs_base__status status = g_dec.decode_tokens(
&g_tok, &g_src,
@@ -1048,10 +1049,12 @@ main1(int argc, char** argv) {
// Skip filler tokens (e.g. whitespace).
if (t.value() == 0) {
start_of_token_chain = !t.link_next();
continue;
}
const char* z = handle_token(t);
const char* z = handle_token(t, start_of_token_chain);
start_of_token_chain = !t.link_next();
if (z == nullptr) {
continue;
} else if (z == g_eod) {
+4 -11
View File
@@ -85,7 +85,6 @@ typedef uint8_t stack_element;
const char* //
fuzz_one_token(wuffs_base__token t,
wuffs_base__token* prev_token,
wuffs_base__io_buffer* src,
size_t* ti,
stack_element* stack,
@@ -102,11 +101,6 @@ fuzz_one_token(wuffs_base__token t,
return "fuzz: internal error: token high bit was not zero";
}
if (wuffs_base__token__link_next(prev_token) !=
(wuffs_base__token__link_prev(&t))) {
return "fuzz: internal error: inconsistent link bits";
}
int64_t vbc = wuffs_base__token__value_base_category(&t);
uint64_t vbd = wuffs_base__token__value_base_detail(&t);
@@ -290,7 +284,7 @@ fuzz_complex(wuffs_base__io_buffer* full_src, uint32_t hash_24_bits) {
}),
});
wuffs_base__token prev_token = wuffs_base__make_token(0);
wuffs_base__token final_token = wuffs_base__make_token(0);
uint32_t no_progress_count = 0;
stack_element stack[STACK_SIZE];
@@ -335,12 +329,11 @@ fuzz_complex(wuffs_base__io_buffer* full_src, uint32_t hash_24_bits) {
while (tok.meta.ri < tok.meta.wi) { // Inner loop.
wuffs_base__token t = tok.data.ptr[tok.meta.ri++];
const char* z =
fuzz_one_token(t, &prev_token, &src, &ti, &stack[0], &depth);
const char* z = fuzz_one_token(t, &src, &ti, &stack[0], &depth);
if (z != NULL) {
return z;
}
prev_token = t;
final_token = t;
} // Inner loop.
// ----
@@ -375,7 +368,7 @@ fuzz_complex(wuffs_base__io_buffer* full_src, uint32_t hash_24_bits) {
if (depth != 0) {
return "fuzz: internal error: decoded OK but final depth was not zero";
} else if (wuffs_base__token__link_next(&prev_token)) {
} else if (wuffs_base__token__link_next(&final_token)) {
return "fuzz: internal error: decoded OK but final token had link_next";
}
return NULL;