aboutsummaryrefslogtreecommitdiffstats
path: root/src/editfns.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/editfns.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/editfns.c')
-rw-r--r--src/editfns.c26
1 files changed, 12 insertions, 14 deletions
diff --git a/src/editfns.c b/src/editfns.c
index 90520d0dced..d9da119845a 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -999,7 +999,7 @@ At the beginning of the buffer or accessible region, return 0. */)
999 else if (!NILP (BVAR (current_buffer, enable_multibyte_characters))) 999 else if (!NILP (BVAR (current_buffer, enable_multibyte_characters)))
1000 { 1000 {
1001 ptrdiff_t pos = PT_BYTE; 1001 ptrdiff_t pos = PT_BYTE;
1002 DEC_POS (pos); 1002 pos -= prev_char_len (pos);
1003 XSETFASTINT (temp, FETCH_CHAR (pos)); 1003 XSETFASTINT (temp, FETCH_CHAR (pos));
1004 } 1004 }
1005 else 1005 else
@@ -1112,7 +1112,7 @@ If POS is out of range, the value is nil. */)
1112 1112
1113 if (!NILP (BVAR (current_buffer, enable_multibyte_characters))) 1113 if (!NILP (BVAR (current_buffer, enable_multibyte_characters)))
1114 { 1114 {
1115 DEC_POS (pos_byte); 1115 pos_byte -= prev_char_len (pos_byte);
1116 XSETFASTINT (val, FETCH_CHAR (pos_byte)); 1116 XSETFASTINT (val, FETCH_CHAR (pos_byte));
1117 } 1117 }
1118 else 1118 else
@@ -1549,7 +1549,7 @@ from adjoining text, if those properties are sticky. */)
1549 make_uninit_string, which can cause the buffer arena to be 1549 make_uninit_string, which can cause the buffer arena to be
1550 compacted. make_string has no way of knowing that the data has 1550 compacted. make_string has no way of knowing that the data has
1551 been moved, and thus copies the wrong data into the string. This 1551 been moved, and thus copies the wrong data into the string. This
1552 doesn't effect most of the other users of make_string, so it should 1552 doesn't affect most of the other users of make_string, so it should
1553 be left as is. But we should use this function when conjuring 1553 be left as is. But we should use this function when conjuring
1554 buffer substrings. */ 1554 buffer substrings. */
1555 1555
@@ -1830,26 +1830,24 @@ determines whether case is significant or ignored. */)
1830 if (! NILP (BVAR (bp1, enable_multibyte_characters))) 1830 if (! NILP (BVAR (bp1, enable_multibyte_characters)))
1831 { 1831 {
1832 c1 = BUF_FETCH_MULTIBYTE_CHAR (bp1, i1_byte); 1832 c1 = BUF_FETCH_MULTIBYTE_CHAR (bp1, i1_byte);
1833 BUF_INC_POS (bp1, i1_byte); 1833 i1_byte += buf_next_char_len (bp1, i1_byte);
1834 i1++; 1834 i1++;
1835 } 1835 }
1836 else 1836 else
1837 { 1837 {
1838 c1 = BUF_FETCH_BYTE (bp1, i1); 1838 c1 = make_char_multibyte (BUF_FETCH_BYTE (bp1, i1));
1839 MAKE_CHAR_MULTIBYTE (c1);
1840 i1++; 1839 i1++;
1841 } 1840 }
1842 1841
1843 if (! NILP (BVAR (bp2, enable_multibyte_characters))) 1842 if (! NILP (BVAR (bp2, enable_multibyte_characters)))
1844 { 1843 {
1845 c2 = BUF_FETCH_MULTIBYTE_CHAR (bp2, i2_byte); 1844 c2 = BUF_FETCH_MULTIBYTE_CHAR (bp2, i2_byte);
1846 BUF_INC_POS (bp2, i2_byte); 1845 i2_byte += buf_next_char_len (bp2, i2_byte);
1847 i2++; 1846 i2++;
1848 } 1847 }
1849 else 1848 else
1850 { 1849 {
1851 c2 = BUF_FETCH_BYTE (bp2, i2); 1850 c2 = make_char_multibyte (BUF_FETCH_BYTE (bp2, i2));
1852 MAKE_CHAR_MULTIBYTE (c2);
1853 i2++; 1851 i2++;
1854 } 1852 }
1855 1853
@@ -2304,7 +2302,7 @@ Both characters must have the same length of multi-byte form. */)
2304 } 2302 }
2305 p = BYTE_POS_ADDR (pos_byte); 2303 p = BYTE_POS_ADDR (pos_byte);
2306 if (multibyte_p) 2304 if (multibyte_p)
2307 INC_POS (pos_byte_next); 2305 pos_byte_next += next_char_len (pos_byte_next);
2308 else 2306 else
2309 ++pos_byte_next; 2307 ++pos_byte_next;
2310 if (pos_byte_next - pos_byte == len 2308 if (pos_byte_next - pos_byte == len
@@ -2365,7 +2363,7 @@ Both characters must have the same length of multi-byte form. */)
2365 decrease it now. */ 2363 decrease it now. */
2366 pos--; 2364 pos--;
2367 else 2365 else
2368 INC_POS (pos_byte_next); 2366 pos_byte_next += next_char_len (pos_byte_next);
2369 2367
2370 if (! NILP (noundo)) 2368 if (! NILP (noundo))
2371 bset_undo_list (current_buffer, tem); 2369 bset_undo_list (current_buffer, tem);
@@ -2442,7 +2440,7 @@ check_translation (ptrdiff_t pos, ptrdiff_t pos_byte, ptrdiff_t end,
2442 memcpy (bufalloc, buf, sizeof initial_buf); 2440 memcpy (bufalloc, buf, sizeof initial_buf);
2443 buf = bufalloc; 2441 buf = bufalloc;
2444 } 2442 }
2445 buf[buf_used++] = STRING_CHAR_AND_LENGTH (p, len1); 2443 buf[buf_used++] = string_char_and_length (p, &len1);
2446 pos_byte += len1; 2444 pos_byte += len1;
2447 } 2445 }
2448 if (XFIXNUM (AREF (elt, i)) != buf[i]) 2446 if (XFIXNUM (AREF (elt, i)) != buf[i])
@@ -2501,7 +2499,7 @@ It returns the number of characters changed. */)
2501 int len, oc; 2499 int len, oc;
2502 2500
2503 if (multibyte) 2501 if (multibyte)
2504 oc = STRING_CHAR_AND_LENGTH (p, len); 2502 oc = string_char_and_length (p, &len);
2505 else 2503 else
2506 oc = *p, len = 1; 2504 oc = *p, len = 1;
2507 if (oc < translatable_chars) 2505 if (oc < translatable_chars)
@@ -2518,7 +2516,7 @@ It returns the number of characters changed. */)
2518 if (string_multibyte) 2516 if (string_multibyte)
2519 { 2517 {
2520 str = tt + string_char_to_byte (table, oc); 2518 str = tt + string_char_to_byte (table, oc);
2521 nc = STRING_CHAR_AND_LENGTH (str, str_len); 2519 nc = string_char_and_length (str, &str_len);
2522 } 2520 }
2523 else 2521 else
2524 { 2522 {