diff options
Diffstat (limited to 'src/nvim/strings.c')
-rw-r--r-- | src/nvim/strings.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/nvim/strings.c b/src/nvim/strings.c index c58e052ae9..27f93fe4ce 100644 --- a/src/nvim/strings.c +++ b/src/nvim/strings.c @@ -394,6 +394,18 @@ void del_trailing_spaces(char_u *ptr) } } +#if !defined(HAVE_STRNLEN) +size_t xstrnlen(const char *s, size_t n) + FUNC_ATTR_NONNULL_ALL FUNC_ATTR_PURE +{ + const char *end = memchr(s, '\0', n); + if (end == NULL) { + return n; + } + return end - s; +} +#endif + #if (!defined(HAVE_STRCASECMP) && !defined(HAVE_STRICMP)) /* * Compare two strings, ignoring case, using current locale. |