To: vim-dev@vim.org Subject: Patch 6.0.241 Fcc: outbox From: Bram Moolenaar MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 6.0.241 Problem: Win32: Expanding the old value of an option that is a path that starts with a backslash, an extra backslash is inserted. Solution: Only insert backslashes where needed. Also handle multi-byte characters properly when removing backslashes. Files: src/option.c *** ../vim60.240/src/option.c Mon Feb 11 20:37:46 2002 --- src/option.c Wed Feb 20 22:02:26 2002 *************** *** 3539,3544 **** --- 3539,3545 ---- * file name characters are not removed, and keep * backslash at start, for "\\machine\path", but * do remove it for "\\\\machine\\path". + * The reverse is found in ExpandOldSetting(). */ while (*arg && !vim_iswhite(*arg)) { *************** *** 3551,3558 **** && arg[2] != '\\'))) #endif ) ! ++arg; ! *s++ = *arg++; } *s = NUL; --- 3552,3570 ---- && arg[2] != '\\'))) #endif ) ! ++arg; /* remove backslash */ ! #ifdef FEAT_MBYTE ! if (has_mbyte ! && (i = (*mb_ptr2len_check)(arg)) > 1) ! { ! /* copy multibyte char */ ! mch_memmove(s, arg, (size_t)i); ! arg += i; ! s += i; ! } ! else ! #endif ! *s++ = *arg++; } *s = NUL; *************** *** 8002,8008 **** else if (var == NULL) var = (char_u *)""; ! /* A backslash is required before some characters */ buf = vim_strsave_escaped(var, escape_chars); if (buf == NULL) --- 8013,8020 ---- else if (var == NULL) var = (char_u *)""; ! /* A backslash is required before some characters. This is the reverse of ! * what happens in do_set(). */ buf = vim_strsave_escaped(var, escape_chars); if (buf == NULL) *************** *** 8011,8016 **** --- 8023,8047 ---- *file = NULL; return FAIL; } + + #ifdef BACKSLASH_IN_FILENAME + /* For MS-Windows et al. we don't double backslashes at the start and + * before a file name character. */ + for (var = buf; *var != NUL; ) + { + if (var[0] == '\\' && var[1] == '\\' + && expand_option_idx >= 0 + && (options[expand_option_idx].flags & P_EXPAND) + && vim_isfilec(var[2]) + && (var[2] != '\\' || (var == buf && var[4] != '\\'))) + mch_memmove(var, var + 1, STRLEN(var)); + #ifdef FEAT_MBYTE + else if (has_mbyte) + var += (*mb_ptr2len_check)(var) - 1; + #endif + ++var; + } + #endif *file[0] = buf; *num_file = 1; *** ../vim60.240/src/version.c Wed Feb 20 21:21:02 2002 --- src/version.c Wed Feb 20 22:05:15 2002 *************** *** 608,609 **** --- 608,611 ---- { /* Add new patch number below this line */ + /**/ + 241, /**/ -- BEDEVERE: Wait. Wait ... tell me, what also floats on water? ALL: Bread? No, no, no. Apples .... gravy ... very small rocks ... ARTHUR: A duck. "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /// Bram Moolenaar -- Bram@moolenaar.net -- http://www.moolenaar.net \\\ /// Creator of Vim -- http://vim.sf.net -- ftp://ftp.vim.org/pub/vim \\\ \\\ Project leader for A-A-P -- http://www.a-a-p.org /// \\\ Help me helping AIDS orphans in Uganda - http://iccf-holland.org ///