commit - e0350ca3bb91fb9ff9a91e048ab68ce059cd7f66
commit + 20412cdab5e17485a4a49f22a7d4369c6558d46d
blob - df1ba9ef34971e75abc9f44ab9410f97200c1ea8
blob + 6bb8bea40ec6e4ee7dd15e4a0647653f5696a6b7
--- pdf.c
+++ pdf.c
HParser *p_textstream;
HParser *p_trailer;
HParser *p_cstream;
-HParser *p_byteostm;
HParser *p_dict;
HParser *kxstream(HAllocator *, const HParsedToken *, void *);
HParser *ktxtstream(HAllocator *, const HParsedToken *, void *);
HParser *kcontentstream(HAllocator *, const HParsedToken *, void *);
-HParser *kbyteostream(HAllocator *, const HParsedToken *, void *);
void
init_runlengthdecode_parser(struct Env *aux)
H_RULE(contentstream, h_left(h_bind(stmbeg, kcontentstream, aux), stmend));
H_RULE(cstream, SEQ(ws, npair, wel, KW("obj"), ws, contentstream,
OPT(ws), OPT(lws), KW("endobj")));
- H_RULE(byteostream, h_left(h_bind(stmbeg, kbyteostream, aux), stmend));
- H_RULE(byteostm, SEQ(ws, npair, wel, KW("obj"), ws, byteostream,
- OPT(ws), OPT(lws), KW("endobj")));
/* global parser variables */
p_textbegin = txtbegin;
p_textstream = txtstream;
p_cstream = CHX(cstream, objdef);
- p_byteostm = byteostm;
p_dict = dict;
p_fail = h_nothing_p();
tok = NULL;
return tok;
-}
-
-
-/*
- * This continuation takes the content stream, decodes it if necessary and returns
- * the byte stream for concatenation with other byte streams priot to test extraction.
- * It is very similar to kstream in approach.
- */
-HParser *
-kbyteostream(HAllocator *mm__, const HParsedToken *x, void *env)
-{
-
- struct Env *aux = env;
- HParsedToken *dict_t = H_INDEX_TOKEN(x, 0);
- Dict *dict = H_CAST(Dict, dict_t);
- const HParsedToken *v = NULL;
- HParser *bytes_p, *dict_p, *value_p;
- struct streamspec *spec;
- size_t sz=0;
-
- /* look for the Length entry -- could be a reference */
- v = dictentry(dict, "Length");
- v = resolve(aux, v); /* resolve indirect references */
- if (v == NULL || v->token_type != TT_SINT || v->sint < 0) {
- if (v == NULL)
- log_message(7, "kbyteostream: stream /Length missing\n");
- else if (v -> token_type != TT_SINT)
- log_message(7, "kbyteostream: stream /Length not an integer\n");
- else if (v < 0)
- log_message(7, "kbyteostream: stream /Length negative\n");
-
- return p_fail;
- }
-
- sz = (size_t)v->sint;
-
- dict_p = p_return__m(mm__, dict_t);
- bytes_p = p_take__m(mm__, sz, aux);
-
- spec = h_alloc(mm__, sizeof(struct streamspec));
- spec->dict = dict;
- spec->parser = p_bytes;
-
- value_p = h_action__m(mm__, bytes_p, act_ks_value, spec);
- // XXX this should be h_bind, i think?! so failures in the
- // postordinate parser propagate...
-
- return h_sequence__m(mm__, dict_p, value_p, NULL);
-
}
pieces = h_arena_malloc(arena, sizeof(HBytes*) * numelts);
for (int i=0; i<numelts; i++) {
entry = H_INDEX_TOKEN(contents, i);
- entry = resolve_item(aux, entry, p_byteostm);
+ entry = resolve(aux, entry);
+ // XXX check that entry is a stream object of the expected type
if (!entry) // TODO: Failure ==> xref error -- Figure out how to handle
goto end;
HParsedToken *res_strm = H_INDEX_TOKEN(entry, 1);