aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenichi Handa1999-09-07 12:19:26 +0000
committerKenichi Handa1999-09-07 12:19:26 +0000
commit44c6492dfa5de85a80824ecc9807b1b7f4accc09 (patch)
treea10a2c366100d772df3703190519abc76c601186 /src
parent9dd2aa1a51b5c63c61349a50b692450c3fc02e89 (diff)
downloademacs-44c6492dfa5de85a80824ecc9807b1b7f4accc09.tar.gz
emacs-44c6492dfa5de85a80824ecc9807b1b7f4accc09.zip
Lots of comments fixed.
(SPLIT_MULTIBYTE_SEQ): Make it work also for ASCII string. (CHAR_COMPONENTS_VALID_P): Name changed from CHAR_COMPONENT_VALID_P. Caller changed.
Diffstat (limited to 'src')
-rw-r--r--src/charset.c63
1 files changed, 40 insertions, 23 deletions
diff --git a/src/charset.c b/src/charset.c
index 0876644ee94..91f510476a0 100644
--- a/src/charset.c
+++ b/src/charset.c
@@ -124,14 +124,20 @@ invalid_character (c)
124 error ("Invalid character: 0%o, %d, 0x%x", c, c, c); 124 error ("Invalid character: 0%o, %d, 0x%x", c, c, c);
125} 125}
126 126
127/* Parse string STR of length LENGTH (>= 2) and check if a composite 127/* Parse composite character string STR of length LENGTH (>= 2) and
128 character is at STR. If there is a valid composite character, set 128 set BYTES, CHARSET, C1, and C2 as below.
129 CHARSET, C1, and C2 to proper values so that MAKE_CHAR can compose 129
130 the composite character from them. Otherwise, set CHARSET to 130 It is assumed that *STR is LEADING_CODE_COMPOSITION and the
131 CHARSET_COMPOSITION, but set C1 to the second byte of the sequence, 131 following (LENGTH - 1) bytes satisfy !CHAR_HEAD_P.
132 C2 to -1 so that MAKE_CHAR can compose the invalid multibyte 132
133 character whose string representation is two bytes of STR[0] and 133 If there is a valid composite character, set CHARSET, C1, and C2 to
134 STR[1]. In any case, set BYTES to LENGTH. */ 134 such values that MAKE_CHAR can make the composite character from
135 them. Otherwise, set CHARSET to CHARSET_COMPOSITION, set C1 to the
136 second byte of the sequence, C2 to -1 so that MAKE_CHAR can make
137 the invalid multibyte character whose string representation is two
138 bytes of STR[0] and STR[1]. In any case, set BYTES to LENGTH.
139
140 This macro should be called only from SPLIT_MULTIBYTE_SEQ. */
135 141
136#define SPLIT_COMPOSITE_SEQ(str, length, bytes, charset, c1, c2) \ 142#define SPLIT_COMPOSITE_SEQ(str, length, bytes, charset, c1, c2) \
137 do { \ 143 do { \
@@ -151,10 +157,16 @@ invalid_character (c)
151 } \ 157 } \
152 } while (0) 158 } while (0)
153 159
154/* Parse string STR of length LENGTH (>= 2) and check if a 160/* Parse non-composite multibyte character string STR of length LENGTH
155 non-composite multibyte character is at STR. Set BYTES to the 161 (>= 2) and set BYTES to the length of actual multibyte sequence,
156 actual length, CHARSET, C1, and C2 to proper values so that 162 CHARSET, C1, and C2 to such values that MAKE_CHAR can make the
157 MAKE_CHAR can compose the multibyte character from them. */ 163 multibyte character from them.
164
165 It is assumed that *STR is one of base leading codes (excluding
166 LEADING_CODE_COMPOSITION) and the following (LENGTH - 1) bytes
167 satisfy !CHAR_HEAD_P.
168
169 This macro should be called only from SPLIT_MULTIBYTE_SEQ. */
158 170
159#define SPLIT_CHARACTER_SEQ(str, length, bytes, charset, c1, c2) \ 171#define SPLIT_CHARACTER_SEQ(str, length, bytes, charset, c1, c2) \
160 do { \ 172 do { \
@@ -182,7 +194,10 @@ invalid_character (c)
182#define SPLIT_MULTIBYTE_SEQ(str, length, bytes, charset, c1, c2) \ 194#define SPLIT_MULTIBYTE_SEQ(str, length, bytes, charset, c1, c2) \
183 do { \ 195 do { \
184 int i; \ 196 int i; \
185 for (i = 1; i < (length) && ! CHAR_HEAD_P ((str)[i]); i++); \ 197 if (ASCII_BYTE_P ((str)[0])) \
198 i = 1; \
199 else \
200 for (i = 1; i < (length) && ! CHAR_HEAD_P ((str)[i]); i++); \
186 if (i == 1) \ 201 if (i == 1) \
187 (bytes) = 1, (charset) = CHARSET_ASCII, (c1) = (str)[0] ; \ 202 (bytes) = 1, (charset) = CHARSET_ASCII, (c1) = (str)[0] ; \
188 else if ((str)[0] == LEADING_CODE_COMPOSITION) \ 203 else if ((str)[0] == LEADING_CODE_COMPOSITION) \
@@ -196,7 +211,7 @@ invalid_character (c)
196 } while (0) 211 } while (0)
197 212
198/* 1 if CHARSET, C1, and C2 compose a valid character, else 0. */ 213/* 1 if CHARSET, C1, and C2 compose a valid character, else 0. */
199#define CHAR_COMPONENT_VALID_P(charset, c1, c2) \ 214#define CHAR_COMPONENTS_VALID_P(charset, c1, c2) \
200 (CHARSET_DIMENSION (charset) == 1 \ 215 (CHARSET_DIMENSION (charset) == 1 \
201 ? ((c1) >= 0x20 && (c1) <= 0x7F) \ 216 ? ((c1) >= 0x20 && (c1) <= 0x7F) \
202 : ((c1) >= 0x20 && (c1) <= 0x7F && (c2) >= 0x20 && (c2) <= 0x7F)) 217 : ((c1) >= 0x20 && (c1) <= 0x7F && (c2) >= 0x20 && (c2) <= 0x7F))
@@ -312,12 +327,12 @@ non_ascii_char_to_string (c, workbuf, str)
312 return (workbuf - *str); 327 return (workbuf - *str);
313} 328}
314 329
315/* Return a non-ASCII character of which multi-byte form is at STR of 330/* Return the non-ASCII character corresponding to multi-byte form at
316 length LEN. If ACTUAL_LEN is not NULL, the byte length of the 331 STR of length LEN. If ACTUAL_LEN is not NULL, store the byte
317 multibyte form is set to the address ACTUAL_LEN. 332 length of the multibyte form in *ACTUAL_LEN.
318 333
319 Use macro `STRING_CHAR (STR, LEN)' instead of calling this function 334 Use macro `STRING_CHAR (STR, LEN)' instead of calling this function
320 directly if STR can hold an ASCII character. */ 335 directly if you want ot handle ASCII characters as well. */
321 336
322int 337int
323string_to_non_ascii_char (str, len, actual_len) 338string_to_non_ascii_char (str, len, actual_len)
@@ -333,7 +348,8 @@ string_to_non_ascii_char (str, len, actual_len)
333 return c; 348 return c;
334} 349}
335 350
336/* Return the length of the multi-byte form at string STR of length LEN. */ 351/* Return the length of the multi-byte form at string STR of length LEN.
352 Use the macro MULTIBYTE_FORM_LENGTH instead. */
337int 353int
338multibyte_form_length (str, len) 354multibyte_form_length (str, len)
339 const unsigned char *str; 355 const unsigned char *str;
@@ -367,7 +383,8 @@ split_non_ascii_string (str, len, charset, c1, c2)
367 *c2 = code2; 383 *c2 = code2;
368} 384}
369 385
370/* Return 1 iff character C has valid printable glyph. */ 386/* Return 1 iff character C has valid printable glyph.
387 Use the macro CHAR_PRINTABLE_P instead. */
371int 388int
372char_printable_p (c) 389char_printable_p (c)
373 int c; 390 int c;
@@ -1063,8 +1080,8 @@ DEFUN ("make-char-internal", Fmake_char_internal, Smake_char_internal, 1, 3, 0,
1063 if (c1 == 0 1080 if (c1 == 0
1064 ? c2 != 0 1081 ? c2 != 0
1065 : (c2 == 0 1082 : (c2 == 0
1066 ? !CHAR_COMPONENT_VALID_P (charset, c1, 0x20) 1083 ? !CHAR_COMPONENTS_VALID_P (charset, c1, 0x20)
1067 : !CHAR_COMPONENT_VALID_P (charset, c1, c2))) 1084 : !CHAR_COMPONENTS_VALID_P (charset, c1, c2)))
1068 error ("Invalid code points: %d %d", c1, c2); 1085 error ("Invalid code points: %d %d", c1, c2);
1069 1086
1070 return make_number (MAKE_CHAR (charset_id, c1, c2)); 1087 return make_number (MAKE_CHAR (charset_id, c1, c2));
@@ -1192,7 +1209,7 @@ char_valid_p (c, genericp)
1192 } 1209 }
1193 } 1210 }
1194 return (CHARSET_DEFINED_P (charset) 1211 return (CHARSET_DEFINED_P (charset)
1195 && CHAR_COMPONENT_VALID_P (charset, c1, c2)); 1212 && CHAR_COMPONENTS_VALID_P (charset, c1, c2));
1196} 1213}
1197 1214
1198DEFUN ("char-valid-p", Fchar_valid_p, Schar_valid_p, 1, 2, 0, 1215DEFUN ("char-valid-p", Fchar_valid_p, Schar_valid_p, 1, 2, 0,