Add test/data/json-quirks.json
diff --git a/script/print-json-token-debug-format.c b/script/print-json-token-debug-format.c
index 7d4827f..7e5001a 100644
--- a/script/print-json-token-debug-format.c
+++ b/script/print-json-token-debug-format.c
@@ -139,6 +139,7 @@
bool all_tokens;
bool human_readable;
+ bool quirks;
} flags = {0};
const char* //
@@ -171,6 +172,10 @@
flags.human_readable = true;
continue;
}
+ if (!strcmp(arg, "q") || !strcmp(arg, "quirks")) {
+ flags.quirks = true;
+ continue;
+ }
return "main: unrecognized flag argument";
}
@@ -218,6 +223,32 @@
return wuffs_base__status__message(&init_status);
}
+ if (flags.quirks) {
+ uint32_t quirks[] = {
+ WUFFS_JSON__QUIRK_ALLOW_BACKSLASH_A,
+ WUFFS_JSON__QUIRK_ALLOW_BACKSLASH_CAPITAL_U,
+ WUFFS_JSON__QUIRK_ALLOW_BACKSLASH_E,
+ WUFFS_JSON__QUIRK_ALLOW_BACKSLASH_QUESTION_MARK,
+ WUFFS_JSON__QUIRK_ALLOW_BACKSLASH_SINGLE_QUOTE,
+ WUFFS_JSON__QUIRK_ALLOW_BACKSLASH_V,
+ WUFFS_JSON__QUIRK_ALLOW_BACKSLASH_X,
+ WUFFS_JSON__QUIRK_ALLOW_BACKSLASH_ZERO,
+ WUFFS_JSON__QUIRK_ALLOW_COMMENT_BLOCK,
+ WUFFS_JSON__QUIRK_ALLOW_COMMENT_LINE,
+ WUFFS_JSON__QUIRK_ALLOW_EXTRA_COMMA,
+ WUFFS_JSON__QUIRK_ALLOW_INF_NAN_NUMBERS,
+ WUFFS_JSON__QUIRK_ALLOW_LEADING_ASCII_RECORD_SEPARATOR,
+ WUFFS_JSON__QUIRK_ALLOW_LEADING_UNICODE_BYTE_ORDER_MARK,
+ WUFFS_JSON__QUIRK_ALLOW_TRAILING_NEW_LINE,
+ WUFFS_JSON__QUIRK_REPLACE_INVALID_UTF_8,
+ 0,
+ };
+ uint32_t i;
+ for (i = 0; quirks[i]; i++) {
+ wuffs_json__decoder__set_quirk_enabled(&dec, quirks[i], true);
+ }
+ }
+
uint64_t pos = 0;
while (true) {
wuffs_base__status status =