Karsten Hopp a3a3c7
To: vim-dev@vim.org
Karsten Hopp a3a3c7
Subject: Patch 7.1.162
Karsten Hopp a3a3c7
Fcc: outbox
Karsten Hopp a3a3c7
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp a3a3c7
Mime-Version: 1.0
Karsten Hopp a3a3c7
Content-Type: text/plain; charset=ISO-8859-1
Karsten Hopp a3a3c7
Content-Transfer-Encoding: 8bit
Karsten Hopp a3a3c7
------------
Karsten Hopp a3a3c7
Karsten Hopp a3a3c7
Patch 7.1.162
Karsten Hopp a3a3c7
Problem:    Crash when using a modifier before "while" or "for". (A.Politz)
Karsten Hopp a3a3c7
Solution:   Skip modifiers when checking for a loop command.
Karsten Hopp a3a3c7
Files:	    src/proto/ex_docmd.pro, src/ex_docmd.c, src/ex_eval.c
Karsten Hopp a3a3c7
Karsten Hopp a3a3c7
Karsten Hopp a3a3c7
*** ../vim-7.1.161/src/proto/ex_docmd.pro	Sun Sep 30 14:00:41 2007
Karsten Hopp a3a3c7
--- src/proto/ex_docmd.pro	Sat Nov 24 16:34:06 2007
Karsten Hopp a3a3c7
***************
Karsten Hopp a3a3c7
*** 5,10 ****
Karsten Hopp a3a3c7
--- 5,11 ----
Karsten Hopp a3a3c7
  int getline_equal __ARGS((char_u *(*fgetline)(int, void *, int), void *cookie, char_u *(*func)(int, void *, int)));
Karsten Hopp a3a3c7
  void *getline_cookie __ARGS((char_u *(*fgetline)(int, void *, int), void *cookie));
Karsten Hopp a3a3c7
  int checkforcmd __ARGS((char_u **pp, char *cmd, int len));
Karsten Hopp a3a3c7
+ int modifier_len __ARGS((char_u *cmd));
Karsten Hopp a3a3c7
  int cmd_exists __ARGS((char_u *name));
Karsten Hopp a3a3c7
  char_u *set_one_cmd_context __ARGS((expand_T *xp, char_u *buff));
Karsten Hopp a3a3c7
  char_u *skip_range __ARGS((char_u *cmd, int *ctx));
Karsten Hopp a3a3c7
*** ../vim-7.1.161/src/ex_docmd.c	Tue Nov 20 12:30:31 2007
Karsten Hopp a3a3c7
--- src/ex_docmd.c	Sat Nov 24 16:41:20 2007
Karsten Hopp a3a3c7
***************
Karsten Hopp a3a3c7
*** 2963,2968 ****
Karsten Hopp a3a3c7
--- 2963,3019 ----
Karsten Hopp a3a3c7
  #endif
Karsten Hopp a3a3c7
  
Karsten Hopp a3a3c7
  #if defined(FEAT_EVAL) || defined(PROTO)
