|
|
1.1 root 1: #define IF 1
2: #define ELSE 2
3: #define CASE 3
4: #define TYPE 4
5: #define DO 5
6: #define STRUCT 6
7: #define OTHER 7
8:
9: #define ALWAYS 01
10: #define NEVER 02
11: #define SOMETIMES 04
12:
13: #define YES 1
14: #define NO 0
15:
16: #define KEYWORD 1
17: #define DATADEF 2
18: #define SINIT 3
19:
20: #define CLEVEL 200
21: #define IFLEVEL 100
22: #define DOLEVEL 100
23: #define OPLENGTH 100
24: #define LINE 2048
25: #define LINELENG 2048
26: #define MAXTABS 8
27: #define TABLENG 8
28: #define TEMP 20480
29:
30: #define OUT outs(clev->tabs); putchar('\n');opflag = lbegin = 1; count = 0
31: #define OUTK OUT; keyflag = 0;
32: #define BUMP clev->tabs++; clev->pdepth++
33: #define UNBUMP clev->tabs -= clev->pdepth; clev->pdepth = 0
34: #define eatspace() while((cc=getch()) == ' ' || cc == '\t'); unget(cc)
35: #define eatallsp() while((cc=getch()) == ' ' || cc == '\t' || cc == '\n'); unget(cc)
36:
37: struct indent { /* one for each level of { } */
38: int tabs;
39: int pdepth;
40: int iflev;
41: int ifc[IFLEVEL];
42: int spdepth[IFLEVEL];
43: } ind[CLEVEL];
44: struct indent *clev = ind;
45: struct keyw {
46: char *name;
47: char punc;
48: char type;
49: } key[] = {
50: "switch", ' ', OTHER,
51: "do", ' ', DO,
52: "while", ' ', OTHER,
53: "if", ' ', IF,
54: "for", ' ', OTHER,
55: "else", ' ', ELSE,
56: "case", ' ', CASE,
57: "default", ' ', CASE,
58: "char", '\t', TYPE,
59: "int", '\t', TYPE,
60: "short", '\t', TYPE,
61: "long", '\t', TYPE,
62: "unsigned", '\t', TYPE,
63: "float", '\t', TYPE,
64: "double", '\t', TYPE,
65: "struct", ' ', STRUCT,
66: "union", ' ', STRUCT,
67: "extern", ' ', TYPE,
68: "register", ' ', TYPE,
69: "static", ' ', TYPE,
70: "typedef", ' ', TYPE,
71: 0, 0, 0
72: };
73: struct op {
74: char *name;
75: char blanks;
76: char setop;
77: } op[] = {
78: "+=", ALWAYS, YES,
79: "-=", ALWAYS, YES,
80: "*=", ALWAYS, YES,
81: "/=", ALWAYS, YES,
82: "%=", ALWAYS, YES,
83: ">>=", ALWAYS, YES,
84: "<<=", ALWAYS, YES,
85: "&=", ALWAYS, YES,
86: "^=", ALWAYS, YES,
87: "|=", ALWAYS, YES,
88: ">>", ALWAYS, YES,
89: "<<", ALWAYS, YES,
90: "<=", ALWAYS, YES,
91: ">=", ALWAYS, YES,
92: "==", ALWAYS, YES,
93: "!=", ALWAYS, YES,
94: "=", ALWAYS, YES,
95: "&&", ALWAYS, YES,
96: "||", ALWAYS, YES,
97: "++", NEVER, NO,
98: "--", NEVER, NO,
99: "->", NEVER, NO,
100: "<", ALWAYS, YES,
101: ">", ALWAYS, YES,
102: "+", ALWAYS, YES,
103: "/", ALWAYS, YES,
104: "%", ALWAYS, YES,
105: "^", ALWAYS, YES,
106: "|", ALWAYS, YES,
107: "!", NEVER, YES,
108: "~", NEVER, YES,
109: "*", SOMETIMES, YES,
110: "&", SOMETIMES, YES,
111: "-", SOMETIMES, YES,
112: "?", ALWAYS,YES,
113: ":", ALWAYS,YES,
114: 0, 0,0
115: };
116: FILE *input = stdin;
117: int strict = 0;
118: int join = 0;
119: int opflag = 1;
120: int keyflag = 0;
121: int paren = 0;
122: int split = 0;
123: int folded = 0;
124: int dolevel =0;
125: int dotabs[DOLEVEL];
126: int docurly[DOLEVEL];
127: int dopdepth[DOLEVEL];
128: int structlev = 0;
129: int question = 0;
130: char string[LINE];
131: char *lastlook;
132: char *p = string;
133: char temp[TEMP];
134: char *tp;
135: int err = 0;
136: char *lastplace = temp;
137: char *tptr = temp;
138: int maxleng = LINELENG;
139: int maxtabs = MAXTABS;
140: int count = 0;
141: char next = '\0';
142: int inswitch =0;
143: int lbegin = 1;
144: int lineno = 0;
145:
146: void work(void);
147: void gotif(void);
148: void gotelse(void);
149: int checkif(char *);
150: void gotdo(void);
151: void resetdo(void);
152: void gottype(struct keyw *lptr);
153: void gotstruct(void);
154: void gotop(int);
155: void keep(struct op *);
156: int getnl(void);
157: void ptabs(int);
158: void outs(int);
159: void putch(char, int);
160: struct keyw *lookup(char *, char *);
161: int comment(int);
162: void putspace(char, int);
163: char getch(void);
164: void unget(char);
165: char *getnext(int);
166: void copy(char *);
167: void clearif(struct indent *);
168: char puttmp(char, int);
169: void error(char *);
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.