commit 2b528fbdf315ca85f18f9ed28a5fef1513039c7c from: Sven M. Hallberg date: Thu Jun 15 14:51:39 2023 UTC fix broken indentation in page content code commit - 1d12105938ec9cbee8e5f64acfb855ae9cd4213f commit + 2b528fbdf315ca85f18f9ed28a5fef1513039c7c blob - c00fc34200488adfa00f95094ea88456e88858ef blob + 5ad8aff4d99d0a16b38d8fb2c052603df75f1159 --- pdf.c +++ pdf.c @@ -1545,8 +1545,8 @@ act_Tf_op(const HParseResult *p, void *u) else if (tokenType == TT_DOUBLE) txte->fref.fontsize = (double) H_FIELD_DOUBLE(1); - // associate the text with the current state - txte->node = aux->curr_node; + // associate the text with the current state + txte->node = aux->curr_node; return H_MAKE(TextEntry, txte); @@ -1673,21 +1673,20 @@ HParsedToken * act_Tm_op(const HParseResult *p, void *u) { TextEntry *txte = H_ALLOC(TextEntry); - struct Env *aux = (struct Env*)u; + struct Env *aux = (struct Env*)u; txte->type = TP_Tm; txte->obj = NULL; assert((p->ast->token_type == TT_SEQUENCE) && - (p->ast->seq->elements[0]->token_type == TT_SEQUENCE) && - (p->ast->seq->elements[0]->seq->used == 6)); + (p->ast->seq->elements[0]->token_type == TT_SEQUENCE) && + (p->ast->seq->elements[0]->seq->used == 6)); for (int i=0; i<6; i++) - txte->fm.cell[i] = p->ast->seq->elements[0]->seq->elements[i]->seq->elements[0]->dbl; - // associate the text with the current state - txte->node = aux->curr_node; + // associate the text with the current state + txte->node = aux->curr_node; return H_MAKE(TextEntry, txte); } @@ -2637,7 +2636,7 @@ init_parser(struct Env *aux) H_RULE(text_ops, CHX(textstate_ops, textpos_ops, textshow_ops, text_inbetween_junk)); /* Text object */ - HParser *txtobj = h_action(SEQ(txtbegin, h_many(text_ops), txtend), act_txtobj, aux); + HParser *txtobj = h_action(SEQ(txtbegin, h_many(text_ops), txtend), act_txtobj, aux); H_RULE(txtobjs, h_many1(txtobj)); @@ -3967,53 +3966,53 @@ void parse_pagenode ( const HParsedToken *contents = NULL; - // Initialize the page tree node - myNode->type = PG_NODE; - myNode->parent_n = parent_n; // NULL for root - myNode->parent_t = parent_t; - myNode->me_t = myRef; - aux->catalog.lastNode++; // keep track of the node count - aux->catalog.lastPage++; // keep track of the page count - aux->curr_node = myNode; - myNode->ts.node = myNode; // set the current page to me - myNode->ts.font = NULL; - myNode->ts.char_spacing = 0.0; - myNode->ts.word_spacing = 0.0; - myNode->ts.line_spacing = 0.0; - // locate the starting point at top left of a 8.5x11" paper - myNode->ts.curr_pos.tx = 0.0; // 8.5" = 612 points - myNode->ts.curr_pos.ty = 0.0; // 11" = 792 points - myNode->pn.dict = myDict; - myNode->nodeNum = aux->catalog.lastNode; - myNode->pn.page_num = aux->catalog.lastPage; - myNode->pn.textStream = NULL; - // initialize by inheriting -- override with local - myNode->pgRsrc = parent_n->pgRsrc; - myNode->mediaBox.tx = parent_n->mediaBox.tx; - myNode->mediaBox.ty = parent_n->mediaBox.ty; + // Initialize the page tree node + myNode->type = PG_NODE; + myNode->parent_n = parent_n; // NULL for root + myNode->parent_t = parent_t; + myNode->me_t = myRef; + aux->catalog.lastNode++; // keep track of the node count + aux->catalog.lastPage++; // keep track of the page count + aux->curr_node = myNode; + myNode->ts.node = myNode; // set the current page to me + myNode->ts.font = NULL; + myNode->ts.char_spacing = 0.0; + myNode->ts.word_spacing = 0.0; + myNode->ts.line_spacing = 0.0; + // locate the starting point at top left of a 8.5x11" paper + myNode->ts.curr_pos.tx = 0.0; // 8.5" = 612 points + myNode->ts.curr_pos.ty = 0.0; // 11" = 792 points + myNode->pn.dict = myDict; + myNode->nodeNum = aux->catalog.lastNode; + myNode->pn.page_num = aux->catalog.lastPage; + myNode->pn.textStream = NULL; + // initialize by inheriting -- override with local + myNode->pgRsrc = parent_n->pgRsrc; + myNode->mediaBox.tx = parent_n->mediaBox.tx; + myNode->mediaBox.ty = parent_n->mediaBox.ty; - const HParsedToken *item = NULL; - item = dictentry(myDict, "Parent"); - bool matched = false; - if (item && parent_t) { // neither item nor parent_t should be NULL - assert(item->token_type == TT_Ref); - if ( ( ((Ref*)item->user)->nr == ((Ref*)parent_t->user)->nr ) && - ( ((Ref*)item->user)->gen == ((Ref*)parent_t->user)->gen ) ) { - matched = true; - } - } - if (! matched) { - fprintf(stdout, "parse_pagenode: Inconsistent or corrupt parent key!\n"); - fprintf(stdout, "Parent (from caller) =\n"); - h_pprintln(stdout, parent_t); - fprintf(stdout, "Parent (from node) =\n"); - h_pprintln(stdout, item); + const HParsedToken *item = NULL; + item = dictentry(myDict, "Parent"); + bool matched = false; + if (item && parent_t) { // neither item nor parent_t should be NULL + assert(item->token_type == TT_Ref); + if (( ((Ref*)item->user)->nr == ((Ref*)parent_t->user)->nr ) && + ( ((Ref*)item->user)->gen == ((Ref*)parent_t->user)->gen )) { + matched = true; + } + } + if (! matched) { + fprintf(stdout, "parse_pagenode: Inconsistent or corrupt parent key!\n"); + fprintf(stdout, "Parent (from caller) =\n"); + h_pprintln(stdout, parent_t); + fprintf(stdout, "Parent (from node) =\n"); + h_pprintln(stdout, item); - // just continue for now - return; - } + // just continue for now + return; + } @@ -4137,48 +4136,48 @@ parse_pagetree( ) { // Initialize the page tree node - myNode->type = PG_TREE; - myNode->parent_n = parent_n; // NULL for root - myNode->parent_t = parent_t; - myNode->me_t = myRef; - aux->catalog.lastNode++; // keep track of the node count - myNode->nodeNum = aux->catalog.lastNode; - if (parent_n) { // inheritable if in a tree node - myNode->pgRsrc = parent_n->pgRsrc; - myNode->mediaBox.tx = parent_n->mediaBox.tx; - myNode->mediaBox.ty = parent_n->mediaBox.ty; - } - else { - myNode->pgRsrc = NULL; - myNode->mediaBox.tx = 0; - myNode->mediaBox.ty = 0; - } + myNode->type = PG_TREE; + myNode->parent_n = parent_n; // NULL for root + myNode->parent_t = parent_t; + myNode->me_t = myRef; + aux->catalog.lastNode++; // keep track of the node count + myNode->nodeNum = aux->catalog.lastNode; + if (parent_n) { // inheritable if in a tree node + myNode->pgRsrc = parent_n->pgRsrc; + myNode->mediaBox.tx = parent_n->mediaBox.tx; + myNode->mediaBox.ty = parent_n->mediaBox.ty; + } + else { + myNode->pgRsrc = NULL; + myNode->mediaBox.tx = 0; + myNode->mediaBox.ty = 0; + } - // make sure that the parent node matches - const HParsedToken *item = NULL; + // make sure that the parent node matches + const HParsedToken *item = NULL; item = dictentry(myDict, "Parent"); // if root node ==> parent should be NULL bool matched = false; if (item && parent_t) { - if ( ( ((Ref*)item->user)->nr == ((Ref*)parent_t->user)->nr ) && - ( ((Ref*)item->user)->gen == ((Ref*)parent_t->user)->gen ) ) { - matched = true; - } + if (( ((Ref*)item->user)->nr == ((Ref*)parent_t->user)->nr ) && + ( ((Ref*)item->user)->gen == ((Ref*)parent_t->user)->gen )) { + matched = true; + } } else { // either the parent is the page tree root or the node does not have a valid Parent key - if (item == parent_t) {// if item is NULL, we expect parent_t to also be NULL (==> root) - matched = true; - } + if (item == parent_t) {// if item is NULL, we expect parent_t to also be NULL (==> root) + matched = true; + } } if (! matched) { - fprintf(stdout, "parse_pagetree: Inconsistent or corrupt parent key!\n"); - fprintf(stdout, "Parent (from caller) =\n"); - h_pprintln(stdout, parent_t); - fprintf(stdout, "Parent (from node) =\n"); - h_pprintln(stdout, item); + fprintf(stdout, "parse_pagetree: Inconsistent or corrupt parent key!\n"); + fprintf(stdout, "Parent (from caller) =\n"); + h_pprintln(stdout, parent_t); + fprintf(stdout, "Parent (from node) =\n"); + h_pprintln(stdout, item); - // just continue for now - return; + // just continue for now + return; } @@ -4255,10 +4254,10 @@ parse_pagetree( HCountedArray *pgTable = H_CAST_SEQ(kids); size_t pgtSz = pgTable->used; if (pgtSz != myNode->pt.numPages) { - fprintf(stdout, "parse_pagetree: Size mismatch:: " - "Kids array size = %lu, Page Count in node = %u\n", - pgtSz, myNode->pt.numPages); - // continue processing the pages + fprintf(stdout, "parse_pagetree: Size mismatch:: " + "Kids array size = %lu, Page Count in node = %u\n", + pgtSz, myNode->pt.numPages); + // continue processing the pages } myNode->pt.kids = (PtNode_T*)h_arena_malloc(pgTable->arena, pgtSz * sizeof(PtNode_T)); @@ -4309,8 +4308,8 @@ parse_catalog(struct Env *aux, const HParsedToken *roo aux->catalog.catalog = NULL; aux->catalog.pRoot = NULL; aux->catalog.lastPage = 0; - aux->catalog.lastNode = 0; - // Initialize the xobject structure + aux->catalog.lastNode = 0; + // Initialize the xobject structure aux->catalog.xObjs.name = NULL; aux->catalog.xObjs.node = NULL; aux->catalog.xObjs.next = NULL;