aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/strings.c
diff options
context:
space:
mode:
authorMatthieu Coudron <mattator@gmail.com>2020-11-14 19:35:26 +0100
committerGitHub <noreply@github.com>2020-11-14 19:35:26 +0100
commit27d630926cab78511075159012ce6ac920d8747e (patch)
treedb9afbe90762056b2f2c538744ce04d571108b89 /src/nvim/strings.c
parentd8c69adbabe963142f433a2ddad172ff46413f15 (diff)
parent5d6ecfa3c7447009da75842c611ea1b9f1db83e7 (diff)
downloadrneovim-27d630926cab78511075159012ce6ac920d8747e.tar.gz
rneovim-27d630926cab78511075159012ce6ac920d8747e.tar.bz2
rneovim-27d630926cab78511075159012ce6ac920d8747e.zip
Merge pull request #13275 from janlazo/vim-8.1.0805
vim-patch:8.1.{805,806,809,810,811}
Diffstat (limited to 'src/nvim/strings.c')
-rw-r--r--src/nvim/strings.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/nvim/strings.c b/src/nvim/strings.c
index 2f5491fda5..81a1a68a94 100644
--- a/src/nvim/strings.c
+++ b/src/nvim/strings.c
@@ -94,8 +94,8 @@ char_u *vim_strsave_escaped_ext(const char_u *string, const char_u *esc_chars,
*/
size_t length = 1; // count the trailing NUL
for (const char_u *p = string; *p; p++) {
- size_t l;
- if (has_mbyte && (l = (size_t)(*mb_ptr2len)(p)) > 1) {
+ const size_t l = (size_t)(utfc_ptr2len(p));
+ if (l > 1) {
length += l; // count a multibyte char
p += l - 1;
continue;
@@ -108,8 +108,8 @@ char_u *vim_strsave_escaped_ext(const char_u *string, const char_u *esc_chars,
char_u *escaped_string = xmalloc(length);
char_u *p2 = escaped_string;
for (const char_u *p = string; *p; p++) {
- size_t l;
- if (has_mbyte && (l = (size_t)(*mb_ptr2len)(p)) > 1) {
+ const size_t l = (size_t)(utfc_ptr2len(p));
+ if (l > 1) {
memcpy(p2, p, l);
p2 += l;
p += l - 1; /* skip multibyte char */
@@ -349,7 +349,7 @@ char *strcase_save(const char *const orig, bool upper)
// thus it's OK to do another malloc()/free().
int newl = utf_char2len(uc);
if (newl != l) {
- // TODO(philix): use xrealloc() in strup_save()
+ // TODO(philix): use xrealloc() in strcase_save()
char *s = xmalloc(STRLEN(res) + (size_t)(1 + newl - l));
memcpy(s, res, (size_t)(p - res));
STRCPY(s + (p - res) + newl, p + l);