To: vim-dev@vim.org
Subject: Patch 7.2.010
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
------------
Patch 7.2.010
Problem: When using "K" in Visual mode not all characters are properly
escaped. (Ben Schmidt)
Solution: Use a function with the functionality of shellescape(). (Jan
Minar)
Files: src/mbyte.c, src/misc2.c, src/normal.c
*** ../vim-7.2.009/src/mbyte.c Wed Aug 6 18:45:36 2008
--- src/mbyte.c Wed Sep 3 22:34:48 2008
***************
*** 2540,2546 ****
return (int)(p - q);
}
- #if defined(FEAT_EVAL) || defined(PROTO)
/*
* Copy a character from "*fp" to "*tp" and advance the pointers.
*/
--- 2540,2545 ----
***************
*** 2555,2561 ****
*tp += l;
*fp += l;
}
- #endif
/*
* Return the offset from "p" to the first byte of a character. When "p" is
--- 2554,2559 ----
*** ../vim-7.2.009/src/misc2.c Thu Jul 24 20:28:58 2008
--- src/misc2.c Wed Sep 3 22:05:21 2008
***************
*** 1257,1263 ****
return escaped_string;
}
- #if !defined(BACKSLASH_IN_FILENAME) || defined(FEAT_EVAL) || defined(PROTO)
/*
* Return TRUE when 'shell' has "csh" in the tail.
*/
--- 1257,1262 ----
***************
*** 1266,1274 ****
{
return (strstr((char *)gettail(p_sh), "csh") != NULL);
}
- #endif
- #if defined(FEAT_EVAL) || defined(PROTO)
/*
* Escape "string" for use as a shell argument with system().
* This uses single quotes, except when we know we need to use double qoutes
--- 1265,1271 ----
***************
*** 1391,1397 ****
return escaped_string;
}
- #endif
/*
* Like vim_strsave(), but make all characters uppercase.
--- 1388,1393 ----
*** ../vim-7.2.009/src/normal.c Thu Jul 31 22:03:54 2008
--- src/normal.c Sat Sep 6 15:06:07 2008
***************
*** 5469,5474 ****
--- 5469,5479 ----
STRCPY(buf, "he! ");
else
{
+ /* An external command will probably use an argument starting
+ * with "-" as an option. To avoid trouble we skip the "-". */
+ while (*ptr == '-')
+ ++ptr;
+
/* When a count is given, turn it into a range. Is this
* really what we want? */
isman = (STRCMP(kp, "man") == 0);
***************
*** 5511,5547 ****
/*
* Now grab the chars in the identifier
*/
! if (cmdchar == '*')
! aux_ptr = (char_u *)(p_magic ? "/.*~[^$\\" : "/^$\\");
! else if (cmdchar == '#')
! aux_ptr = (char_u *)(p_magic ? "/?.*~[^$\\" : "/?^$\\");
! else if (cmdchar == 'K' && !kp_help)
! aux_ptr = (char_u *)" \t\\\"|!";
! else
! /* Don't escape spaces and Tabs in a tag with a backslash */
! aux_ptr = (char_u *)"\\|\"";
!
! p = buf + STRLEN(buf);
! while (n-- > 0)
! {
! /* put a backslash before \ and some others */
! if (vim_strchr(aux_ptr, *ptr) != NULL)
! *p++ = '\\';
! #ifdef FEAT_MBYTE
! /* When current byte is a part of multibyte character, copy all bytes
! * of that character. */
! if (has_mbyte)
{
! int i;
! int len = (*mb_ptr2len)(ptr) - 1;
!
! for (i = 0; i < len && n >= 1; ++i, --n)
! *p++ = *ptr++;
}
#endif
! *p++ = *ptr++;
}
- *p = NUL;
/*
* Execute the command.
--- 5516,5572 ----
/*
* Now grab the chars in the identifier
*/
! if (cmdchar == 'K' && !kp_help)
! {
! /* Escape the argument properly for a shell command */
! p = vim_strsave_shellescape(ptr, TRUE);
! if (p == NULL)
{
! vim_free(buf);
! return;
}
+ buf = (char_u *)vim_realloc(buf, STRLEN(buf) + STRLEN(p) + 1);
+ if (buf == NULL)
+ {
+ vim_free(buf);
+ vim_free(p);
+ return;
+ }
+ STRCAT(buf, p);
+ vim_free(p);
+ }
+ else
+ {
+ if (cmdchar == '*')
+ aux_ptr = (char_u *)(p_magic ? "/.*~[^$\\" : "/^$\\");
+ else if (cmdchar == '#')
+ aux_ptr = (char_u *)(p_magic ? "/?.*~[^$\\" : "/?^$\\");
+ else
+ /* Don't escape spaces and Tabs in a tag with a backslash */
+ aux_ptr = (char_u *)"\\|\"\n*?[";
+
+ p = buf + STRLEN(buf);
+ while (n-- > 0)
+ {
+ /* put a backslash before \ and some others */
+ if (vim_strchr(aux_ptr, *ptr) != NULL)
+ *p++ = '\\';
+ #ifdef FEAT_MBYTE
+ /* When current byte is a part of multibyte character, copy all
+ * bytes of that character. */
+ if (has_mbyte)
+ {
+ int i;
+ int len = (*mb_ptr2len)(ptr) - 1;
+
+ for (i = 0; i < len && n >= 1; ++i, --n)
+ *p++ = *ptr++;
+ }
#endif
! *p++ = *ptr++;
! }
! *p = NUL;
}
/*
* Execute the command.
*** ../vim-7.2.009/src/version.c Mon Sep 1 17:56:05 2008
--- src/version.c Sat Sep 6 16:26:42 2008
***************
*** 678,679 ****
--- 678,681 ----
{ /* Add new patch number below this line */
+ /**/
+ 10,
/**/
--
Q. What happens to programmers when they die?
A: MS-Windows programmers are reinstalled. C++ programmers become undefined,
anyone who refers to them will die as well. Java programmers reincarnate
after being garbage collected.
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ download, build and distribute -- http://www.A-A-P.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///