diff --git a/lzw.c b/lzw.c index 48829ab4d9a3e7dfecedc35e253d4cac68e789cf..81c17060b021e1cefef3be3b3edbad0f95d65b01 100644 --- a/lzw.c +++ b/lzw.c @@ -8,7 +8,7 @@ #include "lzw.h" -FILE *debug; // DEBUG +//FILE *debug; // DEBUG #define BITLIMIT_9 (ctx->earlychange ? 511 : 512) #define BITLIMIT_10 (ctx->earlychange ? 1023 : 1024) @@ -89,6 +89,12 @@ act_LZW_clear(const HParseResult *p, void *u) return H_MAKE_BYTES(NULL, 0); } +HParsedToken* +act_LZW_clear_and_firstcode(const HParseResult *p, void *u) +{ + return p->ast->seq->elements[1]; +} + bool validate_LZW_9bitcodeword(HParseResult *p, void *u) { @@ -422,7 +428,9 @@ void init_LZW_parser() H_AVDRULE(LZW_literal, h_choice(LZW_9bitlitspec, LZW_10bitlitspec, LZW_11bitlitspec, LZW_12bitlitspec, NULL), context); H_ADRULE(LZW_codeword, h_choice(LZW_9bitcodeword, LZW_10bitcodeword, LZW_11bitcodeword, LZW_12bitcodeword, NULL), context); - H_ADRULE(LZW_body, h_many1(h_butnot(h_choice(LZW_literal, h_ignore(LZW_clear), LZW_codeword, NULL), LZW_eod)), context); + H_ADRULE(LZW_clear_and_firstcode, h_sequence(h_ignore(LZW_clear), LZW_firstcode, NULL), context); + + H_ADRULE(LZW_body, h_many1(h_butnot(h_choice(LZW_literal, LZW_clear_and_firstcode, LZW_codeword, NULL), LZW_eod)), context); H_ADRULE(LZW_data, h_sequence(LZW_clear, LZW_firstcode, LZW_body, LZW_eod, LZW_remainingbits, NULL), context); p_lzwdata = LZW_data; diff --git a/pdf.c b/pdf.c index 3268e0775b4e5044902bf3718d91cf5b8912934b..6209013dc625d17e8c907529b87a88bb865ef6b1 100644 --- a/pdf.c +++ b/pdf.c @@ -3273,7 +3273,7 @@ LZWDecode(const Dict *parms, HBytes b, HParser *p) if(!tmp_res) { - fprintf(stderr, "parse error in LZWDecode filter"); + fprintf(stderr, "parse error in LZWDecode filter\n"); return NULL; } diff --git a/t/hello_ascii85.pdf b/t/hello_ascii85.pdf deleted file mode 100644 index 8283dfc52f1df905e2c0cce028eee9969684864b..0000000000000000000000000000000000000000 --- a/t/hello_ascii85.pdf +++ /dev/null @@ -1,62 +0,0 @@ -%PDF-1.4 -1 0 obj -<< /Type /Catalog -/Outlines 2 0 R -/Pages 3 0 R ->> -endobj -2 0 obj -<< /Type /Outlines -/Count 0 ->> -endobj -3 0 obj -<< /Type /Pages -/Kids [ 4 0 R ] -/Count 1 ->> -endobj -4 0 obj -<< /Type /Page -/Parent 3 0 R -/MediaBox [ 0 0 612 792 ] -/Contents 5 0 R -/Resources << /ProcSet 6 0 R -/Font << /F1 7 0 R >> ->> ->> -endobj -5 0 obj -<< /Length 59 /Filter /ASCII85Decode>> -stream -<!k9J0d&5.+B2q[0eb:(0eb:(<+H=a+@p'[Ci:FtDfTZ)+=SF4C'mC/$3~> -endstream -endobj -6 0 obj -[ /PDF /Text ] -endobj -7 0 obj -<< /Type /Font -/Subtype /Type1 -/Name /F1 -/BaseFont /Helvetica -/Encoding /MacRomanEncoding ->> -endobj -xref -0 8 -0000000000 65535 f -0000000009 00000 n -0000000074 00000 n -0000000120 00000 n -0000000179 00000 n -0000000322 00000 n -0000000453 00000 n -0000000483 00000 n -trailer -<< /Size 8 -/Root 1 0 R ->> -startxref -592 -%%EOF diff --git a/t/hello_ascii85_lf.pdf b/t/hello_ascii85_lf.pdf deleted file mode 100644 index 4f54996cce84b86df745dc4912ca558e1760b557..0000000000000000000000000000000000000000 --- a/t/hello_ascii85_lf.pdf +++ /dev/null @@ -1,63 +0,0 @@ -%PDF-1.4 -1 0 obj -<< /Type /Catalog -/Outlines 2 0 R -/Pages 3 0 R ->> -endobj -2 0 obj -<< /Type /Outlines -/Count 0 ->> -endobj -3 0 obj -<< /Type /Pages -/Kids [ 4 0 R ] -/Count 1 ->> -endobj -4 0 obj -<< /Type /Page -/Parent 3 0 R -/MediaBox [ 0 0 612 792 ] -/Contents 5 0 R -/Resources << /ProcSet 6 0 R -/Font << /F1 7 0 R >> ->> ->> -endobj -5 0 obj -<< /Length 60 /Filter /ASCII85Decode>> -stream -<!k9J0d&5.+B2q[0eb:(0eb:(<+H= -a+@p'[Ci:FtDfTZ)+=SF4C'mC/$3~> -endstream -endobj -6 0 obj -[ /PDF /Text ] -endobj -7 0 obj -<< /Type /Font -/Subtype /Type1 -/Name /F1 -/BaseFont /Helvetica -/Encoding /MacRomanEncoding ->> -endobj -xref -0 8 -0000000000 65535 f -0000000009 00000 n -0000000074 00000 n -0000000120 00000 n -0000000179 00000 n -0000000322 00000 n -0000000454 00000 n -0000000484 00000 n -trailer -<< /Size 8 -/Root 1 0 R ->> -startxref -593 -%%EOF diff --git a/t/hello_asciihex.pdf b/t/hello_asciihex.pdf deleted file mode 100644 index 7496f59864d8d8b22ac06557f7ce3d0e3ed2e2c3..0000000000000000000000000000000000000000 --- a/t/hello_asciihex.pdf +++ /dev/null @@ -1,62 +0,0 @@ -%PDF-1.4 -1 0 obj -<< /Type /Catalog -/Outlines 2 0 R -/Pages 3 0 R ->> -endobj -2 0 obj -<< /Type /Outlines -/Count 0 ->> -endobj -3 0 obj -<< /Type /Pages -/Kids [ 4 0 R ] -/Count 1 ->> -endobj -4 0 obj -<< /Type /Page -/Parent 3 0 R -/MediaBox [ 0 0 612 792 ] -/Contents 5 0 R -/Resources << /ProcSet 6 0 R -/Font << /F1 7 0 R >> ->> ->> -endobj -5 0 obj -<< /Length 91 /Filter /ASCIIHexDecode>> -stream -540a2f46312032342054660a313030203130302054640a282048656c6c6f20576f726c64202920546a0a45540a> -endstream -endobj -6 0 obj -[ /PDF /Text ] -endobj -7 0 obj -<< /Type /Font -/Subtype /Type1 -/Name /F1 -/BaseFont /Helvetica -/Encoding /MacRomanEncoding ->> -endobj -xref -0 8 -0000000000 65535 f -0000000009 00000 n -0000000074 00000 n -0000000120 00000 n -0000000179 00000 n -0000000322 00000 n -0000000486 00000 n -0000000516 00000 n -trailer -<< /Size 8 -/Root 1 0 R ->> -startxref -624 -%%EOF diff --git a/t/hello_asciihex_lf.pdf b/t/hello_asciihex_lf.pdf deleted file mode 100644 index b077906ba43c89935d5d6fbe226777cc84afb0bb..0000000000000000000000000000000000000000 --- a/t/hello_asciihex_lf.pdf +++ /dev/null @@ -1,63 +0,0 @@ -%PDF-1.4 -1 0 obj -<< /Type /Catalog -/Outlines 2 0 R -/Pages 3 0 R ->> -endobj -2 0 obj -<< /Type /Outlines -/Count 0 ->> -endobj -3 0 obj -<< /Type /Pages -/Kids [ 4 0 R ] -/Count 1 ->> -endobj -4 0 obj -<< /Type /Page -/Parent 3 0 R -/MediaBox [ 0 0 612 792 ] -/Contents 5 0 R -/Resources << /ProcSet 6 0 R -/Font << /F1 7 0 R >> ->> ->> -endobj -5 0 obj -<< /Length 92 /Filter /ASCIIHexDecode>> -stream -540a2f46312032342054660a3130302031303 -02054640a282048656c6c6f20576f726c64202920546a0a45540a> -endstream -endobj -6 0 obj -[ /PDF /Text ] -endobj -7 0 obj -<< /Type /Font -/Subtype /Type1 -/Name /F1 -/BaseFont /Helvetica -/Encoding /MacRomanEncoding ->> -endobj -xref -0 8 -0000000000 65535 f -0000000009 00000 n -0000000074 00000 n -0000000120 00000 n -0000000179 00000 n -0000000322 00000 n -0000000487 00000 n -0000000517 00000 n -trailer -<< /Size 8 -/Root 1 0 R ->> -startxref -625 -%%EOF diff --git a/t/hello_lzwdecode_march.pdf b/t/hello_lzwdecode_march.pdf deleted file mode 100644 index 7f887ccce2c1c995ea65f1524e28685713f435d3..0000000000000000000000000000000000000000 Binary files a/t/hello_lzwdecode_march.pdf and /dev/null differ diff --git a/t/hello_runlength.pdf b/t/hello_runlength.pdf deleted file mode 100644 index 8f14de953d0952359834e9c7e67874246996a6ec..0000000000000000000000000000000000000000 --- a/t/hello_runlength.pdf +++ /dev/null @@ -1,62 +0,0 @@ -%PDF-1.4 -1 0 obj -<< /Type /Catalog -/Outlines 2 0 R -/Pages 3 0 R ->> -endobj -2 0 obj -<< /Type /Outlines -/Count 0 ->> -endobj -3 0 obj -<< /Type /Pages -/Kids [ 4 0 R ] -/Count 1 ->> -endobj -4 0 obj -<< /Type /Page -/Parent 3 0 R -/MediaBox [ 0 0 612 792 ] -/Contents 5 0 R -/Resources << /ProcSet 6 0 R -/Font << /F1 7 0 R >> ->> ->> -endobj -5 0 obj -<< /Length 23 /Filter /RunLengthDecode>> -stream - AAAAAAAAAAAAAAAAAAAA@B -endstream -endobj -6 0 obj -[ /PDF /Text ] -endobj -7 0 obj -<< /Type /Font -/Subtype /Type1 -/Name /F1 -/BaseFont /Helvetica -/Encoding /MacRomanEncoding ->> -endobj -xref -0 8 -0000000000 65535 f -0000000009 00000 n -0000000074 00000 n -0000000120 00000 n -0000000179 00000 n -0000000322 00000 n -0000000419 00000 n -0000000450 00000 n -trailer -<< /Size 8 -/Root 1 0 R ->> -startxref -557 -%%EOF