diff options
Diffstat (limited to 'src/nvim/strings.c')
| -rw-r--r-- | src/nvim/strings.c | 28 | 
1 files changed, 6 insertions, 22 deletions
diff --git a/src/nvim/strings.c b/src/nvim/strings.c index 3f31914c03..f24de72743 100644 --- a/src/nvim/strings.c +++ b/src/nvim/strings.c @@ -344,14 +344,17 @@ char *strcase_save(const char *const orig, bool upper)    char *p = res;    while (*p != NUL) { -    int l; -      int c = utf_ptr2char((const char_u *)p); +    int l = utf_ptr2len((const char_u *)p); +    if (c == 0) { +      // overlong sequence, use only the first byte +      c = *p; +      l = 1; +    }      int uc = upper ? mb_toupper(c) : mb_tolower(c);      // Reallocate string when byte count changes.  This is rare,      // thus it's OK to do another malloc()/free(). -    l = utf_ptr2len((const char_u *)p);      int newl = utf_char2len(uc);      if (newl != l) {        // TODO(philix): use xrealloc() in strup_save() @@ -456,25 +459,6 @@ char_u *vim_strchr(const char_u *const string, const int c)  }  /* - * Search for last occurrence of "c" in "string". - * Return NULL if not found. - * Does not handle multi-byte char for "c"! - */ -char_u *vim_strrchr(const char_u *string, int c) -  FUNC_ATTR_NONNULL_ALL FUNC_ATTR_PURE -{ -  const char_u *retval = NULL; -  const char_u *p = string; - -  while (*p) { -    if (*p == c) -      retval = p; -    MB_PTR_ADV(p); -  } -  return (char_u *) retval; -} - -/*   * Sort an array of strings.   */  | 
