comparison src/option.c @ 30417:6a1862bfb280 v9.0.0544

patch 9.0.0544: minor issues with setting a string option Commit: https://github.com/vim/vim/commit/fcba86c0316dc0d6341078b50e7967206a1627a0 Author: zeertzjq <zeertzjq@outlook.com> Date: Thu Sep 22 13:57:32 2022 +0100 patch 9.0.0544: minor issues with setting a string option Problem: Minor issues with setting a string option. Solution: Adjust the code, add a test. (closes https://github.com/vim/vim/issues/11192)
author Bram Moolenaar <Bram@vim.org>
date Thu, 22 Sep 2022 15:00:05 +0200
parents aea53db7eeec
children 6c6ac189a05f
comparison
equal deleted inserted replaced
30416:41b0b57c4ebd 30417:6a1862bfb280
1321 ++arg; // jump to after the '=' or ':' 1321 ++arg; // jump to after the '=' or ':'
1322 1322
1323 /* 1323 /*
1324 * Set 'keywordprg' to ":help" if an empty 1324 * Set 'keywordprg' to ":help" if an empty
1325 * value was passed to :set by the user. 1325 * value was passed to :set by the user.
1326 * Misuse errbuf[] for the resulting string.
1327 */ 1326 */
1328 if (varp == (char_u *)&p_kp && (*arg == NUL || *arg == ' ')) 1327 if (varp == (char_u *)&p_kp && (*arg == NUL || *arg == ' '))
1329 { 1328 {
1330 STRCPY(errbuf, ":help");
1331 save_arg = arg; 1329 save_arg = arg;
1332 arg = (char_u *)errbuf; 1330 arg = (char_u *)":help";
1333 } 1331 }
1334 /* 1332 /*
1335 * Convert 'backspace' number to string, for 1333 * Convert 'backspace' number to string, for
1336 * adding, prepending and removing string. 1334 * adding, prepending and removing string.
1337 */ 1335 */
1415 * For MS-DOS and WIN32 backslashes before normal file name characters 1413 * For MS-DOS and WIN32 backslashes before normal file name characters
1416 * are not removed, and keep backslash at start, for "\\machine\path", 1414 * are not removed, and keep backslash at start, for "\\machine\path",
1417 * but do remove it for "\\\\machine\\path". 1415 * but do remove it for "\\\\machine\\path".
1418 * The reverse is found in ExpandOldSetting(). 1416 * The reverse is found in ExpandOldSetting().
1419 */ 1417 */
1420 while (*arg && !VIM_ISWHITE(*arg)) 1418 while (*arg != NUL && !VIM_ISWHITE(*arg))
1421 { 1419 {
1422 int i; 1420 int i;
1423 1421
1424 if (*arg == '\\' && arg[1] != NUL 1422 if (*arg == '\\' && arg[1] != NUL
1425 #ifdef BACKSLASH_IN_FILENAME 1423 #ifdef BACKSLASH_IN_FILENAME
1426 && !((flags & P_EXPAND) 1424 && !((flags & P_EXPAND)
1427 && vim_isfilec(arg[1]) 1425 && vim_isfilec(arg[1])
1428 && !VIM_ISWHITE(arg[1]) 1426 && !VIM_ISWHITE(arg[1])
1429 && (arg[1] != '\\' 1427 && (arg[1] != '\\'
1430 || (s == newval && arg[2] != '\\'))) 1428 || (s == newval && arg[2] != '\\')))
1431 #endif 1429 #endif
1432 ) 1430 )
1433 ++arg; // remove backslash 1431 ++arg; // remove backslash
1434 if (has_mbyte && (i = (*mb_ptr2len)(arg)) > 1) 1432 if (has_mbyte && (i = (*mb_ptr2len)(arg)) > 1)
1435 { 1433 {
1563 } 1561 }
1564 ++s; 1562 ++s;
1565 } 1563 }
1566 } 1564 }
1567 1565
1568 if (save_arg != NULL) // number for 'whichwrap' 1566 if (save_arg != NULL)
1569 arg = save_arg; 1567 arg = save_arg; // arg was temporarily changed, restore it
1570 } 1568 }
1571 1569
1572 /* 1570 /*
1573 * Set the new value. 1571 * Set the new value.
1574 */ 1572 */