std/netpbm: allow spaces and tabs as whitespace

This commit is contained in:
Nigel Tao committed 2025-02-28 21:37:22 +11:00
1 parent 64daf2653e
commit 6e91caf241
3 files changed
+47 -22

No files matched your search

+6
View File
@@ -158,8 +158,14 @@ wuffs_base__magic_number_guess_fourcc(wuffs_base__slice_u8 prefix_data,
{+0x4C5A4950, "\x04\x4C\x5A\x49\x50\x01"}, // LZIP {+0x4C5A4950, "\x04\x4C\x5A\x49\x50\x01"}, // LZIP
{+0x54494646, "\x03\x4D\x4D\x00\x2A"}, // TIFF (big-endian) {+0x54494646, "\x03\x4D\x4D\x00\x2A"}, // TIFF (big-endian)
{+0x45544332, "\x03\x50\x4B\x4D\x20"}, // ETC2 (*.pkm) {+0x45544332, "\x03\x50\x4B\x4D\x20"}, // ETC2 (*.pkm)
{+0x4E50424D, "\x02\x50\x35\x09"}, // NPBM (P5; *.pgm)
{+0x4E50424D, "\x02\x50\x35\x0A"}, // NPBM (P5; *.pgm) {+0x4E50424D, "\x02\x50\x35\x0A"}, // NPBM (P5; *.pgm)
{+0x4E50424D, "\x02\x50\x35\x0D"}, // NPBM (P5; *.pgm)
{+0x4E50424D, "\x02\x50\x35\x20"}, // NPBM (P5; *.pgm)
{+0x4E50424D, "\x02\x50\x36\x09"}, // NPBM (P6; *.ppm)
{+0x4E50424D, "\x02\x50\x36\x0A"}, // NPBM (P6; *.ppm) {+0x4E50424D, "\x02\x50\x36\x0A"}, // NPBM (P6; *.ppm)
{+0x4E50424D, "\x02\x50\x36\x0D"}, // NPBM (P6; *.ppm)
{+0x4E50424D, "\x02\x50\x36\x20"}, // NPBM (P6; *.ppm)
{-0x52494646, "\x03\x52\x49\x46\x46"}, // RIFF {-0x52494646, "\x03\x52\x49\x46\x46"}, // RIFF
{+0x4C5A4D41, "\x04\x5D\x00\x10\x00\x00"}, // LZMA {+0x4C5A4D41, "\x04\x5D\x00\x10\x00\x00"}, // LZMA
{+0x4C5A4D41, "\x02\x5D\x00\x00"}, // LZMA {+0x4C5A4D41, "\x02\x5D\x00\x00"}, // LZMA
+34 -11
View File
@@ -23915,8 +23915,14 @@ wuffs_base__magic_number_guess_fourcc(wuffs_base__slice_u8 prefix_data,
{+0x4C5A4950, "\x04\x4C\x5A\x49\x50\x01"}, // LZIP {+0x4C5A4950, "\x04\x4C\x5A\x49\x50\x01"}, // LZIP
{+0x54494646, "\x03\x4D\x4D\x00\x2A"}, // TIFF (big-endian) {+0x54494646, "\x03\x4D\x4D\x00\x2A"}, // TIFF (big-endian)
{+0x45544332, "\x03\x50\x4B\x4D\x20"}, // ETC2 (*.pkm) {+0x45544332, "\x03\x50\x4B\x4D\x20"}, // ETC2 (*.pkm)
{+0x4E50424D, "\x02\x50\x35\x09"}, // NPBM (P5; *.pgm)
{+0x4E50424D, "\x02\x50\x35\x0A"}, // NPBM (P5; *.pgm) {+0x4E50424D, "\x02\x50\x35\x0A"}, // NPBM (P5; *.pgm)
{+0x4E50424D, "\x02\x50\x35\x0D"}, // NPBM (P5; *.pgm)
{+0x4E50424D, "\x02\x50\x35\x20"}, // NPBM (P5; *.pgm)
{+0x4E50424D, "\x02\x50\x36\x09"}, // NPBM (P6; *.ppm)
{+0x4E50424D, "\x02\x50\x36\x0A"}, // NPBM (P6; *.ppm) {+0x4E50424D, "\x02\x50\x36\x0A"}, // NPBM (P6; *.ppm)
{+0x4E50424D, "\x02\x50\x36\x0D"}, // NPBM (P6; *.ppm)
{+0x4E50424D, "\x02\x50\x36\x20"}, // NPBM (P6; *.ppm)
{-0x52494646, "\x03\x52\x49\x46\x46"}, // RIFF {-0x52494646, "\x03\x52\x49\x46\x46"}, // RIFF
{+0x4C5A4D41, "\x04\x5D\x00\x10\x00\x00"}, // LZMA {+0x4C5A4D41, "\x04\x5D\x00\x10\x00\x00"}, // LZMA
{+0x4C5A4D41, "\x02\x5D\x00\x00"}, // LZMA {+0x4C5A4D41, "\x02\x5D\x00\x00"}, // LZMA
@@ -64486,7 +64492,10 @@ wuffs_netpbm__decoder__do_decode_image_config(
uint8_t t_2 = *iop_a_src++; uint8_t t_2 = *iop_a_src++;
v_c8 = t_2; v_c8 = t_2;
} }
if (v_c8 != 10u) { if ((v_c8 != 32u) &&
(v_c8 != 9u) &&
(v_c8 != 10u) &&
(v_c8 != 13u)) {
status = wuffs_base__make_status(wuffs_netpbm__error__bad_header); status = wuffs_base__make_status(wuffs_netpbm__error__bad_header);
goto exit; goto exit;
} }
@@ -64500,7 +64509,10 @@ wuffs_netpbm__decoder__do_decode_image_config(
uint8_t t_3 = *iop_a_src++; uint8_t t_3 = *iop_a_src++;
v_c8 = t_3; v_c8 = t_3;
} }
if ((v_c8 == 32u) || (v_c8 == 9u)) { if ((v_c8 == 32u) ||
(v_c8 == 9u) ||
(v_c8 == 10u) ||
(v_c8 == 13u)) {
continue; continue;
} else if (v_c8 == 35u) { } else if (v_c8 == 35u) {
while (true) { while (true) {
@@ -64535,7 +64547,10 @@ wuffs_netpbm__decoder__do_decode_image_config(
uint8_t t_5 = *iop_a_src++; uint8_t t_5 = *iop_a_src++;
v_c8 = t_5; v_c8 = t_5;
} }
if ((v_c8 == 32u) || (v_c8 == 9u)) { if ((v_c8 == 32u) ||
(v_c8 == 9u) ||
(v_c8 == 10u) ||
(v_c8 == 13u)) {
break; break;
} else if ((v_c8 < 48u) || (57u < v_c8)) { } else if ((v_c8 < 48u) || (57u < v_c8)) {
status = wuffs_base__make_status(wuffs_netpbm__error__bad_header); status = wuffs_base__make_status(wuffs_netpbm__error__bad_header);
@@ -64558,7 +64573,10 @@ wuffs_netpbm__decoder__do_decode_image_config(
uint8_t t_6 = *iop_a_src++; uint8_t t_6 = *iop_a_src++;
v_c8 = t_6; v_c8 = t_6;
} }
if ((v_c8 == 32u) || (v_c8 == 9u)) { if ((v_c8 == 32u) ||
(v_c8 == 9u) ||
(v_c8 == 10u) ||
(v_c8 == 13u)) {
continue; continue;
} else if (v_c8 == 35u) { } else if (v_c8 == 35u) {
while (true) { while (true) {
@@ -64593,9 +64611,10 @@ wuffs_netpbm__decoder__do_decode_image_config(
uint8_t t_8 = *iop_a_src++; uint8_t t_8 = *iop_a_src++;
v_c8 = t_8; v_c8 = t_8;
} }
if ((v_c8 == 32u) || (v_c8 == 9u) || (v_c8 == 13u)) { if ((v_c8 == 32u) ||
continue; (v_c8 == 9u) ||
} else if (v_c8 == 10u) { (v_c8 == 10u) ||
(v_c8 == 13u)) {
break; break;
} else if ((v_c8 < 48u) || (57u < v_c8)) { } else if ((v_c8 < 48u) || (57u < v_c8)) {
status = wuffs_base__make_status(wuffs_netpbm__error__bad_header); status = wuffs_base__make_status(wuffs_netpbm__error__bad_header);
@@ -64618,7 +64637,10 @@ wuffs_netpbm__decoder__do_decode_image_config(
uint8_t t_9 = *iop_a_src++; uint8_t t_9 = *iop_a_src++;
v_c8 = t_9; v_c8 = t_9;
} }
if ((v_c8 == 32u) || (v_c8 == 9u)) { if ((v_c8 == 32u) ||
(v_c8 == 9u) ||
(v_c8 == 10u) ||
(v_c8 == 13u)) {
continue; continue;
} else if (v_c8 == 35u) { } else if (v_c8 == 35u) {
while (true) { while (true) {
@@ -64653,9 +64675,10 @@ wuffs_netpbm__decoder__do_decode_image_config(
uint8_t t_11 = *iop_a_src++; uint8_t t_11 = *iop_a_src++;
v_c8 = t_11; v_c8 = t_11;
} }
if ((v_c8 == 32u) || (v_c8 == 9u) || (v_c8 == 13u)) { if ((v_c8 == 32u) ||
continue; (v_c8 == 9u) ||
} else if (v_c8 == 10u) { (v_c8 == 10u) ||
(v_c8 == 13u)) {
break; break;
} else if ((v_c8 < 48u) || (57u < v_c8)) { } else if ((v_c8 < 48u) || (57u < v_c8)) {
status = wuffs_base__make_status(wuffs_netpbm__error__bad_header); status = wuffs_base__make_status(wuffs_netpbm__error__bad_header);
+7 -11
View File
@@ -83,14 +83,14 @@ pri func decoder.do_decode_image_config?(dst: nptr base.image_config, src: base.
} }
c8 = args.src.read_u8?() c8 = args.src.read_u8?()
if c8 <> 0x0A { if (c8 <> ' ') and (c8 <> 0x09) and (c8 <> 0x0A) and (c8 <> 0x0D) {
return "#bad header" return "#bad header"
} }
// Decode width. // Decode width.
while true { while true {
c8 = args.src.read_u8?() c8 = args.src.read_u8?()
if (c8 == ' ') or (c8 == 0x09) { if (c8 == ' ') or (c8 == 0x09) or (c8 == 0x0A) or (c8 == 0x0D) {
continue continue
} else if c8 == '#' { } else if c8 == '#' {
// Consume a "#...\n" comment. // Consume a "#...\n" comment.
@@ -109,7 +109,7 @@ pri func decoder.do_decode_image_config?(dst: nptr base.image_config, src: base.
} }
while true { while true {
c8 = args.src.read_u8?() c8 = args.src.read_u8?()
if (c8 == ' ') or (c8 == 0x09) { if (c8 == ' ') or (c8 == 0x09) or (c8 == 0x0A) or (c8 == 0x0D) {
break break
} else if (c8 < '0') or ('9' < c8) { } else if (c8 < '0') or ('9' < c8) {
return "#bad header" return "#bad header"
@@ -124,7 +124,7 @@ pri func decoder.do_decode_image_config?(dst: nptr base.image_config, src: base.
// Decode height. // Decode height.
while true { while true {
c8 = args.src.read_u8?() c8 = args.src.read_u8?()
if (c8 == ' ') or (c8 == 0x09) { if (c8 == ' ') or (c8 == 0x09) or (c8 == 0x0A) or (c8 == 0x0D) {
continue continue
} else if c8 == '#' { } else if c8 == '#' {
// Consume a "#...\n" comment. // Consume a "#...\n" comment.
@@ -143,9 +143,7 @@ pri func decoder.do_decode_image_config?(dst: nptr base.image_config, src: base.
} }
while true { while true {
c8 = args.src.read_u8?() c8 = args.src.read_u8?()
if (c8 == ' ') or (c8 == 0x09) or (c8 == 0x0D) { if (c8 == ' ') or (c8 == 0x09) or (c8 == 0x0A) or (c8 == 0x0D) {
continue
} else if c8 == 0x0A {
break break
} else if (c8 < '0') or ('9' < c8) { } else if (c8 < '0') or ('9' < c8) {
return "#bad header" return "#bad header"
@@ -160,7 +158,7 @@ pri func decoder.do_decode_image_config?(dst: nptr base.image_config, src: base.
// Decode max_value. // Decode max_value.
while true { while true {
c8 = args.src.read_u8?() c8 = args.src.read_u8?()
if (c8 == ' ') or (c8 == 0x09) { if (c8 == ' ') or (c8 == 0x09) or (c8 == 0x0A) or (c8 == 0x0D) {
continue continue
} else if c8 == '#' { } else if c8 == '#' {
// Consume a "#...\n" comment. // Consume a "#...\n" comment.
@@ -179,9 +177,7 @@ pri func decoder.do_decode_image_config?(dst: nptr base.image_config, src: base.
} }
while true { while true {
c8 = args.src.read_u8?() c8 = args.src.read_u8?()
if (c8 == ' ') or (c8 == 0x09) or (c8 == 0x0D) { if (c8 == ' ') or (c8 == 0x09) or (c8 == 0x0A) or (c8 == 0x0D) {
continue
} else if c8 == 0x0A {
break break
} else if (c8 < '0') or ('9' < c8) { } else if (c8 < '0') or ('9' < c8) {
return "#bad header" return "#bad header"