]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0041: Not always using GA_CONCAT_LITERAL v9.2.0041
authorJohn Marriott <basilisk@internode.on.net>
Sat, 21 Feb 2026 17:24:47 +0000 (17:24 +0000)
committerChristian Brabandt <cb@256bit.org>
Sat, 21 Feb 2026 17:24:47 +0000 (17:24 +0000)
Problem:  Not always using GA_CONCAT_LITERAL with string literals.
          (after: v9.2.0031)
Solution: Use the GA_CONCAT_LITERAL, instead of ga_concat_len.
          (John Marriott)

closes: #19468

Signed-off-by: John Marriott <basilisk@internode.on.net>
Signed-off-by: Hirohito Higashi <h.east.727@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
17 files changed:
src/blob.c
src/cmdexpand.c
src/dict.c
src/eval.c
src/getchar.c
src/gui.c
src/if_xcmdsrv.c
src/job.c
src/os_mswin.c
src/regexp_nfa.c
src/scriptfile.c
src/terminal.c
src/userfunc.c
src/version.c
src/vim9class.c
src/vim9execute.c
src/vim9type.c

index e72b5d00a767f24256271929d4a0f1a5d3762f15..691c67958d7a7ddb990ddda3b12802ef9c947569 100644 (file)
@@ -276,13 +276,13 @@ blob2string(blob_T *blob, char_u **tofree, char_u *numbuf)
 
     // Store bytes in the growarray.
     ga_init2(&ga, 1, 4000);
