void walkpages() /* process the pages in the DVI-file */ { register bool wantpage; pagecounter = 0L; while ((opcode = skipnops()) != POST) { if (opcode != BOP) /* should be at start of page now */ errorexit(nobop); else { pagecounter++; pagenr = sget4(); /* get TeX page number */ mseek(DVIfile, 36L, relative); /* skip page header */ backpointer = sget4(); /* get previous page offset */ if (pageswitchon) if (sequenceon) wantpage = inlist(pagecounter); else wantpage = inlist(pagenr); else wantpage = TRUE; if (wantpage) { initpage(); dopage(); printpage(); } else { skippage(); } } } } /* walkpages */
/* * Now we have the main procedure. */ void dosection(sectiontype *s, int c) { charusetype *cu; integer prevptr; int np; int k; integer thispage = 0; char buf[104]; dopsfont(s); #ifdef HPS if (HPS_FLAG) pagecounter = 0; #endif if (multiplesects) { setup(); } cmdout("TeXDict"); cmdout("begin"); numout(hpapersize); numout(vpapersize); doubleout(mag); numout((integer)DPI); numout((integer)VDPI); snprintf(buf, sizeof(buf), "(%.99s)", fulliname); cmdout(buf); newline(); cmdout("@start"); if (multiplesects) cmdout("bos"); /* * We insure raster is even-word aligned, because download might want that. */ if (bytesleft & 1) { bytesleft--; raster++; } cleanres(); cu = (charusetype *) (s + 1); psfont = 1; while (cu->fd) { if (cu->psfused) cu->fd->psflag = EXISTS; download(cu++, psfont++); } fonttableout(); if (! multiplesects) { cmdout("end"); setup(); } for (cu=(charusetype *)(s+1); cu->fd; cu++) cu->fd->psflag = 0; while (c > 0) { c--; prevptr = s->bos; if (! reverse) fseek(dvifile, (long)prevptr, 0); np = s->numpages; while (np-- != 0) { if (reverse) fseek(dvifile, (long)prevptr, 0); pagenum = signedquad(); if ((evenpages && (pagenum & 1)) || (oddpages && (pagenum & 1)==0) || (pagelist && !InPageList(pagenum))) { if (reverse) { skipover(36); prevptr = signedquad()+1; } else { skipover(40); skippage(); skipnop(); } ++np; /* this page wasn't counted for s->numpages */ continue; } /* * We want to take the base 10 log of the number. It's probably * small, so we do it quick. */ if (! quiet) { int t = pagenum, i = 0; if (t < 0) { t = -t; i++; } do { i++; t /= 10; } while (t > 0); if (pagecopies < 20) i += pagecopies - 1; if (i + prettycolumn > STDOUTSIZE) { fprintf(stderr, "\n"); prettycolumn = 0; } prettycolumn += i + 1; #ifdef SHORTINT fprintf(stderr, "[%ld", pagenum); #else /* ~SHORTINT */ fprintf(stderr, "[%d", pagenum); #endif /* ~SHORTINT */ fflush(stderr); } skipover(36); prevptr = signedquad()+1; for (k=0; k<pagecopies; k++) { if (k == 0) { if (pagecopies > 1) thispage = ftell(dvifile); } else { fseek(dvifile, (long)thispage, 0); if (prettycolumn + 1 > STDOUTSIZE) { fprintf(stderr, "\n"); prettycolumn = 0; } fprintf(stderr, "."); fflush(stderr); prettycolumn++; } dopage(); } if (! quiet) { fprintf(stderr, "] "); fflush(stderr); prettycolumn += 2; } if (! reverse) skipnop(); } } if (! multiplesects && ! disablecomments) { newline(); fprintf(bitfile, "%%%%Trailer\n"); } if (multiplesects) { if (! disablecomments) { newline(); fprintf(bitfile, "%%DVIPSSectionTrailer\n"); } cmdout("eos"); cmdout("end"); } #ifdef HPS if (HPS_FLAG) cmdout("\nend"); /* close off HPSDict */ #endif if (multiplesects && ! disablecomments) { newline(); fprintf(bitfile, "%%DVIPSEndSection\n"); linepos = 0; } }