diff options
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) |