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

Side by Side Diff: Modules/cjkcodecs/_codecs_cn.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 | « Misc/NEWS ('k') | Modules/cjkcodecs/_codecs_hk.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_cn.c: Codecs collection for Mainland Chinese encodings 2 * _codecs_cn.c: Codecs collection for Mainland Chinese 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_cn.h" 8 #include "mappings_cn.h"
9 9
10 /** 10 /**
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 if (c < 0x80) { 78 if (c < 0x80) {
79 OUT1(c) 79 OUT1(c)
80 NEXT(1, 1) 80 NEXT(1, 1)
81 continue; 81 continue;
82 } 82 }
83 83
84 REQUIRE_INBUF(2) 84 REQUIRE_INBUF(2)
85 TRYMAP_DEC(gb2312, **outbuf, c ^ 0x80, IN2 ^ 0x80) { 85 TRYMAP_DEC(gb2312, **outbuf, c ^ 0x80, IN2 ^ 0x80) {
86 NEXT(2, 1) 86 NEXT(2, 1)
87 } 87 }
88 else return 1; 88 else return 2;
89 } 89 }
90 90
91 return 0; 91 return 0;
92 } 92 }
93 93
94 94
95 /* 95 /*
96 * GBK codec 96 * GBK codec
97 */ 97 */
98 98
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 134
135 if (c < 0x80) { 135 if (c < 0x80) {
136 OUT1(c) 136 OUT1(c)
137 NEXT(1, 1) 137 NEXT(1, 1)
138 continue; 138 continue;
139 } 139 }
140 140
141 REQUIRE_INBUF(2) 141 REQUIRE_INBUF(2)
142 142
143 GBK_DECODE(c, IN2, **outbuf) 143 GBK_DECODE(c, IN2, **outbuf)
144 else return 1; 144 else return 2;
145 145
146 NEXT(2, 1) 146 NEXT(2, 1)
147 } 147 }
148 148
149 return 0; 149 return 0;
150 } 150 }
151 151
152 152
153 /* 153 /*
154 * GB18030 codec 154 * GB18030 codec
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 c2 = IN2; 260 c2 = IN2;
261 if (c2 >= 0x30 && c2 <= 0x39) { /* 4 bytes seq */ 261 if (c2 >= 0x30 && c2 <= 0x39) { /* 4 bytes seq */
262 const struct _gb18030_to_unibmp_ranges *utr; 262 const struct _gb18030_to_unibmp_ranges *utr;
263 unsigned char c3, c4; 263 unsigned char c3, c4;
264 ucs4_t lseq; 264 ucs4_t lseq;
265 265
266 REQUIRE_INBUF(4) 266 REQUIRE_INBUF(4)
267 c3 = IN3; 267 c3 = IN3;
268 c4 = IN4; 268 c4 = IN4;
269 if (c < 0x81 || c3 < 0x81 || c4 < 0x30 || c4 > 0x39) 269 if (c < 0x81 || c3 < 0x81 || c4 < 0x30 || c4 > 0x39)
270 return 1; 270 return 4;
271 c -= 0x81; c2 -= 0x30; 271 c -= 0x81; c2 -= 0x30;
272 c3 -= 0x81; c4 -= 0x30; 272 c3 -= 0x81; c4 -= 0x30;
273 273
274 if (c < 4) { /* U+0080 - U+FFFF */ 274 if (c < 4) { /* U+0080 - U+FFFF */
275 lseq = ((ucs4_t)c * 10 + c2) * 1260 + 275 lseq = ((ucs4_t)c * 10 + c2) * 1260 +
276 (ucs4_t)c3 * 10 + c4; 276 (ucs4_t)c3 * 10 + c4;
277 if (lseq < 39420) { 277 if (lseq < 39420) {
278 for (utr = gb18030_to_unibmp_ranges; 278 for (utr = gb18030_to_unibmp_ranges;
279 lseq >= (utr + 1)->base; 279 lseq >= (utr + 1)->base;
280 utr++) ; 280 utr++) ;
281 OUT1(utr->first - utr->base + lseq) 281 OUT1(utr->first - utr->base + lseq)
282 NEXT(4, 1) 282 NEXT(4, 1)
283 continue; 283 continue;
284 } 284 }
285 } 285 }
286 else if (c >= 15) { /* U+10000 - U+10FFFF */ 286 else if (c >= 15) { /* U+10000 - U+10FFFF */
287 lseq = 0x10000 + (((ucs4_t)c-15) * 10 + c2) 287 lseq = 0x10000 + (((ucs4_t)c-15) * 10 + c2)
288 * 1260 + (ucs4_t)c3 * 10 + c4; 288 * 1260 + (ucs4_t)c3 * 10 + c4;
289 if (lseq <= 0x10FFFF) { 289 if (lseq <= 0x10FFFF) {
290 WRITEUCS4(lseq); 290 WRITEUCS4(lseq);
291 NEXT_IN(4) 291 NEXT_IN(4)
292 continue; 292 continue;
293 } 293 }
294 } 294 }
295 return 1; 295 return 4;
296 } 296 }
297 297
298 GBK_DECODE(c, c2, **outbuf) 298 GBK_DECODE(c, c2, **outbuf)
299 else TRYMAP_DEC(gb18030ext, **outbuf, c, c2); 299 else TRYMAP_DEC(gb18030ext, **outbuf, c, c2);
300 else return 1; 300 else return 2;
301 301
302 NEXT(2, 1) 302 NEXT(2, 1)
303 } 303 }
304 304
305 return 0; 305 return 0;
306 } 306 }
307 307
308 308
309 /* 309 /*
310 * HZ codec 310 * HZ codec
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 NEXT(2, 1) 393 NEXT(2, 1)
394 continue; 394 continue;
395 } 395 }
396 else if (c2 == '{' && state->i == 0) 396 else if (c2 == '{' && state->i == 0)
397 state->i = 1; /* set GB */ 397 state->i = 1; /* set GB */
398 else if (c2 == '}' && state->i == 1) 398 else if (c2 == '}' && state->i == 1)
399 state->i = 0; /* set ASCII */ 399 state->i = 0; /* set ASCII */
400 else if (c2 == '\n') 400 else if (c2 == '\n')
401 ; /* line-continuation */ 401 ; /* line-continuation */
402 else 402 else
403 return 1; 403 return 2;
404 NEXT(2, 0); 404 NEXT(2, 0);
405 continue; 405 continue;
406 } 406 }
407 407
408 if (c & 0x80) 408 if (c & 0x80)
409 return 1; 409 return 1;
410 410
411 if (state->i == 0) { /* ASCII mode */ 411 if (state->i == 0) { /* ASCII mode */
412 WRITE1(c) 412 WRITE1(c)
413 NEXT(1, 1) 413 NEXT(1, 1)
414 } 414 }
415 else { /* GB mode */ 415 else { /* GB mode */
416 REQUIRE_INBUF(2) 416 REQUIRE_INBUF(2)
417 REQUIRE_OUTBUF(1) 417 REQUIRE_OUTBUF(1)
418 TRYMAP_DEC(gb2312, **outbuf, c, IN2) { 418 TRYMAP_DEC(gb2312, **outbuf, c, IN2) {
419 NEXT(2, 1) 419 NEXT(2, 1)
420 } 420 }
421 else 421 else
422 return 1; 422 return 2;
423 } 423 }
424 } 424 }
425 425
426 return 0; 426 return 0;
427 } 427 }
428 428
429 429
430 BEGIN_MAPPINGS_LIST 430 BEGIN_MAPPINGS_LIST
431 MAPPING_DECONLY(gb2312) 431 MAPPING_DECONLY(gb2312)
432 MAPPING_DECONLY(gbkext) 432 MAPPING_DECONLY(gbkext)
433 MAPPING_ENCONLY(gbcommon) 433 MAPPING_ENCONLY(gbcommon)
434 MAPPING_ENCDEC(gb18030ext) 434 MAPPING_ENCDEC(gb18030ext)
435 END_MAPPINGS_LIST 435 END_MAPPINGS_LIST
436 436
437 BEGIN_CODECS_LIST 437 BEGIN_CODECS_LIST
438 CODEC_STATELESS(gb2312) 438 CODEC_STATELESS(gb2312)
439 CODEC_STATELESS(gbk) 439 CODEC_STATELESS(gbk)
440 CODEC_STATELESS(gb18030) 440 CODEC_STATELESS(gb18030)
441 CODEC_STATEFUL(hz) 441 CODEC_STATEFUL(hz)
442 END_CODECS_LIST 442 END_CODECS_LIST
443 443
444 I_AM_A_MODULE_FOR(cn) 444 I_AM_A_MODULE_FOR(cn)
OLDNEW
« no previous file with comments | « Misc/NEWS ('k') | Modules/cjkcodecs/_codecs_hk.c » ('j') | no next file with comments »

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