~reviczky/luatex/texlive-bin-git

« back to all changes in this revision

Viewing changes to texk/cjkutils/cjkutils-4.8.3/CEFconv/cefconv.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
 
"cefconv (CJK ver. 4.8.3)" \
3
 
 
4
 
/*2:*/
5
 
#line 100 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/CEFconv/cefconv.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=='&')
24
 
{inp= in;
25
 
outp= out;
26
 
*inp= ch;
27
 
*(++inp)= fgetc(stdin);
28
 
 
29
 
if(*inp=='C'&&!feof(stdin))
30
 
{*(++inp)= fgetc(stdin);
31
 
if(*inp=='0'&&!feof(stdin))
32
 
{*(outp++)= 'B';
33
 
*(outp++)= 'g';
34
 
*(outp++)= '5';
35
 
}
36
 
else if(*inp>='1'&&*inp<='7'&&!feof(stdin))
37
 
{*(outp++)= 'C';
38
 
*(outp++)= 'N';
39
 
*(outp++)= 'S';
40
 
*(outp++)= *inp;
41
 
}
42
 
else if((*inp=='X'||*inp=='Y')&&!feof(stdin))
43
 
{*(outp++)= 'C';
44
 
*(outp++)= 'E';
45
 
*(outp++)= 'F';
46
 
*(outp++)= *inp;
47
 
}
48
 
else
49
 
goto no_macro;
50
 
}
51
 
else if(*inp=='U'&&!feof(stdin))
52
 
{*(outp++)= 'U';
53
 
*(outp++)= 'T';
54
 
*(outp++)= 'F';
55
 
*(outp++)= '8';
56
 
}
57
 
else
58
 
goto no_macro;
59
 
 
60
 
*(++inp)= fgetc(stdin);
61
 
if(*inp!='-'||feof(stdin))
62
 
goto no_macro;
63
 
 
64
 
*(outp++)= '\177';
65
 
*(outp++)= '\177';
66
 
*(outp++)= '\"';
67
 
*(outp++)= '0';
68
 
 
69
 
*(++inp)= fgetc(stdin);
70
 
if(isxdigit(*inp)&&*inp<0x80&&!feof(stdin))
71
 
*(outp++)= toupper(*inp);
72
 
else
73
 
goto no_macro;
74
 
 
75
 
*(++inp)= fgetc(stdin);
76
 
if(isxdigit(*inp)&&*inp<0x80&&!feof(stdin))
77
 
*(outp++)= toupper(*inp);
78
 
else
79
 
goto no_macro;
80
 
 
81
 
*(outp++)= '\177';
82
 
*(outp++)= '\"';
83
 
*(outp++)= '0';
84
 
 
85
 
*(++inp)= fgetc(stdin);
86
 
if(isxdigit(*inp)&&*inp<0x80&&!feof(stdin))
87
 
*(outp++)= toupper(*inp);
88
 
else
89
 
goto no_macro;
90
 
 
91
 
*(++inp)= fgetc(stdin);
92
 
if(isxdigit(*inp)&&*inp<0x80&&!feof(stdin))
93
 
*(outp++)= toupper(*inp);
94
 
else
95
 
goto no_macro;
96
 
 
97
 
*(outp++)= '\177';
98
 
*outp= '\0';
99
 
 
100
 
*(++inp)= fgetc(stdin);
101
 
if(*inp!=';'||feof(stdin))
102
 
goto no_macro;
103
 
 
104
 
outp= out;
105
 
fprintf(stdout,"\17772\177");
106
 
while(*outp)
107
 
fputc(*(outp++),stdout);
108
 
 
109
 
ch= fgetc(stdin);
110
 
continue;
111
 
 
112
 
no_macro:
113
 
ch= *inp;
114
 
i= inp-in;
115
 
inp= in;
116
 
while(i--)
117
 
fputc(*(inp++),stdout);
118
 
continue;
119
 
}
120
 
else
121
 
fputc(ch,stdout);
122
 
 
123
 
ch= fgetc(stdin);
124
 
}
125
 
exit(EXIT_SUCCESS);
126
 
return 0;
127
 
}/*:2*/