From c357f0696dfe2932c4233539f5ad7d90e321ec18 Mon Sep 17 00:00:00 2001 From: "Sven M. Hallberg" <pesco@khjk.org> Date: Sun, 24 Nov 2019 15:08:36 +0100 Subject: [PATCH] use new combinators h_tell and h_skip for zero-copy streams --- pdf.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pdf.c b/pdf.c index 3f46b09..5ca4a07 100644 --- a/pdf.c +++ b/pdf.c @@ -156,7 +156,6 @@ act_octal(const HParseResult *p, void *u) return H_MAKE_UINT(x); } -#define act_stream act_token #define act_xrefs h_act_last @@ -284,7 +283,7 @@ init_parser(void) /* streams */ H_RULE(stmbeg, SEQ(dict, KW("stream"), OPT(cr), lf)); H_RULE(stmend, SEQ(OPT(eol), LIT("endstream"))); - H_ARULE(stream, h_left(h_bind(stmbeg, kstream, NULL), stmend)); + H_RULE(stream, h_left(h_bind(stmbeg, kstream, NULL), stmend)); // XXX is whitespace allowed between the eol and "endstream"? H_RULE(obj_, CHX(ref, null, boole, real, intg, name, string, @@ -366,7 +365,9 @@ kstream(HAllocator *mm__, const HParsedToken *x, void *env) // XXX support indirect objects for the Length value! //fprintf(stderr, "parsing stream object, length %zu.\n", sz); // XXX debug - return h_repeat_n__m(mm__, h_uint8__m(mm__), sz); + HParser *tell = h_tell__m(mm__); + HParser *skip = h_skip__m(mm__, sz * 8); + return h_sequence__m(mm__, tell, skip, tell, NULL); fail: #if 0 if (v == NULL) -- GitLab