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

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

Issue 10639: reindent.py converts newlines to platform default
Patch Set: Created 8 years, 10 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_jp.c ('k') | Modules/cjkcodecs/_codecs_tw.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_kr.c: Codecs collection for Korean encodings 2 * _codecs_kr.c: Codecs collection for Korean 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 #include "cjkcodecs.h" 7 #include "cjkcodecs.h"
8 #include "mappings_kr.h" 8 #include "mappings_kr.h"
9 9
10 /* 10 /*
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 116
117 if (c == EUCKR_JAMO_FIRSTBYTE && 117 if (c == EUCKR_JAMO_FIRSTBYTE &&
118 IN2 == EUCKR_JAMO_FILLER) { 118 IN2 == EUCKR_JAMO_FILLER) {
119 /* KS X 1001:1998 Annex 3 make-up sequence */ 119 /* KS X 1001:1998 Annex 3 make-up sequence */
120 DBCHAR cho, jung, jong; 120 DBCHAR cho, jung, jong;
121 121
122 REQUIRE_INBUF(8) 122 REQUIRE_INBUF(8)
123 if ((*inbuf)[2] != EUCKR_JAMO_FIRSTBYTE || 123 if ((*inbuf)[2] != EUCKR_JAMO_FIRSTBYTE ||
124 (*inbuf)[4] != EUCKR_JAMO_FIRSTBYTE || 124 (*inbuf)[4] != EUCKR_JAMO_FIRSTBYTE ||
125 (*inbuf)[6] != EUCKR_JAMO_FIRSTBYTE) 125 (*inbuf)[6] != EUCKR_JAMO_FIRSTBYTE)
126 return 1; 126 return 8;
127 127
128 c = (*inbuf)[3]; 128 c = (*inbuf)[3];
129 if (0xa1 <= c && c <= 0xbe) 129 if (0xa1 <= c && c <= 0xbe)
130 cho = cgk2u_choseong[c - 0xa1]; 130 cho = cgk2u_choseong[c - 0xa1];
131 else 131 else
132 cho = NONE; 132 cho = NONE;
133 133
134 c = (*inbuf)[5]; 134 c = (*inbuf)[5];
135 jung = (0xbf <= c && c <= 0xd3) ? c - 0xbf : NONE; 135 jung = (0xbf <= c && c <= 0xd3) ? c - 0xbf : NONE;
136 136
137 c = (*inbuf)[7]; 137 c = (*inbuf)[7];
138 if (c == EUCKR_JAMO_FILLER) 138 if (c == EUCKR_JAMO_FILLER)
139 jong = 0; 139 jong = 0;
140 else if (0xa1 <= c && c <= 0xbe) 140 else if (0xa1 <= c && c <= 0xbe)
141 jong = cgk2u_jongseong[c - 0xa1]; 141 jong = cgk2u_jongseong[c - 0xa1];
142 else 142 else
143 jong = NONE; 143 jong = NONE;
144 144
145 if (cho == NONE || jung == NONE || jong == NONE) 145 if (cho == NONE || jung == NONE || jong == NONE)
146 return 1; 146 return 8;
147 147
148 OUT1(0xac00 + cho*588 + jung*28 + jong); 148 OUT1(0xac00 + cho*588 + jung*28 + jong);
149 NEXT(8, 1) 149 NEXT(8, 1)
150 } 150 }
151 else TRYMAP_DEC(ksx1001, **outbuf, c ^ 0x80, IN2 ^ 0x80) { 151 else TRYMAP_DEC(ksx1001, **outbuf, c ^ 0x80, IN2 ^ 0x80) {
152 NEXT(2, 1) 152 NEXT(2, 1)
153 } 153 }
154 else 154 else
155 return 1; 155 return 2;
156 } 156 }
157 157
158 return 0; 158 return 0;
159 } 159 }
160 #undef NONE 160 #undef NONE
161 161
162 162
163 /* 163 /*
164 * CP949 codec 164 * CP949 codec
165 */ 165 */
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 201
202 if (c < 0x80) { 202 if (c < 0x80) {
203 OUT1(c) 203 OUT1(c)
204 NEXT(1, 1) 204 NEXT(1, 1)
205 continue; 205 continue;
206 } 206 }
207 207
208 REQUIRE_INBUF(2) 208 REQUIRE_INBUF(2)
209 TRYMAP_DEC(ksx1001, **outbuf, c ^ 0x80, IN2 ^ 0x80); 209 TRYMAP_DEC(ksx1001, **outbuf, c ^ 0x80, IN2 ^ 0x80);
210 else TRYMAP_DEC(cp949ext, **outbuf, c, IN2); 210 else TRYMAP_DEC(cp949ext, **outbuf, c, IN2);
211 else return 1; 211 else return 2;
212 212
213 NEXT(2, 1) 213 NEXT(2, 1)
214 } 214 }
215 215
216 return 0; 216 return 0;
217 } 217 }
218 218
219 219
220 /* 220 /*
221 * JOHAB codec 221 * JOHAB codec
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 368
369 c_cho = (c >> 2) & 0x1f; 369 c_cho = (c >> 2) & 0x1f;
370 c_jung = ((c << 3) | c2 >> 5) & 0x1f; 370 c_jung = ((c << 3) | c2 >> 5) & 0x1f;
371 c_jong = c2 & 0x1f; 371 c_jong = c2 & 0x1f;
372 372
373 i_cho = johabidx_choseong[c_cho]; 373 i_cho = johabidx_choseong[c_cho];
374 i_jung = johabidx_jungseong[c_jung]; 374 i_jung = johabidx_jungseong[c_jung];
375 i_jong = johabidx_jongseong[c_jong]; 375 i_jong = johabidx_jongseong[c_jong];
376 376
377 if (i_cho == NONE || i_jung == NONE || i_jong == NONE) 377 if (i_cho == NONE || i_jung == NONE || i_jong == NONE)
378 return 1; 378 return 2;
379 379
380 /* we don't use U+1100 hangul jamo yet. */ 380 /* we don't use U+1100 hangul jamo yet. */
381 if (i_cho == FILL) { 381 if (i_cho == FILL) {
382 if (i_jung == FILL) { 382 if (i_jung == FILL) {
383 if (i_jong == FILL) 383 if (i_jong == FILL)
384 OUT1(0x3000) 384 OUT1(0x3000)
385 else 385 else
386 OUT1(0x3100 | 386 OUT1(0x3100 |
387 johabjamo_jongseong[c_jong]) 387 johabjamo_jongseong[c_jong])
388 } 388 }
389 else { 389 else {
390 if (i_jong == FILL) 390 if (i_jong == FILL)
391 OUT1(0x3100 | 391 OUT1(0x3100 |
392 johabjamo_jungseong[c_jung]) 392 johabjamo_jungseong[c_jung])
393 else 393 else
394 return 1; 394 return 2;
395 } 395 }
396 } else { 396 } else {
397 if (i_jung == FILL) { 397 if (i_jung == FILL) {
398 if (i_jong == FILL) 398 if (i_jong == FILL)
399 OUT1(0x3100 | 399 OUT1(0x3100 |
400 johabjamo_choseong[c_cho]) 400 johabjamo_choseong[c_cho])
401 else 401 else
402 return 1; 402 return 2;
403 } 403 }
404 else 404 else
405 OUT1(0xac00 + 405 OUT1(0xac00 +
406 i_cho * 588 + 406 i_cho * 588 +
407 i_jung * 28 + 407 i_jung * 28 +
408 (i_jong == FILL ? 0 : i_jong)) 408 (i_jong == FILL ? 0 : i_jong))
409 } 409 }
410 NEXT(2, 1) 410 NEXT(2, 1)
411 } else { 411 } else {
412 /* KS X 1001 except hangul jamos and syllables */ 412 /* KS X 1001 except hangul jamos and syllables */
413 if (c == 0xdf || c > 0xf9 || 413 if (c == 0xdf || c > 0xf9 ||
414 c2 < 0x31 || (c2 >= 0x80 && c2 < 0x91) || 414 c2 < 0x31 || (c2 >= 0x80 && c2 < 0x91) ||
415 (c2 & 0x7f) == 0x7f || 415 (c2 & 0x7f) == 0x7f ||
416 (c == 0xda && (c2 >= 0xa1 && c2 <= 0xd3))) 416 (c == 0xda && (c2 >= 0xa1 && c2 <= 0xd3)))
417 return 1; 417 return 2;
418 else { 418 else {
419 unsigned char t1, t2; 419 unsigned char t1, t2;
420 420
421 t1 = (c < 0xe0 ? 2 * (c - 0xd9) : 421 t1 = (c < 0xe0 ? 2 * (c - 0xd9) :
422 2 * c - 0x197); 422 2 * c - 0x197);
423 t2 = (c2 < 0x91 ? c2 - 0x31 : c2 - 0x43); 423 t2 = (c2 < 0x91 ? c2 - 0x31 : c2 - 0x43);
424 t1 = t1 + (t2 < 0x5e ? 0 : 1) + 0x21; 424 t1 = t1 + (t2 < 0x5e ? 0 : 1) + 0x21;
425 t2 = (t2 < 0x5e ? t2 : t2 - 0x5e) + 0x21; 425 t2 = (t2 < 0x5e ? t2 : t2 - 0x5e) + 0x21;
426 426
427 TRYMAP_DEC(ksx1001, **outbuf, t1, t2); 427 TRYMAP_DEC(ksx1001, **outbuf, t1, t2);
428 else return 1; 428 else return 2;
429 NEXT(2, 1) 429 NEXT(2, 1)
430 } 430 }
431 } 431 }
432 } 432 }
433 433
434 return 0; 434 return 0;
435 } 435 }
436 #undef NONE 436 #undef NONE
437 #undef FILL 437 #undef FILL
438 438
439 439
440 BEGIN_MAPPINGS_LIST 440 BEGIN_MAPPINGS_LIST
441 MAPPING_DECONLY(ksx1001) 441 MAPPING_DECONLY(ksx1001)
442 MAPPING_ENCONLY(cp949) 442 MAPPING_ENCONLY(cp949)
443 MAPPING_DECONLY(cp949ext) 443 MAPPING_DECONLY(cp949ext)
444 END_MAPPINGS_LIST 444 END_MAPPINGS_LIST
445 445
446 BEGIN_CODECS_LIST 446 BEGIN_CODECS_LIST
447 CODEC_STATELESS(euc_kr) 447 CODEC_STATELESS(euc_kr)
448 CODEC_STATELESS(cp949) 448 CODEC_STATELESS(cp949)
449 CODEC_STATELESS(johab) 449 CODEC_STATELESS(johab)
450 END_CODECS_LIST 450 END_CODECS_LIST
451 451
452 I_AM_A_MODULE_FOR(kr) 452 I_AM_A_MODULE_FOR(kr)
OLDNEW
« no previous file with comments | « Modules/cjkcodecs/_codecs_jp.c ('k') | Modules/cjkcodecs/_codecs_tw.c » ('j') | no next file with comments »

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