1: #include <stdio.h>
2: #include "1.defs.h"
3: #include "def.h"
4: extern int linechar, errflag, debug;
5: extern int (*input)(), (*unput)();
6:
7:
8:
9: uptolow(c) /*translates upper to lower case */
10: int c;
11: {
12: if ('A' <= c && c <= 'Z')
13: return(c+'a'-'A');
14: else
15: return(c);
16: }
17:
18: rdfree(func)
19: int (*func)();
20: {
21: int c;
22: while ( (c = (*input)()) != '\n')
23: {
24: (*func)(c);
25: }
26: }
27:
28: rdstand(func)
29: int (*func)();
30: {
31: int c;
32: while ( (c=(*input)()) != '\n')
33: {
34: (*func)(c);
35: }
36: }
37:
38: labfree(func) /* labels in freeform input */
39: int (*func)();
40: {
41: int c;
42: int temp[6];
43: int j;
44: for (j = 0; j < 5; ++j)
45: {
46: while ( (c = (*input)()) == ' ' || c == '\t' );
47: if (c == '\n')
48: {
49: if (j != 0)
50: {
51: temp[j] = '\0';
52: error("label without code - ignored:","","");
53: }
54: }
55: if (c < '0' || c > '9')
56: {
57: (*unput)(c);
58: break;
59: }
60: else
61: {
62: temp[j] = c;
63: (*func)(c);
64: }
65: }
66: for ( ; j < 5; ++j)
67: (*func)(' ');
68: }
69:
70: labstand(func) /* labels in standard form input */
71: int (*func)();
72: {
73: int c;
74: int j;
75:
76: for (j = 0; j < 5; ++j)
77: {
78: c = (*input)();
79: if (c == '\n')
80: {
81: error("line shorter than 5 characters","","");
82: errflag = 1;
83: (*unput)('\n');
84: }
85: if (c == '\t' || c == '\n')
86: {
87: for ( ;j<5; ++j)
88: (*func)(' ');
89: return;
90: }
91: (*func)(c);
92: }
93: (*input)(); /* throw away continuation char */
94: }
95:
96:
97:
98: contfree() /* identify continuation lines in free-form input */
99: {
100: return(nonblchar(_diglet,0)); /* any non-alpha non-digit */
101: }
102:
103:
104: nonblchar(class,yesno)
105: int class,yesno;
106: {
107: #define CARDSIZE 121
108: int temp[CARDSIZE];
109: int j;
110: for (j=0; (temp[j]=(*input)()) == ' ' || temp[j] == '\t'; ++j)
111: if (j>=CARDSIZE-1)
112: {
113: temp[CARDSIZE-1] = '\0';
114: error ("line unexpectedly long","","");
115: break;
116: }
117: if (temp[j]!=EOF && classmatch(temp[j],class)==yesno)
118: return(1);
119: else
120: {
121: for ( ; j >= 0; --j)
122: (*unput)(temp[j]);
123: return(0);
124: }
125: }
126:
127:
128: contstand() /* continuation lines in standard form input */
129: {
130: int temp[6];
131: int i;
132:
133: for (i = 0; i < 6; ++i)
134: {
135: temp[i] = (*input)();
136: if (temp[i] == '\t' || temp[i] == '\n' || temp[i] == '\0' || temp[i] == EOF)
137: {
138: for ( ;i >= 0; --i)
139: (*unput)(temp[i]);
140: return(0);
141: }
142: }
143: if (temp[5] != '0' && temp[5] != ' ')
144: return(1);
145: else
146: {
147: for ( i = 5 ; i >= 0; --i)
148: (*unput)(temp[i]);
149: return(0);
150: }
151: }
152:
153:
154:
155: comstand(posafter) /* standard form comments */
156: int posafter;
157: {
158: int c;
159: c = (*input)();
160: if (!posafter)
161: (*unput)(c);
162: if (c == 'c' || c == '*' || c== '#')
163: return(1);
164: else
165: return(0);
166: }
167:
168:
169: comfree(posafter)
170: int posafter;
171: {
172: return(comstand(posafter));
173: }
174: int (*rline[])() = {rdfree,rdstand};
175: int (*comment[])() = {comfree,comstand};
176: int (*getlabel[])() = {labfree, labstand};
177: int (*chkcont[])() = {contfree,contstand};
178:
179: blankline()
180: {
181: if ( nonblchar(_nl,1) ) /* first non-blank is nl */
182: {
183: (*unput) ('\n');
184: return(1);
185: }
186: else return(0);
187: }
188:
189: #define maxunbp 80
190: char unbuf[maxunbp+1];
191: int unbp;
192:
193: empseek(linebeg)
194: unsigned int linebeg;
195: {
196: unbp = 0;
197: if (fseek(infd,(long)(linebeg+rtnbeg),0) == -1)
198: faterr("in disk seek","","");
199: }
200:
201: inchar()
202: {
203: if (unbp > 0)
204: return( unbuf[--unbp] );
205: else
206: {
207: return( uptolow(getc(infd)) );
208: }
209: }
210:
211:
212: unchar(c)
213: int c;
214: {
215: if (unbp >= maxunbp)
216: faterr("dec.rat: unbuf size exceeded","","");
217: if(c!=EOF)unbuf[unbp++] = c;
218: }
Defined functions
Defined variables
unbp
defined in line
191; used 5 times
Defined macros