summaryrefslogtreecommitdiff
path: root/shells/v7sh/files/patch-print.c
blob: 1bde66cf91a1182ed33ca492017189f1cee22666 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
diff -u -x CVS -x work -x core -x *.core -x #* -x *~ -x *.orig -x *.rej -I $Id.*$ -I $.+BSD.*$ print.c.orig print.c
--- print.c.orig	Fri Jun  4 02:51:02 2004
+++ print.c	Sat Jun 19 18:42:24 2004
@@ -9,20 +9,20 @@
 
 #include	"defs.h"
 
-CHAR		numbuf[6];
+CHAR		numbuf[12];
 
 
 /* printing and io conversion */
 
-newline()
+VOID	newline()
 {	prc(NL);
 }
 
-blank()
+VOID	blank()
 {	prc(SP);
 }
 
-prp()
+VOID	prp()
 {
 	IF (flags&prompt)==0 ANDF cmdadr
 	THEN	prs(cmdadr); prs(colon);
@@ -30,47 +30,49 @@
 }
 
 VOID	prs(as)
-	STRING		as;
+	CSTRING		as;
 {
-	REG STRING	s;
+	REG CSTRING	s;
 
-	IF s=as
-	THEN	write(output,s,length(s)-1);
+	IF (s=as)!=NIL				/* GCC */
+	THEN	write(output,s,(SIZE) length(s)-1);
 	FI
 }
 
 VOID	prc(c)
-	CHAR		c;
+	INT		c;
 {
 	IF c
-	THEN	write(output,&c,1);
+	THEN	write(output,&c,(SIZE) 1);
 	FI
 }
 
-prt(t)
-	L_INT		t;
+VOID	prt(t)
+	CLOCK		t;
 {
-	REG INT	hr, min, sec;
+	REG CLOCK	hr, min, sec;
 
 	t += 30; t /= 60;
 	sec=t%60; t /= 60;
 	min=t%60;
-	IF hr=t/60
-	THEN	prn(hr); prc('h');
+	IF (hr=t/60)!=0				/* GCC */
+	THEN	prl(hr); prc('h');
 	FI
-	prn(min); prc('m');
-	prn(sec); prc('s');
+	prl(min); prc('m');
+	prl(sec); prc('s');
 }
 
-prn(n)
+VOID	prn(n)
 	INT		n;
 {
 	itos(n); prs(numbuf);
 }
 
-itos(n)
+VOID	itos(n)
+	INT		n;
 {
-	REG char *abuf; REG POS a, i; INT pr, d;
+	REG STRING abuf; REG POS a, i; INT pr, d;
+
 	abuf=numbuf; pr=FALSE; a=n;
 	FOR i=10000; i!=1; i/=10
 	DO	IF (pr |= (d=a/i)) THEN *abuf++=d+'0' FI
@@ -80,18 +82,38 @@
 	*abuf++=0;
 }
 
-stoi(icp)
-STRING	icp;
+INT	stoi(icp)
+	CSTRING	icp;
 {
-	REG CHAR	*cp = icp;
+	REG CSTRING	cp = icp;
 	REG INT		r = 0;
-	REG CHAR	c;
+	REG INT		c;
 
 	WHILE (c = *cp, digit(c)) ANDF c ANDF r>=0
 	DO r = r*10 + c - '0'; cp++ OD
 	IF r<0 ORF cp==icp
 	THEN	failed(icp,badnum);
-	ELSE	return(r);
+		/*NOTREACHED*/
 	FI
+	return(r);
 }
 
+VOID	prl(n)	/* for ULIMIT */
+	LONG		n;
+{
+	ltos(n); prs(numbuf);
+}
+
+VOID	ltos(n)
+	LONG		n;
+{
+	REG STRING abuf; REG POS a, i; INT pr, d;
+
+	abuf=numbuf; pr=FALSE; a=n;
+	FOR i=1000000000; i!=1; i/=10
+	DO	IF (pr |= (d=(INT) (a/i))) THEN *abuf++=d+'0' FI
+		a %= i;
+	OD
+	*abuf++=a+'0';
+	*abuf++=0;
+}