0
0
mirror of https://github.com/vim/vim.git synced 2025-09-27 04:14:06 -04:00

updated for version 7.0-183

This commit is contained in:
Bram Moolenaar
2007-01-14 14:28:34 +00:00
parent 89ed3dfd87
commit 863b53b72e
2 changed files with 36 additions and 25 deletions

View File

@@ -898,6 +898,7 @@ set_internal_string_var(name, value)
} }
static lval_T *redir_lval = NULL; static lval_T *redir_lval = NULL;
static garray_T redir_ga; /* only valid when redir_lval is not NULL */
static char_u *redir_endp = NULL; static char_u *redir_endp = NULL;
static char_u *redir_varname = NULL; static char_u *redir_varname = NULL;
@@ -932,6 +933,9 @@ var_redir_start(name, append)
return FAIL; return FAIL;
} }
/* The output is stored in growarray "redir_ga" until redirection ends. */
ga_init2(&redir_ga, (int)sizeof(char), 500);
/* Parse the variable name (can be a dict or list entry). */ /* Parse the variable name (can be a dict or list entry). */
redir_endp = get_lval(redir_varname, NULL, redir_lval, FALSE, FALSE, FALSE, redir_endp = get_lval(redir_varname, NULL, redir_lval, FALSE, FALSE, FALSE,
FNE_CHECK_START); FNE_CHECK_START);
@@ -974,42 +978,36 @@ var_redir_start(name, append)
} }
/* /*
* Append "value[len]" to the variable set by var_redir_start(). * Append "value[value_len]" to the variable set by var_redir_start().
* The actual appending is postponed until redirection ends, because the value
* appended may in fact be the string we write to, changing it may cause freed
* memory to be used:
* :redir => foo
* :let foo
* :redir END
*/ */
void void
var_redir_str(value, len) var_redir_str(value, value_len)
char_u *value; char_u *value;
int len; int value_len;
{ {
char_u *val; size_t len;
typval_T tv;
int save_emsg;
int err;
if (redir_lval == NULL) if (redir_lval == NULL)
return; return;
if (len == -1) if (value_len == -1)
/* Append the entire string */ len = STRLEN(value); /* Append the entire string */
val = vim_strsave(value);
else else
/* Append only the specified number of characters */ len = value_len; /* Append only "value_len" characters */
val = vim_strnsave(value, len);
if (val == NULL)
return;
tv.v_type = VAR_STRING; if (ga_grow(&redir_ga, (int)len) == OK)
tv.vval.v_string = val; {
mch_memmove((char *)redir_ga.ga_data + redir_ga.ga_len, value, len);
save_emsg = did_emsg; redir_ga.ga_len += len;
did_emsg = FALSE; }
set_var_lval(redir_lval, redir_endp, &tv, FALSE, (char_u *)"."); else
err = did_emsg;
did_emsg |= save_emsg;
if (err)
var_redir_stop(); var_redir_stop();
vim_free(tv.vval.v_string);
} }
/* /*
@@ -1018,8 +1016,19 @@ var_redir_str(value, len)
void void
var_redir_stop() var_redir_stop()
{ {
typval_T tv;
if (redir_lval != NULL) if (redir_lval != NULL)
{ {
/* Append the trailing NUL. */
ga_append(&redir_ga, NUL);
/* Assign the text to the variable. */
tv.v_type = VAR_STRING;
tv.vval.v_string = redir_ga.ga_data;
set_var_lval(redir_lval, redir_endp, &tv, FALSE, (char_u *)".");
vim_free(tv.vval.v_string);
clear_lval(redir_lval); clear_lval(redir_lval);
vim_free(redir_lval); vim_free(redir_lval);
redir_lval = NULL; redir_lval = NULL;

View File

@@ -666,6 +666,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
183,
/**/ /**/
182, 182,
/**/ /**/