mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-20 16:47:28 +01:00
Have JSON line-comment tokens exclude the "\n"
Before this commit, line-comment token chains included the final "\n" the way block-comments included the final "*/". The "\n" was mandatory. However, when parsing with both QUIRK_ALLOW_COMMENT_LINE and QUIRK_ALLOW_TRAILING_FILLER, input like "123//xyz" (without a "\n" before the EOF) was rejected before and accepted after this commit. So that line-comments are consistent, in that they either always or never include the final "\n", they now never include the final "\n". An input fragment (parsed with QUIRK_ALLOW_COMMENT_LINE) like "//abc\n\t\t" was, before this commit, parsed as a 6 byte comment token and a 2 byte other-filler token. That split is now 5+3.
This commit is contained in:
1 parent
40ffa334ee
commit
77f855206d
6 files changed
+41
-50
No files matched your search
@@ -33096,16 +33096,19 @@ wuffs_json__decoder__decode_comment(
|
||||
}
|
||||
while (true) {
|
||||
if (((uint64_t)(io2_a_src - iop_a_src)) <= 0) {
|
||||
if (v_length > 0) {
|
||||
if (a_src && a_src->meta.closed) {
|
||||
*iop_a_dst++ = wuffs_base__make_token(
|
||||
(((uint64_t)(4)) << WUFFS_BASE__TOKEN__VALUE_MINOR__SHIFT) |
|
||||
(((uint64_t)(v_length)) << WUFFS_BASE__TOKEN__LENGTH__SHIFT));
|
||||
self->private_impl.f_comment_type = 2;
|
||||
status = wuffs_base__make_status(NULL);
|
||||
goto ok;
|
||||
} else if (v_length > 0) {
|
||||
*iop_a_dst++ = wuffs_base__make_token(
|
||||
(((uint64_t)(4)) << WUFFS_BASE__TOKEN__VALUE_MINOR__SHIFT) |
|
||||
(((uint64_t)(1)) << WUFFS_BASE__TOKEN__CONTINUED__SHIFT) |
|
||||
(((uint64_t)(v_length)) << WUFFS_BASE__TOKEN__LENGTH__SHIFT));
|
||||
}
|
||||
if (a_src && a_src->meta.closed) {
|
||||
status = wuffs_base__make_status(wuffs_json__error__bad_input);
|
||||
goto exit;
|
||||
}
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(6);
|
||||
v_length = 0;
|
||||
@@ -33113,10 +33116,9 @@ wuffs_json__decoder__decode_comment(
|
||||
}
|
||||
v_c = wuffs_base__peek_u8be__no_bounds_check(iop_a_src);
|
||||
if (v_c == 10) {
|
||||
iop_a_src += 1;
|
||||
*iop_a_dst++ = wuffs_base__make_token(
|
||||
(((uint64_t)(4)) << WUFFS_BASE__TOKEN__VALUE_MINOR__SHIFT) |
|
||||
(((uint64_t)((v_length + 1))) << WUFFS_BASE__TOKEN__LENGTH__SHIFT));
|
||||
(((uint64_t)(v_length)) << WUFFS_BASE__TOKEN__LENGTH__SHIFT));
|
||||
self->private_impl.f_comment_type = 2;
|
||||
status = wuffs_base__make_status(NULL);
|
||||
goto ok;
|
||||
|
||||
Reference in new issue
Block a user