diff options
author | dundargoc <33953936+dundargoc@users.noreply.github.com> | 2022-08-02 11:52:33 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-02 11:52:33 +0200 |
commit | c223875a65dd703e42956e064239369817faa0b2 (patch) | |
tree | 1fdb2f144ef4d9e8650f87344149c00a5eb47b8d /src/nvim/mbyte.c | |
parent | 0a049c322fda5f2bb124429086c2713ff99c7142 (diff) | |
download | rneovim-c223875a65dd703e42956e064239369817faa0b2.tar.gz rneovim-c223875a65dd703e42956e064239369817faa0b2.tar.bz2 rneovim-c223875a65dd703e42956e064239369817faa0b2.zip |
refactor: rename function prefix mb to the more accurate utf_cp (#19590)
The "cp" stands for codepoint.
Closes https://github.com/neovim/neovim/issues/7401
Diffstat (limited to 'src/nvim/mbyte.c')
-rw-r--r-- | src/nvim/mbyte.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c index cf4ac27d1a..223b4d6845 100644 --- a/src/nvim/mbyte.c +++ b/src/nvim/mbyte.c @@ -1837,10 +1837,10 @@ int mb_off_next(const char_u *base, const char_u *p) return i; } -/// Return the offset from "p" to the last byte of the character it points -/// into. Can start anywhere in a stream of bytes. -/// Composing characters are not included. -int mb_tail_off(const char *base, const char *p_in) +/// Return the offset from `p_in` to the last byte of the codepoint it points +/// to. Can start anywhere in a stream of bytes. +/// Note: Counts individual codepoints of composed characters separately. +int utf_cp_tail_off(const char *base, const char *p_in) { const uint8_t *p = (uint8_t *)p_in; int i; @@ -1866,15 +1866,16 @@ int mb_tail_off(const char *base, const char *p_in) return i; } -/// Return the offset from "p" to the first byte of the character it points -/// into. Can start anywhere in a stream of bytes. -/// Unlike utf_head_off() this doesn't include composing characters and returns a negative value. +/// Return the offset from "p" to the first byte of the codepoint it points +/// to. Can start anywhere in a stream of bytes. +/// Note: Unlike `utf_head_off`, this counts individual codepoints of composed characters +/// separately and returns a negative offset. /// /// @param[in] base Pointer to start of string /// @param[in] p Pointer to byte for which to return the offset to the previous codepoint // /// @return 0 if invalid sequence, else offset to previous codepoint -int mb_head_off(const char_u *base, const char_u *p) +int utf_cp_head_off(const char_u *base, const char_u *p) { int i; int j; |