From: John Marriott Date: Sat, 21 Feb 2026 17:24:47 +0000 (+0000) Subject: patch 9.2.0041: Not always using GA_CONCAT_LITERAL X-Git-Tag: v9.2.0041^0 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=fc90d8087adc607ee92262f43b8c8c0ec17dbb86;p=thirdparty%2Fvim.git patch 9.2.0041: Not always using GA_CONCAT_LITERAL 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 Signed-off-by: Hirohito Higashi Signed-off-by: Christian Brabandt --- diff --git a/src/blob.c b/src/blob.c index e72b5d00a7..691c67958d 100644 --- a/src/blob.c +++ b/src/blob.c @@ -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); diff --git a/src/cmdexpand.c b/src/cmdexpand.c index cac8aa90bf..61cfe5bc3b 100644 --- a/src/cmdexpand.c +++ b/src/cmdexpand.c @@ -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'); } diff --git a/src/dict.c b/src/dict.c index b888a68983..d83024a97f 100644 --- a/src/dict.c +++ b/src/dict.c @@ -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) diff --git a/src/eval.c b/src/eval.c index 488818a4b0..da95f90e8f 100644 --- a/src/eval.c +++ b/src/eval.c @@ -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; diff --git a/src/getchar.c b/src/getchar.c index bbd84c6f95..eaa7667950 100644 --- a/src/getchar.c +++ b/src/getchar.c @@ -4294,7 +4294,7 @@ getcmdkeycmd( } else if (c1 == K_SNR) { - ga_concat_len(&line_ga, (char_u *)"", 5); + GA_CONCAT_LITERAL(&line_ga, ""); } else { diff --git a/src/gui.c b/src/gui.c index 3661686736..9bb9c98e8f 100644 --- 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); diff --git a/src/if_xcmdsrv.c b/src/if_xcmdsrv.c index b4736b3fb2..dba97be2c8 100644 --- a/src/if_xcmdsrv.c +++ b/src/if_xcmdsrv.c @@ -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, diff --git a/src/job.c b/src/job.c index cfa9578354..5ce9a20cdd 100644 --- 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); diff --git a/src/os_mswin.c b/src/os_mswin.c index 9c2db64d6a..7118bc413a 100644 --- a/src/os_mswin.c +++ b/src/os_mswin.c @@ -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; } diff --git a/src/regexp_nfa.c b/src/regexp_nfa.c index 7d55278516..6a9581d993 100644 --- a/src/regexp_nfa.c +++ b/src/regexp_nfa.c @@ -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); diff --git a/src/scriptfile.c b/src/scriptfile.c index 74ca9e1ccd..70cbe993e5 100644 --- a/src/scriptfile.c +++ b/src/scriptfile.c @@ -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); } } diff --git a/src/terminal.c b/src/terminal.c index 42eb5c823d..8a479f71df 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -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 diff --git a/src/userfunc.c b/src/userfunc.c index 479e220544..0d7cf23a0b 100644 --- a/src/userfunc.c +++ b/src/userfunc.c @@ -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 diff --git a/src/version.c b/src/version.c index ea286f11b2..362d7df857 100644 --- a/src/version.c +++ b/src/version.c @@ -734,6 +734,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 41, /**/ 40, /**/ diff --git a/src/vim9class.c b/src/vim9class.c index 3dc4ddf860..2148f0ffbd 100644 --- a/src/vim9class.c +++ b/src/vim9class.c @@ -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) { diff --git a/src/vim9execute.c b/src/vim9execute.c index bdea74f66a..03417baaee 100644 --- a/src/vim9execute.c +++ b/src/vim9execute.c @@ -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; diff --git a/src/vim9type.c b/src/vim9type.c index 938eee00c5..f6bf1b255d 100644 --- a/src/vim9type.c +++ b/src/vim9type.c @@ -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, ")");