Commit | Line | Data |
---|---|---|
c75047d9 BJ |
1 | /* Copyright (c) 1979 Regents of the University of California */ |
2 | #include "sh.h" | |
3 | ||
4 | /* | |
5 | * C Shell | |
6 | */ | |
7 | ||
8 | p60ths(l) | |
9 | long l; | |
10 | { | |
11 | ||
12 | l += 3; | |
13 | printf("%d.%d", (int) (l / 60), (int) ((l % 60) / 6)); | |
14 | } | |
15 | ||
16 | psecs(l) | |
17 | long l; | |
18 | { | |
19 | register int i; | |
20 | ||
21 | i = l / 3600; | |
22 | if (i) { | |
23 | printf("%d:", i); | |
24 | i = l % 3600; | |
25 | p2dig(i / 60); | |
26 | goto minsec; | |
27 | } | |
28 | i = l; | |
29 | printf("%d", i / 60); | |
30 | minsec: | |
31 | i %= 60; | |
32 | printf(":"); | |
33 | p2dig(i); | |
34 | } | |
35 | ||
36 | p2dig(i) | |
37 | register int i; | |
38 | { | |
39 | ||
40 | printf("%d%d", i / 10, i % 10); | |
41 | } | |
42 | ||
43 | char linbuf[64]; | |
44 | char *linp = linbuf; | |
45 | ||
46 | putchar(c) | |
47 | register int c; | |
48 | { | |
49 | ||
50 | if ((c & QUOTE) == 0 && (c == 0177 || c < ' ' && c != '\t' && c != '\n')) { | |
51 | putchar('^'); | |
52 | if (c == 0177) | |
53 | c = '?'; | |
54 | else | |
55 | c |= 'A' - 1; | |
56 | } | |
57 | c &= TRIM; | |
58 | *linp++ = c; | |
59 | if (c == '\n' || linp >= &linbuf[sizeof linbuf - 2]) | |
60 | flush(); | |
61 | } | |
62 | ||
63 | draino() | |
64 | { | |
65 | ||
66 | linp = linbuf; | |
67 | } | |
68 | ||
69 | flush() | |
70 | { | |
71 | register int unit; | |
72 | ||
73 | if (haderr) | |
74 | unit = didfds ? 2 : SHDIAG; | |
75 | else | |
76 | unit = didfds ? 1 : SHOUT; | |
77 | if (linp != linbuf) { | |
78 | write(unit, linbuf, linp - linbuf); | |
79 | linp = linbuf; | |
80 | } | |
81 | } | |
82 | ||
83 | plist(vp) | |
84 | register struct varent *vp; | |
85 | { | |
86 | register int (*wasintr)(); | |
87 | ||
88 | if (setintr) | |
89 | wasintr = signal(SIGINT, pintr); | |
90 | for (vp = vp->link; vp != 0; vp = vp->link) { | |
91 | int len = blklen(vp->vec); | |
92 | ||
93 | printf(vp->name); | |
94 | printf("\t"); | |
95 | if (len != 1) | |
96 | putchar('('); | |
97 | blkpr(vp->vec); | |
98 | if (len != 1) | |
99 | putchar(')'); | |
100 | printf("\n"); | |
101 | } | |
102 | if (setintr) | |
103 | signal(SIGINT, wasintr); | |
104 | } |