mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-24 00:52:18 +01:00
Rename std/json quirk_allow_final_comma
This commit is contained in:
1 parent
d7c72373f3
commit
93882564fd
4 files changed
+15
-15
No files matched your search
@@ -5934,7 +5934,7 @@ extern const char* wuffs_json__error__unsupported_recursion_depth;
|
|||||||
|
|
||||||
#define WUFFS_JSON__QUIRK_ALLOW_COMMENT_LINE 1225364489
|
#define WUFFS_JSON__QUIRK_ALLOW_COMMENT_LINE 1225364489
|
||||||
|
|
||||||
#define WUFFS_JSON__QUIRK_ALLOW_FINAL_COMMA 1225364490
|
#define WUFFS_JSON__QUIRK_ALLOW_EXTRA_COMMA 1225364490
|
||||||
|
|
||||||
#define WUFFS_JSON__QUIRK_ALLOW_INF_NAN_NUMBERS 1225364491
|
#define WUFFS_JSON__QUIRK_ALLOW_INF_NAN_NUMBERS 1225364491
|
||||||
|
|
||||||
@@ -6015,7 +6015,7 @@ struct wuffs_json__decoder__struct {
|
|||||||
bool f_quirk_enabled_allow_backslash_x;
|
bool f_quirk_enabled_allow_backslash_x;
|
||||||
bool f_quirk_enabled_allow_comment_block;
|
bool f_quirk_enabled_allow_comment_block;
|
||||||
bool f_quirk_enabled_allow_comment_line;
|
bool f_quirk_enabled_allow_comment_line;
|
||||||
bool f_quirk_enabled_allow_final_comma;
|
bool f_quirk_enabled_allow_extra_comma;
|
||||||
bool f_quirk_enabled_allow_inf_nan_numbers;
|
bool f_quirk_enabled_allow_inf_nan_numbers;
|
||||||
bool f_quirk_enabled_allow_leading_ascii_record_separator;
|
bool f_quirk_enabled_allow_leading_ascii_record_separator;
|
||||||
bool f_quirk_enabled_allow_leading_unicode_byte_order_mark;
|
bool f_quirk_enabled_allow_leading_unicode_byte_order_mark;
|
||||||
@@ -20495,7 +20495,7 @@ wuffs_json__decoder__set_quirk_enabled(wuffs_json__decoder* self,
|
|||||||
} else if (a_quirk == 1225364489) {
|
} else if (a_quirk == 1225364489) {
|
||||||
self->private_impl.f_quirk_enabled_allow_comment_line = a_enabled;
|
self->private_impl.f_quirk_enabled_allow_comment_line = a_enabled;
|
||||||
} else if (a_quirk == 1225364490) {
|
} else if (a_quirk == 1225364490) {
|
||||||
self->private_impl.f_quirk_enabled_allow_final_comma = a_enabled;
|
self->private_impl.f_quirk_enabled_allow_extra_comma = a_enabled;
|
||||||
} else if (a_quirk == 1225364491) {
|
} else if (a_quirk == 1225364491) {
|
||||||
self->private_impl.f_quirk_enabled_allow_inf_nan_numbers = a_enabled;
|
self->private_impl.f_quirk_enabled_allow_inf_nan_numbers = a_enabled;
|
||||||
} else if (a_quirk == 1225364492) {
|
} else if (a_quirk == 1225364492) {
|
||||||
@@ -21334,13 +21334,13 @@ wuffs_json__decoder__decode_tokens(wuffs_json__decoder* self,
|
|||||||
(((uint64_t)(0)) << WUFFS_BASE__TOKEN__VALUE_MINOR__SHIFT) |
|
(((uint64_t)(0)) << WUFFS_BASE__TOKEN__VALUE_MINOR__SHIFT) |
|
||||||
(((uint64_t)(1)) << WUFFS_BASE__TOKEN__LENGTH__SHIFT));
|
(((uint64_t)(1)) << WUFFS_BASE__TOKEN__LENGTH__SHIFT));
|
||||||
if (0 == (v_expect & 256)) {
|
if (0 == (v_expect & 256)) {
|
||||||
if (self->private_impl.f_quirk_enabled_allow_final_comma) {
|
if (self->private_impl.f_quirk_enabled_allow_extra_comma) {
|
||||||
v_expect = 4162;
|
v_expect = 4162;
|
||||||
} else {
|
} else {
|
||||||
v_expect = 4098;
|
v_expect = 4098;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (self->private_impl.f_quirk_enabled_allow_final_comma) {
|
if (self->private_impl.f_quirk_enabled_allow_extra_comma) {
|
||||||
v_expect = 8114;
|
v_expect = 8114;
|
||||||
} else {
|
} else {
|
||||||
v_expect = 7858;
|
v_expect = 7858;
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ pub struct decoder? implements base.token_decoder(
|
|||||||
quirk_enabled_allow_backslash_x : base.bool,
|
quirk_enabled_allow_backslash_x : base.bool,
|
||||||
quirk_enabled_allow_comment_block : base.bool,
|
quirk_enabled_allow_comment_block : base.bool,
|
||||||
quirk_enabled_allow_comment_line : base.bool,
|
quirk_enabled_allow_comment_line : base.bool,
|
||||||
quirk_enabled_allow_final_comma : base.bool,
|
quirk_enabled_allow_extra_comma : base.bool,
|
||||||
quirk_enabled_allow_inf_nan_numbers : base.bool,
|
quirk_enabled_allow_inf_nan_numbers : base.bool,
|
||||||
quirk_enabled_allow_leading_ascii_record_separator : base.bool,
|
quirk_enabled_allow_leading_ascii_record_separator : base.bool,
|
||||||
quirk_enabled_allow_leading_unicode_byte_order_mark : base.bool,
|
quirk_enabled_allow_leading_unicode_byte_order_mark : base.bool,
|
||||||
@@ -85,8 +85,8 @@ pub func decoder.set_quirk_enabled!(quirk: base.u32, enabled: base.bool) {
|
|||||||
this.quirk_enabled_allow_comment_block = args.enabled
|
this.quirk_enabled_allow_comment_block = args.enabled
|
||||||
} else if args.quirk == quirk_allow_comment_line {
|
} else if args.quirk == quirk_allow_comment_line {
|
||||||
this.quirk_enabled_allow_comment_line = args.enabled
|
this.quirk_enabled_allow_comment_line = args.enabled
|
||||||
} else if args.quirk == quirk_allow_final_comma {
|
} else if args.quirk == quirk_allow_extra_comma {
|
||||||
this.quirk_enabled_allow_final_comma = args.enabled
|
this.quirk_enabled_allow_extra_comma = args.enabled
|
||||||
} else if args.quirk == quirk_allow_inf_nan_numbers {
|
} else if args.quirk == quirk_allow_inf_nan_numbers {
|
||||||
this.quirk_enabled_allow_inf_nan_numbers = args.enabled
|
this.quirk_enabled_allow_inf_nan_numbers = args.enabled
|
||||||
} else if args.quirk == quirk_allow_leading_ascii_record_separator {
|
} else if args.quirk == quirk_allow_leading_ascii_record_separator {
|
||||||
@@ -832,13 +832,13 @@ pub func decoder.decode_tokens?(dst: base.token_writer, src: base.io_reader) {
|
|||||||
// What's valid after a comma depends on whether or not we're
|
// What's valid after a comma depends on whether or not we're
|
||||||
// in an array or an object.
|
// in an array or an object.
|
||||||
if 0 == (expect & 0x0100) { // 0x0100 is (1 << CLASS_CLOSE_SQUARE_BRACKET).
|
if 0 == (expect & 0x0100) { // 0x0100 is (1 << CLASS_CLOSE_SQUARE_BRACKET).
|
||||||
if this.quirk_enabled_allow_final_comma {
|
if this.quirk_enabled_allow_extra_comma {
|
||||||
expect = 0x1042 // 0x1042 is EXPECT_STRING | EXPECT_CLOSE_CURLY_BRACE.
|
expect = 0x1042 // 0x1042 is EXPECT_STRING | EXPECT_CLOSE_CURLY_BRACE.
|
||||||
} else {
|
} else {
|
||||||
expect = 0x1002 // 0x1002 is EXPECT_STRING.
|
expect = 0x1002 // 0x1002 is EXPECT_STRING.
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if this.quirk_enabled_allow_final_comma {
|
if this.quirk_enabled_allow_extra_comma {
|
||||||
expect = 0x1FB2 // 0x0FB2 is EXPECT_VALUE | EXPECT_CLOSE_SQUARE_BRACKET.
|
expect = 0x1FB2 // 0x0FB2 is EXPECT_VALUE | EXPECT_CLOSE_SQUARE_BRACKET.
|
||||||
} else {
|
} else {
|
||||||
expect = 0x1EB2 // 0x0EB2 is EXPECT_VALUE.
|
expect = 0x1EB2 // 0x0EB2 is EXPECT_VALUE.
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ pub const quirk_allow_comment_line base.u32 = 0x4909_9400 | 0x09
|
|||||||
//
|
//
|
||||||
// For example, `[1,]`, `[1,2,3,]` and `{"k":"v",}` all become acceptable, but
|
// For example, `[1,]`, `[1,2,3,]` and `{"k":"v",}` all become acceptable, but
|
||||||
// `[,]`, `{,}` and `{"k",:"v"}` are still rejected.
|
// `[,]`, `{,}` and `{"k",:"v"}` are still rejected.
|
||||||
pub const quirk_allow_final_comma base.u32 = 0x4909_9400 | 0x0A
|
pub const quirk_allow_extra_comma base.u32 = 0x4909_9400 | 0x0A
|
||||||
|
|
||||||
// When this quirk is enabled, "inf", "Infinity", "NAN" and their
|
// When this quirk is enabled, "inf", "Infinity", "NAN" and their
|
||||||
// case-insensitive variants, optionally preceded immediately by "-" or "+",
|
// case-insensitive variants, optionally preceded immediately by "-" or "+",
|
||||||
|
|||||||
+4
-4
@@ -1330,12 +1330,12 @@ test_wuffs_json_decode_quirk_allow_backslash_x() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const char* //
|
const char* //
|
||||||
test_wuffs_json_decode_quirk_allow_final_comma() {
|
test_wuffs_json_decode_quirk_allow_extra_comma() {
|
||||||
CHECK_FOCUS(__func__);
|
CHECK_FOCUS(__func__);
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
// want has 2 bytes, one for each possible q:
|
// want has 2 bytes, one for each possible q:
|
||||||
// - q&1 sets WUFFS_JSON__QUIRK_ALLOW_FINAL_COMMA.
|
// - q&1 sets WUFFS_JSON__QUIRK_ALLOW_EXTRA_COMMA.
|
||||||
// An 'X', '+' or '-' means that decoding should succeed (and consume the
|
// An 'X', '+' or '-' means that decoding should succeed (and consume the
|
||||||
// entire input), succeed (without consuming the entire input) or fail.
|
// entire input), succeed (without consuming the entire input) or fail.
|
||||||
const char* want;
|
const char* want;
|
||||||
@@ -1356,7 +1356,7 @@ test_wuffs_json_decode_quirk_allow_final_comma() {
|
|||||||
&dec, sizeof dec, WUFFS_VERSION,
|
&dec, sizeof dec, WUFFS_VERSION,
|
||||||
WUFFS_INITIALIZE__DEFAULT_OPTIONS));
|
WUFFS_INITIALIZE__DEFAULT_OPTIONS));
|
||||||
wuffs_json__decoder__set_quirk_enabled(
|
wuffs_json__decoder__set_quirk_enabled(
|
||||||
&dec, WUFFS_JSON__QUIRK_ALLOW_FINAL_COMMA, q & 1);
|
&dec, WUFFS_JSON__QUIRK_ALLOW_EXTRA_COMMA, q & 1);
|
||||||
|
|
||||||
wuffs_base__token_buffer tok =
|
wuffs_base__token_buffer tok =
|
||||||
wuffs_base__make_token_buffer_writer(global_have_token_slice);
|
wuffs_base__make_token_buffer_writer(global_have_token_slice);
|
||||||
@@ -2190,7 +2190,7 @@ proc tests[] = {
|
|||||||
test_wuffs_json_decode_quirk_allow_backslash_etc,
|
test_wuffs_json_decode_quirk_allow_backslash_etc,
|
||||||
test_wuffs_json_decode_quirk_allow_backslash_x,
|
test_wuffs_json_decode_quirk_allow_backslash_x,
|
||||||
test_wuffs_json_decode_quirk_allow_comment_etc,
|
test_wuffs_json_decode_quirk_allow_comment_etc,
|
||||||
test_wuffs_json_decode_quirk_allow_final_comma,
|
test_wuffs_json_decode_quirk_allow_extra_comma,
|
||||||
test_wuffs_json_decode_quirk_allow_inf_nan_numbers,
|
test_wuffs_json_decode_quirk_allow_inf_nan_numbers,
|
||||||
test_wuffs_json_decode_quirk_allow_leading_etc,
|
test_wuffs_json_decode_quirk_allow_leading_etc,
|
||||||
test_wuffs_json_decode_quirk_allow_trailing_etc,
|
test_wuffs_json_decode_quirk_allow_trailing_etc,
|
||||||
|
|||||||
Reference in new issue
Block a user