Karsten Hopp a3a3c7
+ static struct cmdmod
Karsten Hopp a3a3c7
+ {
Karsten Hopp a3a3c7
+     char	*name;
Karsten Hopp a3a3c7
+     int		minlen;
Karsten Hopp a3a3c7
+     int		has_count;  /* :123verbose  :3tab */
Karsten Hopp a3a3c7
+ } cmdmods[] = {
Karsten Hopp a3a3c7
+     {"aboveleft", 3, FALSE},
Karsten Hopp a3a3c7
+     {"belowright", 3, FALSE},
Karsten Hopp a3a3c7
+     {"botright", 2, FALSE},
Karsten Hopp a3a3c7
+     {"browse", 3, FALSE},
Karsten Hopp a3a3c7
+     {"confirm", 4, FALSE},
Karsten Hopp a3a3c7
+     {"hide", 3, FALSE},
Karsten Hopp a3a3c7
+     {"keepalt", 5, FALSE},
Karsten Hopp a3a3c7
+     {"keepjumps", 5, FALSE},
Karsten Hopp a3a3c7
+     {"keepmarks", 3, FALSE},
Karsten Hopp a3a3c7
+     {"leftabove", 5, FALSE},
Karsten Hopp a3a3c7
+     {"lockmarks", 3, FALSE},
Karsten Hopp a3a3c7
+     {"rightbelow", 6, FALSE},
Karsten Hopp a3a3c7
+     {"sandbox", 3, FALSE},
Karsten Hopp a3a3c7
+     {"silent", 3, FALSE},
Karsten Hopp a3a3c7
+     {"tab", 3, TRUE},
Karsten Hopp a3a3c7
+     {"topleft", 2, FALSE},
Karsten Hopp a3a3c7
+     {"verbose", 4, TRUE},
Karsten Hopp a3a3c7
+     {"vertical", 4, FALSE},
Karsten Hopp a3a3c7
+ };
Karsten Hopp a3a3c7
+ 
Karsten Hopp a3a3c7
+ /*
Karsten Hopp a3a3c7
+  * Return length of a command modifier (including optional count).
Karsten Hopp a3a3c7
+  * Return zero when it's not a modifier.
Karsten Hopp a3a3c7
+  */
Karsten Hopp a3a3c7
+     int
Karsten Hopp a3a3c7
+ modifier_len(cmd)
Karsten Hopp a3a3c7
+     char_u	*cmd;
Karsten Hopp a3a3c7
+ {
Karsten Hopp a3a3c7
+     int		i, j;
Karsten Hopp a3a3c7
+     char_u	*p = cmd;
Karsten Hopp a3a3c7
+ 
Karsten Hopp a3a3c7
+     if (VIM_ISDIGIT(*cmd))
Karsten Hopp a3a3c7
+ 	p = skipwhite(skipdigits(cmd));
Karsten Hopp a3a3c7
+     for (i = 0; i < sizeof(cmdmods) / sizeof(struct cmdmod); ++i)
Karsten Hopp a3a3c7
+     {
Karsten Hopp a3a3c7
+ 	for (j = 0; p[j] != NUL; ++j)
Karsten Hopp a3a3c7
+ 	    if (p[j] != cmdmods[i].name[j])
Karsten Hopp a3a3c7
+ 		break;
Karsten Hopp a3a3c7
+ 	if (!isalpha(p[j]) && j >= cmdmods[i].minlen
Karsten Hopp a3a3c7
+ 					&& (p == cmd || cmdmods[i].has_count))
Karsten Hopp a3a3c7
+ 	    return j + (p - cmd);
Karsten Hopp a3a3c7
+     }
Karsten Hopp a3a3c7
+     return 0;
Karsten Hopp a3a3c7
+ }
Karsten Hopp a3a3c7
+ 
Karsten Hopp a3a3c7
  /*
Karsten Hopp a3a3c7
   * Return > 0 if an Ex command "name" exists.
Karsten Hopp a3a3c7
   * Return 2 if there is an exact match.
Karsten Hopp a3a3c7
***************
Karsten Hopp a3a3c7
*** 2977,3006 ****
Karsten Hopp a3a3c7
      int		i;
Karsten Hopp a3a3c7
      int		j;
Karsten Hopp a3a3c7
      char_u	*p;
Karsten Hopp a3a3c7
-     static struct cmdmod
Karsten Hopp a3a3c7
-     {
Karsten Hopp a3a3c7
- 	char	*name;
Karsten Hopp a3a3c7
- 	int	minlen;
Karsten Hopp a3a3c7
-     } cmdmods[] = {
Karsten Hopp a3a3c7
- 	{"aboveleft", 3},
Karsten Hopp a3a3c7
- 	{"belowright", 3},
Karsten Hopp a3a3c7
- 	{"botright", 2},
Karsten Hopp a3a3c7
- 	{"browse", 3},
Karsten Hopp a3a3c7
- 	{"confirm", 4},
Karsten Hopp a3a3c7
- 	{"hide", 3},
Karsten Hopp a3a3c7
- 	{"keepalt", 5},
Karsten Hopp a3a3c7
- 	{"keepjumps", 5},
Karsten Hopp a3a3c7
- 	{"keepmarks", 3},
Karsten Hopp a3a3c7
- 	{"leftabove", 5},
Karsten Hopp a3a3c7
- 	{"lockmarks", 3},
Karsten Hopp a3a3c7
- 	{"rightbelow", 6},
Karsten Hopp a3a3c7
- 	{"sandbox", 3},
Karsten Hopp a3a3c7
- 	{"silent", 3},
Karsten Hopp a3a3c7
- 	{"tab", 3},
Karsten Hopp a3a3c7
- 	{"topleft", 2},
Karsten Hopp a3a3c7
- 	{"verbose", 4},
Karsten Hopp a3a3c7
- 	{"vertical", 4},
Karsten Hopp a3a3c7
-     };
Karsten Hopp a3a3c7
  
Karsten Hopp a3a3c7
      /* Check command modifiers. */
