From d6640d6e4c4f1a85edf924bca0f8a90d1aa6341a Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Tue, 11 Aug 2015 15:53:18 -0700 Subject: [PATCH] Give names to Unicode code points in C code * src/character.h (NO_BREAK_SPACE, SOFT_HYPHEN) (ZERO_WIDTH_NON_JOINER, ZERO_WIDTH_JOINER, HYPHEN) (NON_BREAKING_HYPHEN, LEFT_SINGLE_QUOTATION_MARK) (RIGHT_SINGLE_QUOTATION_MARK, PARAGRAPH_SEPARATOR) (LEFT_POINTING_ANGLE_BRACKET, RIGHT_POINTING_ANGLE_BRACKET) (LEFT_ANGLE_BRACKET, RIGHT_ANGLE_BRACKET) (OBJECT_REPLACEMENT_CHARACTER): New named constants for Unicode code points. * src/bidi.c (bidi_fetch_char, CANONICAL_EQU): * src/composite.c (char_composable_p): * src/lread.c (readevalloop, read1): * src/xdisp.c (get_next_display_element): Use them. * src/doc.c (LEFT_SINGLE_QUOTATION_POINT): Remove; now in character.h. --- src/bidi.c | 8 ++++---- src/character.h | 19 +++++++++++++++++++ src/composite.c | 2 +- src/doc.c | 1 - src/lread.c | 8 ++++---- src/xdisp.c | 5 +++-- 6 files changed, 31 insertions(+), 12 deletions(-) diff --git a/src/bidi.c b/src/bidi.c index e06430c8b84..bcc15b8c8f5 100644 --- a/src/bidi.c +++ b/src/bidi.c @@ -1313,13 +1313,13 @@ bidi_fetch_char (ptrdiff_t charpos, ptrdiff_t bytepos, ptrdiff_t *disp_pos, /* `(space ...)' display specs are handled as paragraph separators for the purposes of the reordering; see UAX#9 section 3 and clause HL1 in section 4.3 there. */ - ch = 0x2029; + ch = PARAGRAPH_SEPARATOR; } else { /* All other display specs are handled as the Unicode Object Replacement Character. */ - ch = 0xFFFC; + ch = OBJECT_REPLACEMENT_CHARACTER; } disp_end_pos = compute_display_string_end (*disp_pos, string); if (disp_end_pos < 0) @@ -2482,8 +2482,8 @@ typedef struct bpa_stack_entry { #define CANONICAL_EQU(c) \ ( ASCII_CHAR_P (c) ? c \ - : (c) == 0x2329 ? 0x3008 \ - : (c) == 0x232a ? 0x3009 \ + : (c) == LEFT_POINTING_ANGLE_BRACKET ? LEFT_ANGLE_BRACKET \ + : (c) == RIGHT_POINTING_ANGLE_BRACKET ? RIGHT_ANGLE_BRACKET \ : c ) #ifdef ENABLE_CHECKING diff --git a/src/character.h b/src/character.h index 859d717a0ba..0b2c419de99 100644 --- a/src/character.h +++ b/src/character.h @@ -59,6 +59,25 @@ INLINE_HEADER_BEGIN /* Maximum leading code of multibyte characters. */ #define MAX_MULTIBYTE_LEADING_CODE 0xF8 +/* Unicode character values. */ +enum +{ + NO_BREAK_SPACE = 0x00A0, + SOFT_HYPHEN = 0x00AD, + ZERO_WIDTH_NON_JOINER = 0x200C, + ZERO_WIDTH_JOINER = 0x200D, + HYPHEN = 0x2010, + NON_BREAKING_HYPHEN = 0x2011, + LEFT_SINGLE_QUOTATION_MARK = 0x2018, + RIGHT_SINGLE_QUOTATION_MARK = 0x2019, + PARAGRAPH_SEPARATOR = 0x2029, + LEFT_POINTING_ANGLE_BRACKET = 0x2329, + RIGHT_POINTING_ANGLE_BRACKET = 0x232A, + LEFT_ANGLE_BRACKET = 0x3008, + RIGHT_ANGLE_BRACKET = 0x3009, + OBJECT_REPLACEMENT_CHARACTER = 0xFFFC, +}; + /* Nonzero iff C is a character that corresponds to a raw 8-bit byte. */ #define CHAR_BYTE8_P(c) ((c) > MAX_5_BYTE_CHAR) diff --git a/src/composite.c b/src/composite.c index 1c18165599d..88cef222d3a 100644 --- a/src/composite.c +++ b/src/composite.c @@ -927,7 +927,7 @@ char_composable_p (int c) { Lisp_Object val; return (c > ' ' - && (c == 0x200C || c == 0x200D + && (c == ZERO_WIDTH_NON_JOINER || c == ZERO_WIDTH_JOINER || (val = CHAR_TABLE_REF (Vunicode_category_table, c), (INTEGERP (val) && (XINT (val) <= UNICODE_CATEGORY_So))))); } diff --git a/src/doc.c b/src/doc.c index a079cd27493..cb52266ef58 100644 --- a/src/doc.c +++ b/src/doc.c @@ -689,7 +689,6 @@ the same file name is found in the `doc-directory'. */) "\xE2\x80\x98" and "\xE2\x80\x99", respectively. */ enum { - LEFT_SINGLE_QUOTATION_MARK = 0x2018, uLSQM0 = 0xE2, uLSQM1 = 0x80, uLSQM2 = 0x98, uRSQM0 = 0xE2, uRSQM1 = 0x80, uRSQM2 = 0x99, }; diff --git a/src/lread.c b/src/lread.c index 11c8d0031c9..fe4d3672b44 100644 --- a/src/lread.c +++ b/src/lread.c @@ -1885,7 +1885,7 @@ readevalloop (Lisp_Object readcharfun, /* Ignore whitespace here, so we can detect eof. */ if (c == ' ' || c == '\t' || c == '\n' || c == '\f' || c == '\r' - || c == 0xa0) /* NBSP */ + || c == NO_BREAK_SPACE) goto read_next; if (!NILP (Vpurify_flag) && c == '(') @@ -2793,7 +2793,7 @@ read1 (Lisp_Object readcharfun, int *pch, bool first_in_list) uninterned_symbol = 1; c = READCHAR; if (!(c > 040 - && c != 0xa0 /* NBSP */ + && c != NO_BREAK_SPACE && (c >= 0200 || strchr ("\"';()[]#`,", c) == NULL))) { @@ -3127,7 +3127,7 @@ read1 (Lisp_Object readcharfun, int *pch, bool first_in_list) default: default_label: if (c <= 040) goto retry; - if (c == 0xa0) /* NBSP */ + if (c == NO_BREAK_SPACE) goto retry; read_symbol: @@ -3167,7 +3167,7 @@ read1 (Lisp_Object readcharfun, int *pch, bool first_in_list) c = READCHAR; } while (c > 040 - && c != 0xa0 /* NBSP */ + && c != NO_BREAK_SPACE && (c >= 0200 || strchr ("\"';()[]#`,", c) == NULL)); diff --git a/src/xdisp.c b/src/xdisp.c index 711fe080b03..7371216d387 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -6890,9 +6890,10 @@ get_next_display_element (struct it *it) non-ASCII spaces and hyphens specially. */ if (! ASCII_CHAR_P (c) && ! NILP (Vnobreak_char_display)) { - if (c == 0xA0) + if (c == NO_BREAK_SPACE) nonascii_space_p = true; - else if (c == 0xAD || c == 0x2010 || c == 0x2011) + else if (c == SOFT_HYPHEN || c == HYPHEN + || c == NON_BREAKING_HYPHEN) nonascii_hyphen_p = true; } -- 2.39.2