]> granicus.if.org Git - vim/commitdiff
patch 8.2.0928: many type casts are used for vim_strnsave() v8.2.0928
authorBram Moolenaar <Bram@vim.org>
Sun, 7 Jun 2020 18:49:05 +0000 (20:49 +0200)
committerBram Moolenaar <Bram@vim.org>
Sun, 7 Jun 2020 18:49:05 +0000 (20:49 +0200)
Problem:    Many type casts are used for vim_strnsave().
Solution:   Make the length argument size_t instead of int. (Ken Takata,
            closes #5633)  Remove some type casts.

13 files changed:
src/autocmd.c
src/channel.c
src/cmdexpand.c
src/dict.c
src/diff.c
src/digraph.c
src/eval.c
src/evalfunc.c
src/highlight.c
src/misc2.c
src/proto/misc2.pro
src/syntax.c
src/version.c

index d6945f30625b214c5a0325abd9896210a54efb59..937e74187ff579562726fc7e60c26ab6b5e72e4c 100644 (file)
@@ -763,7 +763,7 @@ au_event_disable(char *what)
     save_ei = vim_strsave(p_ei);
     if (save_ei != NULL)
     {
-       new_ei = vim_strnsave(p_ei, (int)(STRLEN(p_ei) + STRLEN(what)));
+       new_ei = vim_strnsave(p_ei, STRLEN(p_ei) + STRLEN(what));
        if (new_ei != NULL)
        {
            if (*what == ',' && *p_ei == NUL)
@@ -991,7 +991,7 @@ au_get_grouparg(char_u **argp)
        ;
     if (p > arg)
     {
-       group_name = vim_strnsave(arg, (int)(p - arg));
+       group_name = vim_strnsave(arg, p - arg);
        if (group_name == NULL)         // out of memory
            return AUGROUP_ERROR;
        group = au_find_group(group_name);
index d11b148a89a2bc68df7324a83b4917e7756f7302..740329f1098680be19e6a1e80ddaf4cecb580d69 100644 (file)
@@ -2906,7 +2906,7 @@ may_invoke_callback(channel_T *channel, ch_part_T part)
            {
                // Copy the message into allocated memory (excluding the NL)
                // and remove it from the buffer (including the NL).
-               msg = vim_strnsave(buf, (int)(nl - buf));
+               msg = vim_strnsave(buf, nl - buf);
                channel_consume(channel, part, (int)(nl - buf) + 1);
            }
        }
@@ -3703,7 +3703,7 @@ channel_read_block(
        {
            // Copy the message into allocated memory and remove it from the
            // buffer.
-           msg = vim_strnsave(buf, (int)(nl - buf));
+           msg = vim_strnsave(buf, nl - buf);
            channel_consume(channel, part, (int)(nl - buf) + 1);
        }
     }
index f84bf7abc686f2f9f37a88d33e744a04e187daa3..1e33987131c9dd9ea6b7b24151ea704611ab9f83 100644 (file)
@@ -2555,7 +2555,7 @@ ExpandUserDefined(
        {
            if (ga_grow(&ga, 1) == FAIL)
                break;
-           ((char_u **)ga.ga_data)[ga.ga_len] = vim_strnsave(s, (int)(e - s));
+           ((char_u **)ga.ga_data)[ga.ga_len] = vim_strnsave(s, e - s);
            ++ga.ga_len;
        }
 
index 3824f407cbada923edd6d3ab26e0b6061f59c652..9d942619864c10942b9fc7a9de0bd9601a94a87e 100644 (file)
@@ -779,7 +779,7 @@ get_literal_key(char_u **arg, typval_T *tv)
     for (p = *arg; ASCII_ISALNUM(*p) || *p == '_' || *p == '-'; ++p)
        ;
     tv->v_type = VAR_STRING;
-    tv->vval.v_string = vim_strnsave(*arg, (int)(p - *arg));
+    tv->vval.v_string = vim_strnsave(*arg, p - *arg);
 
     *arg = skipwhite(p);
     return OK;
index 88dc8a653849902973dda2f2ced4e27cb34a8495..1b0ad47782181b1cff7d23249d570174f869efc0 100644 (file)
@@ -1301,7 +1301,7 @@ ex_diffpatch(exarg_T *eap)
        if (curbuf->b_fname != NULL)
        {
            newname = vim_strnsave(curbuf->b_fname,
-                                         (int)(STRLEN(curbuf->b_fname) + 4));
+                                                 STRLEN(curbuf->b_fname) + 4);
            if (newname != NULL)
                STRCAT(newname, ".new");
        }
index dd5920a24fa59414a131d15c08331bc1d4d2d567..d4175d5db9a0d5d86f8d731dab51c970e584c7d2 100644 (file)
@@ -2387,10 +2387,10 @@ ex_loadkeymap(exarg_T *eap)
        {
            kp = (kmap_T *)curbuf->b_kmap_ga.ga_data + curbuf->b_kmap_ga.ga_len;
            s = skiptowhite(p);
-           kp->from = vim_strnsave(p, (int)(s - p));
+           kp->from = vim_strnsave(p, s - p);
            p = skipwhite(s);
            s = skiptowhite(p);
-           kp->to = vim_strnsave(p, (int)(s - p));
+           kp->to = vim_strnsave(p, s - p);
 
            if (kp->from == NULL || kp->to == NULL
                    || STRLEN(kp->from) + STRLEN(kp->to) >= KMAP_LLEN
index b1842647e6e0b76a030f054c9c45854864e3abc7..6ca3628865bf045f854258275b124fc2c2ea1d98 100644 (file)
@@ -3139,7 +3139,7 @@ eval_index(
                    if (n1 >= len || n2 < 0 || n1 > n2)
                        s = NULL;
                    else
-                       s = vim_strnsave(s + n1, (int)(n2 - n1 + 1));
+                       s = vim_strnsave(s + n1, n2 - n1 + 1);
                }
                else
                {
index cdc806db2b5042f9b1b88d70ffbf2920e6c4a4da..44145097dbbb3d8ce4436d2ce09b4441bfccb337 100644 (file)
@@ -5521,7 +5521,7 @@ find_some_match(typval_T *argvars, typval_T *rettv, matchtype_T type)
 
                vim_free(li1->li_tv.vval.v_string);
                li1->li_tv.vval.v_string = vim_strnsave(regmatch.startp[0],
-                               (int)(regmatch.endp[0] - regmatch.startp[0]));
+                                       regmatch.endp[0] - regmatch.startp[0]);
                li3->li_tv.vval.v_number =
                                      (varnumber_T)(regmatch.startp[0] - expr);
                li4->li_tv.vval.v_number =
@@ -5556,7 +5556,7 @@ find_some_match(typval_T *argvars, typval_T *rettv, matchtype_T type)
                    copy_tv(&li->li_tv, rettv);
                else
                    rettv->vval.v_string = vim_strnsave(regmatch.startp[0],
-                               (int)(regmatch.endp[0] - regmatch.startp[0]));
+                                       regmatch.endp[0] - regmatch.startp[0]);
            }
            else if (l != NULL)
                rettv->vval.v_number = idx;
@@ -8861,7 +8861,7 @@ f_trim(typval_T *argvars, typval_T *rettv)
            }
        }
     }
