Ejemplo n.º 1
0
/*
 *   Now our scanpage routine.
 */
static void
pscanpage(void)
{
   register shalfword cmd;
   register chardesctype *cd;
   register fontmaptype *cfnt = 0;
   integer fnt;
   integer mychar;
   register frametype *frp = frames;

#ifdef DEBUG
   if (dd(D_PAGE))
#ifdef SHORTINT
   fprintf(stderr,"PPrescanning page %ld\n", pagenum);
#else   /* ~SHORTINT */
   fprintf(stderr,"PPrescanning page %d\n", pagenum);
#endif  /* ~SHORTINT */
#endif  /* DEBUG */
   curfnt = NULL;
   curpos = NULL;
   bopcolor(0);
   while (1) {
      switch (cmd=dvibyte()) {
case 255: /* pTeX's dir or undefined */
         if (!noptex) {
            dvibyte();
            break;
         }
/* illegal commands */
case 131: case 136: case 139: /* set4, put4, bop */
case 247: case 248: case 249: /* pre, post, post_post */
case 250: case 251: case 252: case 253: case 254: /* undefined */
         sprintf(errbuf,
            "! DVI file contains unexpected command (%d)",cmd);
         error(errbuf);
case 132: case 137: /* eight-byte commands setrule, putrule */
         dvibyte();
         dvibyte();
         dvibyte();
         dvibyte();
case 146: case 151: case 156: case 160: case 165: case 170:
   /* four-byte commands right4, w4, x4, down4, y4, z4 */
         dvibyte();
case 145: case 150: case 155: case 159: case 164: case 169:
   /* three-byte commands right3, w3, x3, down3, y3, z3 */
         dvibyte();
case 144: case 149: case 154: case 158: case 163: case 168:
   /* two-byte commands right2, w2, x2, down2, y2, z2 */
         dvibyte();
case 143: case 148: case 153: case 157: case 162: case 167:
   /* one-byte commands right1, w1, x1, down1, y1, z1 */
         dvibyte();
case 147: case 152: case 161: case 166: /* w0, x0, y0, z0 */
case 138: case 141: case 142: /* nop, push, pop */
         break;
case 130: case 135: /* set3, put3 */
         if (noptex) {
            sprintf(errbuf,
               "! DVI file contains unexpected pTeX command (%d)",cmd);
            error(errbuf);
         }
         mychar = dvibyte(); mychar = (mychar << 8) + dvibyte();
         mychar = (mychar << 8) + dvibyte();
         goto dochar;
case 129: case 134: /* set2, put2 */
         if (noomega && noptex) {
            sprintf(errbuf,
               "! DVI file contains unexpected command (%d)",cmd);
            error(errbuf);
         }
         mychar = dvibyte(); mychar = (mychar << 8) + dvibyte();
         goto dochar;
case 128: case 133: cmd = dvibyte(); /* set1, put1 commands drops through */
default:    /* these are commands 0 (setchar0) thru 127 (setchar 127) */
         mychar = cmd;
dochar:
         if (curfnt==NULL)
            error("! Bad DVI file: no font selected");
         if (mychar>=curfnt->maxchars) {
            sprintf(errbuf,"! invalid char %d from font %s", mychar, curfnt->name);
            error(errbuf);
         }
         if (curfnt->loaded == 2) { /* scanning a virtual font character */
            frp->curp = curpos;
            frp->curl = curlim;
            frp->ff = ffont;
            frp->curf = curfnt;
            if (++frp == &frames[MAXFRAME] )
               error("! virtual recursion stack overflow");
            cd = curfnt->chardesc + mychar;
            if (cd->packptr == 0) {
               fprintf(stderr, "Wrong char code: %04X\n", mychar);
               error("! a non-existent virtual char is being used; check vf/tfm files");
            }
            curpos = cd->packptr + 2;
            curlim = curpos + (256*(long)(*cd->packptr)+(*(cd->packptr+1)));
            ffont = curfnt->localfonts;
            if (ffont==NULL)
               curfnt = NULL;
            else
               ppreselectfont(ffont->desc);
         } else if (curfnt->loaded == 3)
            curfnt->chardesc[mychar].flags = EXISTS;
         break;
case 171: case 172: case 173: case 174: case 175: case 176: case 177:
case 178: case 179: case 180: case 181: case 182: case 183: case 184:
case 185: case 186: case 187: case 188: case 189: case 190: case 191:
case 192: case 193: case 194: case 195: case 196: case 197: case 198:
case 199: case 200: case 201: case 202: case 203: case 204: case 205:
case 206: case 207: case 208: case 209: case 210: case 211: case 212:
case 213: case 214: case 215: case 216: case 217: case 218: case 219:
case 220: case 221: case 222: case 223: case 224: case 225: case 226:
case 227: case 228: case 229: case 230: case 231: case 232: case 233:
case 234: case 235: case 236: case 237: case 238: /* font selection commands */
         if (cmd < 235) fnt = cmd - 171; /* fntnum0 thru fntnum63 */
         else {
            fnt = dvibyte(); /* fnt1 */
            while (cmd-- > 235)
               fnt = (fnt << 8) + dvibyte();
         }
         for (cfnt=ffont; cfnt; cfnt = cfnt->next)
            if (cfnt->fontnum == fnt) goto fontfound;
         error("! no font selected");
fontfound:  curfnt = cfnt->desc;
         ppreselectfont(curfnt);
         break;
case 239: predospecial((integer)dvibyte(), 1); break; /* xxx1 */
case 240: predospecial((integer)twobytes(), 1); break; /* xxx2 */
case 241: predospecial(threebytes(), 1); break; /* xxx3 */
case 242: predospecial(signedquad(), 1); break; /* xxx4 */
case 243: case 244: case 245: case 246: fontdef(cmd-242); break; /* fntdef1 */
case 140: /* eop or end of virtual char */
         if (curpos) {
            --frp;
            curfnt = frp->curf;
            ffont = frp->ff;
            curlim = frp->curl;
            curpos = frp->curp;
            break;
         }
         return;
      }
   }
}
Ejemplo n.º 2
0
void skippage()                /* skip past one page */
{
    register int opcode;

    while ((opcode = (int) get1()) != EOP) {
        if (opcode > POST_POST)
            errorexit(illop);
        else
            switch (opcode) {
                case SET1     :
                case PUT1     :
                case RIGHT1   :
                case W1       :
                case X1       :
                case DOWN1    :
                case Y1       :
                case Z1       : /* assume FNT change can also be skipped */
                case FNT1     : mseek(DVIfile, 1L, relative); break;
                case SET2     :
                case PUT2     :
                case RIGHT2   :
                case W2       :
                case X2       :
                case DOWN2    :
                case Y2       :
                case Z2       :
                case FNT2     : mseek(DVIfile, 2L, relative); break;
                case SET3     :
                case PUT3     :
                case RIGHT3   :
                case W3       :
                case X3       :
                case DOWN3    :
                case Y3       :
                case Z3       :
                case FNT3     : mseek(DVIfile, 3L, relative); break;
                case SET4     :
                case PUT4     :
                case RIGHT4   :
                case W4       :
                case X4       :
                case DOWN4    :
                case Y4       :
                case Z4       :
                case FNT4     : mseek(DVIfile, 4L, relative); break;
                case SET_RULE :
                case PUT_RULE : mseek(DVIfile, 8L, relative); break;
                case BOP      : errorexit(bdbop); break;
                case XXX1     : mseek(DVIfile, get1(), relative); break;
                case XXX2     : mseek(DVIfile, get2(), relative); break;
                case XXX3     : mseek(DVIfile, get3(), relative); break;
                case XXX4     : mseek(DVIfile, get4(), relative); break;
                case FNT_DEF1 :
                case FNT_DEF2 :
                case FNT_DEF3 :
                case FNT_DEF4 : fontdef(opcode - FNT_DEF1 + 1); break;
                case PRE      : errorexit(bdpre); break;
                case POST     : errorexit(bdpst); break;
                case POST_POST: errorexit(bdpp); break;
        }
    }

} /* skippage */
Ejemplo n.º 3
0
/*
 *   And now the big routine.
 */
