components/vim/vim72-patches/7.2.262
changeset 198 172fc01ce997
equal deleted inserted replaced
197:fd801ec0737c 198:172fc01ce997
       
     1 To: [email protected]
       
     2 Subject: Patch 7.2.262
       
     3 Fcc: outbox
       
     4 From: Bram Moolenaar <[email protected]>
       
     5 Mime-Version: 1.0
       
     6 Content-Type: text/plain; charset=UTF-8
       
     7 Content-Transfer-Encoding: 8bit
       
     8 ------------
       
     9 
       
    10 Patch 7.2.262
       
    11 Problem:    When using custom completion for a user command the pattern string
       
    12 	    goes beyond the cursor position. (Hari Krishna Dara)
       
    13 Solution:   Truncate the string at the cursor position.
       
    14 Files:	    src/ex_getln.c, src/structs.h
       
    15 
       
    16 
       
    17 *** ../vim-7.2.261/src/ex_getln.c	2009-06-24 17:04:40.000000000 +0200
       
    18 --- src/ex_getln.c	2009-09-18 16:58:16.000000000 +0200
       
    19 ***************
       
    20 *** 3266,3272 ****
       
    21       int		i, j;
       
    22       char_u	*p1;
       
    23       char_u	*p2;
       
    24 -     int		oldlen;
       
    25       int		difflen;
       
    26       int		v;
       
    27   
       
    28 --- 3266,3271 ----
       
    29 ***************
       
    30 *** 3291,3297 ****
       
    31       out_flush();
       
    32   
       
    33       i = (int)(xp->xp_pattern - ccline.cmdbuff);
       
    34 !     oldlen = ccline.cmdpos - i;
       
    35   
       
    36       if (type == WILD_NEXT || type == WILD_PREV)
       
    37       {
       
    38 --- 3290,3296 ----
       
    39       out_flush();
       
    40   
       
    41       i = (int)(xp->xp_pattern - ccline.cmdbuff);
       
    42 !     xp->xp_pattern_len = ccline.cmdpos - i;
       
    43   
       
    44       if (type == WILD_NEXT || type == WILD_PREV)
       
    45       {
       
    46 ***************
       
    47 *** 3305,3322 ****
       
    48   	/*
       
    49   	 * Translate string into pattern and expand it.
       
    50   	 */
       
    51 ! 	if ((p1 = addstar(&ccline.cmdbuff[i], oldlen, xp->xp_context)) == NULL)
       
    52   	    p2 = NULL;
       
    53   	else
       
    54   	{
       
    55 ! 	    p2 = ExpandOne(xp, p1, vim_strnsave(&ccline.cmdbuff[i], oldlen),
       
    56   		    WILD_HOME_REPLACE|WILD_ADD_SLASH|WILD_SILENT|WILD_ESCAPE
       
    57   							      |options, type);
       
    58   	    vim_free(p1);
       
    59   	    /* longest match: make sure it is not shorter (happens with :help */
       
    60   	    if (p2 != NULL && type == WILD_LONGEST)
       
    61   	    {
       
    62 ! 		for (j = 0; j < oldlen; ++j)
       
    63   		     if (ccline.cmdbuff[i + j] == '*'
       
    64   			     || ccline.cmdbuff[i + j] == '?')
       
    65   			 break;
       
    66 --- 3304,3323 ----
       
    67   	/*
       
    68   	 * Translate string into pattern and expand it.
       
    69   	 */
       
    70 ! 	if ((p1 = addstar(xp->xp_pattern, xp->xp_pattern_len,
       
    71 ! 						     xp->xp_context)) == NULL)
       
    72   	    p2 = NULL;
       
    73   	else
       
    74   	{
       
    75 ! 	    p2 = ExpandOne(xp, p1,
       
    76 ! 			 vim_strnsave(&ccline.cmdbuff[i], xp->xp_pattern_len),
       
    77   		    WILD_HOME_REPLACE|WILD_ADD_SLASH|WILD_SILENT|WILD_ESCAPE
       
    78   							      |options, type);
       
    79   	    vim_free(p1);
       
    80   	    /* longest match: make sure it is not shorter (happens with :help */
       
    81   	    if (p2 != NULL && type == WILD_LONGEST)
       
    82   	    {
       
    83 ! 		for (j = 0; j < xp->xp_pattern_len; ++j)
       
    84   		     if (ccline.cmdbuff[i + j] == '*'
       
    85   			     || ccline.cmdbuff[i + j] == '?')
       
    86   			 break;
       
    87 ***************
       
    88 *** 3331,3337 ****
       
    89   
       
    90       if (p2 != NULL && !got_int)
       
    91       {
       
    92 ! 	difflen = (int)STRLEN(p2) - oldlen;
       
    93   	if (ccline.cmdlen + difflen > ccline.cmdbufflen - 4)
       
    94   	{
       
    95   	    v = realloc_cmdbuff(ccline.cmdlen + difflen);
       
    96 --- 3332,3338 ----
       
    97   
       
    98       if (p2 != NULL && !got_int)
       
    99       {
       
   100 ! 	difflen = (int)STRLEN(p2) - xp->xp_pattern_len;
       
   101   	if (ccline.cmdlen + difflen > ccline.cmdbufflen - 4)
       
   102   	{
       
   103   	    v = realloc_cmdbuff(ccline.cmdlen + difflen);
       
   104 ***************
       
   105 *** 3620,3625 ****
       
   106 --- 3621,3627 ----
       
   107       expand_T	*xp;
       
   108   {
       
   109       xp->xp_pattern = NULL;
       
   110 +     xp->xp_pattern_len = 0;
       
   111       xp->xp_backslash = XP_BS_NONE;
       
   112   #ifndef BACKSLASH_IN_FILENAME
       
   113       xp->xp_shell = FALSE;
       
   114 ***************
       
   115 *** 4311,4318 ****
       
   116       }
       
   117   
       
   118       /* add star to file name, or convert to regexp if not exp. files. */
       
   119 !     file_str = addstar(xp->xp_pattern,
       
   120 ! 			   (int)(str + col - xp->xp_pattern), xp->xp_context);
       
   121       if (file_str == NULL)
       
   122   	return EXPAND_UNSUCCESSFUL;
       
   123   
       
   124 --- 4313,4320 ----
       
   125       }
       
   126   
       
   127       /* add star to file name, or convert to regexp if not exp. files. */
       
   128 !     xp->xp_pattern_len = (int)(str + col - xp->xp_pattern);
       
   129 !     file_str = addstar(xp->xp_pattern, xp->xp_pattern_len, xp->xp_context);
       
   130       if (file_str == NULL)
       
   131   	return EXPAND_UNSUCCESSFUL;
       
   132   
       
   133 ***************
       
   134 *** 4781,4787 ****
       
   135   	sprintf((char *)num, "%d", ccline.cmdpos);
       
   136   	args[1] = ccline.cmdbuff;
       
   137       }
       
   138 !     args[0] = xp->xp_pattern;
       
   139       args[2] = num;
       
   140   
       
   141       /* Save the cmdline, we don't know what the function may do. */
       
   142 --- 4783,4789 ----
       
   143   	sprintf((char *)num, "%d", ccline.cmdpos);
       
   144   	args[1] = ccline.cmdbuff;
       
   145       }
       
   146 !     args[0] = vim_strnsave(xp->xp_pattern, xp->xp_pattern_len);
       
   147       args[2] = num;
       
   148   
       
   149       /* Save the cmdline, we don't know what the function may do. */
       
   150 ***************
       
   151 *** 4797,4802 ****
       
   152 --- 4799,4805 ----
       
   153       if (ccline.cmdbuff != NULL)
       
   154   	ccline.cmdbuff[ccline.cmdlen] = keep;
       
   155   
       
   156 +     vim_free(args[0]);
       
   157       return ret;
       
   158   }
       
   159   
       
   160 *** ../vim-7.2.261/src/structs.h	2009-07-29 12:09:49.000000000 +0200
       
   161 --- src/structs.h	2009-09-18 15:33:15.000000000 +0200
       
   162 ***************
       
   163 *** 432,437 ****
       
   164 --- 432,438 ----
       
   165   {
       
   166       int		xp_context;		/* type of expansion */
       
   167       char_u	*xp_pattern;		/* start of item to expand */
       
   168 +     int		xp_pattern_len;		/* bytes in xp_pattern before cursor */
       
   169   #if defined(FEAT_USR_CMDS) && defined(FEAT_EVAL) && defined(FEAT_CMDL_COMPL)
       
   170       char_u	*xp_arg;		/* completion function */
       
   171       int		xp_scriptID;		/* SID for completion function */
       
   172 *** ../vim-7.2.261/src/version.c	2009-09-18 15:16:37.000000000 +0200
       
   173 --- src/version.c	2009-09-18 17:23:20.000000000 +0200
       
   174 ***************
       
   175 *** 678,679 ****
       
   176 --- 678,681 ----
       
   177   {   /* Add new patch number below this line */
       
   178 + /**/
       
   179 +     262,
       
   180   /**/
       
   181 
       
   182 -- 
       
   183 hundred-and-one symptoms of being an internet addict:
       
   184 252. You vote for foreign officials.
       
   185 
       
   186  /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
       
   187 ///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
       
   188 \\\        download, build and distribute -- http://www.A-A-P.org        ///
       
   189  \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///