changeset 25583:2c0d3a9d33e8

Lots of comments fixed. (PARSE_MULTIBYTE_SEQ): Make it work also for ASCII string. (STRING_CHAR_AND_CHAR_LENGTH): This macro removed.
author Kenichi Handa <handa@m17n.org>
date Tue, 07 Sep 1999 12:18:57 +0000
parents e8428725fec3
children 01026ea61dcc
files src/charset.h
diffstat 1 files changed, 32 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/src/charset.h	Tue Sep 07 11:28:47 1999 +0000
+++ b/src/charset.h	Tue Sep 07 12:18:57 1999 +0000
@@ -488,10 +488,17 @@
 
 #define DEFAULT_NONASCII_INSERT_OFFSET 0x800
 
-/* Parse string STR of length LENGTH (>= 2) and check if a composite
-   character is at STR.  Actually, the whole multibyte sequence
-   starting with LEADING_CODE_COMPOSITION is treated as a single
-   multibyte character.  So, here, we just set BYTES to LENGTH.  */
+/* Parse composite character string STR of length LENGTH (>= 2) and
+   set BYTES to the length of actual multibyte sequence.
+
+   It is assumed that *STR is LEADING_CODE_COMPOSITION and the
+   following (LENGTH - 1) bytes satisfy !CHAR_HEAD_P.
+
+   Actually, the whole multibyte sequence starting with
+   LEADING_CODE_COMPOSITION is treated as a single multibyte
+   character.  So, here, we just set BYTES to LENGTH.
+
+   This macro should be called only from PARSE_MULTIBYTE_SEQ.  */
 
 #define PARSE_COMPOSITE_SEQ(str, length, bytes)	\
   do {						\
@@ -499,9 +506,15 @@
   } while (0)
 
 
-/* Parse string STR of length LENGTH (>= 2) and check if a
-   non-composite multibyte character is at STR.  Set BYTES to the
-   actual sequence length.  */
+/* Parse non-composite multibyte character string STR of length
+   LENGTH (>= 2) and set BYTES to the length of actual multibyte
+   sequence.
+
+   It is assumed that *STR is one of base leading codes (excluding
+   LEADING_CODE_COMPOSITION) and the following (LENGTH - 1) bytes
+   satisfy !CHAR_HEAD_P.
+
+   This macro should be called only from PARSE_MULTIBYTE_SEQ.  */
 
 #define PARSE_CHARACTER_SEQ(str, length, bytes)	\
   do {						\
@@ -517,13 +530,18 @@
 #define PARSE_MULTIBYTE_SEQ(str, length, bytes)			\
   do {								\
     int i = 1;							\
-    while (i < (length) && ! CHAR_HEAD_P ((str)[i])) i++;	\
-    if (i == 1)							\
-      (bytes) = 1;						\
-    else if ((str)[0] == LEADING_CODE_COMPOSITION)		\
-      PARSE_COMPOSITE_SEQ (str, i, bytes);			\
+    if (ASCII_BYTE_P (*str))					\
+      bytes = 1;						\
     else							\
-      PARSE_CHARACTER_SEQ (str, i, bytes);			\
+      {								\
+	while (i < (length) && ! CHAR_HEAD_P ((str)[i])) i++;	\
+	if (i == 1)						\
+	  (bytes) = 1;						\
+	else if ((str)[0] == LEADING_CODE_COMPOSITION)		\
+	  PARSE_COMPOSITE_SEQ (str, i, bytes);			\
+	else							\
+	  PARSE_CHARACTER_SEQ (str, i, bytes);			\
+      }								\
   } while (0)
 
 /* The charset of non-ASCII character C is stored in CHARSET, and the
@@ -546,7 +564,7 @@
 
 /* The charset of character C is stored in CHARSET, and the
    position-codes of C are stored in C1 and C2.
-   We store -1 in C2 if the dimension of the charset 1.  */
+   We store -1 in C2 if the dimension of the charset is 1.  */
 
 #define SPLIT_CHAR(c, charset, c1, c2)		 	\
   (SINGLE_BYTE_CHAR_P (c)			 	\
@@ -623,10 +641,6 @@
    ? ((actual_len) = 1), (unsigned char) *(str)		\
    : string_to_non_ascii_char (str, len, &(actual_len)))
 
-/* This is like STRING_CHAR_AND_LENGTH but the third arg ACTUAL_LEN
-   does not include garbage bytes following the multibyte character.  */
-#define STRING_CHAR_AND_CHAR_LENGTH STRING_CHAR_AND_LENGTH
-
 /* Fetch the "next" multibyte character from Lisp string STRING
    at byte position BYTEIDX, character position CHARIDX.
    Store it into OUTPUT.