X-Git-Url: https://git.hcoop.net/bpt/emacs.git/blobdiff_plain/a8e7d6d783219972c08fd49a3a2afaf26eb139c2..42e910349d699ee3f8024371ca1e60e015fc6aa7:/src/character.h diff --git a/src/character.h b/src/character.h index 88de343b22..6f243a1392 100644 --- a/src/character.h +++ b/src/character.h @@ -25,6 +25,8 @@ along with GNU Emacs. If not, see . */ #include +INLINE_HEADER_BEGIN + /* character code 1st byte byte sequence -------------- -------- ------------- 0-7F 00..7F 0xxxxxxx @@ -89,7 +91,7 @@ along with GNU Emacs. If not, see . */ do { \ if (! ASCII_CHAR_P (c)) \ c = CHAR_TO_BYTE8 (c); \ - } while (0) + } while (false) /* If C is not ASCII, make it multibyte. Assumes C < 256. */ @@ -121,14 +123,14 @@ along with GNU Emacs. If not, see . */ Lisp_Object tmp = XCAR (x); \ CHECK_CHARACTER (tmp); \ XSETCAR ((x), tmp); \ - } while (0) + } while (false) #define CHECK_CHARACTER_CDR(x) \ do { \ Lisp_Object tmp = XCDR (x); \ CHECK_CHARACTER (tmp); \ XSETCDR ((x), tmp); \ - } while (0) + } while (false) /* Nonzero iff C is a character of code less than 0x100. */ #define SINGLE_BYTE_CHAR_P(c) UNSIGNED_CMP (c, <, 0x100) @@ -207,7 +209,7 @@ along with GNU Emacs. If not, see . */ verify (sizeof (c) <= sizeof (unsigned)); \ (p) += char_string (c, p); \ } \ - } while (0) + } while (false) /* Nonzero iff BYTE starts a non-ASCII character in a multibyte @@ -272,7 +274,7 @@ along with GNU Emacs. If not, see . */ do { \ if ((p) < (limit)) \ (p) += BYTES_BY_CHAR_HEAD (*(p)); \ - } while (0) + } while (false) /* If P is after LIMIT, advance P to the previous character boundary. @@ -289,7 +291,7 @@ along with GNU Emacs. If not, see . */ } while (chp >= limit && ! CHAR_HEAD_P (*chp)); \ (p) = (BYTES_BY_CHAR_HEAD (*chp) == (p) - chp) ? chp : (p) - 1; \ } \ - } while (0) + } while (false) /* Return the character code of character whose multibyte form is at P. Note that this macro unifies CJK characters whose codepoints @@ -380,7 +382,7 @@ along with GNU Emacs. If not, see . */ BYTEIDX++; \ } \ } \ - while (0) + while (false) /* Like FETCH_STRING_CHAR_ADVANCE, but return a multibyte character even if STRING is unibyte. */ @@ -404,7 +406,7 @@ along with GNU Emacs. If not, see . */ MAKE_CHAR_MULTIBYTE (OUTPUT); \ } \ } \ - while (0) + while (false) /* Like FETCH_STRING_CHAR_ADVANCE, but assumes STRING is multibyte. */ @@ -419,7 +421,7 @@ along with GNU Emacs. If not, see . */ BYTEIDX += fetch_len; \ CHARIDX++; \ } \ - while (0) + while (false) /* Like FETCH_STRING_CHAR_ADVANCE, but fetch character from the current @@ -434,7 +436,7 @@ along with GNU Emacs. If not, see . */ unsigned char *chp = BYTE_POS_ADDR (BYTEIDX); \ int chlen; \ \ - OUTPUT= STRING_CHAR_AND_LENGTH (chp, chlen); \ + OUTPUT = STRING_CHAR_AND_LENGTH (chp, chlen); \ BYTEIDX += chlen; \ } \ else \ @@ -443,7 +445,7 @@ along with GNU Emacs. If not, see . */ BYTEIDX++; \ } \ } \ - while (0) + while (false) /* Like FETCH_CHAR_ADVANCE, but assumes the current buffer is multibyte. */ @@ -458,7 +460,7 @@ along with GNU Emacs. If not, see . */ BYTEIDX += chlen; \ CHARIDX++; \ } \ - while (0) + while (false) /* Increment the buffer byte position POS_BYTE of the current buffer to @@ -468,7 +470,7 @@ along with GNU Emacs. If not, see . */ do { \ unsigned char *chp = BYTE_POS_ADDR (pos_byte); \ pos_byte += BYTES_BY_CHAR_HEAD (*chp); \ - } while (0) + } while (false) /* Decrement the buffer byte position POS_BYTE of the current buffer to @@ -488,7 +490,7 @@ along with GNU Emacs. If not, see . */ chp--; \ pos_byte--; \ } \ - } while (0) + } while (false) /* Increment both CHARPOS and BYTEPOS, each in the appropriate way. */ @@ -501,7 +503,7 @@ along with GNU Emacs. If not, see . */ else \ INC_POS ((bytepos)); \ } \ - while (0) + while (false) /* Decrement both CHARPOS and BYTEPOS, each in the appropriate way. */ @@ -515,7 +517,7 @@ along with GNU Emacs. If not, see . */ else \ DEC_POS ((bytepos)); \ } \ - while (0) + while (false) /* Increment the buffer byte position POS_BYTE of the current buffer to @@ -527,7 +529,7 @@ along with GNU Emacs. If not, see . */ do { \ unsigned char *chp = BUF_BYTE_ADDRESS (buf, pos_byte); \ pos_byte += BYTES_BY_CHAR_HEAD (*chp); \ - } while (0) + } while (false) /* Decrement the buffer byte position POS_BYTE of the current buffer to @@ -546,31 +548,14 @@ along with GNU Emacs. If not, see . */ chp--; \ pos_byte--; \ } \ - } while (0) - - -/* If C is a character to be unified with a Unicode character, return - the unified Unicode character. */ - -#define MAYBE_UNIFY_CHAR(c) \ - do { \ - if (c > MAX_UNICODE_CHAR && c <= MAX_5_BYTE_CHAR) \ - { \ - Lisp_Object val; \ - val = CHAR_TABLE_REF (Vchar_unify_table, c); \ - if (INTEGERP (val)) \ - c = XFASTINT (val); \ - else if (! NILP (val)) \ - c = maybe_unify_char (c, val); \ - } \ - } while (0) + } while (false) /* Return a non-outlandish value for the tab width. */ #define SANE_TAB_WIDTH(buf) \ sanitize_tab_width (XFASTINT (BVAR (buf, tab_width))) -static inline int +INLINE int sanitize_tab_width (EMACS_INT width) { return 0 < width && width <= 1000 ? width : 8; @@ -591,7 +576,7 @@ sanitize_tab_width (EMACS_INT width) /* Return a non-outlandish value for a character width. */ -static inline int +INLINE int sanitize_char_width (EMACS_INT width) { return 0 <= width && width <= 1000 ? width : 1000; @@ -617,7 +602,7 @@ sanitize_char_width (EMACS_INT width) : 0) /* If C is a high surrogate, return 1. If C is a low surrogate, - return 0. Otherwise, return 0. */ + return 2. Otherwise, return 0. */ #define CHAR_SURROGATE_PAIR_P(c) \ ((c) < 0xD800 ? 0 \ @@ -628,7 +613,7 @@ sanitize_char_width (EMACS_INT width) /* Data type for Unicode general category. The order of members must be in sync with the 8th element of the - member of unidata-prop-alist (in admin/unidata/unidata-getn.el) for + member of unidata-prop-alist (in admin/unidata/unidata-gen.el) for Unicode character property `general-category'. */ typedef enum { @@ -665,27 +650,26 @@ typedef enum { UNICODE_CATEGORY_Cn } unicode_category_t; -extern int char_resolve_modifier_mask (int); +extern EMACS_INT char_resolve_modifier_mask (EMACS_INT) ATTRIBUTE_CONST; extern int char_string (unsigned, unsigned char *); extern int string_char (const unsigned char *, const unsigned char **, int *); extern int translate_char (Lisp_Object, int c); -extern int char_printable_p (int c); extern void parse_str_as_multibyte (const unsigned char *, - EMACS_INT, EMACS_INT *, EMACS_INT *); -extern EMACS_INT count_size_as_multibyte (const unsigned char *, EMACS_INT); -extern EMACS_INT str_as_multibyte (unsigned char *, EMACS_INT, EMACS_INT, - EMACS_INT *); -extern EMACS_INT str_to_multibyte (unsigned char *, EMACS_INT, EMACS_INT); -extern EMACS_INT str_as_unibyte (unsigned char *, EMACS_INT); -extern EMACS_INT str_to_unibyte (const unsigned char *, unsigned char *, - EMACS_INT, int); -extern EMACS_INT strwidth (const char *, EMACS_INT); -extern EMACS_INT c_string_width (const unsigned char *, EMACS_INT, int, - EMACS_INT *, EMACS_INT *); -extern EMACS_INT lisp_string_width (Lisp_Object, EMACS_INT, - EMACS_INT *, EMACS_INT *); + ptrdiff_t, ptrdiff_t *, ptrdiff_t *); +extern ptrdiff_t count_size_as_multibyte (const unsigned char *, ptrdiff_t); +extern ptrdiff_t str_as_multibyte (unsigned char *, ptrdiff_t, ptrdiff_t, + ptrdiff_t *); +extern ptrdiff_t str_to_multibyte (unsigned char *, ptrdiff_t, ptrdiff_t); +extern ptrdiff_t str_as_unibyte (unsigned char *, ptrdiff_t); +extern ptrdiff_t str_to_unibyte (const unsigned char *, unsigned char *, + ptrdiff_t); +extern ptrdiff_t strwidth (const char *, ptrdiff_t); +extern ptrdiff_t c_string_width (const unsigned char *, ptrdiff_t, int, + ptrdiff_t *, ptrdiff_t *); +extern ptrdiff_t lisp_string_width (Lisp_Object, ptrdiff_t, + ptrdiff_t *, ptrdiff_t *); extern Lisp_Object Qcharacterp; extern Lisp_Object Vchar_unify_table; @@ -693,6 +677,8 @@ extern Lisp_Object string_escape_byte8 (Lisp_Object); /* Return a translation table of id number ID. */ #define GET_TRANSLATION_TABLE(id) \ - (XCDR(XVECTOR(Vtranslation_table_vector)->contents[(id)])) + (XCDR (XVECTOR (Vtranslation_table_vector)->contents[(id)])) + +INLINE_HEADER_END #endif /* EMACS_CHARACTER_H */