To: vim_dev@googlegroups.com Subject: Patch 8.2.1014 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.1014 Problem: Using "name" for a string result is confusing. Solution: Rename to "end". Files: src/typval.c *** ../vim-8.2.1013/src/typval.c 2020-05-31 22:06:48.081779441 +0200 --- src/typval.c 2020-06-19 19:28:33.713791837 +0200 *************** *** 1182,1188 **** get_string_tv(char_u **arg, typval_T *rettv, int evaluate) { char_u *p; ! char_u *name; int extra = 0; int len; --- 1182,1188 ---- get_string_tv(char_u **arg, typval_T *rettv, int evaluate) { char_u *p; ! char_u *end; int extra = 0; int len; *************** *** 1216,1227 **** // Copy the string into allocated memory, handling backslashed // characters. len = (int)(p - *arg + extra); ! name = alloc(len); ! if (name == NULL) return FAIL; ! rettv->v_type = VAR_STRING; ! rettv->vval.v_string = name; for (p = *arg + 1; *p != NUL && *p != '"'; ) { --- 1216,1227 ---- // Copy the string into allocated memory, handling backslashed // characters. + rettv->v_type = VAR_STRING; 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 != '"'; ) { *************** *** 1229,1240 **** { 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 'X': // hex: "\x1", "\x12" case 'x': --- 1229,1240 ---- { switch (*++p) { ! 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,1269 **** // For "\u" store the number according to // 'encoding'. if (c != 'X') ! name += (*mb_char2bytes)(nr, name); else ! *name++ = nr; } break; --- 1261,1269 ---- // For "\u" store the number according to // 'encoding'. if (c != 'X') ! end += (*mb_char2bytes)(nr, end); else ! *end++ = nr; } break; *************** *** 1275,1288 **** case '4': case '5': case '6': ! case '7': *name = *p++ - '0'; if (*p >= '0' && *p <= '7') { ! *name = (*name << 3) + *p++ - '0'; if (*p >= '0' && *p <= '7') ! *name = (*name << 3) + *p++ - '0'; } ! ++name; break; // Special key, e.g.: "\" --- 1275,1288 ---- case '4': case '5': case '6': ! case '7': *end = *p++ - '0'; if (*p >= '0' && *p <= '7') { ! *end = (*end << 3) + *p++ - '0'; if (*p >= '0' && *p <= '7') ! *end = (*end << 3) + *p++ - '0'; } ! ++end; break; // Special key, e.g.: "\" *************** *** 1292,1317 **** if (p[1] != '*') flags |= FSK_SIMPLIFY; ! extra = trans_special(&p, name, flags, NULL); if (extra != 0) { ! name += extra; ! if (name >= rettv->vval.v_string + len) iemsg("get_string_tv() used more space than allocated"); break; } } // FALLTHROUGH ! default: MB_COPY_CHAR(p, name); break; } } else ! MB_COPY_CHAR(p, name); ! } ! *name = NUL; if (*p != NUL) // just in case ++p; *arg = p; --- 1292,1316 ---- if (p[1] != '*') flags |= FSK_SIMPLIFY; ! extra = trans_special(&p, end, flags, NULL); if (extra != 0) { ! 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, end); break; } } else ! MB_COPY_CHAR(p, end); } ! *end = NUL; if (*p != NUL) // just in case ++p; *arg = p; *** ../vim-8.2.1013/src/version.c 2020-06-19 19:10:55.477199015 +0200 --- src/version.c 2020-06-19 19:29:17.661643557 +0200 *************** *** 756,757 **** --- 756,759 ---- { /* Add new patch number below this line */ + /**/ + 1014, /**/ -- [Autumn changed into Winter ... Winter changed into Spring ... Spring changed back into Autumn and Autumn gave Winter and Spring a miss and went straight on into Summer ... Until one day ...] "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///