]> granicus.if.org Git - vim/commitdiff
patch 8.2.1014: using "name" for a string result is confusing v8.2.1014
authorBram Moolenaar <Bram@vim.org>
Fri, 19 Jun 2020 17:30:53 +0000 (19:30 +0200)
committerBram Moolenaar <Bram@vim.org>
Fri, 19 Jun 2020 17:30:53 +0000 (19:30 +0200)
Problem:    Using "name" for a string result is confusing.
Solution:   Rename to "end".

src/typval.c
src/version.c

index 23530a5dc54b5169babe3721026a17106b54793e..ebc51c6af32aa75cb46bbadde48bdb8d2a3f891f 100644 (file)
@@ -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 *rettv, int evaluate)
 
     // 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 *rettv, int evaluate)
        {
            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 *rettv, int evaluate)
                              // 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 *rettv, int evaluate)
                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 *rettv, int evaluate)
 
                              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;
index 4cc8261325b5c064a5f7eb168a154313d7a43694..3ccf1dd09489e5cc74306e2d5a963a90197b4514 100644 (file)
@@ -754,6 +754,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1014,
 /**/
     1013,
 /**/