Karsten Hopp a3a3c7
      for (i = 0; i < sizeof(cmdmods) / sizeof(struct cmdmod); ++i)
Karsten Hopp a3a3c7
--- 3028,3033 ----
Karsten Hopp a3a3c7
*** ../vim-7.1.161/src/ex_eval.c	Wed Aug  1 15:47:06 2007
Karsten Hopp a3a3c7
--- src/ex_eval.c	Sat Nov 24 16:34:09 2007
Karsten Hopp a3a3c7
***************
Karsten Hopp a3a3c7
*** 2269,2277 ****
Karsten Hopp a3a3c7
  has_loop_cmd(p)
Karsten Hopp a3a3c7
      char_u	*p;
Karsten Hopp a3a3c7
  {
Karsten Hopp a3a3c7
!     p = skipwhite(p);
Karsten Hopp a3a3c7
!     while (*p == ':')
Karsten Hopp a3a3c7
! 	p = skipwhite(p + 1);
Karsten Hopp a3a3c7
      if ((p[0] == 'w' && p[1] == 'h')
Karsten Hopp a3a3c7
  	    || (p[0] == 'f' && p[1] == 'o' && p[2] == 'r'))
Karsten Hopp a3a3c7
  	return TRUE;
Karsten Hopp a3a3c7
--- 2269,2286 ----
Karsten Hopp a3a3c7
  has_loop_cmd(p)
Karsten Hopp a3a3c7
      char_u	*p;
Karsten Hopp a3a3c7
  {
Karsten Hopp a3a3c7
!     int		len;
Karsten Hopp a3a3c7
! 
Karsten Hopp a3a3c7
!     /* skip modifiers, white space and ':' */
Karsten Hopp a3a3c7
!     for (;;)
Karsten Hopp a3a3c7
!     {
Karsten Hopp a3a3c7
! 	while (*p == ' ' || *p == '\t' || *p == ':')
Karsten Hopp a3a3c7
! 	    ++p;
Karsten Hopp a3a3c7
! 	len = modifier_len(p);
Karsten Hopp a3a3c7
! 	if (len == 0)
Karsten Hopp a3a3c7
! 	    break;
Karsten Hopp a3a3c7
! 	p += len;
Karsten Hopp a3a3c7
!     }
Karsten Hopp a3a3c7
      if ((p[0] == 'w' && p[1] == 'h')
Karsten Hopp a3a3c7
  	    || (p[0] == 'f' && p[1] == 'o' && p[2] == 'r'))
Karsten Hopp a3a3c7
  	return TRUE;
Karsten Hopp a3a3c7
*** ../vim-7.1.161/src/version.c	Sat Nov 24 21:27:33 2007
Karsten Hopp a3a3c7
--- src/version.c	Sat Nov 24 21:48:38 2007
Karsten Hopp a3a3c7
***************
Karsten Hopp a3a3c7
*** 668,669 ****
Karsten Hopp a3a3c7
--- 668,671 ----
Karsten Hopp a3a3c7
  {   /* Add new patch number below this line */
Karsten Hopp a3a3c7
+ /**/
Karsten Hopp a3a3c7
+     162,
Karsten Hopp a3a3c7
  /**/
Karsten Hopp a3a3c7
Karsten Hopp a3a3c7
-- 
Karsten Hopp a3a3c7
hundred-and-one symptoms of being an internet addict:
Karsten Hopp a3a3c7
144. You eagerly await the update of the "Cool Site of the Day."
Karsten Hopp a3a3c7
Karsten Hopp a3a3c7
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp a3a3c7
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp a3a3c7
\\\        download, build and distribute -- http://www.A-A-P.org        ///
Karsten Hopp a3a3c7
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///