diff --git a/release/c/wuffs-unsupported-snapshot.c b/release/c/wuffs-unsupported-snapshot.c index bd4ff6b9..678d6f78 100644 --- a/release/c/wuffs-unsupported-snapshot.c +++ b/release/c/wuffs-unsupported-snapshot.c @@ -6048,37 +6048,37 @@ extern const char* wuffs_json__error__unsupported_recursion_depth; #define WUFFS_JSON__DECODER_SRC_IO_BUFFER_LENGTH_MIN_INCL 100 -#define WUFFS_JSON__QUIRK_ALLOW_BACKSLASH_A 1225364480 +#define WUFFS_JSON__QUIRK_ALLOW_BACKSLASH_A 1225364481 -#define WUFFS_JSON__QUIRK_ALLOW_BACKSLASH_CAPITAL_U 1225364481 +#define WUFFS_JSON__QUIRK_ALLOW_BACKSLASH_CAPITAL_U 1225364482 -#define WUFFS_JSON__QUIRK_ALLOW_BACKSLASH_E 1225364482 +#define WUFFS_JSON__QUIRK_ALLOW_BACKSLASH_E 1225364483 -#define WUFFS_JSON__QUIRK_ALLOW_BACKSLASH_QUESTION_MARK 1225364483 +#define WUFFS_JSON__QUIRK_ALLOW_BACKSLASH_QUESTION_MARK 1225364485 -#define WUFFS_JSON__QUIRK_ALLOW_BACKSLASH_SINGLE_QUOTE 1225364484 +#define WUFFS_JSON__QUIRK_ALLOW_BACKSLASH_SINGLE_QUOTE 1225364486 -#define WUFFS_JSON__QUIRK_ALLOW_BACKSLASH_V 1225364485 +#define WUFFS_JSON__QUIRK_ALLOW_BACKSLASH_V 1225364487 -#define WUFFS_JSON__QUIRK_ALLOW_BACKSLASH_X 1225364486 +#define WUFFS_JSON__QUIRK_ALLOW_BACKSLASH_X 1225364488 -#define WUFFS_JSON__QUIRK_ALLOW_BACKSLASH_ZERO 1225364487 +#define WUFFS_JSON__QUIRK_ALLOW_BACKSLASH_ZERO 1225364489 -#define WUFFS_JSON__QUIRK_ALLOW_COMMENT_BLOCK 1225364488 +#define WUFFS_JSON__QUIRK_ALLOW_COMMENT_BLOCK 1225364490 -#define WUFFS_JSON__QUIRK_ALLOW_COMMENT_LINE 1225364489 +#define WUFFS_JSON__QUIRK_ALLOW_COMMENT_LINE 1225364491 -#define WUFFS_JSON__QUIRK_ALLOW_EXTRA_COMMA 1225364490 +#define WUFFS_JSON__QUIRK_ALLOW_EXTRA_COMMA 1225364492 -#define WUFFS_JSON__QUIRK_ALLOW_INF_NAN_NUMBERS 1225364491 +#define WUFFS_JSON__QUIRK_ALLOW_INF_NAN_NUMBERS 1225364493 -#define WUFFS_JSON__QUIRK_ALLOW_LEADING_ASCII_RECORD_SEPARATOR 1225364492 +#define WUFFS_JSON__QUIRK_ALLOW_LEADING_ASCII_RECORD_SEPARATOR 1225364494 -#define WUFFS_JSON__QUIRK_ALLOW_LEADING_UNICODE_BYTE_ORDER_MARK 1225364493 +#define WUFFS_JSON__QUIRK_ALLOW_LEADING_UNICODE_BYTE_ORDER_MARK 1225364495 -#define WUFFS_JSON__QUIRK_ALLOW_TRAILING_NEW_LINE 1225364494 +#define WUFFS_JSON__QUIRK_ALLOW_TRAILING_NEW_LINE 1225364496 -#define WUFFS_JSON__QUIRK_REPLACE_INVALID_UNICODE 1225364495 +#define WUFFS_JSON__QUIRK_REPLACE_INVALID_UNICODE 1225364497 // ---------------- Struct Declarations @@ -20815,13 +20815,13 @@ const char* wuffs_json__error__internal_error_inconsistent_i_o = static const uint8_t // wuffs_json__lut_backslashes[256] // WUFFS_BASE__POTENTIALLY_UNUSED = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 162, 0, 0, 0, - 0, 4, 0, 0, 0, 0, 0, 0, 0, 175, 6, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 5, 0, 0, 0, 0, 0, 0, 0, 175, 7, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 220, 0, 0, 0, 0, 1, 136, 0, 0, 2, 140, 0, 0, 0, 0, 0, 0, 0, 138, 0, 0, 0, - 141, 0, 137, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 141, 0, 137, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -20834,7 +20834,7 @@ static const uint8_t // static const uint8_t // wuffs_json__lut_quirky_backslashes[8] // WUFFS_BASE__POTENTIALLY_UNUSED = { - 0, 7, 27, 63, 39, 11, 0, 0, + 0, 7, 27, 10, 63, 39, 11, 0, }; static const uint8_t // @@ -21039,39 +21039,39 @@ wuffs_json__decoder__set_quirk_enabled(wuffs_json__decoder* self, return wuffs_base__make_empty_struct(); } - if (a_quirk == 1225364480) { + if (a_quirk == 1225364481) { self->private_impl.f_quirk_enabled_allow_backslash_etc[1] = a_enabled; - } else if (a_quirk == 1225364481) { - self->private_impl.f_quirk_enabled_allow_backslash_capital_u = a_enabled; } else if (a_quirk == 1225364482) { - self->private_impl.f_quirk_enabled_allow_backslash_etc[2] = a_enabled; + self->private_impl.f_quirk_enabled_allow_backslash_capital_u = a_enabled; } else if (a_quirk == 1225364483) { - self->private_impl.f_quirk_enabled_allow_backslash_etc[3] = a_enabled; - } else if (a_quirk == 1225364484) { - self->private_impl.f_quirk_enabled_allow_backslash_etc[4] = a_enabled; + self->private_impl.f_quirk_enabled_allow_backslash_etc[2] = a_enabled; } else if (a_quirk == 1225364485) { - self->private_impl.f_quirk_enabled_allow_backslash_etc[5] = a_enabled; + self->private_impl.f_quirk_enabled_allow_backslash_etc[4] = a_enabled; } else if (a_quirk == 1225364486) { - self->private_impl.f_quirk_enabled_allow_backslash_x = a_enabled; + self->private_impl.f_quirk_enabled_allow_backslash_etc[5] = a_enabled; } else if (a_quirk == 1225364487) { self->private_impl.f_quirk_enabled_allow_backslash_etc[6] = a_enabled; } else if (a_quirk == 1225364488) { - self->private_impl.f_quirk_enabled_allow_comment_block = a_enabled; + self->private_impl.f_quirk_enabled_allow_backslash_x = a_enabled; } else if (a_quirk == 1225364489) { - self->private_impl.f_quirk_enabled_allow_comment_line = a_enabled; + self->private_impl.f_quirk_enabled_allow_backslash_etc[7] = a_enabled; } else if (a_quirk == 1225364490) { - self->private_impl.f_quirk_enabled_allow_extra_comma = a_enabled; + self->private_impl.f_quirk_enabled_allow_comment_block = a_enabled; } else if (a_quirk == 1225364491) { - self->private_impl.f_quirk_enabled_allow_inf_nan_numbers = a_enabled; + self->private_impl.f_quirk_enabled_allow_comment_line = a_enabled; } else if (a_quirk == 1225364492) { + self->private_impl.f_quirk_enabled_allow_extra_comma = a_enabled; + } else if (a_quirk == 1225364493) { + self->private_impl.f_quirk_enabled_allow_inf_nan_numbers = a_enabled; + } else if (a_quirk == 1225364494) { self->private_impl.f_quirk_enabled_allow_leading_ascii_record_separator = a_enabled; - } else if (a_quirk == 1225364493) { + } else if (a_quirk == 1225364495) { self->private_impl.f_quirk_enabled_allow_leading_unicode_byte_order_mark = a_enabled; - } else if (a_quirk == 1225364494) { + } else if (a_quirk == 1225364496) { self->private_impl.f_quirk_enabled_allow_trailing_new_line = a_enabled; - } else if (a_quirk == 1225364495) { + } else if (a_quirk == 1225364497) { self->private_impl.f_quirk_enabled_replace_invalid_unicode = a_enabled; } return wuffs_base__make_empty_struct(); diff --git a/std/json/common_consts.wuffs b/std/json/common_consts.wuffs index 10c7efe6..1beeae96 100644 --- a/std/json/common_consts.wuffs +++ b/std/json/common_consts.wuffs @@ -68,10 +68,11 @@ pri const decoder_number_length_max_incl base.u64 = 99 // validity depends on the relevant quirk. The element's value is an enum: // - 1: "\a", U+0007, quirk_allow_backslash_a. // - 2: "\e", U+001B, quirk_allow_backslash_e. -// - 3: "\?", U+003F, quirk_allow_backslash_question_mark. -// - 4: "\'", U+0027, quirk_allow_backslash_single_quote. -// - 5: "\v", U+000B, quirk_allow_backslash_v. -// - 6: "\0", U+0000, quirk_allow_backslash_zero. +// - 3: "backslash new_line(not_n)", U+000A, quirk_allow_backslash_new_line. +// - 4: "\?", U+003F, quirk_allow_backslash_question_mark. +// - 5: "\'", U+0027, quirk_allow_backslash_single_quote. +// - 6: "\v", U+000B, quirk_allow_backslash_v. +// - 7: "\0", U+0000, quirk_allow_backslash_zero. // The U+1234 values are held in lut_quirky_backslashes, below. // // If the element is zero then "\i" is invalid, or it is a special case, the @@ -80,13 +81,13 @@ pri const lut_backslashes array[256] base.u8 = [ // 0 1 2 3 4 5 6 7 // 8 9 A B C D E F 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x00 ..= 0x07. - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x08 ..= 0x0F. + 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x08 ..= 0x0F. '\n'. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x10 ..= 0x17. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x18 ..= 0x1F. - 0x00, 0x00, 0xA2, 0x00, 0x00, 0x00, 0x00, 0x04, // 0x20 ..= 0x27. '"', '\''. + 0x00, 0x00, 0xA2, 0x00, 0x00, 0x00, 0x00, 0x05, // 0x20 ..= 0x27. '"', '\''. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xAF, // 0x28 ..= 0x2F. '/'. - 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x30 ..= 0x37. '0'. - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, // 0x38 ..= 0x3F. '?' + 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x30 ..= 0x37. '0'. + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, // 0x38 ..= 0x3F. '?' 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x40 ..= 0x47. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x48 ..= 0x4F. @@ -94,7 +95,7 @@ pri const lut_backslashes array[256] base.u8 = [ 0x00, 0x00, 0x00, 0x00, 0xDC, 0x00, 0x00, 0x00, // 0x58 ..= 0x5F. '\\'. 0x00, 0x01, 0x88, 0x00, 0x00, 0x02, 0x8C, 0x00, // 0x60 ..= 0x67. 'a', 'b', 'e', 'f'. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8A, 0x00, // 0x68 ..= 0x6F. 'n'. - 0x00, 0x00, 0x8D, 0x00, 0x89, 0x00, 0x05, 0x00, // 0x70 ..= 0x77. 'r', 't', 'v'. + 0x00, 0x00, 0x8D, 0x00, 0x89, 0x00, 0x06, 0x00, // 0x70 ..= 0x77. 'r', 't', 'v'. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x78 ..= 0x7F. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x80 ..= 0x87. @@ -119,10 +120,10 @@ pri const lut_backslashes array[256] base.u8 = [ ] // lut_quirky_backslashes is discussed in the lut_backslashes comment. The -// first and last elements (indexes 0 and 7) are not used, but 8 is a round -// power of 2, so enforcing index-in-bounds is a simple "&7" operation. +// first element (index 0) is not used, but 8 is a round power of 2, so +// enforcing index-in-bounds is a simple "&7" operation. pri const lut_quirky_backslashes array[8] base.u8 = [ - 0x00, 0x07, 0x1B, 0x3F, 0x27, 0x0B, 0x00, 0x00, + 0x00, 0x07, 0x1B, 0x0A, 0x3F, 0x27, 0x0B, 0x00, ] // lut_chars helps decode bytes within a string: diff --git a/std/json/decode_json.wuffs b/std/json/decode_json.wuffs index c69bfc4f..b8ea3582 100644 --- a/std/json/decode_json.wuffs +++ b/std/json/decode_json.wuffs @@ -74,15 +74,15 @@ pub func decoder.set_quirk_enabled!(quirk: base.u32, enabled: base.bool) { } else if args.quirk == quirk_allow_backslash_e { this.quirk_enabled_allow_backslash_etc[2] = args.enabled } else if args.quirk == quirk_allow_backslash_question_mark { - this.quirk_enabled_allow_backslash_etc[3] = args.enabled - } else if args.quirk == quirk_allow_backslash_single_quote { this.quirk_enabled_allow_backslash_etc[4] = args.enabled - } else if args.quirk == quirk_allow_backslash_v { + } else if args.quirk == quirk_allow_backslash_single_quote { this.quirk_enabled_allow_backslash_etc[5] = args.enabled + } else if args.quirk == quirk_allow_backslash_v { + this.quirk_enabled_allow_backslash_etc[6] = args.enabled } else if args.quirk == quirk_allow_backslash_x { this.quirk_enabled_allow_backslash_x = args.enabled } else if args.quirk == quirk_allow_backslash_zero { - this.quirk_enabled_allow_backslash_etc[6] = args.enabled + this.quirk_enabled_allow_backslash_etc[7] = args.enabled } else if args.quirk == quirk_allow_comment_block { this.quirk_enabled_allow_comment_block = args.enabled } else if args.quirk == quirk_allow_comment_line { diff --git a/std/json/decode_quirks.wuffs b/std/json/decode_quirks.wuffs index e8eee139..ec000c0e 100644 --- a/std/json/decode_quirks.wuffs +++ b/std/json/decode_quirks.wuffs @@ -23,31 +23,31 @@ // When this quirk is enabled, e.g. "abc\az" is accepted as a JSON string, // equivalent to "abc\u0007z", containing an ASCII Bell control character. -pub const quirk_allow_backslash_a base.u32 = 0x4909_9400 | 0x00 +pub const quirk_allow_backslash_a base.u32 = 0x4909_9400 | 0x01 // When this quirk is enabled, e.g. "abc\U0001F4A9z" is accepted as a JSON // string, equivalent to "abc\uD83D\uDCA9z", containing the U+0001F4A9 PILE OF // POO Unicode code point. There are exactly 8 encoded bytes after each "\U". // // This quirk can combine with quirk_replace_invalid_unicode. -pub const quirk_allow_backslash_capital_u base.u32 = 0x4909_9400 | 0x01 +pub const quirk_allow_backslash_capital_u base.u32 = 0x4909_9400 | 0x02 // When this quirk is enabled, e.g. "abc\ez" is accepted as a JSON string, // equivalent to "abc\u001Bz", containing an ASCII Escape control character. -pub const quirk_allow_backslash_e base.u32 = 0x4909_9400 | 0x02 +pub const quirk_allow_backslash_e base.u32 = 0x4909_9400 | 0x03 // When this quirk is enabled, e.g. "abc\?z" is accepted as a JSON string, // equivalent to "abc?z". -pub const quirk_allow_backslash_question_mark base.u32 = 0x4909_9400 | 0x03 +pub const quirk_allow_backslash_question_mark base.u32 = 0x4909_9400 | 0x05 // When this quirk is enabled, e.g. "abc\'z" is accepted as a JSON string, // equivalent to "abc'z". -pub const quirk_allow_backslash_single_quote base.u32 = 0x4909_9400 | 0x04 +pub const quirk_allow_backslash_single_quote base.u32 = 0x4909_9400 | 0x06 // When this quirk is enabled, e.g. "abc\vz" is accepted as a JSON string, // equivalent to "abc\u000Bz", containing an ASCII Vertical Tab control // character. -pub const quirk_allow_backslash_v base.u32 = 0x4909_9400 | 0x05 +pub const quirk_allow_backslash_v base.u32 = 0x4909_9400 | 0x07 // When this quirk is enabled, e.g. "abc\xeFz" is accepted as a JSON string, // decoding to 5 bytes: 0x61, 0x62, 0x63, 0xEF and 0x7A. There are exactly 2 @@ -58,11 +58,11 @@ pub const quirk_allow_backslash_v base.u32 = 0x4909_9400 | 0x05 // guaranteed to split on UTF-8 boundaries. // // "\x", "\x9", "\x9$" and "\X99" are all still rejected. -pub const quirk_allow_backslash_x base.u32 = 0x4909_9400 | 0x06 +pub const quirk_allow_backslash_x base.u32 = 0x4909_9400 | 0x08 // When this quirk is enabled, e.g. "abc\0z" is accepted as a JSON string, // equivalent to "abc\u0000z", containing an ASCII NUL control character. -pub const quirk_allow_backslash_zero base.u32 = 0x4909_9400 | 0x07 +pub const quirk_allow_backslash_zero base.u32 = 0x4909_9400 | 0x09 // When this quirk is enabled, "/* C/C++ style block comments */" are accepted // anywhere whitespace would be, although see the quirk_allow_trailing_new_line @@ -70,7 +70,7 @@ pub const quirk_allow_backslash_zero base.u32 = 0x4909_9400 | 0x07 // // They produce WUFFS_BASE__TOKEN__VBD__FILLER__COMMENT_BLOCK tokens. The token // chain's source bytes includes the starting "/*" and the ending "*/". -pub const quirk_allow_comment_block base.u32 = 0x4909_9400 | 0x08 +pub const quirk_allow_comment_block base.u32 = 0x4909_9400 | 0x0A // When this quirk is enabled, "// C/C++ style line comments\n" are accepted // anywhere whitespace would be, although see the quirk_allow_trailing_new_line @@ -85,7 +85,7 @@ pub const quirk_allow_comment_block base.u32 = 0x4909_9400 | 0x08 // Even if the line comments are on consecutive lines, each line comment is a // separate token chain. There may be whitespace tokens between one line // comment's ending "\n" and the next one's starting "//". -pub const quirk_allow_comment_line base.u32 = 0x4909_9400 | 0x09 +pub const quirk_allow_comment_line base.u32 = 0x4909_9400 | 0x0B // When this quirk is enabled, there may be a comma after the final array // element or object key-value pair and before the closing "]" or "}". A comma @@ -94,12 +94,12 @@ pub const quirk_allow_comment_line base.u32 = 0x4909_9400 | 0x09 // // For example, `[1,]`, `[1,2,3,]` and `{"k":"v",}` all become acceptable, but // `[,]`, `{,}` and `{"k",:"v"}` are still rejected. -pub const quirk_allow_extra_comma base.u32 = 0x4909_9400 | 0x0A +pub const quirk_allow_extra_comma base.u32 = 0x4909_9400 | 0x0C // When this quirk is enabled, "inf", "Infinity", "NAN" and their // case-insensitive variants, optionally preceded immediately by "-" or "+", // are accepted anywhere a JSON number would be. -pub const quirk_allow_inf_nan_numbers base.u32 = 0x4909_9400 | 0x0B +pub const quirk_allow_inf_nan_numbers base.u32 = 0x4909_9400 | 0x0D // When this quirk is enabled, the input byte stream may optionally start with // "\x1E" (the ASCII Record Separator control character). That byte is skipped @@ -110,7 +110,7 @@ pub const quirk_allow_inf_nan_numbers base.u32 = 0x4909_9400 | 0x0B // // When combined with quirk_allow_trailing_new_line, this format is also known // as RFC 7464, Json Text Sequences and MIME type "application/json-seq". -pub const quirk_allow_leading_ascii_record_separator base.u32 = 0x4909_9400 | 0x0C +pub const quirk_allow_leading_ascii_record_separator base.u32 = 0x4909_9400 | 0x0E // When this quirk is enabled, the input byte stream may optionally start with // "\xEF\xBB\xBF", the UTF-8 encoding of the Unicode BOM (Byte Order Mark). @@ -118,7 +118,7 @@ pub const quirk_allow_leading_ascii_record_separator base.u32 = 0x4909_9400 | 0x // // When combined with quirk_allow_leading_ascii_record_separator, either mark // may come first in the byte stream. -pub const quirk_allow_leading_unicode_byte_order_mark base.u32 = 0x4909_9400 | 0x0D +pub const quirk_allow_leading_unicode_byte_order_mark base.u32 = 0x4909_9400 | 0x0F // When this quirk is enabled, following a successful decoding of a top-level // JSON value, any trailing whitespace (ASCII characters 0x09, 0x0A, 0x0D or @@ -154,7 +154,7 @@ pub const quirk_allow_leading_unicode_byte_order_mark base.u32 = 0x4909_9400 | 0 // end-of-file or '\n' is encountered. Treating this as an error avoids any // ambiguity in accounting for new lines within a block comment or ending a // line comment. -pub const quirk_allow_trailing_new_line base.u32 = 0x4909_9400 | 0x0E +pub const quirk_allow_trailing_new_line base.u32 = 0x4909_9400 | 0x10 // When this quirk is enabled, invalid UTF-8 inside a JSON string is accepted. // Each byte of invalid UTF-8 is equivalent to "\uFFFD", the Unicode @@ -170,4 +170,4 @@ pub const quirk_allow_trailing_new_line base.u32 = 0x4909_9400 | 0x0E // When combined with quirk_allow_backslash_capital_u, a "\U12345678" 10-byte // unit that is an invalid Unicode code point (i.e. in the range U+D800 ..= // U+DFFF or above U+10FFFF) is similarly replaced with U+FFFD. -pub const quirk_replace_invalid_unicode base.u32 = 0x4909_9400 | 0x0F +pub const quirk_replace_invalid_unicode base.u32 = 0x4909_9400 | 0x11