aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/character.h20
1 files changed, 8 insertions, 12 deletions
diff --git a/src/character.h b/src/character.h
index bc3e1557844..d4b6c73cd92 100644
--- a/src/character.h
+++ b/src/character.h
@@ -237,7 +237,8 @@ enum
237#define CHAR_HEAD_P(byte) (((byte) & 0xC0) != 0x80) 237#define CHAR_HEAD_P(byte) (((byte) & 0xC0) != 0x80)
238 238
239/* How many bytes a character that starts with BYTE occupies in a 239/* How many bytes a character that starts with BYTE occupies in a
240 multibyte form. */ 240 multibyte form. Unlike MULTIBYTE_LENGTH below, this macro does not
241 validate the multibyte form, but looks only at its first byte. */
241#define BYTES_BY_CHAR_HEAD(byte) \ 242#define BYTES_BY_CHAR_HEAD(byte) \
242 (!((byte) & 0x80) ? 1 \ 243 (!((byte) & 0x80) ? 1 \
243 : !((byte) & 0x20) ? 2 \ 244 : !((byte) & 0x20) ? 2 \
@@ -247,7 +248,9 @@ enum
247 248
248 249
249/* The byte length of multibyte form at unibyte string P ending at 250/* The byte length of multibyte form at unibyte string P ending at
250 PEND. If STR doesn't point to a valid multibyte form, return 0. */ 251 PEND. If the string doesn't point to a valid multibyte form,
252 return 0. Unlike BYTES_BY_CHAR_HEAD, this macro validates the
253 multibyte form. */
251 254
252#define MULTIBYTE_LENGTH(p, pend) \ 255#define MULTIBYTE_LENGTH(p, pend) \
253 (p >= pend ? 0 \ 256 (p >= pend ? 0 \
@@ -263,7 +266,8 @@ enum
263 : 0) 266 : 0)
264 267
265 268
266/* Like MULTIBYTE_LENGTH, but don't check the ending address. */ 269/* Like MULTIBYTE_LENGTH, but don't check the ending address. The
270 multibyte form is still validated, unlike BYTES_BY_CHAR_HEAD. */
267 271
268#define MULTIBYTE_LENGTH_NO_CHECK(p) \ 272#define MULTIBYTE_LENGTH_NO_CHECK(p) \
269 (!((p)[0] & 0x80) ? 1 \ 273 (!((p)[0] & 0x80) ? 1 \
@@ -324,15 +328,7 @@ enum
324 328
325 329
326/* Like STRING_CHAR, but set ACTUAL_LEN to the length of multibyte 330/* Like STRING_CHAR, but set ACTUAL_LEN to the length of multibyte
327 form. 331 form. */
328
329 Note: This macro returns the actual length of the character's
330 multibyte sequence as it is stored in a buffer or string. The
331 character it returns might have a different codepoint that has a
332 different multibyte sequence of a different length, due to possible
333 unification of CJK characters inside string_char. Therefore do NOT
334 assume that the length returned by this macro is identical to the
335 length of the multibyte sequence of the character it returns. */
336 332
337#define STRING_CHAR_AND_LENGTH(p, actual_len) \ 333#define STRING_CHAR_AND_LENGTH(p, actual_len) \
338 (!((p)[0] & 0x80) \ 334 (!((p)[0] & 0x80) \