changeset 36102:cd1abcc15e9c

(ccl_driver) [CCL_ReadMultibyteChar2]: If SRC points an invalid mulitbyte sequence, treat *SRC as a character of eight-bit-graphic.
author Kenichi Handa <handa@m17n.org>
date Thu, 15 Feb 2001 13:07:34 +0000
parents 3fbc0a866e43
children a2fd3972d7c9
files src/ccl.c
diffstat 1 files changed, 18 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/src/ccl.c	Thu Feb 15 13:05:29 2001 +0000
+++ b/src/ccl.c	Thu Feb 15 13:07:34 2001 +0000
@@ -1255,21 +1255,27 @@
 		  reg[rrr] = i;
 		  reg[RRR] = CHARSET_ASCII;
 		}
-	      else if (i <= MAX_CHARSET_OFFICIAL_DIMENSION1)
-		{
-		  if (src >= src_end)
-		    goto ccl_read_multibyte_character_suspend;
-		  reg[RRR] = i;
-		  reg[rrr] = (*src++ & 0x7F);
-		}
 	      else if (i <= MAX_CHARSET_OFFICIAL_DIMENSION2)
 		{
-		  if ((src + 1) >= src_end)
+		  int dimension = BYTES_BY_CHAR_HEAD (i) - 1;
+
+		  if (dimension == 0)
+		    {
+		      /* `i' is a leading code for an undefined charset.  */
+		      reg[RRR] = CHARSET_8_BIT_GRAPHIC;
+		      reg[rrr] = i;
+		    }
+		  else if (src + dimension > src_end)
 		    goto ccl_read_multibyte_character_suspend;
-		  reg[RRR] = i;
-		  i = (*src++ & 0x7F);
-		  reg[rrr] = ((i << 7) | (*src & 0x7F));
-		  src++;
+		  else
+		    {
+		      reg[RRR] = i;
+		      i = (*src++ & 0x7F);
+		      if (dimension == 1)
+			reg[rrr] = i;
+		      else
+			reg[rrr] = ((i << 7) | (*src++ & 0x7F));
+		    }
 		}
 	      else if ((i == LEADING_CODE_PRIVATE_11)
 		       || (i == LEADING_CODE_PRIVATE_12))