0
|
1 /* ml_codeconv.c - (multilingual) code conversion */
|
|
2 /* by takada@seraph.ntt.jp */
|
|
3 /* arranged by MH-plus project */
|
|
4
|
|
5 #ifdef JAPAN
|
|
6
|
|
7 #include "../h/mh.h"
|
|
8 #include <ctype.h>
|
|
9 #include <stdio.h>
|
|
10 #include <sys/types.h>
|
|
11 #include <sys/stat.h>
|
|
12
|
|
13 /* coding system */
|
|
14 typedef int coding_system_t;
|
|
15 #define CS_DEFAULT 0
|
|
16 #define CS_JIS7 1
|
|
17 #define CS_JEUC 2
|
|
18 #define CS_SJIS 3
|
2
|
19 #define CS_UTF8 4
|
0
|
20 #define CS_NOCONV 99
|
|
21
|
|
22 /* coding system list */
|
|
23 #define CSL_SIZE 3
|
|
24 #define CSL_DISPLAY(csl) ((csl)[0])
|
|
25 #define CSL_FILE(csl) ((csl)[1])
|
|
26 #define CSL_PROCESS(csl) ((csl)[2])
|
|
27
|
|
28 /* codeset status */
|
|
29 #define ASCII 0
|
|
30 #define JISX0208 1
|
|
31
|
|
32 #define IS_JIS7(c) ((0x21 <= (c)) && ((c) <= 0x7e))
|
|
33 #define IS_JEUC(c) ((0xa1 <= (c)) && ((c) <= 0xfe))
|
|
34 #define IS_SJIS1(c) (((0x81 <= (c)) && ((c) <= 0x9f)) || \
|
|
35 ((0xe0 <= (c)) && ((c) <= 0xfc)))
|
|
36 #define IS_SJIS2(c) ((0x40 <= (c)) && ((c) <= 0xfc) && ((c) != 0x7f))
|
|
37
|
5
|
38 /* encoding (mhn) */
|
|
39
|
|
40 #define CE_UNKNOWN 0x00
|
|
41 #define CE_BASE64 0x01
|
|
42 #define CE_QUOTED 0x02
|
|
43 #define CE_8BIT 0x03
|
|
44 #define CE_7BIT 0x04
|
|
45 #define CE_BINARY 0x05
|
|
46 #define CE_EXTENSION 0x06
|
|
47 #define CE_EXTERNAL 0x07 /* for external-body */
|
|
48
|
0
|
49 /* hold coding system information */
|
|
50 static coding_system_t ml_coding_info[CSL_SIZE] =
|
|
51 { CS_DEFAULT, CS_DEFAULT, CS_DEFAULT };
|
|
52 int japan_environ;
|
|
53
|
|
54 /* private functions */
|
|
55 static void read_profile();
|
|
56 static coding_system_t coding_to_cs();
|
|
57 static coding_system_t select_coding_system();
|
|
58 static void ml_fputs_sbr();
|
|
59 static void jeuc_fputs();
|
|
60 static void sjis_fputs();
|
|
61 static void jis7_fputs();
|
2
|
62 static void utf8_fputs();
|
0
|
63 static void cntrl_putc();
|
|
64 static void ml_conv_sbr();
|
|
65
|
2
|
66 /* NKF Input/Output pointers */
|
|
67
|
|
68 static unsigned char *nkf_output;
|
|
69 static unsigned char *nkf_input;
|
|
70 static int nkf_input_ctr;
|
|
71 static int nkf_output_ctr;
|
|
72 static int nkf_limit;
|
|
73 static int nkf_ilimit;
|
5
|
74 static void (*nkf_flush)(unsigned char *,int);
|
2
|
75
|
5
|
76 static void nkf_open(unsigned char *opt, unsigned char *in,int ilimit,
|
|
77 unsigned char *out,int limit,void (*flush)(unsigned char *,int),FILE *fp);
|
|
78 static void nkf_continue(unsigned char *in,int ilimit) ;
|
2
|
79 static void nkf_end() ;
|
5
|
80 static void none(unsigned char *a,int b);
|
2
|
81
|
5
|
82 static void my_flush(unsigned char *out,int out_count);
|
|
83 static void extend(unsigned char *out,int out_count);
|
|
84 static void my_pretty(unsigned char *out,int out_count);
|
2
|
85
|
|
86 static FILE *nkf_file;
|
|
87
|
0
|
88
|
|
89 /*
|
|
90 * Initialize: holding coding system information
|
|
91 */
|
|
92 void
|
|
93 ml_init()
|
|
94 {
|
|
95 read_profile(ml_coding_info);
|
|
96 }
|
|
97
|
|
98 /* get coding system list from profile and environment variable */
|
|
99 static void
|
|
100 read_profile(csl)
|
|
101 coding_system_t csl[];
|
|
102 {
|
|
103 char *s, *default_coding;
|
|
104
|
|
105 #if 0 /* We won't refer $LANG nor $LC_CTYPE */
|
|
106 if ((default_coding = getenv("LC_CTYPE")) == NULL)
|
|
107 default_coding = getenv("LANG");
|
|
108 #else
|
|
109 default_coding = ""; /* for CS_DEFAULT */
|
|
110 #endif
|
|
111
|
|
112 if ((s = getenv("MH_DISPLAY_CODING")) == NULL)
|
|
113 if ((s = m_find("display-coding")) == NULL)
|
|
114 s = default_coding;
|
|
115 CSL_DISPLAY(csl) = coding_to_cs(s);
|
|
116
|
|
117 if ((s = getenv("MH_FILE_CODING")) == NULL)
|
|
118 if ((s = m_find("file-coding")) == NULL)
|
|
119 s = default_coding;
|
|
120 CSL_FILE(csl) = coding_to_cs(s);
|
|
121
|
|
122 if ((s = getenv("MH_PROCESS_CODING")) == NULL)
|
|
123 if ((s = m_find("process-coding")) == NULL)
|
|
124 s = default_coding;
|
|
125 CSL_PROCESS(csl) = coding_to_cs(s);
|
|
126
|
|
127 if (CSL_FILE(ml_coding_info) == CS_NOCONV)
|
|
128 japan_environ = 0;
|
|
129 else
|
|
130 japan_environ = 1;
|
|
131 }
|
|
132
|
|
133 static coding_system_t
|
|
134 coding_to_cs(coding)
|
|
135 char *coding;
|
|
136 {
|
|
137 if (*coding == '\0')
|
|
138 return CS_DEFAULT;
|
|
139 else if (uleq(coding, "ja_JP.JIS7"))
|
|
140 return CS_JIS7;
|
|
141 else if (uleq(coding, "ja_JP.EUC"))
|
|
142 return CS_JEUC;
|
2
|
143 else if (uleq(coding, "ja_JP.EUCjp"))
|
|
144 return CS_JEUC;
|
0
|
145 else if (uleq(coding, "ja_JP.SJIS"))
|
|
146 return CS_SJIS;
|
2
|
147 else if (uleq(coding, "ja_JP.UTF-8"))
|
|
148 return CS_UTF8;
|
0
|
149 else if (uleq(coding, "C"))
|
|
150 return CS_NOCONV;
|
|
151
|
|
152 /* for backward compatibility */
|
|
153 else if (uleq(coding,"japanese") || uleq(coding,"ja_JP.jis8")
|
|
154 || uleq(coding,"ja_JP.pjis") || uleq(coding,"ja_JP.jis")
|
|
155 || uleq(coding,"wr_WR.ct") || uleq(coding,"wr_WR.junet")) {
|
|
156 return(CS_JIS7);
|
|
157 } else if (uleq(coding,"ja_JP.ujis")) {
|
|
158 return(CS_JEUC);
|
|
159 } else if (uleq(coding,"ja_JP.mscode")) {
|
|
160 return(CS_SJIS);
|
|
161 } else if (uleq(coding,"noconv")) {
|
|
162 return(CS_NOCONV);
|
|
163 } else {
|
|
164 return(CS_DEFAULT);
|
|
165 }
|
|
166 }
|
|
167
|
|
168 static coding_system_t
|
|
169 select_coding_system(stream)
|
|
170 FILE *stream;
|
|
171 {
|
|
172 struct stat buf;
|
|
173
|
|
174 if (fstat(fileno(stream), &buf)) adios (NULLCP, "unable to fstat stream");
|
|
175 switch (buf.st_mode & S_IFMT) {
|
|
176 case S_IFREG:
|
|
177 return(CSL_FILE(ml_coding_info));
|
|
178 case S_IFIFO:
|
|
179 case 0: /* some system returns zero-filled stat for pipe */
|
|
180 return(CSL_PROCESS(ml_coding_info));
|
|
181 case S_IFCHR:
|
|
182 default:
|
|
183 return(CSL_DISPLAY(ml_coding_info));
|
|
184 }
|
|
185 }
|
|
186
|
|
187
|
|
188 /*
|
|
189 *
|
|
190 */
|
|
191 int
|
|
192 ml_ismlchar(c)
|
|
193 unsigned char c;
|
|
194 {
|
|
195 return japan_environ ? IS_JEUC(c) : 0;
|
|
196 }
|
|
197
|
|
198 int
|
|
199 ml_ismlptr(p)
|
|
200 unsigned char *p;
|
|
201 {
|
|
202 return japan_environ ? (IS_JEUC(*p) && IS_JEUC(*(p+1))) : 0;
|
|
203 }
|
|
204
|
|
205
|
|
206 /*
|
|
207 * Output:
|
|
208 */
|
|
209 void
|
|
210 ml_fputs(scanlk, stream)
|
|
211 char *scanlk;
|
|
212 FILE *stream;
|
|
213 {
|
|
214 ml_fputs_sbr(scanlk, stream, 0);
|
|
215 }
|
|
216
|
|
217 void
|
|
218 ml_pretty_fputs(scanlk, stream)
|
|
219 char *scanlk;
|
|
220 FILE *stream;
|
|
221 {
|
|
222 ml_fputs_sbr(scanlk, stream, 1);
|
|
223 }
|
|
224
|
|
225 void
|
|
226 junet_fputs(scanlk, stream)
|
|
227 char *scanlk;
|
|
228 FILE *stream;
|
|
229 {
|
|
230 jis7_fputs(scanlk, stream, 0);
|
|
231 }
|
|
232
|
|
233
|
|
234 static void
|
|
235 ml_fputs_sbr(scanlk, stream, pretty)
|
|
236 char *scanlk;
|
|
237 FILE *stream;
|
|
238 int pretty;
|
|
239 {
|
|
240 switch (select_coding_system(stream)) {
|
|
241 case CS_NOCONV:
|
|
242 fputs(scanlk, stream);
|
|
243 break;
|
|
244 case CS_SJIS:
|
|
245 sjis_fputs(scanlk, stream, pretty);
|
|
246 break;
|
|
247 case CS_JEUC:
|
|
248 jeuc_fputs(scanlk, stream, pretty);
|
|
249 break;
|
2
|
250 case CS_UTF8:
|
|
251 utf8_fputs(scanlk, stream, pretty);
|
|
252 break;
|
0
|
253 case CS_JIS7:
|
|
254 case CS_DEFAULT:
|
|
255 default:
|
|
256 jis7_fputs(scanlk, stream, pretty);
|
|
257 break;
|
|
258 }
|
|
259 }
|
|
260
|
|
261
|
|
262 /*
|
|
263 * Output routines with code conversion
|
|
264 */
|
2
|
265
|
|
266 char buf[BUFSIZ];
|
|
267
|
|
268 static void
|
|
269 utf8_fputs(scanlk, stream, pretty)
|
|
270 char *scanlk;
|
|
271 FILE *stream;
|
|
272 int pretty;
|
|
273 {
|
5
|
274 nkf_open((unsigned char *)"-w80",(unsigned char *)scanlk,-1,(unsigned char *)buf,BUFSIZ,pretty?my_pretty: my_flush,stream);
|
2
|
275 nkf_end();
|
|
276 }
|
|
277
|
0
|
278 static void
|
|
279 jeuc_fputs(scanlk, stream, pretty)
|
|
280 char *scanlk;
|
|
281 FILE *stream;
|
|
282 int pretty;
|
|
283 {
|
|
284 unsigned char u1, u2;
|
|
285
|
|
286 while (u1 = *scanlk++) {
|
|
287 if (IS_JEUC(u1)) {
|
|
288 u2 = *scanlk;
|
|
289 if (IS_JEUC(u2)) {
|
|
290 scanlk++;
|
|
291 putc(u1, stream); putc(u2, stream);
|
|
292 continue;
|
|
293 }
|
|
294 putc(' ', stream);
|
|
295 } else if (u1 & 0x80) {
|
|
296 putc(' ', stream);
|
|
297 } else if (pretty && iscntrl(u1)) {
|
|
298 cntrl_putc(u1, stream);
|
|
299 } else {
|
|
300 putc(u1, stream);
|
|
301 }
|
|
302 }
|
|
303 }
|
|
304
|
|
305 #define E2S(i1, i2, o1, o2) {\
|
|
306 (i1) &= 0x7f;\
|
|
307 (i2) &= 0x7f;\
|
|
308 (o1) = ((i1) - 0x21) / 2 + 0x81;\
|
|
309 if ((o1) > 0x9f) { (o1) += (0xe0 - 0xa0); }\
|
|
310 if ((i1) & 1) {\
|
|
311 (o2) = (i2) + (0x40 - 0x21);\
|
|
312 if ((o2) > 0x7e) (o2)++;\
|
|
313 } else {\
|
|
314 (o2) = (i2) + (0xfc - 0x7e);\
|
|
315 }\
|
|
316 }
|
|
317
|
|
318 static void
|
|
319 sjis_fputs(scanlk, stream, pretty)
|
|
320 char *scanlk;
|
|
321 FILE *stream;
|
|
322 int pretty;
|
|
323 {
|
|
324 unsigned char u1, u2, s1, s2;
|
|
325
|
|
326 while (u1 = *scanlk++) {
|
|
327 if (IS_JEUC(u1)) {
|
|
328 u2 = *scanlk;
|
|
329 if (IS_JEUC(u2)) {
|
|
330 scanlk++;
|
|
331 E2S(u1, u2, s1, s2);
|
|
332 putc(s1, stream); putc(s2, stream);
|
|
333 continue;
|
|
334 }
|
|
335 putc(' ', stream);
|
|
336 } else if (u1 & 0x80) {
|
|
337 putc(' ', stream);
|
|
338 } else if (pretty && iscntrl(u1)) {
|
|
339 cntrl_putc(u1, stream);
|
|
340 } else {
|
|
341 putc(u1, stream);
|
|
342 }
|
|
343 }
|
|
344 }
|
|
345
|
|
346 #define DSGNT_JISX0208(stream, status) {\
|
|
347 if (kanji_pos == ASCII) {\
|
|
348 fputs("\033$B", (stream)); (status) = JISX0208;\
|
|
349 }}\
|
|
350
|
|
351 #define DSGNT_ASCII(stream, status) {\
|
|
352 if (kanji_pos == JISX0208) {\
|
|
353 fputs("\033(B", (stream)); (status) = ASCII;\
|
|
354 }}\
|
|
355
|
|
356 static void
|
|
357 jis7_fputs(scanlk, stream, pretty)
|
|
358 char *scanlk;
|
|
359 FILE *stream;
|
|
360 int pretty;
|
|
361 {
|
|
362 int kanji_pos; /* ASCII or JISX0208 */
|
|
363 unsigned char u1, u2;
|
|
364
|
|
365 kanji_pos = ASCII;
|
|
366 while (u1 = *scanlk++) {
|
|
367 if (IS_JEUC(u1)) {
|
|
368 u2 = *scanlk;
|
|
369 if (IS_JEUC(u2)) {
|
|
370 scanlk++;
|
|
371 DSGNT_JISX0208(stream, kanji_pos);
|
|
372 putc(u1 & 0x7f, stream); putc(u2 & 0x7f, stream);
|
|
373 continue;
|
|
374 }
|
|
375 DSGNT_ASCII(stream, kanji_pos);
|
|
376 putc(' ', stream);
|
|
377 } else if (u1 & 0x80) {
|
|
378 DSGNT_ASCII(stream, kanji_pos);
|
|
379 putc(' ', stream);
|
|
380 } else if (pretty && iscntrl(u1)) {
|
|
381 DSGNT_ASCII(stream, kanji_pos);
|
|
382 cntrl_putc(u1, stream);
|
|
383 } else {
|
|
384 DSGNT_ASCII(stream, kanji_pos);
|
|
385 putc(u1, stream);
|
|
386 }
|
|
387 }
|
|
388 DSGNT_ASCII(stream, kanji_pos);
|
|
389 }
|
|
390
|
|
391 static void
|
|
392 cntrl_putc(c, stream)
|
|
393 char c;
|
|
394 FILE *stream;
|
|
395 {
|
|
396 switch (c) {
|
|
397 case '\b': putc('\\', stream); putc('b', stream); break;
|
|
398 case '\f': putc('\\', stream); putc('f', stream); break;
|
|
399 case '\n': putc('\\', stream); putc('n', stream); break;
|
|
400 case '\r': putc('\\', stream); putc('r', stream); break;
|
|
401 case '\t': putc('\\', stream); putc('t', stream); break;
|
|
402 default: putc('^', stream); putc(c ^ 0x40, stream); break;
|
|
403 }
|
|
404 }
|
|
405
|
|
406
|
|
407 /*
|
|
408 * Input:
|
|
409 */
|
|
410 char *
|
|
411 ml_conv(s)
|
|
412 char *s;
|
|
413 {
|
|
414 coding_system_t coding;
|
|
415
|
|
416 if ((s == NULL) || ((coding = CSL_FILE(ml_coding_info)) == CS_NOCONV))
|
|
417 return(s);
|
|
418
|
7
|
419 ml_conv_sbr(s, coding, CE_UNKNOWN, 0);
|
5
|
420 return(s);
|
|
421 }
|
|
422
|
|
423 char *
|
7
|
424 ml_conv_decode(s,encode,charset)
|
5
|
425 char *s;
|
7
|
426 int encode,charset;
|
5
|
427 {
|
|
428 coding_system_t coding;
|
|
429
|
|
430 if ((s == NULL) || ((coding = CSL_FILE(ml_coding_info)) == CS_NOCONV))
|
|
431 return(s);
|
|
432
|
7
|
433 ml_conv_sbr(s, coding, encode, charset);
|
0
|
434 return(s);
|
|
435 }
|
|
436
|
2
|
437 /*
|
|
438 Convert to EUC
|
|
439 shirinking only (?)
|
|
440 */
|
0
|
441
|
2
|
442 static char *
|
|
443 cs_output_opt(int cs)
|
|
444 {
|
|
445 switch(cs) {
|
|
446 case CS_JIS7: return "-j";
|
|
447 case CS_JEUC: return "-e";
|
|
448 case CS_SJIS: return "-s";
|
|
449 case CS_UTF8: return "-w80";
|
|
450 case CS_NOCONV: return "-t";
|
|
451 }
|
5
|
452 return "-t";
|
2
|
453 }
|
|
454
|
|
455 static char *
|
7
|
456 cs_input_opt(int cs, int encode, int input_charset)
|
2
|
457 {
|
5
|
458 switch(encode) {
|
7
|
459 case CE_BASE64:
|
|
460 if (input_charset==CS_UTF8)
|
|
461 return "-emBW8";
|
|
462 return "-emB";
|
|
463 case CE_QUOTED:
|
|
464 if (input_charset==CS_UTF8)
|
|
465 return "-emQW8";
|
|
466 return "-emQ";
|
5
|
467 }
|
2
|
468 switch(cs) {
|
3
|
469 case CS_JIS7: return "-Je";
|
|
470 case CS_JEUC: return "-Ee";
|
|
471 case CS_SJIS: return "-Se";
|
|
472 case CS_UTF8: return "-W8e";
|
2
|
473 case CS_NOCONV: return "-t";
|
|
474 }
|
5
|
475 return "-e";
|
2
|
476 }
|
0
|
477
|
|
478 static void
|
7
|
479 ml_conv_sbr(in, cs, encode, input_charset)
|
0
|
480 char *in;
|
|
481 coding_system_t cs;
|
7
|
482 int encode, input_charset;
|
0
|
483 {
|
7
|
484 char *opt = cs_input_opt(cs,encode,input_charset);
|
2
|
485 int len = strlen(in);
|
5
|
486 nkf_open((unsigned char *)opt,(unsigned char *)in,len,(unsigned char *)in,len,extend,0);
|
2
|
487 nkf_end();
|
|
488 nkf_output[nkf_output_ctr]=0;
|
|
489 }
|
|
490
|
|
491 extern void
|
|
492 mime_convert(char *ptr)
|
|
493 {
|
|
494 int len = strlen(ptr);
|
5
|
495 nkf_open((unsigned char *)"-me",(unsigned char *)ptr,len,(unsigned char *)ptr,len,extend,0);
|
2
|
496 nkf_end();
|
|
497 nkf_output[nkf_output_ctr]=0;
|
|
498 }
|
|
499
|
|
500 #undef CR
|
|
501 #undef LIMIT
|
|
502 #undef PROTO
|
|
503
|
|
504 #undef getc
|
|
505 #undef ungetc
|
|
506
|
|
507 #define getc(f) nkf_getc(f)
|
|
508 #define ungetc(c,f) nkf_ungetc(c,f)
|
|
509
|
|
510 static int
|
|
511 nkf_getc(FILE *f) {
|
|
512 if (nkf_ilimit==-1) {
|
|
513 int c = nkf_input[nkf_input_ctr++];
|
|
514 if (c==0) {
|
|
515 nkf_input_ctr--; return -1;
|
0
|
516 }
|
2
|
517 return c;
|
|
518 }
|
|
519 return (nkf_input_ctr>=nkf_ilimit?-1:nkf_input[nkf_input_ctr++]);
|
|
520 }
|
|
521
|
|
522 static int
|
|
523 nkf_ungetc(int c,FILE *f) {
|
|
524 nkf_input_ctr--;
|
|
525 return c;
|
|
526 }
|
|
527
|
|
528
|
|
529 #undef putchar
|
|
530 #undef TRUE
|
|
531 #undef FALSE
|
|
532 #define putchar(c) nkf_putchar(c)
|
|
533
|
|
534 #define debug nkf_debug
|
|
535
|
|
536 static
|
|
537 int
|
|
538 nkf_putchar(unsigned int c)
|
|
539 {
|
|
540 /* string length is enough? */
|
|
541 if(nkf_output_ctr<nkf_limit && c!='\n') {
|
|
542 return nkf_output[nkf_output_ctr++] = c;
|
|
543 } else {
|
|
544 nkf_output[nkf_output_ctr++] = c;
|
|
545 nkf_flush(nkf_output,nkf_output_ctr);
|
|
546 nkf_output_ctr = 0;
|
0
|
547 }
|
2
|
548 return c;
|
|
549 }
|
|
550
|
|
551
|
|
552 /* Include kanji filter main part */
|
|
553 /* getchar and putchar will be replaced during inclusion */
|
|
554
|
|
555 #define version NKF_version
|
|
556 #define PERL_XS 1
|
|
557 #include "../nkf-utf8/utf8tbl.c"
|
|
558 #include "../nkf-utf8/nkf.c"
|
|
559
|
|
560 /*
|
|
561 using opt ( "-w8" etc... )
|
|
562 convert *in into *out
|
|
563 when limit or nkf_end flush is called
|
|
564
|
|
565 nkf_continue can be use to change input ptr
|
|
566 */
|
|
567
|
|
568 static void
|
5
|
569 nkf_open(unsigned char *opt, unsigned char *in,int ilimit,
|
|
570 unsigned char *out,int limit,void (*flush)(unsigned char *,int),FILE *fp) {
|
2
|
571 /* Flags are reset at each call. */
|
|
572 reinit();
|
|
573
|
|
574 /* Process flags except the last once */
|
|
575 options(opt);
|
|
576
|
|
577 nkf_input_ctr = 0;
|
|
578 nkf_input = in;
|
|
579 nkf_ilimit = ilimit;
|
|
580
|
|
581 nkf_file = fp;
|
|
582
|
|
583 nkf_output_ctr = 0;
|
|
584 nkf_output = out;
|
|
585
|
|
586 nkf_limit = limit;
|
|
587 nkf_flush = flush;
|
|
588
|
|
589 /* Convestion */
|
|
590 kanji_convert(NULL);
|
0
|
591 }
|
2
|
592
|
|
593 static void
|
5
|
594 nkf_continue(unsigned char *in,int ilimit) {
|
2
|
595 nkf_input_ctr = 0;
|
|
596 nkf_input = in;
|
|
597 nkf_ilimit = ilimit;
|
|
598 /* Convestion */
|
|
599 kanji_convert(NULL);
|
|
600 }
|
|
601
|
|
602 void
|
|
603 nkf_end() {
|
|
604 if (nkf_output_ctr) {
|
|
605 nkf_flush(nkf_output,nkf_output_ctr);
|
|
606 nkf_output_ctr = 0;
|
|
607 }
|
|
608 }
|
|
609
|
|
610 static void
|
5
|
611 extend(unsigned char *out,int out_count)
|
2
|
612 {
|
|
613 nkf_output += nkf_output_ctr;
|
|
614 }
|
|
615
|
|
616 static void
|
5
|
617 none(unsigned char *a,int b)
|
2
|
618 {
|
|
619 }
|
|
620
|
|
621 static void
|
5
|
622 my_flush(unsigned char *out,int out_count)
|
2
|
623 {
|
|
624 fwrite(out,out_count,1,nkf_file);
|
|
625 }
|
|
626
|
|
627 static void
|
5
|
628 my_pretty(unsigned char *out,int out_count)
|
2
|
629 {
|
|
630 int c;
|
|
631 FILE *fp = nkf_file;
|
|
632 while(out_count-->0) {
|
|
633 c = *out++;
|
|
634 if (iscntrl(c))
|
|
635 cntrl_putc(c, fp);
|
|
636 else
|
|
637 putc(c, fp);
|
|
638 }
|
|
639 }
|
|
640
|
0
|
641 #endif /* JAPAN */
|
2
|
642
|
|
643 /* end */
|