commit a091668f694a14e7da6415d8056c770d72993198 from: Sven M. Hallberg date: Fri Aug 12 16:49:12 2022 UTC eliminate a bunch of useless gotos I don't know what the purpose of any of these was, it looks like they were put in as a matter of course just in case it would later turn out that some final cleanup code was needed. Do not write cruft code just in case. commit - 20412cdab5e17485a4a49f22a7d4369c6558d46d commit + a091668f694a14e7da6415d8056c770d72993198 blob - 6bb8bea40ec6e4ee7dd15e4a0647653f5696a6b7 blob + ec84c6ef47cf4155338902214bcea5f70a826315 --- pdf.c +++ pdf.c @@ -3971,13 +3971,9 @@ getFontinfo(const Dict *fontdict, char *name, struct E if (item) { fontinfo->descendantFonts = item; } - } - else { // xref error - goto end; } } - end: return fontinfo; } @@ -4304,7 +4300,7 @@ void parse_pagenode ( h_pprintln(stdout, item); // just continue for now - goto end; + return; } @@ -4360,7 +4356,7 @@ void parse_pagenode ( // it currently only handles the case where /Contents is // a direct object that happens to be an array. if (contents == NULL) - goto end; + return; if (contents->token_type == TT_SEQUENCE) { size_t numelts = contents->seq->used; size_t bufsz = 0; @@ -4374,7 +4370,7 @@ void parse_pagenode ( 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; + return; HParsedToken *res_strm = H_INDEX_TOKEN(entry, 1); HParseResult *bstrm_r = H_CAST(HParseResult, res_strm); if ( (bstrm_r) && (bstrm_r->ast) ) { @@ -4403,8 +4399,6 @@ void parse_pagenode ( if (tstrm) myNode->pn.textStream = tstrm->ast; } - -end: ; } @@ -4473,7 +4467,7 @@ parse_pagetree( h_pprintln(stdout, item); // just continue for now - goto end; + return; } @@ -4486,7 +4480,7 @@ parse_pagetree( } if ( ! parsed ) { fprintf(stdout, "parse_pagetree: Required page node count missing or corrupt!\n"); - goto end; // Should just be a warning? + return; // Should just be a warning? } myNode->pt.numPages = H_CAST_SINT(item); @@ -4545,7 +4539,7 @@ parse_pagetree( } if ( ! parsed ) { fprintf(stdout, "parse_pagetree: This tree node has no pages!\n"); - goto end; // Nothing more to do here + return; } @@ -4590,8 +4584,6 @@ parse_pagetree( } // end loop - -end: return; } @@ -4628,7 +4620,7 @@ parse_catalog(struct Env *aux, const HParsedToken *roo // Ensure the reference is to the catalog dictionary dict_t = resolve(aux, root); if (!dict_t) { // TODO: Failure ==> xref error -- Figure out how to handle - goto end; + return; } aux->catalog.catalog = get_dictoftype(dict_t, NULL, "Catalog", aux); // catalog dictionary token @@ -4639,7 +4631,7 @@ parse_catalog(struct Env *aux, const HParsedToken *roo // Catalog found -- Now get the root of the page tree associated with the catalog ptRef = dictentry(catalog, "Pages"); // indirect reference to a dictionary if ( (ptRef == NULL) || (ptRef->token_type != TT_Ref) ) { - goto end; + return; } aux->catalog.pRoot = ptRef; // indirect reference to the page tree @@ -4647,12 +4639,12 @@ parse_catalog(struct Env *aux, const HParsedToken *roo /* resolve and process the page tree root reference to extract the dictionary --> Page Tree Object */ dict_t = resolve(aux, ptRef); // page tree root node if (!dict_t) { - goto end; + return; } // make sure the retrieved token is a dictionary of /Type "Pages" dict_t = get_dictoftype(dict_t, NULL, "Pages", aux); // page tree root dictionary (parent is NULL) if (!dict_t) { - goto end; // Nothing more to do here + return; // Nothing more to do here } ptRoot = H_CAST(Dict, dict_t); @@ -4660,12 +4652,9 @@ parse_catalog(struct Env *aux, const HParsedToken *roo parse_pagetree(aux, &aux->catalog.pgTree, ptRef, ptRoot, NULL, NULL); } else { // looks like the field "Type:Catalog" is a hint, not a requirement for a valid pdf - goto end; + return; } - - end: - return; } /*