1
0
forked from aniani/vim

patch 8.2.1014: using "name" for a string result is confusing

Problem:    Using "name" for a string result is confusing.
Solution:   Rename to "end".
This commit is contained in:
Bram Moolenaar
2020-06-19 19:30:53 +02:00
parent ec9b017b87
commit 1e0b7b11db
2 changed files with 26 additions and 25 deletions

View File

@@ -1182,7 +1182,7 @@ get_number_tv(
get_string_tv(char_u **arg, typval_T *rettv, int evaluate) get_string_tv(char_u **arg, typval_T *rettv, int evaluate)
{ {
char_u *p; char_u *p;
char_u *name; char_u *end;
int extra = 0; int extra = 0;
int len; int len;
@@ -1216,12 +1216,12 @@ get_string_tv(char_u **arg, typval_T *rettv, int evaluate)
// Copy the string into allocated memory, handling backslashed // Copy the string into allocated memory, handling backslashed
// characters. // characters.
len = (int)(p - *arg + extra);
name = alloc(len);
if (name == NULL)
return FAIL;
rettv->v_type = VAR_STRING; rettv->v_type = VAR_STRING;
rettv->vval.v_string = name; len = (int)(p - *arg + extra);
rettv->vval.v_string = alloc(len);
if (rettv->vval.v_string == NULL)
return FAIL;
end = rettv->vval.v_string;
for (p = *arg + 1; *p != NUL && *p != '"'; ) for (p = *arg + 1; *p != NUL && *p != '"'; )
{ {
@@ -1229,12 +1229,12 @@ get_string_tv(char_u **arg, typval_T *rettv, int evaluate)
{ {
switch (*++p) switch (*++p)
{ {
case 'b': *name++ = BS; ++p; break; case 'b': *end++ = BS; ++p; break;
case 'e': *name++ = ESC; ++p; break; case 'e': *end++ = ESC; ++p; break;
case 'f': *name++ = FF; ++p; break; case 'f': *end++ = FF; ++p; break;
case 'n': *name++ = NL; ++p; break; case 'n': *end++ = NL; ++p; break;
case 'r': *name++ = CAR; ++p; break; case 'r': *end++ = CAR; ++p; break;
case 't': *name++ = TAB; ++p; break; case 't': *end++ = TAB; ++p; break;
case 'X': // hex: "\x1", "\x12" case 'X': // hex: "\x1", "\x12"
case 'x': case 'x':
@@ -1261,9 +1261,9 @@ get_string_tv(char_u **arg, typval_T *rettv, int evaluate)
// For "\u" store the number according to // For "\u" store the number according to
// 'encoding'. // 'encoding'.
if (c != 'X') if (c != 'X')
name += (*mb_char2bytes)(nr, name); end += (*mb_char2bytes)(nr, end);
else else
*name++ = nr; *end++ = nr;
} }
break; break;
@@ -1275,14 +1275,14 @@ get_string_tv(char_u **arg, typval_T *rettv, int evaluate)
case '4': case '4':
case '5': case '5':
case '6': case '6':
case '7': *name = *p++ - '0'; case '7': *end = *p++ - '0';
if (*p >= '0' && *p <= '7') if (*p >= '0' && *p <= '7')
{ {
*name = (*name << 3) + *p++ - '0'; *end = (*end << 3) + *p++ - '0';
if (*p >= '0' && *p <= '7') if (*p >= '0' && *p <= '7')
*name = (*name << 3) + *p++ - '0'; *end = (*end << 3) + *p++ - '0';
} }
++name; ++end;
break; break;
// Special key, e.g.: "\<C-W>" // Special key, e.g.: "\<C-W>"
@@ -1292,26 +1292,25 @@ get_string_tv(char_u **arg, typval_T *rettv, int evaluate)
if (p[1] != '*') if (p[1] != '*')
flags |= FSK_SIMPLIFY; flags |= FSK_SIMPLIFY;
extra = trans_special(&p, name, flags, NULL); extra = trans_special(&p, end, flags, NULL);
if (extra != 0) if (extra != 0)
{ {
name += extra; end += extra;
if (name >= rettv->vval.v_string + len) if (end >= rettv->vval.v_string + len)
iemsg("get_string_tv() used more space than allocated"); iemsg("get_string_tv() used more space than allocated");
break; break;
} }
} }
// FALLTHROUGH // FALLTHROUGH
default: MB_COPY_CHAR(p, name); default: MB_COPY_CHAR(p, end);
break; break;
} }
} }
else else
MB_COPY_CHAR(p, name); MB_COPY_CHAR(p, end);
} }
*name = NUL; *end = NUL;
if (*p != NUL) // just in case if (*p != NUL) // just in case
++p; ++p;
*arg = p; *arg = p;

View File

@@ -754,6 +754,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 */
/**/
1014,
/**/ /**/
1013, 1013,
/**/ /**/