11 char oname[]="/tmp/cvoptaXXXXXX";
12 char ooname[]="/tmp/cvoptbXXXXXX";
18 #define __P(args) args
24 int main __P((int argc, char **argv));
26 void put __P((int c));
27 void comment __P((int c));
29 int main(argc, argv) int argc; char **argv; {
61 int c, snlflg, nlflg, t, smode, m, ssmode, peekc, side;
66 smode = nlflg = snlflg = ssmode = 0;
68 if (freopen(argv[1], "r", stdin) == NULL) {
69 fprintf(stderr, "%s?\n", argv[1]);
73 if (freopen(argv[2], "w", stdout) == NULL) {
74 fprintf(stderr, "%s?\n", argv[2]);
79 if ((obuf = fopen(oname, "w")) == NULL) {
80 fprintf(stderr, "%s?\n", oname);
84 if ((oobuf = fopen(ooname, "w")) == NULL) {
85 fprintf(stderr, "%s?\n", ooname);
90 if (fd < 0 || (obuf = fdopen(fd, "w")) == NULL) {
91 fprintf(stderr, "%s?\n", oname);
95 if (fd < 0 || (oobuf = fdopen(fd, "w")) == NULL) {
96 fprintf(stderr, "%s?\n", ooname);
100 printf("#include \"c1.h\"");
104 if (c!='\n' && c!='\t')
106 if (ssmode!=0 && c!='%') {
109 fprintf(curbuf, "\nstatic char L%d[]=\"", labno++);
114 fprintf(obuf, "\t{0},\n};\n");
116 if (freopen(oname, "r", stdin) == NULL) {
117 fprintf(stderr, "%s?\n",oname);
120 while ((c = getchar()) != EOF)
124 if (freopen(ooname, "r", stdin) == NULL) {
125 fprintf(stderr, "%s?\n",ooname);
128 while ((c = getchar()) != EOF)
134 if ((c=getchar())=='1' || c=='2') {
165 put(getchar()+'E'-'1');
173 if ((c=getchar()) == '1')
194 switch (c=getchar()) {
230 if ((peekc=getchar())=='[') {
231 printf("\n#define ");
232 while((c=getchar())!=']' && c!=':')
234 printf(" L%d\n",labno);
235 if (c==':') getchar();
240 ungetc(peekc, stdin);
244 switch (c=getchar()) {
291 if ((c=getchar())=='*')
295 if (opno==0) fprintf(curbuf,"\nstruct optab optab[]={\n");
296 fprintf(curbuf,"\t{");
298 fprintf(curbuf, "%d,%d,", m, t);
301 printf("\n#define L%d ", labno++);
302 while ((c=getchar())!=']')
311 while ((c=getchar())!='%') putc(c,oobuf);
312 if ((c=getchar())=='}') goto loop;
313 else {putc('%',oobuf); putc(c,oobuf);}
317 fprintf(curbuf, "L%d}, /* %d */\n", labno,opno);
325 comment(c); goto loop1;
351 fprintf(curbuf, "\";");
357 fprintf(curbuf, "\\n");
363 comment(c); goto loop;
372 fseek(curbuf,(long)(lbuf-lbufp),2);
374 if (opno!=0) {fprintf(curbuf,"\t{0},\n"); ++opno;}
375 printf("\n#define %s &optab[%d]\n",lbuf,opno);
376 fprintf(curbuf,"/* %s */",lbuf);
391 switch(c=getchar()) {
402 if (f==9) /* unsigned word/int seen yet? */
403 f = 10; /* yes - it is unsigned byte */
405 f = 3; /* no - it is regular (signed) byte */
417 if (f==3) /* regular (signed) byte seen ? */
418 f = 10; /* yes - unsigned byte now */
419 else if (f == 8) /* regular (signed) long seen? */
420 f = 11; /* yes - it is unsigned long now */
422 f = 9; /* otherwise we have unsigned word */
430 if (f == 9) /* seen unsigned yet? */
431 f = 11; /* yes - it is unsigned long now */
433 f = 8; /* no - it is unsigned word now */
447 fprintf(curbuf, "\\%o", c+0200);
449 if (c=='"') putc('\\',curbuf);
454 void comment(c) int c; {
456 if ((c=getchar())=='*') for (;;) {
457 do putc(c,curbuf); while ((c=getchar())!='*');
459 if ((c=getchar())=='/') {putc(c,curbuf); break;}
460 } else ungetc(c,stdin);