diff options
author | Lewis Russell <lewis6991@gmail.com> | 2024-09-30 12:09:36 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-30 12:09:36 +0100 |
commit | 2c88cfcac42d0a4e0b1a1396539b5add807c336c (patch) | |
tree | 0301447a10df4021c0157e5e96738f4a6adbcc0d /src/nvim/strings.c | |
parent | 20251be15a4ad3f6e7016450ca3338d52b2f0951 (diff) | |
parent | 0fb5299e53cc0d7a5c03c333b1ed79262a0db3f9 (diff) | |
download | rneovim-2c88cfcac42d0a4e0b1a1396539b5add807c336c.tar.gz rneovim-2c88cfcac42d0a4e0b1a1396539b5add807c336c.tar.bz2 rneovim-2c88cfcac42d0a4e0b1a1396539b5add807c336c.zip |
Merge pull request #30526 from lewis6991/fix/linematchnul
Diffstat (limited to 'src/nvim/strings.c')
-rw-r--r-- | src/nvim/strings.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/nvim/strings.c b/src/nvim/strings.c index b7a87ae030..118abbae6d 100644 --- a/src/nvim/strings.c +++ b/src/nvim/strings.c @@ -496,6 +496,20 @@ char *vim_strchr(const char *const string, const int c) } } +// Sized version of strchr that can handle embedded NULs. +// Adjusts n to the new size. +char *strnchr(const char *p, size_t *n, int c) +{ + while (*n > 0) { + if (*p == c) { + return (char *)p; + } + p++; + (*n)--; + } + return NULL; +} + // Sort an array of strings. static int sort_compare(const void *s1, const void *s2) |