-    ga_concat_len(&ga, (char_u *)"0z", 2);
+    GA_CONCAT_LITERAL(&ga, "0z");
     for (i = 0; i < blob_len(blob); i++)
     {
        size_t  numbuflen;
 
        if (i > 0 && (i & 3) == 0)
-           ga_concat_len(&ga, (char_u *)".", 1);
+           GA_CONCAT_LITERAL(&ga, ".");
        numbuflen = vim_snprintf_safelen((char *)numbuf, NUMBUFLEN,
            "%02X", blob_get(blob, i));
        ga_concat_len(&ga, numbuf, numbuflen);
index cac8aa90bf2b4cf54121e2ccfca3f2bc2d114257..61cfe5bc3b74aebfaafb26e85cfb81c44dd53dd7 100644 (file)
@@ -4763,7 +4763,7 @@ copy_substring_from_pos(pos_T *start, pos_T *end, char_u **match,
     if (!is_single_line)
     {
        if (exacttext)
-           ga_concat_len(&ga, (char_u *)"\\n", 2);
+           GA_CONCAT_LITERAL(&ga, "\\n");
        else
            ga_append(&ga, '\n');
     }
@@ -4781,7 +4781,7 @@ copy_substring_from_pos(pos_T *start, pos_T *end, char_u **match,
                return FAIL;
            ga_concat_len(&ga, line, linelen);
            if (exacttext)
-               ga_concat_len(&ga, (char_u *)"\\n", 2);
+               GA_CONCAT_LITERAL(&ga, "\\n");
            else
                ga_append(&ga, '\n');
        }
index b888a68983b1a8f45e5c7e5fa3581b76107e3986..d83024a97fe00d8566bd28ebca7dfe768262df3f 100644 (file)
@@ -817,7 +817,7 @@ dict2string(typval_T *tv, int copyID, int restore_copyID)
            if (first)
                first = FALSE;
            else
-               ga_concat_len(&ga, (char_u *)", ", 2);
+               GA_CONCAT_LITERAL(&ga, ", ");
 
            tofree = string_quote(hi->hi_key, FALSE);
            if (tofree != NULL)
@@ -825,7 +825,7 @@ dict2string(typval_T *tv, int copyID, int restore_copyID)
                ga_concat(&ga, tofree);
                vim_free(tofree);
            }
-           ga_concat_len(&ga, (char_u *)": ", 2);
+           GA_CONCAT_LITERAL(&ga, ": ");
            s = echo_string_core(&HI2DI(hi)->di_tv, &tofree, numbuf, copyID,
                                                 FALSE, restore_copyID, TRUE);
            if (s != NULL)
index 488818a4b05cc87f4527d6150166ba7ab02ff414..da95f90e8f6d70a2a5ce802cab76f5a3ed24b7c4 100644 (file)
@@ -6296,14 +6296,14 @@ partial_tv2string(
     fname = string_quote(pt == NULL ? NULL : partial_name(pt), FALSE);
 
     ga_init2(&ga, 1, 100);
-    ga_concat_len(&ga, (char_u *)"function(", 9);
+    GA_CONCAT_LITERAL(&ga, "function(");
     if (fname != NULL)
     {
        // When using uf_name prepend "g:" for a global function.
        if (pt != NULL && pt->pt_name == NULL && fname[0] == '\''
                                                && vim_isupper(fname[1]))
        {
-           ga_concat_len(&ga, (char_u *)"'g:", 3);
+           GA_CONCAT_LITERAL(&ga, "'g:");
            ga_concat(&ga, fname + 1);
        }
        else
@@ -6312,28 +6312,29 @@ partial_tv2string(
     }
     if (pt != NULL && pt->pt_argc > 0)
     {
-       ga_concat_len(&ga, (char_u *)", [", 3);
+       GA_CONCAT_LITERAL(&ga, ", [");
        for (i = 0; i < pt->pt_argc; ++i)
        {
            if (i > 0)
-               ga_concat_len(&ga, (char_u *)", ", 2);
+               GA_CONCAT_LITERAL(&ga, ", ");
            ga_concat(&ga, tv2string(&pt->pt_argv[i], &tf, numbuf, copyID));
            vim_free(tf);
        }
-       ga_concat_len(&ga, (char_u *)"]", 1);
+       GA_CONCAT_LITERAL(&ga, "]");
     }
     if (pt != NULL && pt->pt_dict != NULL)
     {
        typval_T dtv;
 
-       ga_concat_len(&ga, (char_u *)", ", 2);
+       GA_CONCAT_LITERAL(&ga, ", ");
        dtv.v_type = VAR_DICT;
        dtv.vval.v_dict = pt->pt_dict;
        ga_concat(&ga, tv2string(&dtv, &tf, numbuf, copyID));
        vim_free(tf);
     }
     // terminate with ')' and a NUL
-    ga_concat_len(&ga, (char_u *)")", 2);
+    GA_CONCAT_LITERAL(&ga, ")");
+    ga_append(&ga, NUL);
 
     *tofree = ga.ga_data;
     r = *tofree;
index bbd84c6f9582466a3e407ceac1f9ee316c8dde01..eaa7667950721a4a874bfc7d2e2b06387bd64afc 100644 (file)
@@ -4294,7 +4294,7 @@ getcmdkeycmd(
        }
        else if (c1 == K_SNR)
        {
-           ga_concat_len(&line_ga, (char_u *)"<SNR>", 5);
+           GA_CONCAT_LITERAL(&line_ga, "<SNR>");
        }
        else
        {
index 36616867368f672677a8973162996bfff292c65e..9bb9c98e8f7c7f593529995c8209431e4ed107cd 100644 (file)
--- a/src/gui.c
+++ b/src/gui.c
@@ -5310,26 +5310,26 @@ gui_do_findrepl(
 
     ga_init2(&ga, 1, 100);
     if (type == FRD_REPLACEALL)
-       ga_concat_len(&ga, (char_u *)"%s/", 3);
+       GA_CONCAT_LITERAL(&ga, "%s/");
 
-    ga_concat_len(&ga, (char_u *)"\\V", 2);
+    GA_CONCAT_LITERAL(&ga, "\\V");
     if (flags & FRD_MATCH_CASE)
-       ga_concat_len(&ga, (char_u *)"\\C", 2);
+       GA_CONCAT_LITERAL(&ga, "\\C");
     else
-       ga_concat_len(&ga, (char_u *)"\\c", 2);
+       GA_CONCAT_LITERAL(&ga, "\\c");
     if (flags & FRD_WHOLE_WORD)
-       ga_concat_len(&ga, (char_u *)"\\<", 2);
+       GA_CONCAT_LITERAL(&ga, "\\<");
     // escape slash and backslash
     p = vim_strsave_escaped(find_text, (char_u *)"/\\");
     if (p != NULL)
        ga_concat(&ga, p);
     vim_free(p);
     if (flags & FRD_WHOLE_WORD)
-       ga_concat_len(&ga, (char_u *)"\\>", 2);
+       GA_CONCAT_LITERAL(&ga, "\\>");
 
     if (type == FRD_REPLACEALL)
     {
-       ga_concat_len(&ga, (char_u *)"/", 1);
+       GA_CONCAT_LITERAL(&ga, "/");
        // Escape slash and backslash.
        // Also escape tilde and ampersand if 'magic' is set.
        p = vim_strsave_escaped(repl_text,
@@ -5337,7 +5337,7 @@ gui_do_findrepl(
        if (p != NULL)
            ga_concat(&ga, p);
        vim_free(p);
-       ga_concat_len(&ga, (char_u *)"/g", 2);
+       GA_CONCAT_LITERAL(&ga, "/g");
     }
     ga_append(&ga, NUL);
 
index b4736b3fb2a28545d2a02c12e8c22399f06f4baf..dba97be2c8c4a339e9676da0bc25c67d342f778e 100644 (file)
@@ -666,7 +666,7 @@ serverGetVimNames(Display *dpy)
            if (WindowValid(dpy, (Window)w))
            {
                ga_concat(&ga, p + 1);
-               ga_concat_len(&ga, (char_u *)"\n", 1);
+               GA_CONCAT_LITERAL(&ga, "\n");
            }
            while (*p != 0)
                p++;
@@ -1343,7 +1343,7 @@ server_parse_message(
                            ga_concat(&reply,
                                   (char_u *)_(e_invalid_expression_received));
                            ga_append(&reply, 0);
-                           ga_concat_len(&reply, (char_u *)"-c 1", 4);
+                           GA_CONCAT_LITERAL(&reply, "-c 1");
                        }
                        ga_append(&reply, NUL);
                        (void)AppendPropCarefully(dpy, resWindow, commProperty,
index cfa95783541f8fdd976333641c970ba894b214d5..5ce9a20cddfa3eaa207046b8fdb96d7c7ace0025 100644 (file)
--- a/src/job.c
+++ b/src/job.c
@@ -1452,7 +1452,7 @@ job_start(
        for (i = 0; i < argc; ++i)
        {
            if (i > 0)
-               ga_concat_len(&ga, (char_u *)"  ", 2);
+               GA_CONCAT_LITERAL(&ga, "  ");
            ga_concat(&ga, (char_u *)argv[i]);
        }
        ga_append(&ga, NUL);
index 9c2db64d6afaa961b591e1a045bea0c970818891..7118bc413aa3c4b0d857c5b2ec4069d1e149c72c 100644 (file)
@@ -2246,7 +2246,7 @@ enumWindowsGetNames(HWND hwnd, LPARAM lparam)
 
     // Add the name to the list
     ga_concat(ga, (char_u *)server);
-    ga_concat_len(ga, (char_u *)"\n", 1);
+    GA_CONCAT_LITERAL(ga, "\n");
     return TRUE;
 }
 
index 7d55278516d440b466d5982cba4ca78ae3b91ed2..6a9581d99356978130a8c5aabc8a428b37d9ce15 100644 (file)
@@ -2891,16 +2891,16 @@ nfa_print_state2(FILE *debugf, nfa_state_T *state, garray_T *indent)
     // grow indent for state->out
     indent->ga_len -= 1;
     if (state->out1)
-       ga_concat_len(indent, (char_u *)"| ", 2);
+       GA_CONCAT_LITERAL(indent, "| ");
     else
-       ga_concat_len(indent, (char_u *)"  ", 2);
+       GA_CONCAT_LITERAL(indent, "  ");
     ga_append(indent, NUL);
 
     nfa_print_state2(debugf, state->out, indent);
 
     // replace last part of indent for state->out1
     indent->ga_len -= 3;
-    ga_concat_len(indent, (char_u *)"  ", 2);
+    GA_CONCAT_LITERAL(indent, "  ");
     ga_append(indent, NUL);
 
     nfa_print_state2(debugf, state->out1, indent);
index 74ca9e1ccd9cd1bdb29b61a997dbb70c5ddeb09b..70cbe993e51ba716307e4053e625eb07bba6e5f6 100644 (file)
@@ -251,7 +251,7 @@ estack_sfile(estack_arg_T which UNUSED)
                ga.ga_len += (int)added;
            }
            if (idx != exestack.ga_len - 1)
-               ga_concat_len(&ga, (char_u *)"..", 2);
+               GA_CONCAT_LITERAL(&ga, "..");
        }
     }
 
@@ -2558,7 +2558,7 @@ getsourceline(
                ga_concat(&ga, p + 1);
            else if (*p == '|')
            {
-               ga_concat_len(&ga, (char_u *)" ", 1);
+               GA_CONCAT_LITERAL(&ga, " ");
                ga_concat(&ga, p);
            }
            for (;;)
@@ -2583,7 +2583,7 @@ getsourceline(
                        ga_concat(&ga, p + 1);
                    else
                    {
-                       ga_concat_len(&ga, (char_u *)" ", 1);
+                       GA_CONCAT_LITERAL(&ga, " ");
                        ga_concat(&ga, p);
                    }
                }
index 42eb5c823dd6cbd8ad486996a34b9c150ab43ba5..8a479f71df936498ae312fdba7623165abfb602a 100644 (file)
@@ -5401,7 +5401,7 @@ f_term_dumpwrite(typval_T *argvars, typval_T *rettv UNUSED)
     static void
 dump_is_corrupt(garray_T *gap)
 {
-    ga_concat_len(gap, (char_u *)"CORRUPT", 7);
+    GA_CONCAT_LITERAL(gap, "CORRUPT");
 }
 
     static void
index 479e220544454db8a0905afc756b4ccb10fbe1db..0d7cf23a0babf583d73c5aa37bf5ab4ba0041e39 100644 (file)
@@ -1405,7 +1405,7 @@ get_function_body(
            // For a :def function "python << EOF" concatenates all the lines,
            // to be used for the instruction later.
            ga_concat(&heredoc_ga, theline);
-           ga_concat_len(&heredoc_ga, (char_u *)"\n", 1);
+           GA_CONCAT_LITERAL(&heredoc_ga, "\n");
            p = vim_strnsave((char_u *)"", 0);
        }
        else
index ea286f11b24eea62a141671e291b19ac4d777c97..362d7df8579fa942726d8e3f46ddc99c14ae792d 100644 (file)
@@ -734,6 +734,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    41,
 /**/
     40,
 /**/
index 3dc4ddf8608b9ad507a2a23f59ea0c08303d6303..2148f0ffbd713d049ca9f65c8c79dd9822adbbbe 100644 (file)
@@ -1458,7 +1458,7 @@ add_default_constructor(
     int                is_enum = IS_ENUM(cl);
 
     ga_init2(&fga, 1, 1000);
-    ga_concat_len(&fga, (char_u *)"new(", 4);
+    GA_CONCAT_LITERAL(&fga, "new(");
     for (int i = 0; i < cl->class_obj_member_count; ++i)
     {
        if (i < 2 && is_enum)
@@ -1469,13 +1469,13 @@ add_default_constructor(
            continue;
 
        if (i > (is_enum ? 2 : 0))
-           ga_concat_len(&fga, (char_u *)", ", 2);
-       ga_concat_len(&fga, (char_u *)"this.", 5);
+           GA_CONCAT_LITERAL(&fga, ", ");
+       GA_CONCAT_LITERAL(&fga, "this.");
        ocmember_T *m = cl->class_obj_members + i;
        ga_concat_len(&fga, (char_u *)m->ocm_name.string, m->ocm_name.length);
-       ga_concat_len(&fga, (char_u *)" = v:none", 9);
+       GA_CONCAT_LITERAL(&fga, " = v:none");
     }
-    ga_concat_len(&fga, (char_u *)")\nenddef\n", 9);   // Note: not 11!
+    GA_CONCAT_LITERAL(&fga, ")\nenddef\n");
     ga_append(&fga, NUL);
 
     exarg_T fea;
@@ -1826,18 +1826,18 @@ enum_add_values_member(
     int                rc = FAIL;
 
     ga_init2(&fga, 1, 1000);
-    ga_concat_len(&fga, (char_u *)"[", 1);
+    GA_CONCAT_LITERAL(&fga, "[");
     for (int i = 0; i < num_enum_values; ++i)
     {
        ocmember_T *m = ((ocmember_T *)gap->ga_data) + i;
 
        if (i > 0)
-           ga_concat_len(&fga, (char_u *)", ", 2);
+           GA_CONCAT_LITERAL(&fga, ", ");
        ga_concat_len(&fga, en->class_name.string, en->class_name.length);
-       ga_concat_len(&fga, (char_u *)".", 1);
+       GA_CONCAT_LITERAL(&fga, ".");
        ga_concat_len(&fga, (char_u *)m->ocm_name.string, m->ocm_name.length);
     }
-    ga_concat_len(&fga, (char_u *)"]", 1);
+    GA_CONCAT_LITERAL(&fga, "]");
     ga_append(&fga, NUL);
 
     char_u *varname = (char_u *)"values";
@@ -4291,30 +4291,30 @@ object2string(
 
     if (cl != NULL && IS_ENUM(cl))
     {
-       ga_concat_len(&ga, (char_u *)"enum ", 5);
+       GA_CONCAT_LITERAL(&ga, "enum ");
        ga_concat_len(&ga, cl->class_name.string, cl->class_name.length);
        char_u *enum_name = ((typval_T *)(obj + 1))->vval.v_string;
-       ga_concat_len(&ga, (char_u *)".", 1);
+       GA_CONCAT_LITERAL(&ga, ".");
        ga_concat(&ga, enum_name);
     }
     else
     {
-       ga_concat_len(&ga, (char_u *)"object of ", 10);
+       GA_CONCAT_LITERAL(&ga, "object of ");
        if (cl == NULL)
-           ga_concat_len(&ga, (char_u *)"[unknown]", 9);
+           GA_CONCAT_LITERAL(&ga, "[unknown]");
        else
            ga_concat_len(&ga, cl->class_name.string, cl->class_name.length);
     }
     if (cl != NULL)
     {
-       ga_concat_len(&ga, (char_u *)" {", 2);
+       GA_CONCAT_LITERAL(&ga, " {");
        for (int i = 0; i < cl->class_obj_member_count; ++i)
        {
            if (i > 0)
-               ga_concat_len(&ga, (char_u *)", ", 2);
+               GA_CONCAT_LITERAL(&ga, ", ");
            ocmember_T *m = &cl->class_obj_members[i];
            ga_concat_len(&ga, m->ocm_name.string, m->ocm_name.length);
-           ga_concat_len(&ga, (char_u *)": ", 2);
+           GA_CONCAT_LITERAL(&ga, ": ");
            char_u *tf = NULL;
            char_u *s = echo_string_core((typval_T *)(obj + 1) + i,
                                         &tf, numbuf, copyID, echo_style,
@@ -4329,7 +4329,7 @@ object2string(
            }
            line_breakcheck();
        }
-       ga_concat_len(&ga, (char_u *)"}", 1);
+       GA_CONCAT_LITERAL(&ga, "}");
     }
     if (ok == FAIL)
     {
index bdea74f66a208217e0250773981e0bf6216eddf7..03417baaee0737fc4e4ab65a991a8537b32c126e 100644 (file)
@@ -1764,7 +1764,7 @@ do_2string(typval_T *tv, int is_2string_any, int tostring_flags)
                                        if (p != NULL)
                                        {
                                            ga_concat(&ga, p);
-                                           ga_concat_len(&ga, (char_u *)" ", 1);
+                                           GA_CONCAT_LITERAL(&ga, " ");
                                            vim_free(p);
                                        }
                                        s = e + 1;
index 938eee00c52795b7a8b61ed085aab0a5497c72ed..f6bf1b255d594addad4ce5395f6707109d43d76c 100644 (file)
@@ -2585,11 +2585,11 @@ type_name_tuple(type_T *type, char **tofree)
 
     if (type->tt_argcount <= 0)
        // empty tuple
-       ga_concat_len(&ga, (char_u *)"any", 3);
+       GA_CONCAT_LITERAL(&ga, "any");
     else
     {
        if (type->tt_args == NULL)
-           ga_concat_len(&ga, (char_u *)"[unknown]", 9);
+           GA_CONCAT_LITERAL(&ga, "[unknown]");
        else
        {
            for (i = 0; i < type->tt_argcount; ++i)
@@ -2606,7 +2606,7 @@ type_name_tuple(type_T *type, char **tofree)
                if (ga_grow(&ga, (int)arg_type.length + 8) == FAIL)
                    goto failed;
                if (varargs && i == type->tt_argcount - 1)
-                   ga_concat_len(&ga, (char_u *)"...", 3);
+                   GA_CONCAT_LITERAL(&ga, "...");
                ga_concat_len(&ga, arg_type.string, arg_type.length);
                VIM_CLEAR(arg_free);
            }
@@ -2694,7 +2694,7 @@ type_name_func(type_T *type, char **tofree)
        if (ga_grow(&ga, (int)arg_type.length + 8) == FAIL)
            goto failed;
        if (varargs && i == type->tt_argcount - 1)
-           ga_concat_len(&ga, (char_u *)"...", 3);
+           GA_CONCAT_LITERAL(&ga, "...");
        else if (i >= type->tt_min_argcount)
            *((char *)ga.ga_data + ga.ga_len++) = '?';
        ga_concat_len(&ga, arg_type.string, arg_type.length);
@@ -2702,7 +2702,7 @@ type_name_func(type_T *type, char **tofree)
     }
     if (type->tt_argcount < 0)
        // any number of arguments
-       ga_concat_len(&ga, (char_u *)"...", 3);
+       GA_CONCAT_LITERAL(&ga, "...");
 
     if (type->tt_member == &t_void)
        STRCPY((char *)ga.ga_data + ga.ga_len, ")");