aboutsummaryrefslogtreecommitdiffstats
path: root/src/font.c
diff options
context:
space:
mode:
authorPaul Eggert2020-04-17 07:57:25 -0700
committerPaul Eggert2020-04-17 09:17:35 -0700
commit27d101832ada36e431ae6cdecb5c82a180566377 (patch)
tree13e20d71f22cf4736bbfa02be54735b1484610bb /src/font.c
parent3e46a2315f1a999f5811f57a60a2a55f95d8fbb0 (diff)
downloademacs-27d101832ada36e431ae6cdecb5c82a180566377.tar.gz
emacs-27d101832ada36e431ae6cdecb5c82a180566377.zip
Prefer more inline functions in character.h
* src/buffer.h (fetch_char_advance, fetch_char_advance_no_check) (buf_next_char_len, next_char_len, buf_prev_char_len) (prev_char_len, inc_both, dec_both): New inline functions, replacing the old character.h macros FETCH_CHAR_ADVANCE, FETCH_CHAR_ADVANCE_NO_CHECK, BUF_INC_POS, INC_POS, BUF_DEC_POS, DEC_POS, INC_BOTH, DEC_BOTH respectively. All callers changed. These new functions all assume buffer primitives and so need to be here rather than in character.h. * src/casefiddle.c (make_char_unibyte): New static function, replacing the old MAKE_CHAR_UNIBYTE macro. All callers changed. (do_casify_unibyte_string): Use SINGLE_BYTE_CHAR_P instead of open-coding it. * src/ccl.c (GET_TRANSLATION_TABLE): New static function, replacing the old macro of the same name. * src/character.c (string_char): Omit 2nd arg. 3rd arg can no longer be NULL. All callers changed. * src/character.h (SINGLE_BYTE_CHAR_P): Move up. (MAKE_CHAR_UNIBYTE, MAKE_CHAR_MULTIBYTE, PREV_CHAR_BOUNDARY) (STRING_CHAR_AND_LENGTH, STRING_CHAR_ADVANCE) (FETCH_STRING_CHAR_ADVANCE) (FETCH_STRING_CHAR_AS_MULTIBYTE_ADVANCE) (FETCH_STRING_CHAR_ADVANCE_NO_CHECK, FETCH_CHAR_ADVANCE) (FETCH_CHAR_ADVANCE_NO_CHECK, INC_POS, DEC_POS, INC_BOTH) (DEC_BOTH, BUF_INC_POS, BUF_DEC_POS): Remove. (make_char_multibyte): New static function, replacing the old macro MAKE_CHAR_MULTIBYTE. All callers changed. (CHAR_STRING_ADVANCE): Remove; all callers changed to use CHAR_STRING. (NEXT_CHAR_BOUNDARY): Remove; it was unused. (raw_prev_char_len): New inline function, replacing the old PREV_CHAR_BOUNDARY macro. All callers changed. (string_char_and_length): New inline function, replacing the old STRING_CHAR_AND_LENGTH macro. All callers changed. (STRING_CHAR): Rewrite in terms of string_char_and_length. (string_char_advance): New inline function, replacing the old STRING_CHAR_ADVANCE macro. All callers changed. (fetch_string_char_advance): New inline function, replacing the old FETCH_STRING_CHAR_ADVANCE macro. All callers changed. (fetch_string_char_as_multibyte_advance): New inline function, replacing the old FETCH_STRING_CHAR_AS_MULTIBYTE_ADVANCE macro. All callers changed. (fetch_string_char_advance_no_check): New inline function, replacing the old FETCH_STRING_CHAR_ADVANCE_NO_CHECK macro. All callers changed. * src/regex-emacs.c (HEAD_ADDR_VSTRING): Remove; no longer used. * src/syntax.c (scan_lists): Use dec_bytepos instead of open-coding it. * src/xdisp.c (string_char_and_length): Rename from string_char_and_length to avoid name conflict with new function in character.h. All callers changed.
Diffstat (limited to 'src/font.c')
-rw-r--r--src/font.c38
1 files changed, 17 insertions, 21 deletions
diff --git a/src/font.c b/src/font.c
index 0c9e752e089..ab00402b40b 100644
--- a/src/font.c
+++ b/src/font.c
@@ -3856,13 +3856,10 @@ font_range (ptrdiff_t pos, ptrdiff_t pos_byte, ptrdiff_t *limit,
3856 3856
3857 while (pos < *limit) 3857 while (pos < *limit)
3858 { 3858 {
3859 Lisp_Object category; 3859 c = (NILP (string)
3860 3860 ? fetch_char_advance_no_check (&pos, &pos_byte)
3861 if (NILP (string)) 3861 : fetch_string_char_advance_no_check (string, &pos, &pos_byte));
3862 FETCH_CHAR_ADVANCE_NO_CHECK (c, pos, pos_byte); 3862 Lisp_Object category = CHAR_TABLE_REF (Vunicode_category_table, c);
3863 else
3864 FETCH_STRING_CHAR_ADVANCE_NO_CHECK (c, string, pos, pos_byte);
3865 category = CHAR_TABLE_REF (Vunicode_category_table, c);
3866 if (FIXNUMP (category) 3863 if (FIXNUMP (category)
3867 && (XFIXNUM (category) == UNICODE_CATEGORY_Cf 3864 && (XFIXNUM (category) == UNICODE_CATEGORY_Cf
3868 || CHAR_VARIATION_SELECTOR_P (c))) 3865 || CHAR_VARIATION_SELECTOR_P (c)))
@@ -4891,7 +4888,7 @@ the corresponding element is nil. */)
4891 Lisp_Object object) 4888 Lisp_Object object)
4892{ 4889{
4893 struct font *font = CHECK_FONT_GET_OBJECT (font_object); 4890 struct font *font = CHECK_FONT_GET_OBJECT (font_object);
4894 ptrdiff_t i, len; 4891 ptrdiff_t len;
4895 Lisp_Object *chars, vec; 4892 Lisp_Object *chars, vec;
4896 USE_SAFE_ALLOCA; 4893 USE_SAFE_ALLOCA;
4897 4894
@@ -4906,10 +4903,9 @@ the corresponding element is nil. */)
4906 SAFE_ALLOCA_LISP (chars, len); 4903 SAFE_ALLOCA_LISP (chars, len);
4907 charpos = XFIXNAT (from); 4904 charpos = XFIXNAT (from);
4908 bytepos = CHAR_TO_BYTE (charpos); 4905 bytepos = CHAR_TO_BYTE (charpos);
4909 for (i = 0; charpos < XFIXNAT (to); i++) 4906 for (ptrdiff_t i = 0; charpos < XFIXNAT (to); i++)
4910 { 4907 {
4911 int c; 4908 int c = fetch_char_advance (&charpos, &bytepos);
4912 FETCH_CHAR_ADVANCE (c, charpos, bytepos);
4913 chars[i] = make_fixnum (c); 4909 chars[i] = make_fixnum (c);
4914 } 4910 }
4915 } 4911 }
@@ -4929,18 +4925,18 @@ the corresponding element is nil. */)
4929 int c; 4925 int c;
4930 4926
4931 /* Skip IFROM characters from the beginning. */ 4927 /* Skip IFROM characters from the beginning. */
4932 for (i = 0; i < ifrom; i++) 4928 for (ptrdiff_t i = 0; i < ifrom; i++)
4933 c = STRING_CHAR_ADVANCE (p); 4929 p += BYTES_BY_CHAR_HEAD (*p);
4934 4930
4935 /* Now fetch an interesting characters. */ 4931 /* Now fetch an interesting characters. */
4936 for (i = 0; i < len; i++) 4932 for (ptrdiff_t i = 0; i < len; i++)
4937 { 4933 {
4938 c = STRING_CHAR_ADVANCE (p); 4934 c = string_char_advance (&p);
4939 chars[i] = make_fixnum (c); 4935 chars[i] = make_fixnum (c);
4940 } 4936 }
4941 } 4937 }
4942 else 4938 else
4943 for (i = 0; i < len; i++) 4939 for (ptrdiff_t i = 0; i < len; i++)
4944 chars[i] = make_fixnum (p[ifrom + i]); 4940 chars[i] = make_fixnum (p[ifrom + i]);
4945 } 4941 }
4946 else if (VECTORP (object)) 4942 else if (VECTORP (object))
@@ -4951,7 +4947,7 @@ the corresponding element is nil. */)
4951 if (ifrom == ito) 4947 if (ifrom == ito)
4952 return Qnil; 4948 return Qnil;
4953 len = ito - ifrom; 4949 len = ito - ifrom;
4954 for (i = 0; i < len; i++) 4950 for (ptrdiff_t i = 0; i < len; i++)
4955 { 4951 {
4956 Lisp_Object elt = AREF (object, ifrom + i); 4952 Lisp_Object elt = AREF (object, ifrom + i);
4957 CHECK_CHARACTER (elt); 4953 CHECK_CHARACTER (elt);
@@ -4962,7 +4958,7 @@ the corresponding element is nil. */)
4962 wrong_type_argument (Qarrayp, object); 4958 wrong_type_argument (Qarrayp, object);
4963 4959
4964 vec = make_uninit_vector (len); 4960 vec = make_uninit_vector (len);
4965 for (i = 0; i < len; i++) 4961 for (ptrdiff_t i = 0; i < len; i++)
4966 { 4962 {
4967 Lisp_Object g; 4963 Lisp_Object g;
4968 int c = XFIXNAT (chars[i]); 4964 int c = XFIXNAT (chars[i]);