aboutsummaryrefslogtreecommitdiffstats
path: root/src/coding.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/coding.c')
-rw-r--r--src/coding.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/src/coding.c b/src/coding.c
index 6dbf05ce0aa..e2a328fd908 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -3600,7 +3600,7 @@ decode_coding_iso_2022 (coding)
3600 3600
3601 while (1) 3601 while (1)
3602 { 3602 {
3603 int c1, c2; 3603 int c1, c2, c3;
3604 3604
3605 src_base = src; 3605 src_base = src;
3606 consumed_chars_base = consumed_chars; 3606 consumed_chars_base = consumed_chars;
@@ -3984,26 +3984,28 @@ decode_coding_iso_2022 (coding)
3984 } 3984 }
3985 3985
3986 /* Now we know CHARSET and 1st position code C1 of a character. 3986 /* Now we know CHARSET and 1st position code C1 of a character.
3987 Produce a decoded character while getting 2nd position code 3987 Produce a decoded character while getting 2nd and 3rd
3988 C2 if necessary. */ 3988 position codes C2, C3 if necessary. */
3989 c1 &= 0x7F;
3990 if (CHARSET_DIMENSION (charset) > 1) 3989 if (CHARSET_DIMENSION (charset) > 1)
3991 { 3990 {
3992 ONE_MORE_BYTE (c2); 3991 ONE_MORE_BYTE (c2);
3993 if (c2 < 0x20 || (c2 >= 0x80 && c2 < 0xA0)) 3992 if (c2 < 0x20 || (c2 >= 0x80 && c2 < 0xA0)
3993 || ((c1 & 0x80) != (c2 & 0x80)))
3994 /* C2 is not in a valid range. */ 3994 /* C2 is not in a valid range. */
3995 goto invalid_code; 3995 goto invalid_code;
3996 c1 = (c1 << 8) | (c2 & 0x7F); 3996 if (CHARSET_DIMENSION (charset) == 2)
3997 if (CHARSET_DIMENSION (charset) > 2) 3997 c1 = (c1 << 8) | c2;
3998 else
3998 { 3999 {
3999 ONE_MORE_BYTE (c2); 4000 ONE_MORE_BYTE (c3);
4000 if (c2 < 0x20 || (c2 >= 0x80 && c2 < 0xA0)) 4001 if (c3 < 0x20 || (c3 >= 0x80 && c3 < 0xA0)
4001 /* C2 is not in a valid range. */ 4002 || ((c1 & 0x80) != (c3 & 0x80)))
4003 /* C3 is not in a valid range. */
4002 goto invalid_code; 4004 goto invalid_code;
4003 c1 = (c1 << 8) | (c2 & 0x7F); 4005 c1 = (c1 << 16) | (c2 << 8) | c2;
4004 } 4006 }
4005 } 4007 }
4006 4008 c1 &= 0x7F7F7F;
4007 CODING_DECODE_CHAR (coding, src, src_base, src_end, charset, c1, c); 4009 CODING_DECODE_CHAR (coding, src, src_base, src_end, charset, c1, c);
4008 if (c < 0) 4010 if (c < 0)
4009 { 4011 {