components/vim/vim72-patches/7.2.010
changeset 379 c6a17bba1da3
parent 378 f0b61ed1d10d
child 380 e92b3b4a1c66
equal deleted inserted replaced
378:f0b61ed1d10d 379:c6a17bba1da3
     1 To: [email protected]
       
     2 Subject: Patch 7.2.010
       
     3 Fcc: outbox
       
     4 From: Bram Moolenaar <[email protected]>
       
     5 Mime-Version: 1.0
       
     6 Content-Type: text/plain; charset=ISO-8859-1
       
     7 Content-Transfer-Encoding: 8bit
       
     8 ------------
       
     9 
       
    10 Patch 7.2.010
       
    11 Problem:    When using "K" in Visual mode not all characters are properly
       
    12 	    escaped. (Ben Schmidt)
       
    13 Solution:   Use a function with the functionality of shellescape(). (Jan
       
    14 	    Minar)
       
    15 Files:	    src/mbyte.c, src/misc2.c, src/normal.c
       
    16 
       
    17 
       
    18 *** ../vim-7.2.009/src/mbyte.c	Wed Aug  6 18:45:36 2008
       
    19 --- src/mbyte.c	Wed Sep  3 22:34:48 2008
       
    20 ***************
       
    21 *** 2540,2546 ****
       
    22       return (int)(p - q);
       
    23   }
       
    24   
       
    25 - #if defined(FEAT_EVAL) || defined(PROTO)
       
    26   /*
       
    27    * Copy a character from "*fp" to "*tp" and advance the pointers.
       
    28    */
       
    29 --- 2540,2545 ----
       
    30 ***************
       
    31 *** 2555,2561 ****
       
    32       *tp += l;
       
    33       *fp += l;
       
    34   }
       
    35 - #endif
       
    36   
       
    37   /*
       
    38    * Return the offset from "p" to the first byte of a character.  When "p" is
       
    39 --- 2554,2559 ----
       
    40 *** ../vim-7.2.009/src/misc2.c	Thu Jul 24 20:28:58 2008
       
    41 --- src/misc2.c	Wed Sep  3 22:05:21 2008
       
    42 ***************
       
    43 *** 1257,1263 ****
       
    44       return escaped_string;
       
    45   }
       
    46   
       
    47 - #if !defined(BACKSLASH_IN_FILENAME) || defined(FEAT_EVAL) || defined(PROTO)
       
    48   /*
       
    49    * Return TRUE when 'shell' has "csh" in the tail.
       
    50    */
       
    51 --- 1257,1262 ----
       
    52 ***************
       
    53 *** 1266,1274 ****
       
    54   {
       
    55       return (strstr((char *)gettail(p_sh), "csh") != NULL);
       
    56   }
       
    57 - #endif
       
    58   
       
    59 - #if defined(FEAT_EVAL) || defined(PROTO)
       
    60   /*
       
    61    * Escape "string" for use as a shell argument with system().
       
    62    * This uses single quotes, except when we know we need to use double qoutes
       
    63 --- 1265,1271 ----
       
    64 ***************
       
    65 *** 1391,1397 ****
       
    66   
       
    67       return escaped_string;
       
    68   }
       
    69 - #endif
       
    70   
       
    71   /*
       
    72    * Like vim_strsave(), but make all characters uppercase.
       
    73 --- 1388,1393 ----
       
    74 *** ../vim-7.2.009/src/normal.c	Thu Jul 31 22:03:54 2008
       
    75 --- src/normal.c	Sat Sep  6 15:06:07 2008
       
    76 ***************
       
    77 *** 5469,5474 ****
       
    78 --- 5469,5479 ----
       
    79   		STRCPY(buf, "he! ");
       
    80   	    else
       
    81   	    {
       
    82 + 		/* An external command will probably use an argument starting
       
    83 + 		 * with "-" as an option.  To avoid trouble we skip the "-". */
       
    84 + 		while (*ptr == '-')
       
    85 + 		    ++ptr;
       
    86 + 
       
    87   		/* When a count is given, turn it into a range.  Is this
       
    88   		 * really what we want? */
       
    89   		isman = (STRCMP(kp, "man") == 0);
       
    90 ***************
       
    91 *** 5511,5547 ****
       
    92       /*
       
    93        * Now grab the chars in the identifier
       
    94        */
       
    95 !     if (cmdchar == '*')
       
    96 ! 	aux_ptr = (char_u *)(p_magic ? "/.*~[^$\\" : "/^$\\");
       
    97 !     else if (cmdchar == '#')
       
    98 ! 	aux_ptr = (char_u *)(p_magic ? "/?.*~[^$\\" : "/?^$\\");
       
    99 !     else if (cmdchar == 'K' && !kp_help)
       
   100 ! 	aux_ptr = (char_u *)" \t\\\"|!";
       
   101 !     else
       
   102 ! 	/* Don't escape spaces and Tabs in a tag with a backslash */
       
   103 ! 	aux_ptr = (char_u *)"\\|\"";
       
   104 ! 
       
   105 !     p = buf + STRLEN(buf);
       
   106 !     while (n-- > 0)
       
   107 !     {
       
   108 ! 	/* put a backslash before \ and some others */
       
   109 ! 	if (vim_strchr(aux_ptr, *ptr) != NULL)
       
   110 ! 	    *p++ = '\\';
       
   111 ! #ifdef FEAT_MBYTE
       
   112 ! 	/* When current byte is a part of multibyte character, copy all bytes
       
   113 ! 	 * of that character. */
       
   114 ! 	if (has_mbyte)
       
   115   	{
       
   116 ! 	    int i;
       
   117 ! 	    int len = (*mb_ptr2len)(ptr) - 1;
       
   118 ! 
       
   119 ! 	    for (i = 0; i < len && n >= 1; ++i, --n)
       
   120 ! 		*p++ = *ptr++;
       
   121   	}
       
   122   #endif
       
   123 ! 	*p++ = *ptr++;
       
   124       }
       
   125 -     *p = NUL;
       
   126   
       
   127       /*
       
   128        * Execute the command.
       
   129 --- 5516,5572 ----
       
   130       /*
       
   131        * Now grab the chars in the identifier
       
   132        */
       
   133 !     if (cmdchar == 'K' && !kp_help)
       
   134 !     {
       
   135 ! 	/* Escape the argument properly for a shell command */
       
   136 ! 	p = vim_strsave_shellescape(ptr, TRUE);
       
   137 ! 	if (p == NULL)
       
   138   	{
       
   139 ! 	    vim_free(buf);
       
   140 ! 	    return;
       
   141   	}
       
   142 + 	buf = (char_u *)vim_realloc(buf, STRLEN(buf) + STRLEN(p) + 1);
       
   143 + 	if (buf == NULL)
       
   144 + 	{
       
   145 + 	    vim_free(buf);
       
   146 + 	    vim_free(p);
       
   147 + 	    return;
       
   148 + 	}
       
   149 + 	STRCAT(buf, p);
       
   150 + 	vim_free(p);
       
   151 +     }
       
   152 +     else
       
   153 +     {
       
   154 + 	if (cmdchar == '*')
       
   155 + 	    aux_ptr = (char_u *)(p_magic ? "/.*~[^$\\" : "/^$\\");
       
   156 + 	else if (cmdchar == '#')
       
   157 + 	    aux_ptr = (char_u *)(p_magic ? "/?.*~[^$\\" : "/?^$\\");
       
   158 + 	else
       
   159 + 	    /* Don't escape spaces and Tabs in a tag with a backslash */
       
   160 + 	    aux_ptr = (char_u *)"\\|\"\n*?[";
       
   161 + 
       
   162 + 	p = buf + STRLEN(buf);
       
   163 + 	while (n-- > 0)
       
   164 + 	{
       
   165 + 	    /* put a backslash before \ and some others */
       
   166 + 	    if (vim_strchr(aux_ptr, *ptr) != NULL)
       
   167 + 		*p++ = '\\';
       
   168 + #ifdef FEAT_MBYTE
       
   169 + 	    /* When current byte is a part of multibyte character, copy all
       
   170 + 	     * bytes of that character. */
       
   171 + 	    if (has_mbyte)
       
   172 + 	    {
       
   173 + 		int i;
       
   174 + 		int len = (*mb_ptr2len)(ptr) - 1;
       
   175 + 
       
   176 + 		for (i = 0; i < len && n >= 1; ++i, --n)
       
   177 + 		    *p++ = *ptr++;
       
   178 + 	    }
       
   179   #endif
       
   180 ! 	    *p++ = *ptr++;
       
   181 ! 	}
       
   182 ! 	*p = NUL;
       
   183       }
       
   184   
       
   185       /*
       
   186        * Execute the command.
       
   187 *** ../vim-7.2.009/src/version.c	Mon Sep  1 17:56:05 2008
       
   188 --- src/version.c	Sat Sep  6 16:26:42 2008
       
   189 ***************
       
   190 *** 678,679 ****
       
   191 --- 678,681 ----
       
   192   {   /* Add new patch number below this line */
       
   193 + /**/
       
   194 +     10,
       
   195   /**/
       
   196 
       
   197 -- 
       
   198 Q. What happens to programmers when they die?
       
   199 A: MS-Windows programmers are reinstalled.  C++ programmers become undefined,
       
   200    anyone who refers to them will die as well.  Java programmers reincarnate
       
   201    after being garbage collected.
       
   202 
       
   203  /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
       
   204 ///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
       
   205 \\\        download, build and distribute -- http://www.A-A-P.org        ///
       
   206  \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///