changeset 23653:67907ea2c6ac

(SPLIT_NON_ASCII_CHAR): Check dimension of an invalid character correctly. (STRING_CHAR): Handle an invalid charater correctly.
author Kenichi Handa <handa@m17n.org>
date Fri, 06 Nov 1998 10:59:09 +0000
parents 42bf6553a2e9
children e70afb86651a
files src/charset.h
diffstat 1 files changed, 9 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/charset.h	Fri Nov 06 09:31:52 1998 +0000
+++ b/src/charset.h	Fri Nov 06 10:59:09 1998 +0000
@@ -508,16 +508,16 @@
    Do not use this macro for an ASCII character.  */
 
 #define SPLIT_NON_ASCII_CHAR(c, charset, c1, c2)			 \
-  ((c) < MIN_CHAR_OFFICIAL_DIMENSION2					 \
-   ? (charset = CHAR_FIELD2 (c) + 0x70,					 \
-      c1 = CHAR_FIELD3 (c),						 \
-      c2 = -1)								 \
-   : (charset = ((c) < MIN_CHAR_COMPOSITION				 \
+  ((c) & CHAR_FIELD1_MASK						 \
+   ? (charset = ((c) < MIN_CHAR_COMPOSITION				 \
 		 ? (CHAR_FIELD1 (c)					 \
 		    + ((c) < MIN_CHAR_PRIVATE_DIMENSION2 ? 0x8F : 0xE0)) \
 		 : CHARSET_COMPOSITION),				 \
       c1 = CHAR_FIELD2 (c),						 \
-      c2 = CHAR_FIELD3 (c)))
+      c2 = CHAR_FIELD3 (c))						 \
+   : (charset = CHAR_FIELD2 (c) + 0x70,					 \
+      c1 = CHAR_FIELD3 (c),						 \
+      c2 = -1))
 
 /* The charset of character C is stored in CHARSET, and the
    position-codes of C are stored in C1 and C2.
@@ -576,10 +576,9 @@
    is at STR and the length is LEN.  If STR doesn't contain valid
    multi-byte form, only the first byte in STR is returned.  */
 
-#define STRING_CHAR(str, len)				    	\
-  ((BYTES_BY_CHAR_HEAD ((unsigned char) *(str)) == 1	    	\
-    || BYTES_BY_CHAR_HEAD ((unsigned char) *(str)) > (len))	\
-   ? (unsigned char) *(str)				    	\
+#define STRING_CHAR(str, len)				\
+  (BYTES_BY_CHAR_HEAD ((unsigned char) *(str)) == 1	\
+   ? (unsigned char) *(str)				\
    : string_to_non_ascii_char (str, len, 0, 0))
 
 /* This is like STRING_CHAR but the third arg ACTUAL_LEN is set to