1: char  *_ptrbf, *_ptrst, *__fmt;
   2: printf(a1,a2,a3,a4){
   3: auto char  c, *s,  adj, *ptr,*p, buf[30];
   4: extern cputc(),_putstr(), cout;
   5: auto int  *adx, x, n, m, width, prec,i, padchar, fd;
   6: double zz, *dblptr;
   7: char (*f)();
   8: _ptrbf = buf;
   9: 
  10: fd=cout;
  11: adx = &a1;
  12: f = cputc;
  13: if (a1 == -1)
  14:   {
  15:   f = _putstr;
  16:   _ptrst = a2;
  17:   adx =+ 2;
  18:   }
  19: else if (a1 >= 0 && a1 <= 9)
  20:   fd = *adx++;
  21: __fmt = *adx++;
  22: 
  23: 
  24: while( c = *__fmt++ ){
  25:    if(c != '%') (*f)(c,fd);
  26:    else { x = *adx++;
  27:       if( *__fmt == '-' ){ adj = 'l';  __fmt++; }
  28:       else adj = 'r';
  29:    padchar = (*__fmt=='0') ? '0' : ' ';
  30:       width = __conv();
  31:       if( *__fmt == '.'){++__fmt; prec = __conv();}
  32:       else prec = 0;
  33: 
  34:    s = 0;
  35:    switch ( c = *__fmt++ ) {
  36:      case 'D':
  37:      case 'd':
  38:     _prt1(x); break;
  39:      case 'o':
  40:      case 'O':
  41:          _prnt8(x); break;
  42:      case 'x':
  43:      case 'X':
  44:           _prntx(x); break;
  45:       case 'S':
  46:      case 's':    s=x;
  47:         break;
  48:      case 'C':
  49:      case 'c':   *_ptrbf++ = x&0777;
  50:          break;
  51:      case 'E':
  52:      case 'e':
  53:      case 'F':
  54:      case 'f':
  55:       dblptr = adx-1;
  56:       zz = *dblptr;
  57:       adx =+ 3;
  58:       ftoa (zz, buf, prec, c);
  59:       prec = 0;
  60:       s = buf;
  61:      break;
  62:      default:   (*f)(c,fd);
  63:          adx--;
  64:    }
  65:    if (s == 0)
  66:     {*_ptrbf = '\0'; s = buf;}
  67:    n = _clenf (s);
  68:    n = (prec<n && prec != 0) ? prec : n;
  69:    m = width-n;
  70:    if (adj == 'r') while (m-- > 0) (*f)(padchar,fd);
  71:    while (n--) (*f)(*s++,fd);
  72:    while (m-- > 0) (*f)(padchar,fd);
  73:    _ptrbf = buf;
  74:    }
  75: }
  76: if(a1 == -1) (*f)('\0',fd);
  77: }
  78: 
  79: 
  80: _prnt8 (n)
  81: { /* print in octal */
  82: int p, k, sw;
  83: if (n==0) {*_ptrbf++ = '0'; return;}
  84: sw = 0;
  85: for (p=15; p >= 0; p =- 3)
  86:   if ((k = (n>>p)&07) || sw)
  87:    {
  88:     *_ptrbf++ = '0' + k;
  89:      sw = 1;
  90:      }
  91: }
  92: _prntx (n)
  93: {
  94:     int d,a;
  95:     if (a = n>>4)
  96:         _prntx ( a & 07777);
  97:     d = n&017;
  98:     *_ptrbf++ =  d > 9 ? 'A'+d-10 : '0' + d;
  99: }
 100: 
 101: __conv()
 102: {
 103: auto c,n;
 104: n = 0;
 105: while( ((c = *__fmt++) >= '0') && (c<='9')) n = n*10+c-'0';
 106: __fmt--;
 107: return(n);
 108: }
 109: 
 110: _putstr(chr,str){
 111: *_ptrst++ = chr;
 112: return; ieh305i(); /* force loading of dummy.s */
 113: }
 114: _prt1(n)
 115: {
 116: int digs[15], *dpt;
 117: dpt = digs;
 118: if (n >= 0)
 119:    n = -n;
 120: else
 121:    *_ptrbf++ = '-';
 122: for (; n != 0; n = n/10)
 123:  *dpt++ = n%10;
 124: if (dpt == digs)
 125:    *dpt++ = 0;
 126: while (dpt != digs)
 127:    { --dpt;
 128:    *_ptrbf++ =  '0' - *dpt;
 129: }
 130: }

Defined functions

__conv defined in line 101; used 2 times
_prnt8 defined in line 80; used 1 times
  • in line 41
_prntx defined in line 92; used 2 times
_prt1 defined in line 114; used 1 times
  • in line 38
_putstr defined in line 110; used 2 times
  • in line 4, 15
printf defined in line 2; never used

Defined variables

__fmt defined in line 1; used 10 times
_ptrbf defined in line 1; used 9 times
_ptrst defined in line 1; used 2 times
Last modified: 1975-05-14
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 635
Valid CSS Valid XHTML 1.0 Strict