[KoCo-CVS] [Commit] cjkcodecs/src _big5.c _cp932.c _cp949.c _cp950.c _euc_jisx0213.c _euc_jp.c _euc_
Brought to you by:
perky
From: Hye-Shik C. <pe...@us...> - 2003-07-09 21:35:20
|
perky 03/07/09 14:35:19 Modified: src _big5.c _cp932.c _cp949.c _cp950.c _euc_jisx0213.c _euc_jp.c _euc_kr.c _gb18030.c _gb2312.c _gbk.c _iso_2022_jp.c _johab.c _shift_jis.c _shift_jisx0213.c codeccommon.h Log: Utilize WRITE* and OUT* macro. Revision Changes Path 1.7 +4 -4 cjkcodecs/src/_big5.c Index: _big5.c =================================================================== RCS file: /cvsroot/koco/cjkcodecs/src/_big5.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- _big5.c 9 Jun 2003 10:25:36 -0000 1.6 +++ _big5.c 9 Jul 2003 21:35:18 -0000 1.7 @@ -26,7 +26,7 @@ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - * $Id: _big5.c,v 1.6 2003/06/09 10:25:36 perky Exp $ + * $Id: _big5.c,v 1.7 2003/07/09 21:35:18 perky Exp $ */ #include "codeccommon.h" @@ -64,18 +64,18 @@ DECODER(big5) { while (inleft > 0) { - unsigned char c = **inbuf; + unsigned char c = IN1; RESERVE_OUTBUF(1) if (c < 0x80) { - **outbuf = c; + OUT1(c) NEXT(1, 1) continue; } RESERVE_INBUF(2) - TRYMAP_DEC(big5, **outbuf, c, (*inbuf)[1]) { + TRYMAP_DEC(big5, **outbuf, c, IN2) { NEXT(2, 1) } else return 2; } 1.5 +20 -22 cjkcodecs/src/_cp932.c Index: _cp932.c =================================================================== RCS file: /cvsroot/koco/cjkcodecs/src/_cp932.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- _cp932.c 20 Jun 2003 09:04:52 -0000 1.4 +++ _cp932.c 9 Jul 2003 21:35:19 -0000 1.5 @@ -26,7 +26,7 @@ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - * $Id: _cp932.c,v 1.4 2003/06/20 09:04:52 perky Exp $ + * $Id: _cp932.c,v 1.5 2003/07/09 21:35:19 perky Exp $ */ #include "codeccommon.h" @@ -39,27 +39,25 @@ ENCODER(cp932) { while (inleft > 0) { - Py_UNICODE c = **inbuf; + Py_UNICODE c = IN1; DBCHAR code; unsigned char c1, c2; if (c <= 0x80) { - RESERVE_OUTBUF(1) - **outbuf = (unsigned char)c; + WRITE1(c) NEXT(1, 1) continue; } else if (c >= 0xff61 && c <= 0xff9f) { - RESERVE_OUTBUF(1) - **outbuf = (unsigned char)(c - 0xfec0); + WRITE1(c - 0xfec0) NEXT(1, 1) continue; } else if (c >= 0xf8f0 && c <= 0xf8f3) { /* Windows compatability */ RESERVE_OUTBUF(1) if (c == 0xf8f0) - **outbuf = 0xa0; + OUT1(0xa0) else - **outbuf = (unsigned char)(c - 0xfef1 + 0xfd); + OUT1(c - 0xfef1 + 0xfd) NEXT(1, 1) continue; } @@ -68,8 +66,8 @@ RESERVE_OUTBUF(2) TRYMAP_ENC(cp932ext, code, c) { - (*outbuf)[0] = code >> 8; - (*outbuf)[1] = code & 0xff; + OUT1(code >> 8) + OUT2(code & 0xff) } else TRYMAP_ENC(jisxcommon, code, c) { if (code & 0x8000) /* MSB set: JIS X 0212 */ return 1; @@ -79,14 +77,14 @@ c2 = code & 0xff; c2 = (((c1 - 0x21) & 1) ? 0x5e : 0) + (c2 - 0x21); c1 = (c1 - 0x21) >> 1; - (*outbuf)[0] = c1 < 0x1f ? c1 + 0x81 : c1 + 0xc1; - (*outbuf)[1] = c2 < 0x3f ? c2 + 0x40 : c2 + 0x41; + OUT1(c1 < 0x1f ? c1 + 0x81 : c1 + 0xc1) + OUT2(c2 < 0x3f ? c2 + 0x40 : c2 + 0x41) } else if (c >= 0xe000 && c < 0xe758) { /* User-defined area */ c1 = (Py_UNICODE)(c - 0xe000) / 188; c2 = (Py_UNICODE)(c - 0xe000) % 188; - (*outbuf)[0] = c1 + 0xf0; - (*outbuf)[1] = (c2 < 0x3f ? c2 + 0x40 : c2 + 0x41); + OUT1(c1 + 0xf0) + OUT2(c2 < 0x3f ? c2 + 0x40 : c2 + 0x41) } else return 1; @@ -99,29 +97,29 @@ DECODER(cp932) { while (inleft > 0) { - unsigned char c = **inbuf, c2; + unsigned char c = IN1, c2; RESERVE_OUTBUF(1) if (c <= 0x80) { - **outbuf = c; + OUT1(c) NEXT(1, 1) continue; } else if (c >= 0xa0 && c <= 0xdf) { if (c == 0xa0) - **outbuf = 0xf8f0; /* half-width katakana */ + OUT1(0xf8f0) /* half-width katakana */ else - **outbuf = 0xfec0 + c; + OUT1(0xfec0 + c) NEXT(1, 1) continue; } else if (c >= 0xfd/* && c <= 0xff*/) { /* Windows compatibility */ - **outbuf = 0xf8f1 - 0xfd + c; + OUT1(0xf8f1 - 0xfd + c) NEXT(1, 1) continue; } RESERVE_INBUF(2) - c2 = (*inbuf)[1]; + c2 = IN2; TRYMAP_DEC(cp932ext, **outbuf, c, c2); else if ((c >= 0x81 && c <= 0x9f) || (c >= 0xe0 && c <= 0xea)) { @@ -137,8 +135,8 @@ else return 2; } else if (c >= 0xf0 && c <= 0xf9) { if ((c2 >= 0x40 && c2 <= 0x7e) || (c2 >= 0x80 && c2 <= 0xfc)) - **outbuf = 0xe000 + 188 * (c - 0xf0) + - (c2 < 0x80 ? c2 - 0x40 : c2 - 0x41); + OUT1(0xe000 + 188 * (c - 0xf0) + + (c2 < 0x80 ? c2 - 0x40 : c2 - 0x41)) else return 2; } else 1.11 +10 -11 cjkcodecs/src/_cp949.c Index: _cp949.c =================================================================== RCS file: /cvsroot/koco/cjkcodecs/src/_cp949.c,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- _cp949.c 9 Jun 2003 10:25:36 -0000 1.10 +++ _cp949.c 9 Jul 2003 21:35:19 -0000 1.11 @@ -26,7 +26,7 @@ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - * $Id: _cp949.c,v 1.10 2003/06/09 10:25:36 perky Exp $ + * $Id: _cp949.c,v 1.11 2003/07/09 21:35:19 perky Exp $ */ #include "codeccommon.h" @@ -38,12 +38,11 @@ ENCODER(cp949) { while (inleft > 0) { - Py_UNICODE c = **inbuf; + Py_UNICODE c = IN1; DBCHAR code; if (c < 0x80) { - RESERVE_OUTBUF(1) - **outbuf = c; + WRITE1(c) NEXT(1, 1) continue; } @@ -53,11 +52,11 @@ TRYMAP_ENC(cp949, code, c); else return 1; - (*outbuf)[0] = (code >> 8) | 0x80; + OUT1((code >> 8) | 0x80) if (code & 0x8000) - (*outbuf)[1] = (code & 0xFF); /* MSB set: CP949 */ + OUT2(code & 0xFF) /* MSB set: CP949 */ else - (*outbuf)[1] = (code & 0xFF) | 0x80; /* MSB unset: ks x 1001 */ + OUT2((code & 0xFF) | 0x80) /* MSB unset: ks x 1001 */ NEXT(1, 2) } @@ -67,19 +66,19 @@ DECODER(cp949) { while (inleft > 0) { - unsigned char c = **inbuf; + unsigned char c = IN1; RESERVE_OUTBUF(1) if (c < 0x80) { - **outbuf = c; + OUT1(c) NEXT(1, 1) continue; } RESERVE_INBUF(2) - TRYMAP_DEC(ksx1001, **outbuf, c ^ 0x80, (*inbuf)[1] ^ 0x80); - else TRYMAP_DEC(cp949ext, **outbuf, c, (*inbuf)[1]); + TRYMAP_DEC(ksx1001, **outbuf, c ^ 0x80, IN2 ^ 0x80); + else TRYMAP_DEC(cp949ext, **outbuf, c, IN2); else return 2; NEXT(2, 1) 1.7 +9 -10 cjkcodecs/src/_cp950.c Index: _cp950.c =================================================================== RCS file: /cvsroot/koco/cjkcodecs/src/_cp950.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- _cp950.c 9 Jun 2003 10:25:36 -0000 1.6 +++ _cp950.c 9 Jul 2003 21:35:19 -0000 1.7 @@ -26,7 +26,7 @@ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - * $Id: _cp950.c,v 1.6 2003/06/09 10:25:36 perky Exp $ + * $Id: _cp950.c,v 1.7 2003/07/09 21:35:19 perky Exp $ */ #include "codeccommon.h" @@ -39,12 +39,11 @@ ENCODER(cp950) { while (inleft > 0) { - Py_UNICODE c = **inbuf; + Py_UNICODE c = IN1; DBCHAR code; if (c < 0x80) { - RESERVE_OUTBUF(1) - **outbuf = c; + WRITE1(c) NEXT(1, 1) continue; } @@ -55,8 +54,8 @@ else TRYMAP_ENC(big5, code, c); else return 1; - (*outbuf)[0] = code >> 8; - (*outbuf)[1] = code & 0xFF; + OUT1(code >> 8) + OUT2(code & 0xFF) NEXT(1, 2) } @@ -66,20 +65,20 @@ DECODER(cp950) { while (inleft > 0) { - unsigned char c = **inbuf; + unsigned char c = IN1; RESERVE_OUTBUF(1) if (c < 0x80) { - **outbuf = c; + OUT1(c) NEXT(1, 1) continue; } RESERVE_INBUF(2) - TRYMAP_DEC(cp950ext, **outbuf, c, (*inbuf)[1]); - else TRYMAP_DEC(big5, **outbuf, c, (*inbuf)[1]); + TRYMAP_DEC(cp950ext, **outbuf, c, IN2); + else TRYMAP_DEC(big5, **outbuf, c, IN2); else return 2; NEXT(2, 1) 1.6 +12 -20 cjkcodecs/src/_euc_jisx0213.c Index: _euc_jisx0213.c =================================================================== RCS file: /cvsroot/koco/cjkcodecs/src/_euc_jisx0213.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- _euc_jisx0213.c 9 Jul 2003 20:46:56 -0000 1.5 +++ _euc_jisx0213.c 9 Jul 2003 21:35:19 -0000 1.6 @@ -26,7 +26,7 @@ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - * $Id: _euc_jisx0213.c,v 1.5 2003/07/09 20:46:56 perky Exp $ + * $Id: _euc_jisx0213.c,v 1.6 2003/07/09 21:35:19 perky Exp $ */ #define USING_BINARY_PAIR_SEARCH @@ -53,8 +53,7 @@ int insize; if (c < 0x80) { - RESERVE_OUTBUF(1) - **outbuf = c; + WRITE1(c) NEXT(1, 1) continue; } @@ -89,9 +88,7 @@ } else TRYMAP_ENC(jisxcommon, code, c); else if (c >= 0xff61 && c <= 0xff9f) { /* JIS X 0201 half-width katakana */ - RESERVE_OUTBUF(2) - (*outbuf)[0] = 0x8e; - (*outbuf)[1] = (unsigned char)(c - 0xfec0); + WRITE2(0x8e, c - 0xfec0) NEXT(1, 2) continue; } else if (c == 0xff3c) @@ -107,16 +104,11 @@ if (code & 0x8000) { /* Codeset 2 */ - RESERVE_OUTBUF(3) - (*outbuf)[0] = 0x8f; - (*outbuf)[1] = code >> 8; - (*outbuf)[2] = (code & 0xFF) | 0x80; + WRITE3(0x8f, code >> 8, (code & 0xFF) | 0x80) NEXT(insize, 3) } else { /* Codeset 1 */ - RESERVE_OUTBUF(2) - (*outbuf)[0] = (code >> 8) | 0x80; - (*outbuf)[1] = (code & 0xFF) | 0x80; + WRITE2((code >> 8) | 0x80, (code & 0xFF) | 0x80) NEXT(insize, 2) } } @@ -127,13 +119,13 @@ DECODER(euc_jisx0213) { while (inleft > 0) { - unsigned char c = **inbuf; + unsigned char c = IN1; ucs4_t code; RESERVE_OUTBUF(1) if (c < 0x80) { - **outbuf = c; + OUT1(c) NEXT(1, 1) continue; } @@ -143,9 +135,9 @@ unsigned char c2; RESERVE_INBUF(2) - c2 = (*inbuf)[1]; + c2 = IN2; if (c2 >= 0xa1 && c2 <= 0xdf) { - **outbuf = 0xfec0 + c2; + OUT1(0xfec0 + c2) NEXT(2, 1) } else return 2; @@ -153,8 +145,8 @@ unsigned char c2, c3; RESERVE_INBUF(3) - c2 = (*inbuf)[1] ^ 0x80; - c3 = (*inbuf)[2] ^ 0x80; + c2 = IN2 ^ 0x80; + c3 = IN3 ^ 0x80; /* JIS X 0213 Plane 2 or JIS X 0212 (see NOTES.euc-jisx0213) */ TRYMAP_DEC(jisx0213_2_bmp, **outbuf, c2, c3) ; @@ -170,7 +162,7 @@ RESERVE_INBUF(2) c ^= 0x80; - c2 = (*inbuf)[1] ^ 0x80; + c2 = IN2 ^ 0x80; /* JIS X 0213 Plane 1 */ if (c == 0xa1 && c2 == 0xc0) **outbuf = 0xff3c; 1.5 +19 -30 cjkcodecs/src/_euc_jp.c Index: _euc_jp.c =================================================================== RCS file: /cvsroot/koco/cjkcodecs/src/_euc_jp.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- _euc_jp.c 6 Jul 2003 10:30:26 -0000 1.4 +++ _euc_jp.c 9 Jul 2003 21:35:19 -0000 1.5 @@ -26,7 +26,7 @@ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - * $Id: _euc_jp.c,v 1.4 2003/07/06 10:30:26 perky Exp $ + * $Id: _euc_jp.c,v 1.5 2003/07/09 21:35:19 perky Exp $ */ #include "codeccommon.h" @@ -38,12 +38,11 @@ ENCODER(euc_jp) { while (inleft > 0) { - Py_UNICODE c = **inbuf; + Py_UNICODE c = IN1; DBCHAR code; if (c < 0x80) { - RESERVE_OUTBUF(1) - **outbuf = c; + WRITE1(c) NEXT(1, 1) continue; } @@ -53,24 +52,19 @@ TRYMAP_ENC(jisxcommon, code, c); else if (c >= 0xff61 && c <= 0xff9f) { /* JIS X 0201 half-width katakana */ - RESERVE_OUTBUF(2) - (*outbuf)[0] = 0x8e; - (*outbuf)[1] = (unsigned char)(c - 0xfec0); + WRITE2(0x8e, c - 0xfec0) NEXT(1, 2) continue; } else if (c >= 0xe000 && c < 0xe3ac) { /* User-defined area 1 */ - RESERVE_OUTBUF(2) - (*outbuf)[0] = (Py_UNICODE)(c - 0xe000) / 94 + 0xf5; - (*outbuf)[1] = (Py_UNICODE)(c - 0xe000) % 94 + 0xa1; + WRITE2((Py_UNICODE)(c - 0xe000) / 94 + 0xf5, + (Py_UNICODE)(c - 0xe000) % 94 + 0xa1) NEXT(1, 2) continue; } else if (c >= 0xe3ac && c < 0xe758) { /* User-defined area 2 */ - RESERVE_OUTBUF(3) - (*outbuf)[0] = 0x8f; - (*outbuf)[1] = (Py_UNICODE)(c - 0xe3ac) / 94 + 0xf5; - (*outbuf)[2] = (Py_UNICODE)(c - 0xe3ac) % 94 + 0xa1; + WRITE3(0x8f, (Py_UNICODE)(c - 0xe3ac) / 94 + 0xf5, + (Py_UNICODE)(c - 0xe3ac) % 94 + 0xa1) NEXT(1, 3) continue; } else if (c == 0xff3c) /* F/W REVERSE SOLIDUS (see NOTES.euc-jp) */ @@ -80,16 +74,11 @@ if (code & 0x8000) { /* JIS X 0212 */ - RESERVE_OUTBUF(3) - (*outbuf)[0] = 0x8f; - (*outbuf)[1] = code >> 8; - (*outbuf)[2] = (code & 0xFF) | 0x80; + WRITE3(0x8f, code >> 8, (code & 0xFF) | 0x80) NEXT(1, 3) } else { /* JIS X 0208 */ - RESERVE_OUTBUF(2) - (*outbuf)[0] = (code >> 8) | 0x80; - (*outbuf)[1] = (code & 0xFF) | 0x80; + WRITE2((code >> 8) | 0x80, (code & 0xFF) | 0x80) NEXT(1, 2) } } @@ -100,12 +89,12 @@ DECODER(euc_jp) { while (inleft > 0) { - unsigned char c = **inbuf; + unsigned char c = IN1; RESERVE_OUTBUF(1) if (c < 0x80) { - **outbuf = c; + OUT1(c) NEXT(1, 1) continue; } @@ -115,9 +104,9 @@ unsigned char c2; RESERVE_INBUF(2) - c2 = (*inbuf)[1]; + c2 = IN2; if (c2 >= 0xa1 && c2 <= 0xdf) { - **outbuf = 0xfec0 + c2; + OUT1(0xfec0 + c2) NEXT(2, 1) } else return 2; @@ -125,8 +114,8 @@ unsigned char c2, c3; RESERVE_INBUF(3) - c2 = (*inbuf)[1]; - c3 = (*inbuf)[2]; + c2 = IN2; + c3 = IN3; if (c2 < 0xf5) { /* JIS X 0212 */ TRYMAP_DEC(jisx0212, **outbuf, c2 ^ 0x80, c3 ^ 0x80); @@ -135,14 +124,14 @@ /* User-defined area 2 */ if (c2 == 0xff || c3 < 0xa1 || c3 == 0xff) return 3; - **outbuf = 0xe3ac + 94 * (c2 - 0xf5) + (c3 - 0xa1); + OUT1(0xe3ac + 94 * (c2 - 0xf5) + (c3 - 0xa1)) } NEXT(3, 1) } else { unsigned char c2; RESERVE_INBUF(2) - c2 = (*inbuf)[1]; + c2 = IN2; if (c < 0xf5) { /* JIS X 0208 */ if (c == 0xa1 && c2 == 0xc0) **outbuf = 0xff3c; @@ -152,7 +141,7 @@ /* User-defined area 1 */ if (c2 < 0xa1 || c2 == 0xff) return 2; - **outbuf = 0xe000 + 94 * (c - 0xf5) + (c2 - 0xa1); + OUT1(0xe000 + 94 * (c - 0xf5) + (c2 - 0xa1)) } NEXT(2, 1) } 1.14 +8 -9 cjkcodecs/src/_euc_kr.c Index: _euc_kr.c =================================================================== RCS file: /cvsroot/koco/cjkcodecs/src/_euc_kr.c,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- _euc_kr.c 9 Jun 2003 10:25:36 -0000 1.13 +++ _euc_kr.c 9 Jul 2003 21:35:19 -0000 1.14 @@ -26,7 +26,7 @@ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - * $Id: _euc_kr.c,v 1.13 2003/06/09 10:25:36 perky Exp $ + * $Id: _euc_kr.c,v 1.14 2003/07/09 21:35:19 perky Exp $ */ #include "codeccommon.h" @@ -37,12 +37,11 @@ ENCODER(euc_kr) { while (inleft > 0) { - Py_UNICODE c = **inbuf; + Py_UNICODE c = IN1; DBCHAR code; if (c < 0x80) { - RESERVE_OUTBUF(1) - **outbuf = c; + WRITE1(c) NEXT(1, 1) continue; } @@ -55,8 +54,8 @@ if (code & 0x8000) /* MSB set: CP949 */ return 1; - (*outbuf)[0] = (code >> 8) | 0x80; - (*outbuf)[1] = (code & 0xFF) | 0x80; + OUT1((code >> 8) | 0x80) + OUT2((code & 0xFF) | 0x80) NEXT(1, 2) } @@ -66,19 +65,19 @@ DECODER(euc_kr) { while (inleft > 0) { - unsigned char c = **inbuf; + unsigned char c = IN1; RESERVE_OUTBUF(1) if (c < 0x80) { - **outbuf = c; + OUT1(c) NEXT(1, 1) continue; } RESERVE_INBUF(2) - TRYMAP_DEC(ksx1001, **outbuf, c ^ 0x80, (*inbuf)[1] ^ 0x80) { + TRYMAP_DEC(ksx1001, **outbuf, c ^ 0x80, IN2 ^ 0x80) { NEXT(2, 1) } else return 2; 1.11 +20 -21 cjkcodecs/src/_gb18030.c Index: _gb18030.c =================================================================== RCS file: /cvsroot/koco/cjkcodecs/src/_gb18030.c,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- _gb18030.c 9 Jul 2003 20:46:56 -0000 1.10 +++ _gb18030.c 9 Jul 2003 21:35:19 -0000 1.11 @@ -26,7 +26,7 @@ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - * $Id: _gb18030.c,v 1.10 2003/07/09 20:46:56 perky Exp $ + * $Id: _gb18030.c,v 1.11 2003/07/09 21:35:19 perky Exp $ */ #include "codeccommon.h" @@ -42,12 +42,11 @@ ENCODER(gb18030) { while (inleft > 0) { - ucs4_t c = **inbuf; + ucs4_t c = IN1; DBCHAR code; if (c < 0x80) { - RESERVE_OUTBUF(1) - **outbuf = c; + WRITE1(c) NEXT(1, 1) continue; } @@ -64,13 +63,13 @@ RESERVE_OUTBUF(4) - (*outbuf)[3] = (unsigned char)(tc % 10) + 0x30; + OUT4((unsigned char)(tc % 10) + 0x30) tc /= 10; - (*outbuf)[2] = (unsigned char)(tc % 126) + 0x81; + OUT3((unsigned char)(tc % 126) + 0x81) tc /= 126; - (*outbuf)[1] = (unsigned char)(tc % 10) + 0x30; + OUT2((unsigned char)(tc % 10) + 0x30) tc /= 10; - (*outbuf)[0] = (unsigned char)(tc + 0x90); + OUT1((unsigned char)(tc + 0x90)) #if Py_UNICODE_SIZE == 2 NEXT(2, 4) /* surrogates pair */ @@ -98,13 +97,13 @@ tc = c - utrrange->first + utrrange->base; - (*outbuf)[3] = (unsigned char)(tc % 10) + 0x30; + OUT4((unsigned char)(tc % 10) + 0x30) tc /= 10; - (*outbuf)[2] = (unsigned char)(tc % 126) + 0x81; + OUT3((unsigned char)(tc % 126) + 0x81) tc /= 126; - (*outbuf)[1] = (unsigned char)(tc % 10) + 0x30; + OUT2((unsigned char)(tc % 10) + 0x30) tc /= 10; - (*outbuf)[0] = (unsigned char)tc + 0x81; + OUT1((unsigned char)tc + 0x81) NEXT(1, 4) break; @@ -118,11 +117,11 @@ continue; } - (*outbuf)[0] = (code >> 8) | 0x80; + OUT1((code >> 8) | 0x80) if (code & 0x8000) - (*outbuf)[1] = (code & 0xFF); /* MSB set: GBK or GB18030ext */ + OUT2((code & 0xFF)) /* MSB set: GBK or GB18030ext */ else - (*outbuf)[1] = (code & 0xFF) | 0x80; /* MSB unset: GB2312 */ + OUT2((code & 0xFF) | 0x80) /* MSB unset: GB2312 */ NEXT(1, 2) } @@ -133,27 +132,27 @@ DECODER(gb18030) { while (inleft > 0) { - unsigned char c = **inbuf, c2; + unsigned char c = IN1, c2; RESERVE_OUTBUF(1) if (c < 0x80) { - **outbuf = c; + OUT1(c) NEXT(1, 1) continue; } RESERVE_INBUF(2) - c2 = (*inbuf)[1]; + c2 = IN2; if (c2 >= 0x30 && c2 <= 0x39) { /* 4 bytes seq */ const struct _gb18030_to_unibmp_ranges *utr; unsigned char c3, c4; ucs4_t lseq; RESERVE_INBUF(4) - c3 = (*inbuf)[2]; - c4 = (*inbuf)[3]; + c3 = IN3; + c4 = IN4; if (c < 0x81 || c3 < 0x81 || c4 < 0x30 || c4 > 0x39) return 4; c -= 0x81; c2 -= 0x30; @@ -166,7 +165,7 @@ for (utr = gb18030_to_unibmp_ranges; lseq >= (utr + 1)->base; utr++) ; - **outbuf = utr->first - utr->base + lseq; + OUT1(utr->first - utr->base + lseq) NEXT(4, 1) continue; } 1.9 +7 -8 cjkcodecs/src/_gb2312.c Index: _gb2312.c =================================================================== RCS file: /cvsroot/koco/cjkcodecs/src/_gb2312.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- _gb2312.c 9 Jun 2003 10:25:36 -0000 1.8 +++ _gb2312.c 9 Jul 2003 21:35:19 -0000 1.9 @@ -26,7 +26,7 @@ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - * $Id: _gb2312.c,v 1.8 2003/06/09 10:25:36 perky Exp $ + * $Id: _gb2312.c,v 1.9 2003/07/09 21:35:19 perky Exp $ */ #include "codeccommon.h" @@ -37,12 +37,11 @@ ENCODER(gb2312) { while (inleft > 0) { - Py_UNICODE c = **inbuf; + Py_UNICODE c = IN1; DBCHAR code; if (c < 0x80) { - RESERVE_OUTBUF(1) - **outbuf = c; + WRITE1(c) NEXT(1, 1) continue; } @@ -55,8 +54,8 @@ if (code & 0x8000) /* MSB set: GBK */ return 1; - (*outbuf)[0] = (code >> 8) | 0x80; - (*outbuf)[1] = (code & 0xFF) | 0x80; + OUT1((code >> 8) | 0x80) + OUT2((code & 0xFF) | 0x80) NEXT(1, 2) } @@ -71,13 +70,13 @@ RESERVE_OUTBUF(1) if (c < 0x80) { - **outbuf = c; + OUT1(c) NEXT(1, 1) continue; } RESERVE_INBUF(2) - TRYMAP_DEC(gb2312, **outbuf, c ^ 0x80, (*inbuf)[1] ^ 0x80) { + TRYMAP_DEC(gb2312, **outbuf, c ^ 0x80, IN2 ^ 0x80) { NEXT(2, 1) } else return 2; } 1.8 +11 -12 cjkcodecs/src/_gbk.c Index: _gbk.c =================================================================== RCS file: /cvsroot/koco/cjkcodecs/src/_gbk.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- _gbk.c 9 Jun 2003 10:25:36 -0000 1.7 +++ _gbk.c 9 Jul 2003 21:35:19 -0000 1.8 @@ -26,7 +26,7 @@ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - * $Id: _gbk.c,v 1.7 2003/06/09 10:25:36 perky Exp $ + * $Id: _gbk.c,v 1.8 2003/07/09 21:35:19 perky Exp $ */ #include "codeccommon.h" @@ -39,12 +39,11 @@ ENCODER(gbk) { while (inleft > 0) { - Py_UNICODE c = **inbuf; + Py_UNICODE c = IN1; DBCHAR code; if (c < 0x80) { - RESERVE_OUTBUF(1) - **outbuf = c; + WRITE1(c) NEXT(1, 1) continue; } @@ -56,11 +55,11 @@ else TRYMAP_ENC(gbcommon, code, c); else return 1; - (*outbuf)[0] = (code >> 8) | 0x80; + OUT1((code >> 8) | 0x80) if (code & 0x8000) - (*outbuf)[1] = (code & 0xFF); /* MSB set: GBK */ + OUT2((code & 0xFF)) /* MSB set: GBK */ else - (*outbuf)[1] = (code & 0xFF) | 0x80; /* MSB unset: GB2312 */ + OUT2((code & 0xFF) | 0x80) /* MSB unset: GB2312 */ NEXT(1, 2) } @@ -70,21 +69,21 @@ DECODER(gbk) { while (inleft > 0) { - unsigned char c = **inbuf; + unsigned char c = IN1; RESERVE_OUTBUF(1) if (c < 0x80) { - **outbuf = c; + OUT1(c) NEXT(1, 1) continue; } RESERVE_INBUF(2) - GBK_PREDECODE(c, (*inbuf)[1], **outbuf) - else TRYMAP_DEC(gb2312, **outbuf, c ^ 0x80, (*inbuf)[1] ^ 0x80); - else TRYMAP_DEC(gbkext, **outbuf, c, (*inbuf)[1]); + GBK_PREDECODE(c, IN2, **outbuf) + else TRYMAP_DEC(gb2312, **outbuf, c ^ 0x80, IN2 ^ 0x80); + else TRYMAP_DEC(gbkext, **outbuf, c, IN2); else return 2; NEXT(2, 1) 1.8 +2 -2 cjkcodecs/src/_iso_2022_jp.c Index: _iso_2022_jp.c =================================================================== RCS file: /cvsroot/koco/cjkcodecs/src/_iso_2022_jp.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- _iso_2022_jp.c 9 Jul 2003 18:47:47 -0000 1.7 +++ _iso_2022_jp.c 9 Jul 2003 21:35:19 -0000 1.8 @@ -26,7 +26,7 @@ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - * $Id: _iso_2022_jp.c,v 1.7 2003/07/09 18:47:47 perky Exp $ + * $Id: _iso_2022_jp.c,v 1.8 2003/07/09 21:35:19 perky Exp $ */ #define ISO2022_DESIGNATIONS \ @@ -65,7 +65,7 @@ ENCODER(iso_2022_jp) { while (inleft > 0) { - Py_UNICODE c = **inbuf; + Py_UNICODE c = IN1; DBCHAR code; if (c < 0x80) { 1.7 +18 -19 cjkcodecs/src/_johab.c Index: _johab.c =================================================================== RCS file: /cvsroot/koco/cjkcodecs/src/_johab.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- _johab.c 9 Jul 2003 20:30:15 -0000 1.6 +++ _johab.c 9 Jul 2003 21:35:19 -0000 1.7 @@ -26,7 +26,7 @@ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - * $Id: _johab.c,v 1.6 2003/07/09 20:30:15 perky Exp $ + * $Id: _johab.c,v 1.7 2003/07/09 21:35:19 perky Exp $ */ #include "codeccommon.h" @@ -64,12 +64,11 @@ ENCODER(johab) { while (inleft > 0) { - Py_UNICODE c = **inbuf; + Py_UNICODE c = IN1; DBCHAR code; if (c < 0x80) { - RESERVE_OUTBUF(1) - **outbuf = c; + WRITE1(c) NEXT(1, 1) continue; } @@ -96,8 +95,8 @@ && (c2 >= 0x21 && c2 <= 0x7e)) { t1 = (c1 < 0x4a ? (c1 - 0x21 + 0x1b2) : (c1 - 0x21 + 0x197)); t2 = ((t1 & 1) ? 0x5e : 0) + (c2 - 0x21); - (*outbuf)[0] = t1 >> 1; - (*outbuf)[1] = (t2 < 0x4e ? t2 + 0x31 : t2 + 0x43); + OUT1(t1 >> 1) + OUT2(t2 < 0x4e ? t2 + 0x31 : t2 + 0x43) NEXT(1, 2) continue; } else @@ -105,8 +104,8 @@ } else return 1; - (*outbuf)[0] = code >> 8; - (*outbuf)[1] = code & 0xFF; + OUT1(code >> 8) + OUT2(code & 0xff) NEXT(1, 2) } @@ -157,18 +156,18 @@ DECODER(johab) { while (inleft > 0) { - unsigned char c = **inbuf, c2; + unsigned char c = IN1, c2; RESERVE_OUTBUF(1) if (c < 0x80) { - **outbuf = c; + OUT1(c) NEXT(1, 1) continue; } RESERVE_INBUF(2) - c2 = (*inbuf)[1]; + c2 = IN2; if (c < 0xd8) { /* johab hangul */ @@ -190,26 +189,26 @@ if (i_cho == FILL) { if (i_jung == FILL) { if (i_jong == FILL) - **outbuf = 0x3000; + OUT1(0x3000) else - **outbuf = 0x3100 | johabjamo_jongseong[c_jong]; + OUT1(0x3100 | johabjamo_jongseong[c_jong]) } else { if (i_jong == FILL) - **outbuf = 0x3100 | johabjamo_jungseong[c_jung]; + OUT1(0x3100 | johabjamo_jungseong[c_jung]) else return 2; } } else { if (i_jung == FILL) { if (i_jong == FILL) - **outbuf = 0x3100 | johabjamo_choseong[c_cho]; + OUT1(0x3100 | johabjamo_choseong[c_cho]) else return 2; } else - **outbuf = 0xac00 + - i_cho * 588 + - i_jung * 28 + - (i_jong == FILL ? 0 : i_jong); + OUT1(0xac00 + + i_cho * 588 + + i_jung * 28 + + (i_jong == FILL ? 0 : i_jong)) } NEXT(2, 1) } else { 1.6 +12 -12 cjkcodecs/src/_shift_jis.c Index: _shift_jis.c =================================================================== RCS file: /cvsroot/koco/cjkcodecs/src/_shift_jis.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- _shift_jis.c 31 May 2003 11:50:19 -0000 1.5 +++ _shift_jis.c 9 Jul 2003 21:35:19 -0000 1.6 @@ -26,7 +26,7 @@ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - * $Id: _shift_jis.c,v 1.5 2003/05/31 11:50:19 perky Exp $ + * $Id: _shift_jis.c,v 1.6 2003/07/09 21:35:19 perky Exp $ */ #include "codeccommon.h" @@ -38,7 +38,7 @@ ENCODER(shift_jis) { while (inleft > 0) { - Py_UNICODE c = **inbuf; + Py_UNICODE c = IN1; DBCHAR code; unsigned char c1, c2; @@ -49,7 +49,7 @@ if (code < 0x80 || (code >= 0xa1 && code <= 0xdf)) { RESERVE_OUTBUF(1) - **outbuf = (unsigned char)code; + OUT1(code) NEXT(1, 1) continue; } @@ -62,8 +62,8 @@ /* user-defined area */ c1 = (Py_UNICODE)(c - 0xe000) / 188; c2 = (Py_UNICODE)(c - 0xe000) % 188; - (*outbuf)[0] = c1 + 0xf0; - (*outbuf)[1] = (c2 < 0x3f ? c2 + 0x40 : c2 + 0x41); + OUT1(c1 + 0xf0) + OUT2(c2 < 0x3f ? c2 + 0x40 : c2 + 0x41) NEXT(1, 2) continue; } else @@ -77,8 +77,8 @@ c2 = code & 0xff; c2 = (((c1 - 0x21) & 1) ? 0x5e : 0) + (c2 - 0x21); c1 = (c1 - 0x21) >> 1; - (*outbuf)[0] = c1 < 0x1f ? c1 + 0x81 : c1 + 0xc1; - (*outbuf)[1] = c2 < 0x3f ? c2 + 0x40 : c2 + 0x41; + OUT1(c1 < 0x1f ? c1 + 0x81 : c1 + 0xc1) + OUT2(c2 < 0x3f ? c2 + 0x40 : c2 + 0x41) NEXT(1, 2) } @@ -88,7 +88,7 @@ DECODER(shift_jis) { while (inleft > 0) { - unsigned char c = **inbuf; + unsigned char c = IN1; RESERVE_OUTBUF(1) JISX0201_DECODE(c, **outbuf) @@ -96,7 +96,7 @@ unsigned char c1, c2; RESERVE_INBUF(2) - c2 = (*inbuf)[1]; + c2 = IN2; if (c2 < 0x40 || (c2 > 0x7e && c2 < 0x80) || c2 > 0xfc) return 2; @@ -114,10 +114,10 @@ unsigned char c2; RESERVE_INBUF(2) - c2 = (*inbuf)[1]; + c2 = IN2; if ((c2 >= 0x40 && c2 <= 0x7e) || (c2 >= 0x80 && c2 <= 0xfc)) { - **outbuf = 0xe000 + 188 * (c - 0xf0) + - (c2 < 0x80 ? c2 - 0x40 : c2 - 0x41); + OUT1(0xe000 + 188 * (c - 0xf0) + + (c2 < 0x80 ? c2 - 0x40 : c2 - 0x41)) NEXT(2, 1) continue; } else 1.4 +2 -2 cjkcodecs/src/_shift_jisx0213.c Index: _shift_jisx0213.c =================================================================== RCS file: /cvsroot/koco/cjkcodecs/src/_shift_jisx0213.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- _shift_jisx0213.c 9 Jul 2003 20:46:57 -0000 1.3 +++ _shift_jisx0213.c 9 Jul 2003 21:35:19 -0000 1.4 @@ -26,7 +26,7 @@ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - * $Id: _shift_jisx0213.c,v 1.3 2003/07/09 20:46:57 perky Exp $ + * $Id: _shift_jisx0213.c,v 1.4 2003/07/09 21:35:19 perky Exp $ */ #define USING_BINARY_PAIR_SEARCH @@ -48,7 +48,7 @@ ENCODER(shift_jisx0213) { while (inleft > 0) { - ucs4_t c = **inbuf; + ucs4_t c = IN1; DBCHAR code = NOCHAR; int c1, c2; size_t insize; 1.23 +5 -5 cjkcodecs/src/codeccommon.h Index: codeccommon.h =================================================================== RCS file: /cvsroot/koco/cjkcodecs/src/codeccommon.h,v retrieving revision 1.22 retrieving revision 1.23 diff -u -r1.22 -r1.23 --- codeccommon.h 9 Jul 2003 20:46:57 -0000 1.22 +++ codeccommon.h 9 Jul 2003 21:35:19 -0000 1.23 @@ -26,7 +26,7 @@ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - * $Id: codeccommon.h,v 1.22 2003/07/09 20:46:57 perky Exp $ + * $Id: codeccommon.h,v 1.23 2003/07/09 21:35:19 perky Exp $ */ #include "Python.h" @@ -93,10 +93,10 @@ #define IN3 ((*inbuf)[2]) #define IN4 ((*inbuf)[3]) -#define OUT1(c) ((*outbuf)[0]) = (unsigned char)(c); -#define OUT2(c) ((*outbuf)[1]) = (unsigned char)(c); -#define OUT3(c) ((*outbuf)[2]) = (unsigned char)(c); -#define OUT4(c) ((*outbuf)[3]) = (unsigned char)(c); +#define OUT1(c) ((*outbuf)[0]) = (c); +#define OUT2(c) ((*outbuf)[1]) = (c); +#define OUT3(c) ((*outbuf)[2]) = (c); +#define OUT4(c) ((*outbuf)[3]) = (c); #define WRITE1(c1) \ RESERVE_OUTBUF(1) \ |