1: /*
2: * pi - Pascal interpreter code translator
3: *
4: * Charles Haley, Bill Joy UCB
5: * Version 1.2 January 1979
6: *
7: *
8: * pxp - Pascal execution profiler
9: *
10: * Bill Joy UCB
11: * Version 1.2 January 1979
12: *
13: * 1996/3/22 - make Perror look like that in ../pi/subr.c
14: */
15:
16: #include "0.h"
17: #include <sys/types.h>
18: #include <sys/uio.h>
19:
20: #ifndef PI1
21: /*
22: * Does the string fp end in '.' and the character c ?
23: */
24: dotted(fp, c)
25: register char *fp;
26: char c;
27: {
28: register int i;
29:
30: i = strlen(fp);
31: return (i > 1 && fp[i - 2] == '.' && fp[i - 1] == c);
32: }
33:
34: /*
35: * Toggle the option c.
36: */
37: togopt(c)
38: char c;
39: {
40: register char *tp;
41:
42: tp = &opts[c-'a'];
43: *tp = 1 - *tp;
44: }
45:
46: /*
47: * Set the time vector "tvec" to the
48: * modification time stamp of the current file.
49: */
50: gettime()
51: {
52: struct stat stbuf;
53:
54: stat(filename, stbuf);
55: tvec = stbuf.st_mtime;
56: }
57:
58: /*
59: * Convert a "ctime" into a Pascal style time line
60: */
61: myctime(tv)
62: time_t *tv;
63: {
64: register char *cp, *dp;
65: char *cpp;
66: register i;
67: static char mycbuf[26];
68:
69: cpp = ctime(tv);
70: dp = mycbuf;
71: cp = cpp;
72: cpp[16] = 0;
73: while (*dp++ = *cp++);
74: dp--;
75: cp = cpp+19;
76: cpp[24] = 0;
77: while (*dp++ = *cp++);
78: return (mycbuf);
79: }
80:
81: /*
82: * Is "fp" in the command line list of names ?
83: */
84: inpflist(fp)
85: char *fp;
86: {
87: register i, *pfp;
88:
89: pfp = pflist;
90: for (i = pflstc; i > 0; i--)
91: if (strcmp(fp, *pfp++) == 0)
92: return (1);
93: return (0);
94: }
95: #endif
96:
97: /*
98: * Boom!
99: *
100: * Can't use 'fprintf(stderr...)' because that would require stdio.h and
101: * that can't be used because the 'ferror' macro would conflict with the routine
102: * of the same name. But we don't want to use sys_errlist[] because that's
103: * ~2kb of D space.
104: */
105:
106: Perror(file, mesg)
107: char *file, *mesg;
108: {
109: struct iovec iov[3];
110:
111: iov[0].iov_base = file;
112: iov[0].iov_len = strlen(file);
113: iov[1].iov_base = ": ";
114: iov[1].iov_len = 2;
115: iov[2].iov_base = mesg;
116: iov[2].iov_len = strlen(mesg);
117: writev(2, iov, 3);
118: }
119:
120: calloc(num, size)
121: int num, size;
122: {
123: register int p1, *p2, nbyte;
124:
125: nbyte = (num*size+1) & ~01;
126: if ((p1 = alloc(nbyte)) == -1 || p1==0)
127: return (-1);
128: p2 = p1;
129: nbyte >>= 1; /* 2 bytes/word */
130: do {
131: *p2++ = 0;
132: } while (--nbyte);
133: return (p1);
134: }
135:
136: copy(to, from, bytes)
137: register char *to, *from;
138: register int bytes;
139: {
140:
141: if (bytes != 0)
142: do
143: *to++ = *from++;
144: while (--bytes);
145: }
146:
147: /*
148: * Is ch one of the characters in the string cp ?
149: */
150: any(cp, ch)
151: register char *cp;
152: char ch;
153: {
154:
155: while (*cp)
156: if (*cp++ == ch)
157: return (1);
158: return (0);
159: }
160:
161: opush(c)
162: register CHAR c;
163: {
164:
165: c -= 'a';
166: optstk[c] <<= 1;
167: optstk[c] |= opts[c];
168: opts[c] = 1;
169: #ifdef PI0
170: send(ROPUSH, c);
171: #endif
172: }
173:
174: opop(c)
175: register CHAR c;
176: {
177:
178: c -= 'a';
179: opts[c] = optstk[c] & 1;
180: optstk[c] >>= 1;
181: #ifdef PI0
182: send(ROPOP, c);
183: #endif
184: }
Defined functions
any
defined in line
150; used 5 times
copy
defined in line
136; used 14 times
- in /usr/src/ucb/pascal/pxp/pas.y line
505
- in /usr/src/ucb/pascal/pxp/yylex.c line
33,
48
- in /usr/src/ucb/pascal/pxp/yypanic.c line
42,
136
- in /usr/src/ucb/pascal/pxp/yyrecover.c line
222,
234,
287,
307,
359,
372,
415,
454,
690
opop
defined in line
174; used 2 times