summaryrefslogtreecommitdiff
path: root/Build/source/texk/cjkutils/cjkutils-4.8.2/CEFconv/cefconv.c
blob: 8c3e624108ec9331c135e14ab16c6aaf817bdcfa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#define banner  \
"cefconv (CJK ver. 4.8.2)" \

/*2:*/
#line 100 "/home/wl/git/cjk/cjk-4.8.2/utils/CEFconv/cefconv.w"

#include <ctype.h> 
#include <stdio.h> 
#include <stdlib.h> 


int main(argc,argv)
int argc;
char*argv[];

{int ch,i;
unsigned char in[16];
unsigned char out[32];
unsigned char*inp,*outp;

fprintf(stdout,"\\def\\CNSpreproc{%s}",banner);

ch= fgetc(stdin);

while(!feof(stdin))
{if(ch=='&')
{inp= in;
outp= out;
*inp= ch;
*(++inp)= fgetc(stdin);

if(*inp=='C'&&!feof(stdin))
{*(++inp)= fgetc(stdin);
if(*inp=='0'&&!feof(stdin))
{*(outp++)= 'B';
*(outp++)= 'g';
*(outp++)= '5';
}
else if(*inp>='1'&&*inp<='7'&&!feof(stdin))
{*(outp++)= 'C';
*(outp++)= 'N';
*(outp++)= 'S';
*(outp++)= *inp;
}
else if((*inp=='X'||*inp=='Y')&&!feof(stdin))
{*(outp++)= 'C';
*(outp++)= 'E';
*(outp++)= 'F';
*(outp++)= *inp;
}
else
goto no_macro;
}
else if(*inp=='U'&&!feof(stdin))
{*(outp++)= 'U';
*(outp++)= 'T';
*(outp++)= 'F';
*(outp++)= '8';
}
else
goto no_macro;

*(++inp)= fgetc(stdin);
if(*inp!='-'||feof(stdin))
goto no_macro;

*(outp++)= '\177';
*(outp++)= '\177';
*(outp++)= '\"';
*(outp++)= '0';

*(++inp)= fgetc(stdin);
if(isxdigit(*inp)&&*inp<0x80&&!feof(stdin))
*(outp++)= toupper(*inp);
else
goto no_macro;

*(++inp)= fgetc(stdin);
if(isxdigit(*inp)&&*inp<0x80&&!feof(stdin))
*(outp++)= toupper(*inp);
else
goto no_macro;

*(outp++)= '\177';
*(outp++)= '\"';
*(outp++)= '0';

*(++inp)= fgetc(stdin);
if(isxdigit(*inp)&&*inp<0x80&&!feof(stdin))
*(outp++)= toupper(*inp);
else
goto no_macro;

*(++inp)= fgetc(stdin);
if(isxdigit(*inp)&&*inp<0x80&&!feof(stdin))
*(outp++)= toupper(*inp);
else
goto no_macro;

*(outp++)= '\177';
*outp= '\0';

*(++inp)= fgetc(stdin);
if(*inp!=';'||feof(stdin))
goto no_macro;

outp= out;
fprintf(stdout,"\17772\177");
while(*outp)
fputc(*(outp++),stdout);

ch= fgetc(stdin);
continue;

no_macro:
ch= *inp;
i= inp-in;
inp= in;
while(i--)
fputc(*(inp++),stdout);
continue;
}
else
fputc(ch,stdout);

ch= fgetc(stdin);
}
exit(EXIT_SUCCESS);
return 0;
}/*:2*/