-    rettv->vval.v_string = vim_strnsave(head, (int)(tail - head));
+    rettv->vval.v_string = vim_strnsave(head, tail - head);
 }
 
 #ifdef FEAT_FLOAT
index 6291f24aca72508761feef9b0c34203603463184..5d123ac877e73cb42d6ee4d7c081294e11892af6 100644 (file)
@@ -906,7 +906,7 @@ do_highlight(
        while (*linep && !VIM_ISWHITE(*linep) && *linep != '=')
            ++linep;
        vim_free(key);
-       key = vim_strnsave_up(key_start, (int)(linep - key_start));
+       key = vim_strnsave_up(key_start, linep - key_start);
        if (key == NULL)
        {
            error = TRUE;
index 02fd4187ca2ce16d3908f08c0ed98f3520ba06a4..41b9f711e7cb26ea9ad5ec678dfe872d62f5ed3e 100644 (file)
@@ -1291,7 +1291,7 @@ vim_strsave(char_u *string)
  * shorter.
  */
     char_u *
-vim_strnsave(char_u *string, int len)
+vim_strnsave(char_u *string, size_t len)
 {
     char_u     *p;
 
@@ -1538,7 +1538,7 @@ vim_strsave_up(char_u *string)
  * This uses ASCII lower-to-upper case translation, language independent.
  */
     char_u *
-vim_strnsave_up(char_u *string, int len)
+vim_strnsave_up(char_u *string, size_t len)
 {
     char_u *p1;
 
index 44f22f266948689acf399739dd000455cdbc4b66..347745252531f1801f712ec1eba3b53df17f5a24 100644 (file)
@@ -32,14 +32,14 @@ void *mem_realloc(void *ptr, size_t size);
 void do_outofmem_msg(size_t size);
 void free_all_mem(void);
 char_u *vim_strsave(char_u *string);
-char_u *vim_strnsave(char_u *string, int len);
+char_u *vim_strnsave(char_u *string, size_t len);
 char_u *vim_memsave(char_u *p, size_t len);
 char_u *vim_strsave_escaped(char_u *string, char_u *esc_chars);
 char_u *vim_strsave_escaped_ext(char_u *string, char_u *esc_chars, int cc, int bsl);
 int csh_like_shell(void);
 char_u *vim_strsave_shellescape(char_u *string, int do_special, int do_newline);
 char_u *vim_strsave_up(char_u *string);
-char_u *vim_strnsave_up(char_u *string, int len);
+char_u *vim_strnsave_up(char_u *string, size_t len);
 void vim_strup(char_u *p);
 char_u *strup_save(char_u *orig);
 char_u *strlow_save(char_u *orig);
index f2f74a181a8c4e9472835a2a01731107e21e7f04..5c9dd0b0225c76591d80637391a213060fed80c8 100644 (file)
@@ -5097,7 +5097,7 @@ syn_cmd_region(
        while (*key_end && !VIM_ISWHITE(*key_end) && *key_end != '=')
            ++key_end;
        vim_free(key);
-       key = vim_strnsave_up(rest, (int)(key_end - rest));
+       key = vim_strnsave_up(rest, key_end - rest);
        if (key == NULL)                        // out of memory
        {
            rest = NULL;
@@ -5762,7 +5762,7 @@ syn_cmd_sync(exarg_T *eap, int syncing UNUSED)
        arg_end = skiptowhite(arg_start);
        next_arg = skipwhite(arg_end);
        vim_free(key);
-       key = vim_strnsave_up(arg_start, (int)(arg_end - arg_start));
+       key = vim_strnsave_up(arg_start, arg_end - arg_start);
        if (STRCMP(key, "CCOMMENT") == 0)
        {
            if (!eap->skip)
index 32264ca87d3ac11b8957715f2bcc5af467137deb..3eb845c36e30abddab1b5eeb4b8a0a1b602594df 100644 (file)
@@ -754,6 +754,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    928,
 /**/
     927,
 /**/