|
|
1.1 root 1: /* Copyright (c) 1979 Regents of the University of California */
2: /*
3: * pi - Pascal interpreter code translator
4: *
5: * Charles Haley, Bill Joy UCB
6: * Version 1.2 January 1979
7: *
8: *
9: * pxp - Pascal execution profiler
10: *
11: * Bill Joy UCB
12: * Version 1.2 January 1979
13: */
14:
15: #include "0.h"
16:
17: #ifndef PI1
18: /*
19: * Does the string fp end in '.' and the character c ?
20: */
21: dotted(fp, c)
22: register char *fp;
23: char c;
24: {
25: register int i;
26:
27: i = strlen(fp);
28: return (i > 1 && fp[i - 2] == '.' && fp[i - 1] == c);
29: }
30:
31: /*
32: * Toggle the option c.
33: */
34: togopt(c)
35: char c;
36: {
37: register char *tp;
38:
39: tp = &opts[c-'a'];
40: *tp = 1 - *tp;
41: }
42:
43: /*
44: * Set the time vector "tvec" to the
45: * modification time stamp of the current file.
46: */
47: #include <sys/types.h>
48: #include <stat.h>
49: gettime()
50: {
51: struct stat stb;
52:
53: stat(filename, &stb);
54: tvec = stb.st_mtime;
55: }
56:
57: /*
58: * Convert a "ctime" into a Pascal styple time line
59: */
60: myctime(tv)
61: long *tv;
62: {
63: register char *cp, *dp;
64: char *cpp;
65: register i;
66: static char mycbuf[26];
67:
68: cpp = ctime(tv);
69: dp = mycbuf;
70: cp = cpp;
71: cpp[16] = 0;
72: while (*dp++ = *cp++);
73: dp--;
74: cp = cpp+19;
75: cpp[24] = 0;
76: while (*dp++ = *cp++);
77: return (mycbuf);
78: }
79:
80: /*
81: * Is "fp" in the command line list of names ?
82: */
83: inpflist(fp)
84: char *fp;
85: {
86: register i, *pfp;
87:
88: pfp = pflist;
89: for (i = pflstc; i > 0; i--)
90: if (strcmp(fp, *pfp++) == 0)
91: return (1);
92: return (0);
93: }
94: #endif
95:
96: extern int errno;
97: extern char *sys_errlist[];
98:
99: /*
100: * Boom!
101: */
102: Perror(file, error)
103: char *file, *error;
104: {
105:
106: errno = 0;
107: sys_errlist[0] = error;
108: perror(file);
109: }
110:
111: char *
112: alloc(size)
113: int size;
114: {
115:
116: return (calloc(size, 1));
117: }
118:
119: copy(to, from, bytes)
120: register char *to, *from;
121: register int bytes;
122: {
123:
124: if (bytes != 0)
125: do
126: *to++ = *from++;
127: while (--bytes);
128: }
129:
130: /*
131: * Is ch one of the characters in the string cp ?
132: */
133: any(cp, ch)
134: register char *cp;
135: char ch;
136: {
137:
138: while (*cp)
139: if (*cp++ == ch)
140: return (1);
141: return (0);
142: }
143:
144: opush(c)
145: register CHAR c;
146: {
147:
148: c =- 'a';
149: optstk[c] =<< 1;
150: optstk[c] =| opts[c];
151: opts[c] = 1;
152: #ifdef PI0
153: send(ROPUSH, c);
154: #endif
155: }
156:
157: opop(c)
158: register CHAR c;
159: {
160:
161: c =- 'a';
162: opts[c] = optstk[c] & 1;
163: optstk[c] =>> 1;
164: #ifdef PI0
165: send(ROPOP, c);
166: #endif
167: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.