~reviczky/luatex/texlive-bin-git

« back to all changes in this revision

Viewing changes to texk/cjkutils/cjkutils-4.8.3/CEFconv/cefsconv.c

  • Committer: Adam Reviczky
  • Date: 2015-04-26 22:40:47 UTC
  • Revision ID: adam.reviczky@kclalumni.net-20150426224047-i2p26n3wqphupq6z
TeX Live 2015 import (rev. 37052)

Show diffs side-by-side

added added

removed removed

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