diff options
author | Bram Moolenaar <Bram@vim.org> | 2017-01-26 22:51:56 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2017-01-26 22:51:56 +0100 |
commit | cc5b22b3bfdc0e9e835cf7871166badda31447bd (patch) | |
tree | 11e117ab82deca899a492b823dd0b0cb1c0ed37b /src/evalfunc.c | |
parent | 65c836e6004647196ae0bc18e409a9e7b79207c0 (diff) |
patch 8.0.0243: tolower() does not work if the byte count changesv8.0.0243
Problem: When making a character lower case with tolower() changes the byte
cound, it is not made lower case.
Solution: Add strlow_save(). (Dominique Pelle, closes #1406)
Diffstat (limited to 'src/evalfunc.c')
-rw-r--r-- | src/evalfunc.c | 33 |
1 files changed, 1 insertions, 32 deletions
diff --git a/src/evalfunc.c b/src/evalfunc.c index 9ebd2df41d..99d01c42de 100644 --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -12503,39 +12503,8 @@ f_timer_stopall(typval_T *argvars UNUSED, typval_T *rettv UNUSED) static void f_tolower(typval_T *argvars, typval_T *rettv) { - char_u *p; - - p = vim_strsave(get_tv_string(&argvars[0])); rettv->v_type = VAR_STRING; - rettv->vval.v_string = p; - - if (p != NULL) - while (*p != NUL) - { -#ifdef FEAT_MBYTE - int l; - - if (enc_utf8) - { - int c, lc; - - c = utf_ptr2char(p); - lc = utf_tolower(c); - l = utf_ptr2len(p); - /* TODO: reallocate string when byte count changes. */ - if (utf_char2len(lc) == l) - utf_char2bytes(lc, p); - p += l; - } - else if (has_mbyte && (l = (*mb_ptr2len)(p)) > 1) - p += l; /* skip multi-byte character */ - else -#endif - { - *p = TOLOWER_LOC(*p); /* note that tolower() can be a macro */ - ++p; - } - } + rettv->vval.v_string = strlow_save(get_tv_string(&argvars[0])); } /* |