void
skippage()
{
   register shalfword cmd ;
   register integer i ;

#ifdef DEBUG
   if (dd(D_PAGE))
#ifdef SHORTINT
   (void)fprintf(stderr,"Skipping page %ld\n", pagenum) ;
#else   /* ~SHORTINT */
   (void)fprintf(stderr,"Skipping page %d\n", pagenum) ;
#endif  /* ~SHORTINT */
#endif  /* DEBUG */
   skipover(40) ; /* skip rest of bop command */
   while ((cmd=dvibyte())!=140) {
     switch (cmd) {
/* illegal options */
case 129: case 130: case 131: case 134: case 135: case 136: case 139: 
case 247: case 248: case 249: case 250: case 251: case 252: case 253:
case 254: case 255:
         (void)sprintf(errbuf,
#ifdef SHORTINT
            "! DVI file contains unexpected command (%ld)",cmd) ;
#else   /* ~SHORTINT */
            "! DVI file contains unexpected command (%d)",cmd) ;
#endif  /* ~SHORTINT */
         error(errbuf) ;
/* eight byte commands */
case 132: case 137:
   cmd = dvibyte() ;
   cmd = dvibyte() ;
   cmd = dvibyte() ;
   cmd = dvibyte() ;
/* four byte commands */
case 146: case 151: case 156: case 160: case 165: case 170: case 238:
   cmd = dvibyte() ;
/* three byte commands */
case 145: case 150: case 155: case 159: case 164: case 169: case 237:
   cmd = dvibyte() ;
/* two byte commands */
case 144: case 149: case 154: case 158: case 163: case 168: case 236:
   cmd = dvibyte() ;
/* one byte commands */
case 128: case 133: case 143: case 148: case 153: case 157: case 162:
case 167: case 235:
   cmd = dvibyte() ;
   break ;
/* specials */
case 239: i = dvibyte() ; predospecial(i, 0) ; break ;
case 240: i = twobytes() ; predospecial(i, 0) ; break ;
case 241: i = threebytes() ; predospecial(i, 0) ; break ;
case 242: i = signedquad() ; predospecial(i, 0) ; break ;
/* font definition */
case 243: case 244: case 245: case 246:
   fontdef(cmd - 242) ;
   break ;
default: ;
      }
   }
}
Ejemplo n.º 4
0
void dopage()
{

    while ((opcode = (int) get1()) != EOP) {    /* process page until eop */
        if (opcode <= LASTCHAR)
            dochar((char) opcode);
        else if ((opcode >= FONT_00) && (opcode <= FONT_63)) 
            setfont(opcode - FONT_00);
        else if (opcode > POST_POST)
            errorexit(illop);
        else
            switch (opcode) {
                case SET1     : setchar(get1()); break;
                case SET2     : setchar(get2()); break;
                case SET3     : setchar(get3()); break;
                case SET4     : setchar(get4()); break;
                case SET_RULE : { long height = sget4();
                                  rule(MOVE, sget4(), height); break;
                                }
                case PUT1     : putcharacter(get1()); break;
                case PUT2     : putcharacter(get2()); break;
                case PUT3     : putcharacter(get3()); break;
                case PUT4     : putcharacter(get4()); break;
                case PUT_RULE : { long height = sget4();
                                  rule(STAY, sget4(), height); break;
                                }
                case NOP      : break;  /* no-op */
                case BOP      : errorexit(bdbop); break;
/*              case EOP      : break;  strange place to have EOP */
                case PUSH     : if (sptr >= stackmax)            /* push */
                                     errorexit(stkof);
                                stack[sptr].hh = h;
                                stack[sptr].vv = v;
                                stack[sptr].ww = w;
                                stack[sptr].xx = x;
                                stack[sptr].yy = y;
                                stack[sptr].zz = z;
                                sptr++;
                                break;
                case POP      : if (sptr == 0)                   /* pop */
                                    errorexit(stkuf);
                                sptr--;
                                h = stack[sptr].hh;
                                v = stack[sptr].vv;
                                w = stack[sptr].ww;
                                x = stack[sptr].xx;
                                y = stack[sptr].yy;
                                z = stack[sptr].zz;
                                break;
                case RIGHT1   : (void) horizontalmove(sget1()); break;
                case RIGHT2   : (void) horizontalmove(sget2()); break;
                case RIGHT3   : (void) horizontalmove(sget3()); break;
                case RIGHT4   : (void) horizontalmove(sget4()); break;
                case W0       : h += w; break;
                case W1       : w = horizontalmove(sget1()); break;
                case W2       : w = horizontalmove(sget2()); break;
                case W3       : w = horizontalmove(sget3()); break;
                case W4       : w = horizontalmove(sget4()); break;
                case X0       : h += x; break;
                case X1       : x = horizontalmove(sget1()); break;
                case X2       : x = horizontalmove(sget2()); break;
                case X3       : x = horizontalmove(sget3()); break;
                case X4       : x = horizontalmove(sget4()); break;
                case DOWN1    : v += sget1(); break;
                case DOWN2    : v += sget2(); break;
                case DOWN3    : v += sget3(); break;
                case DOWN4    : v += sget4(); break;
                case Y0       : v += y; break;
                case Y1       : y = sget1(); v += y; break;
                case Y2       : y = sget2(); v += y; break;
                case Y3       : y = sget3(); v += y; break;
                case Y4       : y = sget4(); v += y; break;
                case Z0       : v += z; break;
                case Z1       : z = sget1(); v += z; break;
                case Z2       : z = sget2(); v += z; break;
                case Z3       : z = sget3(); v += z; break;
                case Z4       : z = sget4(); v += z; break;
                case FNT1     :
                case FNT2     :
                case FNT3     :
                case FNT4     : setfont(num(opcode - FNT1 + 1));
                                break;
                case XXX1     : mseek(DVIfile, get1(), relative); break;
                case XXX2     : mseek(DVIfile, get2(), relative); break;
                case XXX3     : mseek(DVIfile, get3(), relative); break;
                case XXX4     : mseek(DVIfile, get4(), relative); break;
                case FNT_DEF1 :
                case FNT_DEF2 :
                case FNT_DEF3 :
                case FNT_DEF4 : fontdef(opcode - FNT_DEF1 + 1);
                                break;
                case PRE      : errorexit(bdpre); break;
                case POST     : errorexit(bdpst); break;
                case POST_POST: errorexit(bdpp); break;
            }
    }

} /* dopage */
Ejemplo n.º 5
0
/*
 *   And now the big routine.
 */
