changeset 20925:0aeac2b45846 v8.2.1014

patch 8.2.1014: using "name" for a string result is confusing Commit: https://github.com/vim/vim/commit/1e0b7b11db61bd906266d3174fee0bbaf20a101f Author: Bram Moolenaar <Bram@vim.org> Date: Fri Jun 19 19:30:53 2020 +0200 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".
author Bram Moolenaar <Bram@vim.org>
date Fri, 19 Jun 2020 19:45:03 +0200
parents c8f68af254b6
children 6ef0f635ce16
files src/typval.c src/version.c
diffstat 2 files changed, 25 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/src/typval.c
+++ b/src/typval.c
@@ -1182,7 +1182,7 @@ get_number_tv(
 get_string_tv(char_u **arg, typval_T *rettv, int evaluate)
 {
     char_u	*p;
-    char_u	*name;
+    char_u	*end;
     int		extra = 0;
     int		len;
 
@@ -1216,12 +1216,12 @@ get_string_tv(char_u **arg, typval_T *re
 
     // Copy the string into allocated memory, handling backslashed
     // characters.
+    rettv->v_type = VAR_STRING;
     len = (int)(p - *arg + extra);
-    name = alloc(len);
-    if (name == NULL)
+    rettv->vval.v_string = alloc(len);
+    if (rettv->vval.v_string == NULL)
 	return FAIL;
-    rettv->v_type = VAR_STRING;
-    rettv->vval.v_string = name;
+    end = rettv->vval.v_string;
 
     for (p = *arg + 1; *p != NUL && *p != '"'; )
     {
@@ -1229,12 +1229,12 @@ get_string_tv(char_u **arg, typval_T *re
 	{
 	    switch (*++p)
 	    {
-		case 'b': *name++ = BS; ++p; break;
-		case 'e': *name++ = ESC; ++p; break;
-		case 'f': *name++ = FF; ++p; break;
-		case 'n': *name++ = NL; ++p; break;
-		case 'r': *name++ = CAR; ++p; break;
-		case 't': *name++ = TAB; ++p; break;
+		case 'b': *end++ = BS; ++p; break;
+		case 'e': *end++ = ESC; ++p; break;
+		case 'f': *end++ = FF; ++p; break;
+		case 'n': *end++ = NL; ++p; break;
+		case 'r': *end++ = CAR; ++p; break;
+		case 't': *end++ = TAB; ++p; break;
 
 		case 'X': // hex: "\x1", "\x12"
 		case 'x':
@@ -1261,9 +1261,9 @@ get_string_tv(char_u **arg, typval_T *re
 			      // For "\u" store the number according to
 			      // 'encoding'.
 			      if (c != 'X')
-				  name += (*mb_char2bytes)(nr, name);
+				  end += (*mb_char2bytes)(nr, end);
 			      else
-				  *name++ = nr;
+				  *end++ = nr;
 			  }
 			  break;
 
@@ -1275,14 +1275,14 @@ get_string_tv(char_u **arg, typval_T *re
 		case '4':
 		case '5':
 		case '6':
-		case '7': *name = *p++ - '0';
+		case '7': *end = *p++ - '0';
 			  if (*p >= '0' && *p <= '7')
 			  {
-			      *name = (*name << 3) + *p++ - '0';
+			      *end = (*end << 3) + *p++ - '0';
 			      if (*p >= '0' && *p <= '7')
-				  *name = (*name << 3) + *p++ - '0';
+				  *end = (*end << 3) + *p++ - '0';
 			  }
-			  ++name;
+			  ++end;
 			  break;
 
 			  // Special key, e.g.: "\<C-W>"
@@ -1292,26 +1292,25 @@ get_string_tv(char_u **arg, typval_T *re
 
 			      if (p[1] != '*')
 				  flags |= FSK_SIMPLIFY;
-			      extra = trans_special(&p, name, flags, NULL);
+			      extra = trans_special(&p, end, flags, NULL);
 			      if (extra != 0)
 			      {
-				  name += extra;
-				  if (name >= rettv->vval.v_string + len)
+				  end += extra;
+				  if (end >= rettv->vval.v_string + len)
 				      iemsg("get_string_tv() used more space than allocated");
 				  break;
 			      }
 			  }
 			  // FALLTHROUGH
 
-		default:  MB_COPY_CHAR(p, name);
+		default:  MB_COPY_CHAR(p, end);
 			  break;
 	    }
 	}
 	else
-	    MB_COPY_CHAR(p, name);
-
+	    MB_COPY_CHAR(p, end);
     }
-    *name = NUL;
+    *end = NUL;
     if (*p != NUL) // just in case
 	++p;
     *arg = p;
--- a/src/version.c
+++ b/src/version.c
@@ -755,6 +755,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    1014,
+/**/
     1013,
 /**/
     1012,