aboutsummaryrefslogtreecommitdiffstats
path: root/src/buffer.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/buffer.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/buffer.c')
-rw-r--r--src/buffer.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/buffer.c b/src/buffer.c
index f3532a86189..5398414e6eb 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -2308,7 +2308,7 @@ advance_to_char_boundary (ptrdiff_t byte_pos)
2308 c = FETCH_BYTE (byte_pos); 2308 c = FETCH_BYTE (byte_pos);
2309 } 2309 }
2310 while (! CHAR_HEAD_P (c) && byte_pos > BEG); 2310 while (! CHAR_HEAD_P (c) && byte_pos > BEG);
2311 INC_POS (byte_pos); 2311 byte_pos += next_char_len (byte_pos);
2312 if (byte_pos < orig_byte_pos) 2312 if (byte_pos < orig_byte_pos)
2313 byte_pos = orig_byte_pos; 2313 byte_pos = orig_byte_pos;
2314 /* If C is a constituent of a multibyte sequence, BYTE_POS was 2314 /* If C is a constituent of a multibyte sequence, BYTE_POS was
@@ -2552,8 +2552,6 @@ current buffer is cleared. */)
2552 p = BEG_ADDR; 2552 p = BEG_ADDR;
2553 while (1) 2553 while (1)
2554 { 2554 {
2555 int c, bytes;
2556
2557 if (pos == stop) 2555 if (pos == stop)
2558 { 2556 {
2559 if (pos == Z) 2557 if (pos == Z)
@@ -2565,7 +2563,7 @@ current buffer is cleared. */)
2565 p++, pos++; 2563 p++, pos++;
2566 else if (CHAR_BYTE8_HEAD_P (*p)) 2564 else if (CHAR_BYTE8_HEAD_P (*p))
2567 { 2565 {
2568 c = STRING_CHAR_AND_LENGTH (p, bytes); 2566 int bytes, c = string_char_and_length (p, &bytes);
2569 /* Delete all bytes for this 8-bit character but the 2567 /* Delete all bytes for this 8-bit character but the
2570 last one, and change the last one to the character 2568 last one, and change the last one to the character
2571 code. */ 2569 code. */
@@ -2582,7 +2580,7 @@ current buffer is cleared. */)
2582 } 2580 }
2583 else 2581 else
2584 { 2582 {
2585 bytes = BYTES_BY_CHAR_HEAD (*p); 2583 int bytes = BYTES_BY_CHAR_HEAD (*p);
2586 p += bytes, pos += bytes; 2584 p += bytes, pos += bytes;
2587 } 2585 }
2588 } 2586 }