]> git.ipfire.org Git - thirdparty/vim.git/commit
patch 9.1.1076: vim_strnchr() is strange and unnecessary v9.1.1076
authorzeertzjq <zeertzjq@outlook.com>
Tue, 4 Feb 2025 15:48:36 +0000 (16:48 +0100)
committerChristian Brabandt <cb@256bit.org>
Tue, 4 Feb 2025 15:48:36 +0000 (16:48 +0100)
commit34e1e8de91ff4a8922d454e3147ea425784aa0a0
tree710a28a678c79fca63b022f9090aacc71e7d4a7b
parentf7cb9f9280c675537a1536864d58e32adf35d344
patch 9.1.1076: vim_strnchr() is strange and unnecessary

Problem:  vim_strnchr() is strange and unnecessary (after v9.1.1009)
Solution: Remove vim_strnchr() and use memchr() instead.  Also remove a
          comment referencing an #if that is no longer present.

vim_strnchr() is strange in several ways:
- It's named like vim_strchr(), but unlike vim_strchr() it doesn't
  support finding a multibyte char.
- Its logic is similar to vim_strbyte(), but unlike vim_strbyte() it
  uses char instead of char_u.
- It takes a pointer as its size argument, which isn't convenient for
  all its callers.
- It allows embedded NULs, unlike other "strn*" functions which stop
  when encountering a NUL byte.

In comparison, memchr() also allows embedded NULs, and it converts bytes
in the string to (unsigned char).

closes: #16579

Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/linematch.c
src/strings.c
src/version.c