From 8258ee270b10862ed8152ae22f99c6ba846e79a7 Mon Sep 17 00:00:00 2001 From: "Sven M. Hallberg" <pesco@khjk.org> Date: Thu, 28 Jul 2022 16:25:16 +0200 Subject: [PATCH] remove dead and/or broken TT_SEQUENCE case from parse_pagenode For context, this part of the code is concerned with parsing a content stream as specified by the /Contents entry of a page node. The section being removed by this commit is trying to deal with the case that /Contents is an array (represented as a sequence token by the parser). It was originally introduced in commit 285b6f89 as the else branch of an 'if' that checked for token type TT_Objstm. The sequence case was apparently found to be buggy, so the next commit, ddf109c3, introduced a different case for TT_SEQUENCE that does nothing, leaving this as the new else. So this code is certainly broken (it tries to access a sequence if and only if that token is not a sequence) and unreachable (no token types appear beside TT_Objstm and TT_SEQUENCE) if we are lucky. As noted correctly by the preceding comment introduced with ddf109c3, this bit of code is at best an incomplete version of a later piece that attempts to accomplish the same thing. We will come back to that one. --- pdf.c | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/pdf.c b/pdf.c index e55b182..ee177de 100644 --- a/pdf.c +++ b/pdf.c @@ -4494,27 +4494,6 @@ void parse_pagenode ( myNode->pn.textStream = NULL; goto end; //XXX: This avoids crashing } - else { - // XXX contents->token_type != TT_SEQUENCE, but we're accessing contents->seq!? - // XXX what is this code supposed to do? --pesco - if(contents->seq->used >= 1) - { - // XXX needed?! - //HParsedToken *tok0 = H_INDEX_TOKEN(contents, 0); - //h_pprintln(stdout, tok0); - } - - if(contents->seq->used >= 2) - { - HParsedToken *res_strm = H_INDEX_TOKEN(contents, 1); - if (res_strm->token_type == TT_SEQUENCE) { // this seems like a big assumption - myNode->pn.textStream = res_strm; - - } - else - myNode->pn.textStream = NULL; - } - } } else if (contents_t->token_type == TT_SEQUENCE) { size_t numelts = contents_t->seq->used; -- GitLab