summaryrefslogtreecommitdiff
path: root/iconvdata/gbgbk.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1999-12-28 02:59:59 +0000
committerUlrich Drepper <drepper@redhat.com>1999-12-28 02:59:59 +0000
commitffa156afcc46a0b8688a0094e62bc240b4b279a1 (patch)
tree7e4796907a02fde9a61a48c4cbafc48229eedba9 /iconvdata/gbgbk.c
parentf3d703cd527d3566808da08ce30b22ec288a78a9 (diff)
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.
Diffstat (limited to 'iconvdata/gbgbk.c')
-rw-r--r--iconvdata/gbgbk.c29
1 files changed, 25 insertions, 4 deletions
diff --git a/iconvdata/gbgbk.c b/iconvdata/gbgbk.c
index 95aaba24a0..6a716937f0 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++; \
} \