1: #ifndef lint
   2: static char sccsid[] = "@(#)print.c	4.2 8/11/83";
   3: #endif
   4: 
   5: #
   6: /*
   7:  * UNIX shell
   8:  *
   9:  * S. R. Bourne
  10:  * Bell Telephone Laboratories
  11:  *
  12:  */
  13: 
  14: #include    "defs.h"
  15: 
  16: CHAR        numbuf[6];
  17: 
  18: 
  19: /* printing and io conversion */
  20: 
  21: newline()
  22: {   prc(NL);
  23: }
  24: 
  25: blank()
  26: {   prc(SP);
  27: }
  28: 
  29: prp()
  30: {
  31:     IF (flags&prompt)==0 ANDF cmdadr
  32:     THEN    prs(cmdadr); prs(colon);
  33:     FI
  34: }
  35: 
  36: VOID    prs(as)
  37:     STRING      as;
  38: {
  39:     REG STRING  s;
  40: 
  41:     IF s=as
  42:     THEN    write(output,s,length(s)-1);
  43:     FI
  44: }
  45: 
  46: VOID    prc(c)
  47:     CHAR        c;
  48: {
  49:     IF c
  50:     THEN    write(output,&c,1);
  51:     FI
  52: }
  53: 
  54: prt(t)
  55:     L_INT       t;
  56: {
  57:     REG INT hr, min, sec;
  58: 
  59:     t += 30; t /= 60;
  60:     sec=t%60; t /= 60;
  61:     min=t%60;
  62:     IF hr=t/60
  63:     THEN    prn(hr); prc('h');
  64:     FI
  65:     prn(min); prc('m');
  66:     prn(sec); prc('s');
  67: }
  68: 
  69: prn(n)
  70:     INT     n;
  71: {
  72:     itos(n); prs(numbuf);
  73: }
  74: 
  75: itos(n)
  76: {
  77:     REG char *abuf; REG POS a, i; INT pr, d;
  78:     abuf=numbuf; pr=FALSE; a=n;
  79:     FOR i=10000; i!=1; i/=10
  80:     DO  IF (pr |= (d=a/i)) THEN *abuf++=d+'0' FI
  81:         a %= i;
  82:     OD
  83:     *abuf++=a+'0';
  84:     *abuf++=0;
  85: }
  86: 
  87: stoi(icp)
  88: STRING  icp;
  89: {
  90:     REG CHAR    *cp = icp;
  91:     REG INT     r = 0;
  92:     REG CHAR    c;
  93: 
  94:     WHILE (c = *cp, digit(c)) ANDF c ANDF r>=0
  95:     DO r = r*10 + c - '0'; cp++ OD
  96:     IF r<0 ORF cp==icp
  97:     THEN    failed(icp,badnum);
  98:     ELSE    return(r);
  99:     FI
 100: }

Defined functions

blank defined in line 25; used 6 times
itos defined in line 75; used 4 times
prc defined in line 46; used 16 times
prn defined in line 69; used 9 times
prp defined in line 29; used 3 times
prs defined in line 36; used 31 times
prt defined in line 54; used 2 times
stoi defined in line 87; used 4 times

Defined variables

sccsid defined in line 2; never used
Last modified: 1983-08-12
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 2567
Valid CSS Valid XHTML 1.0 Strict