diff options
author | Claes Nästén <pekdon@gmail.com> | 2021-12-06 07:49:15 +0100 |
---|---|---|
committer | Claes Nästén <pekdon@gmail.com> | 2021-12-06 17:34:26 +0100 |
commit | 8f1fdbc54a873abc7375c785b2b6ee5440910de2 (patch) | |
tree | 3d2d70542b1b87a48d56252c25d6c0b15db83b41 /src/nvim/strings.c | |
parent | 8fdf1b265d982b80bfa8e6d98374514ece20a03e (diff) | |
download | rneovim-8f1fdbc54a873abc7375c785b2b6ee5440910de2.tar.gz rneovim-8f1fdbc54a873abc7375c785b2b6ee5440910de2.tar.bz2 rneovim-8f1fdbc54a873abc7375c785b2b6ee5440910de2.zip |
fix: add STRNLEN compatability macro
Older SunOS systems come without strnlen, add STRNLEN macro in line with
the other str* compat macros.
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. |