Debian Codegraph @

texk/cjkutils/cefsconv.c

raw
1 #define banner \
2 "cefsconv (CJK ver. 4.8.5)" \
3
4 /*2:*/
5 #line 111 "./cjkutils-src/CEFconv/cefsconv.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>=0x81&&ch<=0x9F)||(ch>=0xE0&&ch<=0xEF))
31 {fprintf(stdout,"\177%c\177",ch);
32
33 ch= fgetc(stdin);
34 if(!feof(stdin))
35 fprintf(stdout,"%d\177",ch);
36 }
37 else if(ch=='&')
38
39 {inp= in;
40 outp= out;
41 *inp= ch;
42 *(++inp)= fgetc(stdin);
43
44 if(*inp=='C'&&!feof(stdin))
45 {*(++inp)= fgetc(stdin);
46 if(*inp=='0'&&!feof(stdin))
47 {*(outp++)= 'B';
48 *(outp++)= 'g';
49 *(outp++)= '5';
50 }
51 else if(*inp>='1'&&*inp<='7'&&!feof(stdin))
52 {*(outp++)= 'C';
53 *(outp++)= 'N';
54 *(outp++)= 'S';
55 *(outp++)= *inp;
56 }
57 else if((*inp=='X'||*inp=='Y')&&!feof(stdin))
58 {*(outp++)= 'C';
59 *(outp++)= 'E';
60 *(outp++)= 'F';
61 *(outp++)= *inp;
62 }
63 else
64 goto no_macro;
65 }
66 else if(*inp=='U'&&!feof(stdin))
67 {*(outp++)= 'U';
68 *(outp++)= 'T';
69 *(outp++)= 'F';
70 *(outp++)= '8';
71 }
72 else
73 goto no_macro;
74
75 *(++inp)= fgetc(stdin);
76 if(*inp!='-'||feof(stdin))
77 goto no_macro;
78
79 *(outp++)= '\177';
80 *(outp++)= '\177';
81 *(outp++)= '\"';
82 *(outp++)= '0';
83
84 *(++inp)= fgetc(stdin);
85 if(isxdigit(*inp)&&*inp<0x80&&!feof(stdin))
86 *(outp++)= toupper(*inp);
87 else
88 goto no_macro;
89
90 *(++inp)= fgetc(stdin);
91 if(isxdigit(*inp)&&*inp<0x80&&!feof(stdin))
92 *(outp++)= toupper(*inp);
93 else
94 goto no_macro;
95
96 *(outp++)= '\177';
97 *(outp++)= '\"';
98 *(outp++)= '0';
99
100 *(++inp)= fgetc(stdin);
101 if(isxdigit(*inp)&&*inp<0x80&&!feof(stdin))
102 *(outp++)= toupper(*inp);
103 else
104 goto no_macro;
105
106 *(++inp)= fgetc(stdin);
107 if(isxdigit(*inp)&&*inp<0x80&&!feof(stdin))
108 *(outp++)= toupper(*inp);
109 else
110 goto no_macro;
111
112 *(outp++)= '\177';
113 *outp= '\0';
114
115 *(++inp)= fgetc(stdin);
116 if(*inp!=';'||feof(stdin))
117 goto no_macro;
118
119 outp= out;
120 fprintf(stdout,"\17772\177");
121 while(*outp)
122 fputc(*(outp++),stdout);
123
124 ch= fgetc(stdin);
125 continue;
126
127 no_macro:
128 ch= *inp;
129 i= inp-in;
130 inp= in;
131 while(i--)
132 fputc(*(inp++),stdout);
133 continue;
134 }
135 else
136 fputc(ch,stdout);
137
138 ch= fgetc(stdin);
139 }
140 exit(EXIT_SUCCESS);
141 return 0;
142 }/*:2*/