Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(16)

Side by Side Diff: Modules/cjkcodecs/_codecs_jp.c

Issue 10639: reindent.py converts newlines to platform default
Patch Set: Created 8 years, 8 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Modules/cjkcodecs/_codecs_hk.c ('k') | Modules/cjkcodecs/_codecs_kr.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * _codecs_jp.c: Codecs collection for Japanese encodings 2 * _codecs_jp.c: Codecs collection for Japanese encodings
3 * 3 *
4 * Written by Hye-Shik Chang <perky@FreeBSD.org> 4 * Written by Hye-Shik Chang <perky@FreeBSD.org>
5 */ 5 */
6 6
7 #define USING_BINARY_PAIR_SEARCH 7 #define USING_BINARY_PAIR_SEARCH
8 #define EMPBASE 0x20000 8 #define EMPBASE 0x20000
9 9
10 #include "cjkcodecs.h" 10 #include "cjkcodecs.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 NEXT(1, 1) 105 NEXT(1, 1)
106 continue; 106 continue;
107 } 107 }
108 108
109 REQUIRE_INBUF(2) 109 REQUIRE_INBUF(2)
110 c2 = IN2; 110 c2 = IN2;
111 111
112 TRYMAP_DEC(cp932ext, **outbuf, c, c2); 112 TRYMAP_DEC(cp932ext, **outbuf, c, c2);
113 else if ((c >= 0x81 && c <= 0x9f) || (c >= 0xe0 && c <= 0xea)){ 113 else if ((c >= 0x81 && c <= 0x9f) || (c >= 0xe0 && c <= 0xea)){
114 if (c2 < 0x40 || (c2 > 0x7e && c2 < 0x80) || c2 > 0xfc) 114 if (c2 < 0x40 || (c2 > 0x7e && c2 < 0x80) || c2 > 0xfc)
115 return 1; 115 return 2;
116 116
117 c = (c < 0xe0 ? c - 0x81 : c - 0xc1); 117 c = (c < 0xe0 ? c - 0x81 : c - 0xc1);
118 c2 = (c2 < 0x80 ? c2 - 0x40 : c2 - 0x41); 118 c2 = (c2 < 0x80 ? c2 - 0x40 : c2 - 0x41);
119 c = (2 * c + (c2 < 0x5e ? 0 : 1) + 0x21); 119 c = (2 * c + (c2 < 0x5e ? 0 : 1) + 0x21);
120 c2 = (c2 < 0x5e ? c2 : c2 - 0x5e) + 0x21; 120 c2 = (c2 < 0x5e ? c2 : c2 - 0x5e) + 0x21;
121 121
122 TRYMAP_DEC(jisx0208, **outbuf, c, c2); 122 TRYMAP_DEC(jisx0208, **outbuf, c, c2);
123 else return 1; 123 else return 2;
124 } 124 }
125 else if (c >= 0xf0 && c <= 0xf9) { 125 else if (c >= 0xf0 && c <= 0xf9) {
126 if ((c2 >= 0x40 && c2 <= 0x7e) || 126 if ((c2 >= 0x40 && c2 <= 0x7e) ||
127 (c2 >= 0x80 && c2 <= 0xfc)) 127 (c2 >= 0x80 && c2 <= 0xfc))
128 OUT1(0xe000 + 188 * (c - 0xf0) + 128 OUT1(0xe000 + 188 * (c - 0xf0) +
129 (c2 < 0x80 ? c2 - 0x40 : c2 - 0x41)) 129 (c2 < 0x80 ? c2 - 0x40 : c2 - 0x41))
130 else 130 else
131 return 1; 131 return 2;
132 } 132 }
133 else 133 else
134 return 1; 134 return 2;
135 135
136 NEXT(2, 1) 136 NEXT(2, 1)
137 } 137 }
138 138
139 return 0; 139 return 0;
140 } 140 }
141 141
142 142
143 /* 143 /*
144 * EUC-JIS-2004 codec 144 * EUC-JIS-2004 codec
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 /* JIS X 0201 half-width katakana */ 249 /* JIS X 0201 half-width katakana */
250 unsigned char c2; 250 unsigned char c2;
251 251
252 REQUIRE_INBUF(2) 252 REQUIRE_INBUF(2)
253 c2 = IN2; 253 c2 = IN2;
254 if (c2 >= 0xa1 && c2 <= 0xdf) { 254 if (c2 >= 0xa1 && c2 <= 0xdf) {
255 OUT1(0xfec0 + c2) 255 OUT1(0xfec0 + c2)
256 NEXT(2, 1) 256 NEXT(2, 1)
257 } 257 }
258 else 258 else
259 return 1; 259 return 2;
260 } 260 }
261 else if (c == 0x8f) { 261 else if (c == 0x8f) {
262 unsigned char c2, c3; 262 unsigned char c2, c3;
263 263
264 REQUIRE_INBUF(3) 264 REQUIRE_INBUF(3)
265 c2 = IN2 ^ 0x80; 265 c2 = IN2 ^ 0x80;
266 c3 = IN3 ^ 0x80; 266 c3 = IN3 ^ 0x80;
267 267
268 /* JIS X 0213 Plane 2 or JIS X 0212 (see NOTES) */ 268 /* JIS X 0213 Plane 2 or JIS X 0212 (see NOTES) */
269 EMULATE_JISX0213_2000_DECODE_PLANE2(**outbuf, c2, c3) 269 EMULATE_JISX0213_2000_DECODE_PLANE2(**outbuf, c2, c3)
270 else TRYMAP_DEC(jisx0213_2_bmp, **outbuf, c2, c3) ; 270 else TRYMAP_DEC(jisx0213_2_bmp, **outbuf, c2, c3) ;
271 else TRYMAP_DEC(jisx0213_2_emp, code, c2, c3) { 271 else TRYMAP_DEC(jisx0213_2_emp, code, c2, c3) {
272 WRITEUCS4(EMPBASE | code) 272 WRITEUCS4(EMPBASE | code)
273 NEXT_IN(3) 273 NEXT_IN(3)
274 continue; 274 continue;
275 } 275 }
276 else TRYMAP_DEC(jisx0212, **outbuf, c2, c3) ; 276 else TRYMAP_DEC(jisx0212, **outbuf, c2, c3) ;
277 else return 1; 277 else return 3;
278 NEXT(3, 1) 278 NEXT(3, 1)
279 } 279 }
280 else { 280 else {
281 unsigned char c2; 281 unsigned char c2;
282 282
283 REQUIRE_INBUF(2) 283 REQUIRE_INBUF(2)
284 c ^= 0x80; 284 c ^= 0x80;
285 c2 = IN2 ^ 0x80; 285 c2 = IN2 ^ 0x80;
286 286
287 /* JIS X 0213 Plane 1 */ 287 /* JIS X 0213 Plane 1 */
288 EMULATE_JISX0213_2000_DECODE_PLANE1(**outbuf, c, c2) 288 EMULATE_JISX0213_2000_DECODE_PLANE1(**outbuf, c, c2)
289 else if (c == 0x21 && c2 == 0x40) **outbuf = 0xff3c; 289 else if (c == 0x21 && c2 == 0x40) **outbuf = 0xff3c;
290 else if (c == 0x22 && c2 == 0x32) **outbuf = 0xff5e; 290 else if (c == 0x22 && c2 == 0x32) **outbuf = 0xff5e;
291 else TRYMAP_DEC(jisx0208, **outbuf, c, c2); 291 else TRYMAP_DEC(jisx0208, **outbuf, c, c2);
292 else TRYMAP_DEC(jisx0213_1_bmp, **outbuf, c, c2); 292 else TRYMAP_DEC(jisx0213_1_bmp, **outbuf, c, c2);
293 else TRYMAP_DEC(jisx0213_1_emp, code, c, c2) { 293 else TRYMAP_DEC(jisx0213_1_emp, code, c, c2) {
294 WRITEUCS4(EMPBASE | code) 294 WRITEUCS4(EMPBASE | code)
295 NEXT_IN(2) 295 NEXT_IN(2)
296 continue; 296 continue;
297 } 297 }
298 else TRYMAP_DEC(jisx0213_pair, code, c, c2) { 298 else TRYMAP_DEC(jisx0213_pair, code, c, c2) {
299 WRITE2(code >> 16, code & 0xffff) 299 WRITE2(code >> 16, code & 0xffff)
300 NEXT(2, 2) 300 NEXT(2, 2)
301 continue; 301 continue;
302 } 302 }
303 else return 1; 303 else return 2;
304 NEXT(2, 1) 304 NEXT(2, 1)
305 } 305 }
306 } 306 }
307 307
308 return 0; 308 return 0;
309 } 309 }
310 310
311 311
312 /* 312 /*
313 * EUC-JP codec 313 * EUC-JP codec
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 /* JIS X 0201 half-width katakana */ 381 /* JIS X 0201 half-width katakana */
382 unsigned char c2; 382 unsigned char c2;
383 383
384 REQUIRE_INBUF(2) 384 REQUIRE_INBUF(2)
385 c2 = IN2; 385 c2 = IN2;
386 if (c2 >= 0xa1 && c2 <= 0xdf) { 386 if (c2 >= 0xa1 && c2 <= 0xdf) {
387 OUT1(0xfec0 + c2) 387 OUT1(0xfec0 + c2)
388 NEXT(2, 1) 388 NEXT(2, 1)
389 } 389 }
390 else 390 else
391 return 1; 391 return 2;
392 } 392 }
393 else if (c == 0x8f) { 393 else if (c == 0x8f) {
394 unsigned char c2, c3; 394 unsigned char c2, c3;
395 395
396 REQUIRE_INBUF(3) 396 REQUIRE_INBUF(3)
397 c2 = IN2; 397 c2 = IN2;
398 c3 = IN3; 398 c3 = IN3;
399 /* JIS X 0212 */ 399 /* JIS X 0212 */
400 TRYMAP_DEC(jisx0212, **outbuf, c2 ^ 0x80, c3 ^ 0x80) { 400 TRYMAP_DEC(jisx0212, **outbuf, c2 ^ 0x80, c3 ^ 0x80) {
401 NEXT(3, 1) 401 NEXT(3, 1)
402 } 402 }
403 else 403 else
404 return 1; 404 return 3;
405 } 405 }
406 else { 406 else {
407 unsigned char c2; 407 unsigned char c2;
408 408
409 REQUIRE_INBUF(2) 409 REQUIRE_INBUF(2)
410 c2 = IN2; 410 c2 = IN2;
411 /* JIS X 0208 */ 411 /* JIS X 0208 */
412 #ifndef STRICT_BUILD 412 #ifndef STRICT_BUILD
413 if (c == 0xa1 && c2 == 0xc0) 413 if (c == 0xa1 && c2 == 0xc0)
414 /* FULL-WIDTH REVERSE SOLIDUS */ 414 /* FULL-WIDTH REVERSE SOLIDUS */
415 **outbuf = 0xff3c; 415 **outbuf = 0xff3c;
416 else 416 else
417 #endif 417 #endif
418 TRYMAP_DEC(jisx0208, **outbuf, 418 TRYMAP_DEC(jisx0208, **outbuf,
419 c ^ 0x80, c2 ^ 0x80) ; 419 c ^ 0x80, c2 ^ 0x80) ;
420 else return 1; 420 else return 2;
421 NEXT(2, 1) 421 NEXT(2, 1)
422 } 422 }
423 } 423 }
424 424
425 return 0; 425 return 0;
426 } 426 }
427 427
428 428
429 /* 429 /*
430 * SHIFT_JIS codec 430 * SHIFT_JIS codec
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 #else 495 #else
496 if (c < 0x80) **outbuf = c; 496 if (c < 0x80) **outbuf = c;
497 #endif 497 #endif
498 else JISX0201_K_DECODE(c, **outbuf) 498 else JISX0201_K_DECODE(c, **outbuf)
499 else if ((c >= 0x81 && c <= 0x9f) || (c >= 0xe0 && c <= 0xea)){ 499 else if ((c >= 0x81 && c <= 0x9f) || (c >= 0xe0 && c <= 0xea)){
500 unsigned char c1, c2; 500 unsigned char c1, c2;
501 501
502 REQUIRE_INBUF(2) 502 REQUIRE_INBUF(2)
503 c2 = IN2; 503 c2 = IN2;
504 if (c2 < 0x40 || (c2 > 0x7e && c2 < 0x80) || c2 > 0xfc) 504 if (c2 < 0x40 || (c2 > 0x7e && c2 < 0x80) || c2 > 0xfc)
505 return 1; 505 return 2;
506 506
507 c1 = (c < 0xe0 ? c - 0x81 : c - 0xc1); 507 c1 = (c < 0xe0 ? c - 0x81 : c - 0xc1);
508 c2 = (c2 < 0x80 ? c2 - 0x40 : c2 - 0x41); 508 c2 = (c2 < 0x80 ? c2 - 0x40 : c2 - 0x41);
509 c1 = (2 * c1 + (c2 < 0x5e ? 0 : 1) + 0x21); 509 c1 = (2 * c1 + (c2 < 0x5e ? 0 : 1) + 0x21);
510 c2 = (c2 < 0x5e ? c2 : c2 - 0x5e) + 0x21; 510 c2 = (c2 < 0x5e ? c2 : c2 - 0x5e) + 0x21;
511 511
512 #ifndef STRICT_BUILD 512 #ifndef STRICT_BUILD
513 if (c1 == 0x21 && c2 == 0x40) { 513 if (c1 == 0x21 && c2 == 0x40) {
514 /* FULL-WIDTH REVERSE SOLIDUS */ 514 /* FULL-WIDTH REVERSE SOLIDUS */
515 OUT1(0xff3c) 515 OUT1(0xff3c)
516 NEXT(2, 1) 516 NEXT(2, 1)
517 continue; 517 continue;
518 } 518 }
519 #endif 519 #endif
520 TRYMAP_DEC(jisx0208, **outbuf, c1, c2) { 520 TRYMAP_DEC(jisx0208, **outbuf, c1, c2) {
521 NEXT(2, 1) 521 NEXT(2, 1)
522 continue; 522 continue;
523 } 523 }
524 else 524 else
525 return 1; 525 return 2;
526 } 526 }
527 else 527 else
528 return 1; 528 return 2;
529 529
530 NEXT(1, 1) /* JIS X 0201 */ 530 NEXT(1, 1) /* JIS X 0201 */
531 } 531 }
532 532
533 return 0; 533 return 0;
534 } 534 }
535 535
536 536
537 /* 537 /*
538 * SHIFT_JIS-2004 codec 538 * SHIFT_JIS-2004 codec
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
638 638
639 REQUIRE_OUTBUF(1) 639 REQUIRE_OUTBUF(1)
640 JISX0201_DECODE(c, **outbuf) 640 JISX0201_DECODE(c, **outbuf)
641 else if ((c >= 0x81 && c <= 0x9f) || (c >= 0xe0 && c <= 0xfc)){ 641 else if ((c >= 0x81 && c <= 0x9f) || (c >= 0xe0 && c <= 0xfc)){
642 unsigned char c1, c2; 642 unsigned char c1, c2;
643 ucs4_t code; 643 ucs4_t code;
644 644
645 REQUIRE_INBUF(2) 645 REQUIRE_INBUF(2)
646 c2 = IN2; 646 c2 = IN2;
647 if (c2 < 0x40 || (c2 > 0x7e && c2 < 0x80) || c2 > 0xfc) 647 if (c2 < 0x40 || (c2 > 0x7e && c2 < 0x80) || c2 > 0xfc)
648 return 1; 648 return 2;
649 649
650 c1 = (c < 0xe0 ? c - 0x81 : c - 0xc1); 650 c1 = (c < 0xe0 ? c - 0x81 : c - 0xc1);
651 c2 = (c2 < 0x80 ? c2 - 0x40 : c2 - 0x41); 651 c2 = (c2 < 0x80 ? c2 - 0x40 : c2 - 0x41);
652 c1 = (2 * c1 + (c2 < 0x5e ? 0 : 1)); 652 c1 = (2 * c1 + (c2 < 0x5e ? 0 : 1));
653 c2 = (c2 < 0x5e ? c2 : c2 - 0x5e) + 0x21; 653 c2 = (c2 < 0x5e ? c2 : c2 - 0x5e) + 0x21;
654 654
655 if (c1 < 0x5e) { /* Plane 1 */ 655 if (c1 < 0x5e) { /* Plane 1 */
656 c1 += 0x21; 656 c1 += 0x21;
657 EMULATE_JISX0213_2000_DECODE_PLANE1(**outbuf, 657 EMULATE_JISX0213_2000_DECODE_PLANE1(**outbuf,
658 c1, c2) 658 c1, c2)
659 else TRYMAP_DEC(jisx0208, **outbuf, c1, c2) { 659 else TRYMAP_DEC(jisx0208, **outbuf, c1, c2) {
660 NEXT_OUT(1) 660 NEXT_OUT(1)
661 } 661 }
662 else TRYMAP_DEC(jisx0213_1_bmp, **outbuf, 662 else TRYMAP_DEC(jisx0213_1_bmp, **outbuf,
663 c1, c2) { 663 c1, c2) {
664 NEXT_OUT(1) 664 NEXT_OUT(1)
665 } 665 }
666 else TRYMAP_DEC(jisx0213_1_emp, code, c1, c2) { 666 else TRYMAP_DEC(jisx0213_1_emp, code, c1, c2) {
667 WRITEUCS4(EMPBASE | code) 667 WRITEUCS4(EMPBASE | code)
668 } 668 }
669 else TRYMAP_DEC(jisx0213_pair, code, c1, c2) { 669 else TRYMAP_DEC(jisx0213_pair, code, c1, c2) {
670 WRITE2(code >> 16, code & 0xffff) 670 WRITE2(code >> 16, code & 0xffff)
671 NEXT_OUT(2) 671 NEXT_OUT(2)
672 } 672 }
673 else 673 else
674 return 1; 674 return 2;
675 NEXT_IN(2) 675 NEXT_IN(2)
676 } 676 }
677 else { /* Plane 2 */ 677 else { /* Plane 2 */
678 if (c1 >= 0x67) c1 += 0x07; 678 if (c1 >= 0x67) c1 += 0x07;
679 else if (c1 >= 0x63 || c1 == 0x5f) c1 -= 0x37; 679 else if (c1 >= 0x63 || c1 == 0x5f) c1 -= 0x37;
680 else c1 -= 0x3d; 680 else c1 -= 0x3d;
681 681
682 EMULATE_JISX0213_2000_DECODE_PLANE2(**outbuf, 682 EMULATE_JISX0213_2000_DECODE_PLANE2(**outbuf,
683 c1, c2) 683 c1, c2)
684 else TRYMAP_DEC(jisx0213_2_bmp, **outbuf, 684 else TRYMAP_DEC(jisx0213_2_bmp, **outbuf,
685 c1, c2) ; 685 c1, c2) ;
686 else TRYMAP_DEC(jisx0213_2_emp, code, c1, c2) { 686 else TRYMAP_DEC(jisx0213_2_emp, code, c1, c2) {
687 WRITEUCS4(EMPBASE | code) 687 WRITEUCS4(EMPBASE | code)
688 NEXT_IN(2) 688 NEXT_IN(2)
689 continue; 689 continue;
690 } 690 }
691 else 691 else
692 return 1; 692 return 2;
693 NEXT(2, 1) 693 NEXT(2, 1)
694 } 694 }
695 continue; 695 continue;
696 } 696 }
697 else 697 else
698 return 1; 698 return 2;
699 699
700 NEXT(1, 1) /* JIS X 0201 */ 700 NEXT(1, 1) /* JIS X 0201 */
701 } 701 }
702 702
703 return 0; 703 return 0;
704 } 704 }
705 705
706 706
707 BEGIN_MAPPINGS_LIST 707 BEGIN_MAPPINGS_LIST
708 MAPPING_DECONLY(jisx0208) 708 MAPPING_DECONLY(jisx0208)
(...skipping 13 matching lines...) Expand all
722 CODEC_STATELESS(shift_jis) 722 CODEC_STATELESS(shift_jis)
723 CODEC_STATELESS(cp932) 723 CODEC_STATELESS(cp932)
724 CODEC_STATELESS(euc_jp) 724 CODEC_STATELESS(euc_jp)
725 CODEC_STATELESS(shift_jis_2004) 725 CODEC_STATELESS(shift_jis_2004)
726 CODEC_STATELESS(euc_jis_2004) 726 CODEC_STATELESS(euc_jis_2004)
727 { "euc_jisx0213", (void *)2000, NULL, _STATELESS_METHODS(euc_jis_2004) }, 727 { "euc_jisx0213", (void *)2000, NULL, _STATELESS_METHODS(euc_jis_2004) },
728 { "shift_jisx0213", (void *)2000, NULL, _STATELESS_METHODS(shift_jis_2004) }, 728 { "shift_jisx0213", (void *)2000, NULL, _STATELESS_METHODS(shift_jis_2004) },
729 END_CODECS_LIST 729 END_CODECS_LIST
730 730
731 I_AM_A_MODULE_FOR(jp) 731 I_AM_A_MODULE_FOR(jp)
OLDNEW
« no previous file with comments | « Modules/cjkcodecs/_codecs_hk.c ('k') | Modules/cjkcodecs/_codecs_kr.c » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+