1*442bc7a3Ssam #ifndef lint
2*442bc7a3Ssam static char sccsid[] = "@(#)print.c 4.2 08/11/83";
3*442bc7a3Ssam #endif
481057bbdSmckusick
581057bbdSmckusick #
681057bbdSmckusick /*
781057bbdSmckusick * UNIX shell
881057bbdSmckusick *
981057bbdSmckusick * S. R. Bourne
1081057bbdSmckusick * Bell Telephone Laboratories
1181057bbdSmckusick *
1281057bbdSmckusick */
1381057bbdSmckusick
1481057bbdSmckusick #include "defs.h"
1581057bbdSmckusick
1681057bbdSmckusick CHAR numbuf[6];
1781057bbdSmckusick
1881057bbdSmckusick
1981057bbdSmckusick /* printing and io conversion */
2081057bbdSmckusick
newline()2181057bbdSmckusick newline()
2281057bbdSmckusick { prc(NL);
2381057bbdSmckusick }
2481057bbdSmckusick
blank()2581057bbdSmckusick blank()
2681057bbdSmckusick { prc(SP);
2781057bbdSmckusick }
2881057bbdSmckusick
prp()2981057bbdSmckusick prp()
3081057bbdSmckusick {
3181057bbdSmckusick IF (flags&prompt)==0 ANDF cmdadr
3281057bbdSmckusick THEN prs(cmdadr); prs(colon);
3381057bbdSmckusick FI
3481057bbdSmckusick }
3581057bbdSmckusick
prs(as)3681057bbdSmckusick VOID prs(as)
3781057bbdSmckusick STRING as;
3881057bbdSmckusick {
3981057bbdSmckusick REG STRING s;
4081057bbdSmckusick
4181057bbdSmckusick IF s=as
4281057bbdSmckusick THEN write(output,s,length(s)-1);
4381057bbdSmckusick FI
4481057bbdSmckusick }
4581057bbdSmckusick
prc(c)4681057bbdSmckusick VOID prc(c)
4781057bbdSmckusick CHAR c;
4881057bbdSmckusick {
4981057bbdSmckusick IF c
5081057bbdSmckusick THEN write(output,&c,1);
5181057bbdSmckusick FI
5281057bbdSmckusick }
5381057bbdSmckusick
prt(t)5481057bbdSmckusick prt(t)
5581057bbdSmckusick L_INT t;
5681057bbdSmckusick {
5781057bbdSmckusick REG INT hr, min, sec;
5881057bbdSmckusick
5981057bbdSmckusick t += 30; t /= 60;
6081057bbdSmckusick sec=t%60; t /= 60;
6181057bbdSmckusick min=t%60;
6281057bbdSmckusick IF hr=t/60
6381057bbdSmckusick THEN prn(hr); prc('h');
6481057bbdSmckusick FI
6581057bbdSmckusick prn(min); prc('m');
6681057bbdSmckusick prn(sec); prc('s');
6781057bbdSmckusick }
6881057bbdSmckusick
prn(n)6981057bbdSmckusick prn(n)
7081057bbdSmckusick INT n;
7181057bbdSmckusick {
7281057bbdSmckusick itos(n); prs(numbuf);
7381057bbdSmckusick }
7481057bbdSmckusick
itos(n)7581057bbdSmckusick itos(n)
7681057bbdSmckusick {
7781057bbdSmckusick REG char *abuf; REG POS a, i; INT pr, d;
7881057bbdSmckusick abuf=numbuf; pr=FALSE; a=n;
7981057bbdSmckusick FOR i=10000; i!=1; i/=10
8081057bbdSmckusick DO IF (pr |= (d=a/i)) THEN *abuf++=d+'0' FI
8181057bbdSmckusick a %= i;
8281057bbdSmckusick OD
8381057bbdSmckusick *abuf++=a+'0';
8481057bbdSmckusick *abuf++=0;
8581057bbdSmckusick }
8681057bbdSmckusick
stoi(icp)8781057bbdSmckusick stoi(icp)
8881057bbdSmckusick STRING icp;
8981057bbdSmckusick {
9081057bbdSmckusick REG CHAR *cp = icp;
9181057bbdSmckusick REG INT r = 0;
9281057bbdSmckusick REG CHAR c;
9381057bbdSmckusick
9481057bbdSmckusick WHILE (c = *cp, digit(c)) ANDF c ANDF r>=0
9581057bbdSmckusick DO r = r*10 + c - '0'; cp++ OD
9681057bbdSmckusick IF r<0 ORF cp==icp
9781057bbdSmckusick THEN failed(icp,badnum);
9881057bbdSmckusick ELSE return(r);
9981057bbdSmckusick FI
10081057bbdSmckusick }
10181057bbdSmckusick
102