void min_printf(const char *fmt, ...) { char ch; do { ch = *(fmt++); putcharacter(ch); } while (ch); }
static int myputchar(int c) { return putcharacter(c, stdout); }
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 */
void tfp_printf(const char *fmt, ...) { va_list va; char *p; unsigned int i; char ch; va_start(va, fmt); while ((ch = *(fmt++))) { if (ch != '%') { putcharacter(ch); } else { char lz = 0; char w = 0; ch = *(fmt++); if (ch == '0') { ch = *(fmt++); lz = 1; } if (ch >= '0' && ch <= '9') { w = 0; while (ch >= '0' && ch <= '9') { w = (((w << 2) + w) << 1) + ch - '0'; ch = *fmt++; } } bf = buf; p = bf; zs = 0; switch (ch) { case 0: goto abort; case 'u': case 'd': num = va_arg(va, unsigned int); if (ch == 'd' && (int) num < 0) { num = -(int)num; out('-'); } for (i = 100000000; i != 1; i /= 10) divOut(i); outDgt(num); break; case 'p': case 'x': case 'X': uc = ch == 'X'; num = va_arg(va, unsigned int); for (i = 0x10000000; i != 0x1; i >>= 4) divOut(i); outDgt(num); break; case 'c': out((char)(va_arg(va, int))); break; case 's': p = va_arg(va, char*); break; case '%': out('%'); break; default: break; } *bf = 0; bf = p; while (*bf++ && w > 0) w--; while (w-- > 0) putcharacter(lz ? '0' : ' '); while ((ch = *p++)) putcharacter(ch); } } abort: putcharacter('\0'); va_end(va); }