Debian Codegraph @

texk/cjkutils/cefconv.c

raw
1 #define banner \
2 "cefconv (CJK ver. 4.8.5)" \
3
4 /*2:*/
5 #line 100 "./cjkutils-src/CEFconv/cefconv.w"
6
7 #include <ctype.h>
8 #include <stdio.h>
9 #include <stdlib.h>
10 #ifdef WIN32
11 #include <fcntl.h>
12 #include <io.h>
13 #endif
14
15
16 int main(int argc,char*argv[])
17 {int ch,i;
18 unsigned char in[16];
19 unsigned char out[32];
20 unsigned char*inp,*outp;
21
22 #ifdef WIN32
23 setmode(fileno(stdout),_O_BINARY);
24 #endif
25 fprintf(stdout,"\\def\\CNSpreproc{%s}",banner);
26
27 ch= fgetc(stdin);
28
29 while(!feof(stdin))
30 {if(ch=='&')
31 {inp= in;
32 outp= out;
33 *inp= ch;
34 *(++inp)= fgetc(stdin);
35
36 if(*inp=='C'&&!feof(stdin))
37 {*(++inp)= fgetc(stdin);
38 if(*inp=='0'&&!feof(stdin))
39 {*(outp++)= 'B';
40 *(outp++)= 'g';
41 *(outp++)= '5';
42 }
43 else if(*inp>='1'&&*inp<='7'&&!feof(stdin))
44 {*(outp++)= 'C';
45 *(outp++)= 'N';
46 *(outp++)= 'S';
47 *(outp++)= *inp;
48 }
49 else if((*inp=='X'||*inp=='Y')&&!feof(stdin))
50 {*(outp++)= 'C';
51 *(outp++)= 'E';
52 *(outp++)= 'F';
53 *(outp++)= *inp;
54 }
55 else
56 goto no_macro;
57 }
58 else if(*inp=='U'&&!feof(stdin))
59 {*(outp++)= 'U';
60 *(outp++)= 'T';
61 *(outp++)= 'F';
62 *(outp++)= '8';
63 }
64 else
65 goto no_macro;
66
67 *(++inp)= fgetc(stdin);
68 if(*inp!='-'||feof(stdin))
69 goto no_macro;
70
71 *(outp++)= '\177';
72 *(outp++)= '\177';
73 *(outp++)= '\"';
74 *(outp++)= '0';
75
76 *(++inp)= fgetc(stdin);
77 if(isxdigit(*inp)&&*inp<0x80&&!feof(stdin))
78 *(outp++)= toupper(*inp);
79 else
80 goto no_macro;
81
82 *(++inp)= fgetc(stdin);
83 if(isxdigit(*inp)&&*inp<0x80&&!feof(stdin))
84 *(outp++)= toupper(*inp);
85 else
86 goto no_macro;
87
88 *(outp++)= '\177';
89 *(outp++)= '\"';
90 *(outp++)= '0';
91
92 *(++inp)= fgetc(stdin);
93 if(isxdigit(*inp)&&*inp<0x80&&!feof(stdin))
94 *(outp++)= toupper(*inp);
95 else
96 goto no_macro;
97
98 *(++inp)= fgetc(stdin);
99 if(isxdigit(*inp)&&*inp<0x80&&!feof(stdin))
100 *(outp++)= toupper(*inp);
101 else
102 goto no_macro;
103
104 *(outp++)= '\177';
105 *outp= '\0';
106
107 *(++inp)= fgetc(stdin);
108 if(*inp!=';'||feof(stdin))
109 goto no_macro;
110
111 outp= out;
112 fprintf(stdout,"\17772\177");
113 while(*outp)
114 fputc(*(outp++),stdout);
115
116 ch= fgetc(stdin);
117 continue;
118
119 no_macro:
120 ch= *inp;
121 i= inp-in;
122 inp= in;
123 while(i--)
124 fputc(*(inp++),stdout);
125 continue;
126 }
127 else
128 fputc(ch,stdout);
129
130 ch= fgetc(stdin);
131 }
132 exit(EXIT_SUCCESS);
133 return 0;
134 }/*:2*/