1: #
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: #include "yy.h"
17:
18: int line 1;
19:
20: /*
21: * Yymain initializes each of the utility
22: * clusters and then starts the processing
23: * by calling yyparse.
24: */
25: yymain()
26: {
27:
28: /*
29: * Initialize the scanner
30: */
31: #ifdef PXP
32: if (bracket == 0) {
33: #endif
34: if (getline() == -1) {
35: Perror(filename, "No lines in file");
36: pexit(NOSTART);
37: }
38: #ifdef PXP
39: } else
40: yyline = 0;
41: #endif
42:
43: #ifdef PI
44: magic();
45:
46: #endif
47: /*
48: * Initialize the clusters
49: *
50: initstring();
51: */
52: inithash();
53: inittree();
54: #ifdef PI
55: initnl();
56: #endif
57:
58: /*
59: * Process the input
60: */
61: yyparse();
62: #ifdef PI
63: magic2();
64: #ifdef DEBUG
65: dumpnl(0);
66: #endif
67: #endif
68: #ifdef PXP
69: prttab();
70: if (onefile) {
71: extern int outcol;
72:
73: if (outcol)
74: putchar('\n');
75: flush();
76: if (eflg) {
77: writef(2, "File not rewritten because of errors\n");
78: pexit(ERRS);
79: }
80: signal(1, 1);
81: signal(2, 1);
82: copyfile();
83: }
84: #endif
85: pexit(eflg ? ERRS : AOK);
86: }
87:
88: #ifdef PXP
89: copyfile()
90: {
91: extern int fout[];
92: register int c;
93:
94: close(1);
95: if (creat(firstname, 0644) != 1) {
96: perror(firstname);
97: pexit(ERRS);
98: }
99: lseek(fout[0], (long)0, 0);
100: while ((c = read(fout[0], &fout[3], 512)) > 0) {
101: if (write(1, &fout[3], c) != c) {
102: perror(firstname);
103: pexit(ERRS);
104: }
105: }
106: }
107: #endif
108:
109: static
110: struct {
111: int magic;
112: int txt_size;
113: int data_size;
114: } header;
115:
116: #ifdef PI
117: magic()
118: {
119: int buf[512];
120: register int hf, i;
121:
122: hf = open("/usr/lib/npx_header", 0);
123: if (hf >= 0 && read(hf, buf, 1024) > 16) {
124: header.magic = buf[0];
125: header.txt_size = buf[1];
126: header.data_size = buf[2];
127: for (i = 0; i < 512; i++)
128: word(buf[i]);
129: }
130: close(hf);
131: word(0404);
132: }
133:
134: magic2()
135: {
136: int i;
137:
138: if (header.magic != 0407)
139: return;
140: pflush();
141: lseek(ofil, (long)0, 0);
142: header.data_size = lc - header.txt_size;
143: header.data_size =- 16;
144: write(ofil, &header, sizeof header);
145: lseek(ofil, (long)1022, 0);
146: i = ((int) lc) - 1024;
147: write(ofil, &i, 2);
148: }
149: #endif
150:
151: #ifdef PXP
152: writef(i, cp)
153: {
154:
155: write(i, cp, strlen(cp));
156: }
157: #endif
Defined functions
Defined variables
line
defined in line
18;
never used