From ffa156afcc46a0b8688a0094e62bc240b4b279a1 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Tue, 28 Dec 1999 02:59:59 +0000 Subject: Update. * iconvdata/gb2312.h (ucs4_to_gb2312): Fix mapping of 0x0101, 0x2312, and 0x2500..0x254b. * iconvdata/TESTS: Add EUC-CN. * iconvdata/testdata/EUC-CN: New file. --- iconvdata/gbgbk.c | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) (limited to 'iconvdata/gbgbk.c') diff --git a/iconvdata/gbgbk.c b/iconvdata/gbgbk.c index 95aaba2..6a71693 100644 --- a/iconvdata/gbgbk.c +++ b/iconvdata/gbgbk.c @@ -34,7 +34,7 @@ #define MAX_NEEDED_TO 2 -/* First define the conversion function from ISO 8859-1 to UCS4. */ +/* First define the conversion function from GBK to GB2312. */ #define MIN_NEEDED_INPUT MIN_NEEDED_FROM #define MAX_NEEDED_INPUT MAX_NEEDED_FROM #define MIN_NEEDED_OUTPUT MIN_NEEDED_TO @@ -67,7 +67,7 @@ is not available we will not flag this as an error but instead \ map the two positions. But this means that the mapping \ \ - UCS4 -> GB2312 -> GBK ->UCS4 \ + UCS4 -> GB2312 -> GBK -> UCS4 \ \ might not produce identical text. */ \ if (NEED_LENGTH_TEST && inptr + 1 >= inend) \ @@ -78,11 +78,17 @@ break; \ } \ \ + if (NEED_LENGTH_TEST && outend - outptr < 2) \ + { \ + /* We ran out of space. */ \ + result = __GCONV_FULL_OUTPUT; \ + break; \ + } \ + \ ch = (ch << 8) | inptr[1]; \ \ /* Now determine whether the character is valid. */ \ - if (ch >= 0xa1a1 && ch <= 0x777e \ - && inptr[1] >= 0xa1 && inptr[1] != 0xff) \ + if (ch >= 0xa1a1 && ch <= 0xf7fe && inptr[1] >= 0xa1) \ { \ /* So far so good. Now test the exceptions. */ \ if ((ch >= 0xa2a1 && ch <= 0xa2aa) \ @@ -123,6 +129,21 @@ \ if (ch > 0x7f) \ { \ + if (NEED_LENGTH_TEST && inptr + 1 >= inend) \ + { \ + /* The second character is not available. Store \ + the intermediate result. */ \ + result = __GCONV_INCOMPLETE_INPUT; \ + break; \ + } \ + \ + if (NEED_LENGTH_TEST && outend - outptr < 2) \ + { \ + /* We ran out of space. */ \ + result = __GCONV_FULL_OUTPUT; \ + break; \ + } \ + \ *outptr++ = ch; \ ch = *inptr++; \ } \ -- cgit v1.1