diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2013-04-11 20:09:04 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2013-04-11 20:09:04 (GMT) |
commit | a0dd0213cc457bdf2b04206548f5a269db256d4d (patch) | |
tree | d282d6b615e9feef64d68fa48cac54e22fd97150 /Modules/cjkcodecs/_codecs_tw.c | |
parent | d8a5cc91e6559e11ca28e6a915017433b14b12d1 (diff) | |
download | cpython-a0dd0213cc457bdf2b04206548f5a269db256d4d.zip cpython-a0dd0213cc457bdf2b04206548f5a269db256d4d.tar.gz cpython-a0dd0213cc457bdf2b04206548f5a269db256d4d.tar.bz2 |
Close #17693: Rewrite CJK decoders to use the _PyUnicodeWriter API instead of
the legacy Py_UNICODE API.
Add also a new _PyUnicodeWriter_WriteChar() function.
Diffstat (limited to 'Modules/cjkcodecs/_codecs_tw.c')
-rw-r--r-- | Modules/cjkcodecs/_codecs_tw.c | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/Modules/cjkcodecs/_codecs_tw.c b/Modules/cjkcodecs/_codecs_tw.c index 916298d..a91c01b 100644 --- a/Modules/cjkcodecs/_codecs_tw.c +++ b/Modules/cjkcodecs/_codecs_tw.c @@ -14,7 +14,7 @@ ENCODER(big5) { while (inleft > 0) { - Py_UNICODE c = **inbuf; + Py_UCS4 c = **inbuf; DBCHAR code; if (c < 0x80) { @@ -43,17 +43,15 @@ DECODER(big5) while (inleft > 0) { unsigned char c = IN1; - REQUIRE_OUTBUF(1) - if (c < 0x80) { - OUT1(c) - NEXT(1, 1) + OUTCHAR(c); + NEXT_IN(1); continue; } REQUIRE_INBUF(2) - TRYMAP_DEC(big5, **outbuf, c, IN2) { - NEXT(2, 1) + TRYMAP_DEC(big5, writer, c, IN2) { + NEXT_IN(2); } else return 1; } @@ -69,7 +67,7 @@ DECODER(big5) ENCODER(cp950) { while (inleft > 0) { - Py_UNICODE c = IN1; + Py_UCS4 c = IN1; DBCHAR code; if (c < 0x80) { @@ -97,21 +95,19 @@ DECODER(cp950) while (inleft > 0) { unsigned char c = IN1; - REQUIRE_OUTBUF(1) - if (c < 0x80) { - OUT1(c) - NEXT(1, 1) + OUTCHAR(c); + NEXT_IN(1); continue; } REQUIRE_INBUF(2) - TRYMAP_DEC(cp950ext, **outbuf, c, IN2); - else TRYMAP_DEC(big5, **outbuf, c, IN2); + TRYMAP_DEC(cp950ext, writer, c, IN2); + else TRYMAP_DEC(big5, writer, c, IN2); else return 1; - NEXT(2, 1) + NEXT_IN(2); } return 0; |