void
skippage(void)
{
   register shalfword cmd;
   register integer i;

#ifdef DEBUG
   if (dd(D_PAGE))
#ifdef SHORTINT
   fprintf(stderr,"Skipping page %ld\n", pagenum);
#else   /* ~SHORTINT */
   fprintf(stderr,"Skipping page %d\n", pagenum);
#endif  /* ~SHORTINT */
#endif  /* DEBUG */
/* skipover(40); skip rest of bop command? how did this get in here? */
   bopcolor(0);
   while ((cmd=dvibyte())!=140) {
     switch (cmd) {
case 255: /* pTeX's dir or undefined */
   if (!noptex) {
      cmd = dvibyte();
      break;
   }
/* illegal commands */
case 139: case 247: case 248: case 249: /* bop, pre, post, post_post */
case 250: case 251: case 252: case 253: case 254: /* undefined */
         sprintf(errbuf,
            "! DVI file contains unexpected command (%d)",cmd);
         error(errbuf);
/* eight byte commands */
case 132: case 137:
   cmd = dvibyte();
   cmd = dvibyte();
   cmd = dvibyte();
   cmd = dvibyte();
/* four byte commands */
case 131: case 136:
case 146: case 151: case 156: case 160: case 165: case 170: case 238:
   cmd = dvibyte();
/* three byte commands */
case 130: case 135:
case 145: case 150: case 155: case 159: case 164: case 169: case 237:
   cmd = dvibyte();
/* two byte commands */
case 129: case 134:
case 144: case 149: case 154: case 158: case 163: case 168: case 236:
   cmd = dvibyte();
/* one byte commands */
case 128: case 133:
case 143: case 148: case 153: case 157: case 162: case 167: case 235:
   cmd = dvibyte();
   break;
/* specials */
case 239: i = dvibyte(); predospecial(i, 0); break;
case 240: i = twobytes(); predospecial(i, 0); break;
case 241: i = threebytes(); predospecial(i, 0); break;
case 242: i = signedquad(); predospecial(i, 0); break;
/* font definition */
case 243: case 244: case 245: case 246:
   fontdef(cmd - 242);
   break;
default:;
      }
   }
}