mirror of
https://github.com/macvim-dev/macvim.git
synced 2026-06-11 15:37:29 +02:00
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 <basilisk@internode.on.net>
Signed-off-by: Hirohito Higashi <h.east.727@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
7b7a6f941b
commit
fc90d8087a
+2
-2
@@ -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);
|
||||
|
||||
+2
-2
@@ -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');
|
||||
}
|
||||
|
||||
+2
-2
@@ -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)
|
||||
|
||||
+8
-7
@@ -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;
|
||||
|
||||
+1
-1
@@ -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
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
+2
-2
@@ -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,
|
||||
|
||||
@@ -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);
|
||||
|
||||
+1
-1
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -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);
|
||||
|
||||
+3
-3
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -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
|
||||
|
||||
+1
-1
@@ -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
|
||||
|
||||
@@ -734,6 +734,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
41,
|
||||
/**/
|
||||
40,
|
||||
/**/
|
||||
|
||||
+17
-17
@@ -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)
|
||||
{
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
+5
-5
@@ -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, ")");
|
||||
|
||||
Reference in New Issue
Block a user