aboutsummaryrefslogtreecommitdiff
path: root/iconvdata/iso-2022-jp.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1999-09-06 07:55:04 +0000
committerUlrich Drepper <drepper@redhat.com>1999-09-06 07:55:04 +0000
commit07c7a0552ab5031edb6af78197b5584a61d055eb (patch)
tree409216c8df390b7665486477e670782a19efe08b /iconvdata/iso-2022-jp.c
parentbd952512eac147864ad25e8bcca5c5094b0d958a (diff)
downloadglibc-07c7a0552ab5031edb6af78197b5584a61d055eb.zip
glibc-07c7a0552ab5031edb6af78197b5584a61d055eb.tar.gz
glibc-07c7a0552ab5031edb6af78197b5584a61d055eb.tar.bz2
Update.
1999-09-06 Ulrich Drepper <drepper@cygnus.com> * iconvdata/iso-2022-jp.c: When translating to ISO-2022-JP* write escape sequences out even if the character itself does not fit into the buffer. * iconvdata/jis0201.h (ucs4_to_jisx0201): Correct mapping for U005C.
Diffstat (limited to 'iconvdata/iso-2022-jp.c')
-rw-r--r--iconvdata/iso-2022-jp.c79
1 files changed, 70 insertions, 9 deletions
diff --git a/iconvdata/iso-2022-jp.c b/iconvdata/iso-2022-jp.c
index 31b1cbc..669b65a 100644
--- a/iconvdata/iso-2022-jp.c
+++ b/iconvdata/iso-2022-jp.c
@@ -470,6 +470,11 @@ gconv_end (struct __gconv_step *data)
if (var == iso2022jp2 && ch == 0x0a) \
set2 = UNSPECIFIED_set; \
} \
+ /* ISO-2022-JP recommends to encode the newline character always in \
+ ASCII since this allows a context-free interpretation of the \
+ characters at the beginning of the next line. Otherwise it would \
+ have to be known whether the last line ended using ASCII or \
+ JIS X 0201. */ \
else if (set == JISX0201_Roman_set) \
{ \
unsigned char buf[2]; \
@@ -576,7 +581,7 @@ gconv_end (struct __gconv_step *data)
{ \
/* We must encode using ASCII. First write out the \
escape sequence. */ \
- if (NEED_LENGTH_TEST && outptr + 4 > outend) \
+ if (NEED_LENGTH_TEST && outptr + 3 > outend) \
{ \
result = __GCONV_FULL_OUTPUT; \
break; \
@@ -586,6 +591,12 @@ gconv_end (struct __gconv_step *data)
*outptr++ = '('; \
*outptr++ = 'B'; \
set = ASCII_set; \
+ \
+ if (NEED_LENGTH_TEST && outptr + 1 > outend) \
+ { \
+ result = __GCONV_FULL_OUTPUT; \
+ break; \
+ } \
*outptr++ = ch; \
\
/* At the beginning of a line, G2 designation is cleared. */ \
@@ -605,7 +616,7 @@ gconv_end (struct __gconv_step *data)
if (written != __UNKNOWN_10646_CHAR && buf[0] < 0x80) \
{ \
/* We use JIS X 0201. */ \
- if (NEED_LENGTH_TEST && outptr + 4 > outend) \
+ if (NEED_LENGTH_TEST && outptr + 3 > outend) \
{ \
result = __GCONV_FULL_OUTPUT; \
break; \
@@ -615,6 +626,12 @@ gconv_end (struct __gconv_step *data)
*outptr++ = '('; \
*outptr++ = 'J'; \
set = JISX0201_Roman_set; \
+ \
+ if (NEED_LENGTH_TEST && outptr + 1 > outend) \
+ { \
+ result = __GCONV_FULL_OUTPUT; \
+ break; \
+ } \
*outptr++ = buf[0]; \
} \
else \
@@ -623,7 +640,7 @@ gconv_end (struct __gconv_step *data)
if (written != __UNKNOWN_10646_CHAR) \
{ \
/* We use JIS X 0208. */ \
- if (NEED_LENGTH_TEST && outptr + 5 > outend) \
+ if (NEED_LENGTH_TEST && outptr + 3 > outend) \
{ \
result = __GCONV_FULL_OUTPUT; \
break; \
@@ -633,6 +650,12 @@ gconv_end (struct __gconv_step *data)
*outptr++ = '$'; \
*outptr++ = 'B'; \
set = JISX0208_1983_set; \
+ \
+ if (NEED_LENGTH_TEST && outptr + 2 > outend) \
+ { \
+ result = __GCONV_FULL_OUTPUT; \
+ break; \
+ } \
*outptr++ = buf[0]; \
*outptr++ = buf[1]; \
} \
@@ -648,7 +671,7 @@ gconv_end (struct __gconv_step *data)
if (written != __UNKNOWN_10646_CHAR) \
{ \
/* We use JIS X 0212. */ \
- if (NEED_LENGTH_TEST && outptr + 6 > outend) \
+ if (NEED_LENGTH_TEST && outptr + 4 > outend) \
{ \
result = __GCONV_FULL_OUTPUT; \
break; \
@@ -658,6 +681,12 @@ gconv_end (struct __gconv_step *data)
*outptr++ = '('; \
*outptr++ = 'D'; \
set = JISX0212_set; \
+ \
+ if (NEED_LENGTH_TEST && outptr + 2 > outend) \
+ { \
+ result = __GCONV_FULL_OUTPUT; \
+ break; \
+ } \
*outptr++ = buf[0]; \
*outptr++ = buf[1]; \
} \
@@ -668,7 +697,7 @@ gconv_end (struct __gconv_step *data)
&& buf[0] >= 0x80) \
{ \
/* We use JIS X 0201. */ \
- if (NEED_LENGTH_TEST && outptr + 4 > outend) \
+ if (NEED_LENGTH_TEST && outptr + 3 > outend) \
{ \
result = __GCONV_FULL_OUTPUT; \
break; \
@@ -678,12 +707,18 @@ gconv_end (struct __gconv_step *data)
*outptr++ = '('; \
*outptr++ = 'I'; \
set = JISX0201_Kana_set; \
+ \
+ if (NEED_LENGTH_TEST && outptr + 1 > outend) \
+ { \
+ result = __GCONV_FULL_OUTPUT; \
+ break; \
+ } \
*outptr++ = buf[0] - 0x80; \
} \
else if (ch != 0xa5 && ch >= 0x80 && ch <= 0xff) \
{ \
/* ISO 8859-1 upper half. */ \
- if (NEED_LENGTH_TEST && outptr + 6 > outend) \
+ if (NEED_LENGTH_TEST && outptr + 3 > outend) \
{ \
result = __GCONV_FULL_OUTPUT; \
break; \
@@ -693,6 +728,12 @@ gconv_end (struct __gconv_step *data)
*outptr++ = '.'; \
*outptr++ = 'A'; \
set2 = ISO88591_set; \
+ \
+ if (NEED_LENGTH_TEST && outptr + 3 > outend) \
+ { \
+ result = __GCONV_FULL_OUTPUT; \
+ break; \
+ } \
*outptr++ = ESC; \
*outptr++ = 'N'; \
*outptr++ = ch; \
@@ -703,7 +744,7 @@ gconv_end (struct __gconv_step *data)
if (written != __UNKNOWN_10646_CHAR) \
{ \
/* We use GB 2312. */ \
- if (NEED_LENGTH_TEST && outptr + 5 > outend) \
+ if (NEED_LENGTH_TEST && outptr + 3 > outend) \
{ \
result = __GCONV_FULL_OUTPUT; \
break; \
@@ -713,6 +754,12 @@ gconv_end (struct __gconv_step *data)
*outptr++ = '$'; \
*outptr++ = 'A'; \
set = GB2312_set; \
+ \
+ if (NEED_LENGTH_TEST && outptr + 2 > outend) \
+ { \
+ result = __GCONV_FULL_OUTPUT; \
+ break; \
+ } \
*outptr++ = buf[0]; \
*outptr++ = buf[1]; \
} \
@@ -723,7 +770,7 @@ gconv_end (struct __gconv_step *data)
{ \
/* We use KSC 5601. */ \
if (NEED_LENGTH_TEST \
- && outptr + 6 > outend) \
+ && outptr + 4 > outend) \
{ \
result = __GCONV_FULL_OUTPUT; \
break; \
@@ -733,6 +780,13 @@ gconv_end (struct __gconv_step *data)
*outptr++ = '('; \
*outptr++ = 'C'; \
set = KSC5601_set; \
+ \
+ if (NEED_LENGTH_TEST \
+ && outptr + 2 > outend) \
+ { \
+ result = __GCONV_FULL_OUTPUT; \
+ break; \
+ } \
*outptr++ = buf[0]; \
*outptr++ = buf[1]; \
} \
@@ -753,7 +807,7 @@ gconv_end (struct __gconv_step *data)
{ \
/* We use ISO 8859-7 greek. */ \
if (NEED_LENGTH_TEST \
- && outptr + 6 > outend) \
+ && outptr + 3 > outend) \
{ \
result = __GCONV_FULL_OUTPUT; \
break; \
@@ -762,6 +816,13 @@ gconv_end (struct __gconv_step *data)
*outptr++ = '.'; \
*outptr++ = 'F'; \
set2 = ISO88597_set; \
+ \
+ if (NEED_LENGTH_TEST \
+ && outptr + 3 > outend) \
+ { \
+ result = __GCONV_FULL_OUTPUT; \
+ break; \
+ } \
*outptr++ = ESC; \
*outptr++ = 'N'; \
*outptr++ = gch; \