patch to fix access to uninitialized value in os_unix.c (with: set mouse=a)

2008-01-13 Fir de Conversatie Dominique Pelle
Valgrind memory checker detects use of uninitialised value vim:

==6865== Conditional jump or move depends on uninitialised value(s)
==6865==at 0x814E0BA: do_xterm_trace (os_unix.c:6121)
==6865==by 0x814E038: start_xterm_trace (os_unix.c:6081)
==6865==by 0x81B25BA: check_termcode (term.c:4301)
==6865==by 0x80D4A58: vgetorpeek (getchar.c:2253)
==6865==by 0x80D3B9C: vgetc (getchar.c:1552)
==6865==by 0x80D4117: safe_vgetc (getchar.c:1757)
==6865==by 0x8121D96: normal_cmd (normal.c:625)
==6865==by 0x80E5A49: main_loop (main.c:1181)
==6865==by 0x80E5599: main (main.c:940)

Steps to reproduce:

1/ Run vim with the mouse option in a terminal:

   $ valgrind vim -u NONE -c 'set mouse=a' 2 vg.log

2/ Left click with the mouse anywhere in the terminal to position cursor

3/ Observe the valgrind error at os_unix.c:6121 (do_xterm_trace)
   Cursor is positioned properly where I click (no apparent wrong
   behavior despite the error).

Code in os_unix.c:

6118 /* Get the hints just before tracking starts.  The font size might
6119  * have changed recently */
6120 XGetWMNormalHints(xterm_dpy, x11_window, xterm_hints, got_hints);
6121 if (!(got_hints  PResizeInc)
6122 || xterm_hints.width_inc = 1
6123 || xterm_hints.height_inc = 1)
6124 {
6125 xterm_trace = -1;  /* Not enough data -- disable tracing */
6126 return FALSE;
6127 }

When error happens, call to XGetWMNormalHints(...) at line 6120 fails
somehow [i.e. it returns a 0 (error), I don't know why].   When
XGetWMNormalHints(...) fails, it does not initialize output value
got_hints, hence access to uninitialized value later at line 6121.

Here is a snippet of the man page of XGetWMNormalHints(...):

---
The XGetWMNormalHints function returns the size hints stored in the WM_NOR‐
MAL_HINTS property on the specified window.  If the property is of type
WM_SIZE_HINTS, is of format 32, and is long enough to contain either an old
(pre-ICCCM) or new size hints structure, XGetWMNormalHints sets the various
fields of the XSizeHints structure, sets the supplied_return argument to the
list of fields that were supplied by the user (whether or not they contained
defined values), and returns a nonzero status.  Otherwise, it returns a zero
status.

If XGetWMNormalHints returns successfully and a pre-ICCCM size hints property
is read, the supplied_return argument will contain the following bits:
---

I attach a patch which fixes it by checking the return value of
XGetWMNormalHints(...). It would be interesting to know why
XGetWMNormalHints(...) failed in the first place though.

I am using vim-7.1 (Patches 1-220) built with 'configure --with-feature=huge',
without optimizations (-g -O0) on Linux in a gnome-terminal.

-- Dominique

--~--~-~--~~~---~--~~
You received this message from the vim_dev maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---

Index: os_unix.c
===
RCS file: /cvsroot/vim/vim7/src/os_unix.c,v
retrieving revision 1.75
diff -c -r1.75 os_unix.c
*** os_unix.c	3 Jan 2008 17:55:44 -	1.75
--- os_unix.c	13 Jan 2008 07:57:25 -
***
*** 6117,6124 
  {
  	/* Get the hints just before tracking starts.  The font size might
  	 * have changed recently */
! 	XGetWMNormalHints(xterm_dpy, x11_window, xterm_hints, got_hints);
! 	if (!(got_hints  PResizeInc)
  		|| xterm_hints.width_inc = 1
  		|| xterm_hints.height_inc = 1)
  	{
--- 6117,6124 
  {
  	/* Get the hints just before tracking starts.  The font size might
  	 * have changed recently */
! if (!XGetWMNormalHints(xterm_dpy, x11_window, xterm_hints, got_hints)
! 		|| !(got_hints  PResizeInc)
  		|| xterm_hints.width_inc = 1
  		|| xterm_hints.height_inc = 1)
  	{


Patch 7.1.222

2008-01-13 Fir de Conversatie Bram Moolenaar


Patch 7.1.222 (after 7.1.217)
Problem:Wildcards in argument of :helptags are not expanded.  (Marcel
Svitalsky)
Solution:   Expand wildcards in the directory name.
Files:  src/ex_cmds.c


*** ../vim-7.1.221/src/ex_cmds.cFri Jan 11 21:00:49 2008
--- src/ex_cmds.c   Sat Jan 12 21:40:51 2008
***
*** 6106,6111 
--- 6106,6113 
  #ifdef FEAT_MULTI_LANG
  char_ulang[2];
  #endif
+ expand_T  xpc;
+ char_u*dirname;
  char_uext[5];
  char_ufname[8];
  int   filecount;
***
*** 6119,6125 
eap-arg = skipwhite(eap-arg + 3);
  }
  
! if (!mch_isdir(eap-arg))
  {
EMSG2(_(E150: Not a directory: %s), eap-arg);
return;
--- 6121,6131 
eap-arg = skipwhite(eap-arg + 3);
  }
  
! ExpandInit(xpc);
! xpc.xp_context = EXPAND_DIRECTORIES;
! dirname = ExpandOne(xpc, eap-arg, NULL,
!   WILD_LIST_NOTFOUND|WILD_SILENT, WILD_EXPAND_FREE);
! if (dirname == NULL || !mch_isdir(dirname))
  {
EMSG2(_(E150: Not a directory: %s), eap-arg);
return;
***
*** 6127,6133 
  
  #ifdef FEAT_MULTI_LANG
  /* Get a list of all files in the directory. */
! STRCPY(NameBuff, eap-arg);
  add_pathsep(NameBuff);
  STRCAT(NameBuff, *);
  if (gen_expand_wildcards(1, NameBuff, filecount, files,
--- 6133,6139 
  
  #ifdef FEAT_MULTI_LANG
  /* Get a list of all files in the directory. */
! STRCPY(NameBuff, dirname);
  add_pathsep(NameBuff);
  STRCAT(NameBuff, *);
  if (gen_expand_wildcards(1, NameBuff, filecount, files,
***
*** 6135,6140 
--- 6141,6147 
|| filecount == 0)
  {
EMSG2(E151: No match: %s, NameBuff);
+   vim_free(dirname);
return;
  }
  
***
*** 6200,6206 
ext[1] = fname[5];
ext[2] = fname[6];
}
!   helptags_one(eap-arg, ext, fname, add_help_tags);
  }
  
  ga_clear(ga);
--- 6207,6213 
ext[1] = fname[5];
ext[2] = fname[6];
}
!   helptags_one(dirname, ext, fname, add_help_tags);
  }
  
  ga_clear(ga);
***
*** 6208,6215 
  
  #else
  /* No language support, just use *.txt and tags. */
! helptags_one(eap-arg, (char_u *).txt, (char_u *)tags, add_help_tags);
  #endif
  }
  
  static void
--- 6215,6223 
  
  #else
  /* No language support, just use *.txt and tags. */
! helptags_one(dirname, (char_u *).txt, (char_u *)tags, add_help_tags);
  #endif
+ vim_free(dirname);
  }
  
  static void
*** ../vim-7.1.221/src/version.cSat Jan 12 18:13:05 2008
--- src/version.c   Sun Jan 13 13:27:04 2008
***
*** 668,669 
--- 668,671 
  {   /* Add new patch number below this line */
+ /**/
+ 222,
  /**/

-- 
   Arthur pulls Pin out.  The MONK blesses the grenade as ...
ARTHUR:  (quietly) One, two, five ...
GALAHAD: Three, sir!
ARTHUR:  Three.
 Monty Python and the Holy Grail PYTHON (MONTY) PICTURES LTD

 /// Bram Moolenaar -- [EMAIL PROTECTED] -- 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///

--~--~-~--~~~---~--~~
You received this message from the vim_dev maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



Re: Patch for Unix filename expansion to try out

2008-01-13 Fir de Conversatie Bram Moolenaar


Dasn wrote:

 Hmm, I might be boring bossy, but still expecting to use glob(3) or
 fnmatch(3) directly ...

They are not available on all systems.  And only do normal wildcards,
which is something that Vim does itself anyway.  We need the shell for
things like backticks.

-- 
ARTHUR:  But if he was dying, he wouldn't bother to carve
 Arrggghhh.  He'd just say it.
BROTHER MAYNARD: It's down there carved in stone.
GALAHAD: Perhaps he was dictating.
 Monty Python and the Holy Grail PYTHON (MONTY) PICTURES LTD

 /// Bram Moolenaar -- [EMAIL PROTECTED] -- 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///

--~--~-~--~~~---~--~~
You received this message from the vim_dev maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



Patch 7.1.223

2008-01-13 Fir de Conversatie Bram Moolenaar


Patch 7.1.223
Problem:glob() doesn't work properly when 'shell' is sh or bash and
the expanded name contains spaces, '~', single quotes and other
special characters.  (Adri Verhoef, Charles Campbell)
Solution:   For Posix shells define a vimglob() function to list the matches
instead of using echo directly.
Files:  src/os_unix.c


*** ../vim-7.1.222/src/os_unix.cThu Jan  3 18:55:21 2008
--- src/os_unix.c   Sun Jan 13 13:52:53 2008
***
*** 4946,4951 
--- 4946,4954 
  char_u*p;
  int   dir;
  #ifdef __EMX__
+ /*
+  * This is the OS/2 implementation.
+  */
  # define EXPL_ALLOC_INC   16
  char_u**expl_files;
  size_tfiles_alloced, files_free;
***
*** 5056,5075 
  return OK;
  
  #else /* __EMX__ */
! 
  int   j;
  char_u*tempname;
  char_u*command;
  FILE  *fd;
  char_u*buffer;
! #define STYLE_ECHO  0 /* use echo to expand */
! #define STYLE_GLOB  1 /* use glob to expand, for csh */
! #define STYLE_PRINT 2 /* use print -N to expand, for zsh */
! #define STYLE_BT3 /* `cmd` expansion, execute the pattern directly */
  int   shell_style = STYLE_ECHO;
  int   check_spaces;
  static intdid_find_nul = FALSE;
  int   ampersent = FALSE;
  
  *num_file = 0;/* default: no files found */
  *file = NULL;
--- 5059,5084 
  return OK;
  
  #else /* __EMX__ */
! /*
!  * This is the non-OS/2 implementation (really Unix).
!  */
  int   j;
  char_u*tempname;
  char_u*command;
  FILE  *fd;
  char_u*buffer;
! #define STYLE_ECHO0   /* use echo, the default */
! #define STYLE_GLOB1   /* use glob, for csh */
! #define STYLE_VIMGLOB 2   /* use vimglob, for Posix sh */
! #define STYLE_PRINT   3   /* use print -N, for zsh */
! #define STYLE_BT  4   /* `cmd` expansion, execute the pattern
!* directly */
  int   shell_style = STYLE_ECHO;
  int   check_spaces;
  static intdid_find_nul = FALSE;
  int   ampersent = FALSE;
+   /* vimglob() function to define for Posix shell */
+ static char *sh_vimglob_func = vimglob() { while [ $# -ge 1 ]; do echo 
-n \$1\; echo; shift; done }; vimglob ;
  
  *num_file = 0;/* default: no files found */
  *file = NULL;
***
*** 5107,5115 
  
  /*
   * Let the shell expand the patterns and write the result into the temp
!  * file.  if expanding `cmd` execute it directly.
!  * If we use csh, glob will work better than echo.
!  * If we use zsh, print -N will work better than glob.
   */
  if (num_pat == 1  *pat[0] == '`'
 (len = STRLEN(pat[0]))  2
--- 5116,5132 
  
  /*
   * Let the shell expand the patterns and write the result into the temp
!  * file.
!  * STYLE_BT:  NL separated
!  *If expanding `cmd` execute it directly.
!  * STYLE_GLOB:NUL separated
!  *If we use *csh, glob will work better than echo.
!  * STYLE_PRINT:   NL or NUL separated
!  *If we use *zsh, print -N will work better than glob.
!  * STYLE_VIMGLOB: NL separated
!  *If we use *sh*, we define vimglob().
!  * STYLE_ECHO:space separated.
!  *A shell we don't know, stay safe and use echo.
   */
  if (num_pat == 1  *pat[0] == '`'
 (len = STRLEN(pat[0]))  2
***
*** 5122,5130 
else if (STRCMP(p_sh + len - 3, zsh) == 0)
shell_style = STYLE_PRINT;
  }
! 
! /* unset nonomatch; print -N  plus two is 29 */
  len = STRLEN(tempname) + 29;
  for (i = 0; i  num_pat; ++i)
  {
/* Count the length of the patterns in the same way as they are put in
--- 5139,5155 
else if (STRCMP(p_sh + len - 3, zsh) == 0)
shell_style = STYLE_PRINT;
  }
! if (shell_style == STYLE_ECHO  strstr((char *)gettail(p_sh),
!   sh) != NULL)
!   shell_style = STYLE_VIMGLOB;
! 
! /* Compute the length of the command.  We need 2 extra bytes: for the
!  * optional '' and for the NUL.
!  * Worst case: unset nonomatch; print -N  plus two is 29 */
  len = STRLEN(tempname) + 29;
+ if (shell_style == STYLE_VIMGLOB)
+   len += STRLEN(sh_vimglob_func);
+ 
  for (i = 0; i  num_pat; ++i)
  {
/* Count the length of the patterns in the same way as they are put in
***
*** 5183,5192 
--- 5208,5221 
STRCAT(command, glob );
else if (shell_style == STYLE_PRINT)
STRCAT(command, print -N );
+   else if (shell_style == STYLE_VIMGLOB)
+   

Re: patch to fix access to uninitialized value in os_unix.c (with: set mouse=a)

2008-01-13 Fir de Conversatie Bram Moolenaar


Dominique Pelle wrote:

 Valgrind memory checker detects use of uninitialised value vim:
 
 ==6865== Conditional jump or move depends on uninitialised value(s)
 ==6865==at 0x814E0BA: do_xterm_trace (os_unix.c:6121)
 ==6865==by 0x814E038: start_xterm_trace (os_unix.c:6081)
 ==6865==by 0x81B25BA: check_termcode (term.c:4301)
 ==6865==by 0x80D4A58: vgetorpeek (getchar.c:2253)
 ==6865==by 0x80D3B9C: vgetc (getchar.c:1552)
 ==6865==by 0x80D4117: safe_vgetc (getchar.c:1757)
 ==6865==by 0x8121D96: normal_cmd (normal.c:625)
 ==6865==by 0x80E5A49: main_loop (main.c:1181)
 ==6865==by 0x80E5599: main (main.c:940)
 
 Steps to reproduce:
 
 1/ Run vim with the mouse option in a terminal:
 
$ valgrind vim -u NONE -c 'set mouse=a' 2 vg.log
 
 2/ Left click with the mouse anywhere in the terminal to position cursor
 
 3/ Observe the valgrind error at os_unix.c:6121 (do_xterm_trace)
Cursor is positioned properly where I click (no apparent wrong
behavior despite the error).
 
 Code in os_unix.c:
 
 6118 /* Get the hints just before tracking starts.  The font size 
 might
 6119  * have changed recently */
 6120 XGetWMNormalHints(xterm_dpy, x11_window, xterm_hints, 
 got_hints);
 6121 if (!(got_hints  PResizeInc)
 6122 || xterm_hints.width_inc = 1
 6123 || xterm_hints.height_inc = 1)
 6124 {
 6125 xterm_trace = -1;  /* Not enough data -- disable tracing */
 6126 return FALSE;
 6127 }
 
 When error happens, call to XGetWMNormalHints(...) at line 6120 fails
 somehow [i.e. it returns a 0 (error), I don't know why].   When
 XGetWMNormalHints(...) fails, it does not initialize output value
 got_hints, hence access to uninitialized value later at line 6121.
 
 Here is a snippet of the man page of XGetWMNormalHints(...):
 
 ---
 The XGetWMNormalHints function returns the size hints stored in the WM_NOR‐
 MAL_HINTS property on the specified window.  If the property is of type
 WM_SIZE_HINTS, is of format 32, and is long enough to contain either an old
 (pre-ICCCM) or new size hints structure, XGetWMNormalHints sets the various
 fields of the XSizeHints structure, sets the supplied_return argument to the
 list of fields that were supplied by the user (whether or not they contained
 defined values), and returns a nonzero status.  Otherwise, it returns a zero
 status.
 
 If XGetWMNormalHints returns successfully and a pre-ICCCM size hints property
 is read, the supplied_return argument will contain the following bits:
 ---
 
 I attach a patch which fixes it by checking the return value of
 XGetWMNormalHints(...). It would be interesting to know why
 XGetWMNormalHints(...) failed in the first place though.
 
 I am using vim-7.1 (Patches 1-220) built with 'configure --with-feature=huge',
 without optimizations (-g -O0) on Linux in a gnome-terminal.

Looks like a good fix.  I'll include it.  Thanks!

- Bram

-- 
ARTHUR:  What does it say?
BROTHER MAYNARD: It reads ... Here may be found the last words of Joseph of
 Aramathea. He who is valorous and pure of heart may find
 the Holy Grail in the arrggghhh...
ARTHUR:  What?
BROTHER MAYNARD: The Arrggghhh...
 Monty Python and the Holy Grail PYTHON (MONTY) PICTURES LTD

 /// Bram Moolenaar -- [EMAIL PROTECTED] -- 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///

--~--~-~--~~~---~--~~
You received this message from the vim_dev maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



Patch 7.1.224

2008-01-13 Fir de Conversatie Bram Moolenaar


Patch 7.1.224
Problem:When using vim -F -o file1 file2 only one window is
right-to-left.  Same for -H.  (Ben Schmidt)
Solution:   use set_option_value() to set 'rightleft'.
Files:  src/main.c


*** ../vim-7.1.223/src/main.c   Fri Jan 11 20:25:42 2008
--- src/main.c  Sun Jan 13 16:12:09 2008
***
*** 1775,1781 
  
case 'F':   /* -F start in Farsi mode: rl + fkmap set */
  #ifdef FEAT_FKMAP
!   curwin-w_p_rl = p_fkmap = TRUE;
  #else
mch_errmsg(_(e_nofarsi));
mch_exit(2);
--- 1775,1782 
  
case 'F':   /* -F start in Farsi mode: rl + fkmap set */
  #ifdef FEAT_FKMAP
!   p_fkmap = TRUE;
!   set_option_value((char_u *)rl, 1L, NULL, 0);
  #else
mch_errmsg(_(e_nofarsi));
mch_exit(2);
***
*** 1792,1798 
  
case 'H':   /* -H start in Hebrew mode: rl + hkmap set */
  #ifdef FEAT_RIGHTLEFT
!   curwin-w_p_rl = p_hkmap = TRUE;
  #else
mch_errmsg(_(e_nohebrew));
mch_exit(2);
--- 1793,1800 
  
case 'H':   /* -H start in Hebrew mode: rl + hkmap set */
  #ifdef FEAT_RIGHTLEFT
!   p_hkmap = TRUE;
!   set_option_value((char_u *)rl, 1L, NULL, 0);
  #else
mch_errmsg(_(e_nohebrew));
mch_exit(2);
*** ../vim-7.1.223/src/version.cSun Jan 13 13:53:30 2008
--- src/version.c   Sun Jan 13 16:15:49 2008
***
*** 668,669 
--- 668,671 
  {   /* Add new patch number below this line */
+ /**/
+ 224,
  /**/

-- 
LAUNCELOT: Isn't there a St. Arrggghhh's in Cornwall?
ARTHUR:No, that's Saint Ives.
 Monty Python and the Holy Grail PYTHON (MONTY) PICTURES LTD

 /// Bram Moolenaar -- [EMAIL PROTECTED] -- 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///

--~--~-~--~~~---~--~~
You received this message from the vim_dev maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



Patch 7.1.226

2008-01-13 Fir de Conversatie Bram Moolenaar


Patch 7.1.226
Problem:Command line completion doesn't work when a file name contains a
'' character.
Solution:   Accept all characters in a file name, except ones that end a
command or white space.
Files:  src/ex_docmd.c


*** ../vim-7.1.225/src/ex_docmd.c   Wed Jan  9 20:29:51 2008
--- src/ex_docmd.c  Wed Jan  9 20:11:13 2008
***
*** 3338,3349 
}
in_quote = !in_quote;
}
  #ifdef SPACE_IN_FILENAME
!   else if (!vim_isfilec_or_wc(c)
! (!(ea.argt  NOSPC) || usefilter))
! #else
!   else if (!vim_isfilec_or_wc(c))
  #endif
{
while (*p != NUL)
{
--- 3338,3350 
}
in_quote = !in_quote;
}
+   /* An argument can contain just about everything, except
+* characters that end the command and white space. */
+   else if (c == '|' || c == '\n' || c == '' || (vim_iswhite(c)
  #ifdef SPACE_IN_FILENAME
! (!(ea.argt  NOSPC) || usefilter)
  #endif
+   ))
{
while (*p != NUL)
{
*** ../vim-7.1.225/src/version.cSun Jan 13 16:30:23 2008
--- src/version.c   Sun Jan 13 17:10:15 2008
***
*** 668,669 
--- 668,671 
  {   /* Add new patch number below this line */
+ /**/
+ 226,
  /**/

-- 
   [Another hideous roar.]
BEDEVERE: That's it!
ARTHUR:   What?
BEDEVERE: It's The Legendary Black Beast of Arrggghhh!
 Monty Python and the Holy Grail PYTHON (MONTY) PICTURES LTD

 /// Bram Moolenaar -- [EMAIL PROTECTED] -- 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///

--~--~-~--~~~---~--~~
You received this message from the vim_dev maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



Patch 7.1.227

2008-01-13 Fir de Conversatie Bram Moolenaar


Patch 7.1.227
Problem:Hang in syntax HL when moving over a ). (Dominique Pelle)
Solution:   Avoid storing a syntax state in the wrong position in the list of
remembered states.
Files:  src/syntax.c


*** ../vim-7.1.226/src/syntax.c Sat Jan 12 16:45:25 2008
--- src/syntax.cSat Jan 12 16:45:44 2008
***
*** 372,378 
  static int syn_stack_cleanup __ARGS((void));
  static void syn_stack_free_entry __ARGS((buf_T *buf, synstate_T *p));
  static synstate_T *syn_stack_find_entry __ARGS((linenr_T lnum));
! static synstate_T *store_current_state __ARGS((synstate_T *sp));
  static void load_current_state __ARGS((synstate_T *from));
  static void invalidate_current_state __ARGS((void));
  static int syn_stack_equal __ARGS((synstate_T *sp));
--- 372,378 
  static int syn_stack_cleanup __ARGS((void));
  static void syn_stack_free_entry __ARGS((buf_T *buf, synstate_T *p));
  static synstate_T *syn_stack_find_entry __ARGS((linenr_T lnum));
! static synstate_T *store_current_state __ARGS((void));
  static void load_current_state __ARGS((synstate_T *from));
  static void invalidate_current_state __ARGS((void));
  static int syn_stack_equal __ARGS((synstate_T *sp));
***
*** 464,470 
  synstate_T*p;
  synstate_T*last_valid = NULL;
  synstate_T*last_min_valid = NULL;
! synstate_T*sp, *prev;
  linenr_T  parsed_lnum;
  linenr_T  first_stored;
  int   dist;
--- 464,470 
  synstate_T*p;
  synstate_T*last_valid = NULL;
  synstate_T*last_min_valid = NULL;
! synstate_T*sp, *prev = NULL;
  linenr_T  parsed_lnum;
  linenr_T  first_stored;
  int   dist;
***
*** 502,508 
if (!current_state_stored)
{
++current_lnum;
!   (void)store_current_state(NULL);
}
  
/*
--- 502,508 
if (!current_state_stored)
{
++current_lnum;
!   (void)store_current_state();
}
  
/*
***
*** 558,564 
dist = 99;
  else
dist = syn_buf-b_ml.ml_line_count / (syn_buf-b_sst_len - Rows) + 1;
- prev = syn_stack_find_entry(current_lnum);
  while (current_lnum  lnum)
  {
syn_start_line();
--- 558,563 
***
*** 573,581 
 * equal to the current state.  If so, then validate all saved
 * states that depended on a change before the parsed line. */
if (prev == NULL)
sp = syn_buf-b_sst_first;
else
!   sp = prev-sst_next;
if (sp != NULL
 sp-sst_lnum == current_lnum
 syn_stack_equal(sp))
--- 572,584 
 * equal to the current state.  If so, then validate all saved
 * states that depended on a change before the parsed line. */
if (prev == NULL)
+   prev = syn_stack_find_entry(current_lnum - 1);
+   if (prev == NULL)
sp = syn_buf-b_sst_first;
else
!   sp = prev;
!   while (sp != NULL  sp-sst_lnum  current_lnum)
!   sp = sp-sst_next;
if (sp != NULL
 sp-sst_lnum == current_lnum
 syn_stack_equal(sp))
***
*** 601,607 
else if (prev == NULL
|| current_lnum == lnum
|| current_lnum = prev-sst_lnum + dist)
!   prev = store_current_state(prev);
}
  
/* This can take a long time: break when CTRL-C pressed.  The current
--- 604,610 
else if (prev == NULL
|| current_lnum == lnum
|| current_lnum = prev-sst_lnum + dist)
!   prev = store_current_state();
}
  
/* This can take a long time: break when CTRL-C pressed.  The current
***
*** 1353,1369 
   * The current state must be valid for the start of the current_lnum line!
   */
  static synstate_T *
! store_current_state(sp)
! synstate_T*sp;/* at or before where state is to be saved or
!  NULL */
  {
  int   i;
  synstate_T*p;
  bufstate_T*bp;
  stateitem_T   *cur_si;
! 
! if (sp == NULL)
!   sp = syn_stack_find_entry(current_lnum);
  
  /*
   * If the current state contains a start or end pattern that continues
--- 1356,1368 
   * The current state must be valid for the start of the current_lnum line!
   */
  static synstate_T *
! store_current_state()
  {
  int   i;
  synstate_T*p;
  bufstate_T*bp;
  stateitem_T   *cur_si;
! synstate_T*sp = syn_stack_find_entry(current_lnum);
  
  /*
   * If the current state contains a start or end pattern that 

Patch 7.1.228

2008-01-13 Fir de Conversatie Bram Moolenaar


Patch 7.1.228
Problem:When 'foldmethod' is indent and a fold is created with  it
can't be closed with zc.  (Daniel Shahaf)
Solution:   Reset the small flag of a fold when adding a line to it.
Files:  src/fold.c


*** ../vim-7.1.227/src/fold.c   Sun Oct 14 15:32:10 2007
--- src/fold.c  Sun Jan 13 21:26:48 2008
***
*** 2676,2681 
--- 2676,2682 
  if (fp-fd_len  flp-lnum - fp-fd_top)
  {
fp-fd_len = flp-lnum - fp-fd_top;
+   fp-fd_small = MAYBE;
fold_changed = TRUE;
  }
  
*** ../vim-7.1.227/src/version.cSun Jan 13 17:39:29 2008
--- src/version.c   Sun Jan 13 21:56:53 2008
***
*** 668,669 
--- 668,671 
  {   /* Add new patch number below this line */
+ /**/
+ 228,
  /**/

-- 
VOICE OVER: As the horrendous Black Beast lunged forward, escape for Arthur
and his knights seemed hopeless,  when, suddenly ... the animator
suffered a fatal heart attack.
ANIMATOR:   Agh!
VOICE OVER: The cartoon peril was no more ... The Quest for Holy Grail could
continue.
 Monty Python and the Holy Grail PYTHON (MONTY) PICTURES LTD

 /// Bram Moolenaar -- [EMAIL PROTECTED] -- 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///

--~--~-~--~~~---~--~~
You received this message from the vim_dev maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



Documentation for /ordinary-atom missing \*?

2008-01-13 Fir de Conversatie Nico Weber

Hi,

you can use '\*' to match a literal '*' (with 'magic' set). I can't  
find this mentioned anywhere in the documentation. User error or  
missing documentation?

Thanks,
Nico

--~--~-~--~~~---~--~~
You received this message from the vim_dev maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



Re: Documentation for /ordinary-atom missing \*?

2008-01-13 Fir de Conversatie Tony Mechelynck

Nico Weber wrote:
 Hi,
 
 you can use '\*' to match a literal '*' (with 'magic' set). I can't  
 find this mentioned anywhere in the documentation. User error or  
 missing documentation?
 
 Thanks,
 Nico

It might be useful to mention it there, but it is not really missing: look 
under :help /magic and you'll see:

 3. Magic  */magic*
 
 Some characters in the pattern are taken literally.  They match with the same
 character in the text.  When preceded with a backslash however, these
 characters get a special meaning.
 
 Other characters have a special meaning without a backslash.  They need to be
 preceded with a backslash to match literally.
 
 If a character is taken literally or not depends on the 'magic' option and the
 items mentioned next.

IOW, any character which (like *) has a special meaning in a pattern when it's 
not backslash-escaped, will match itself when it is, and any character which 
has a special meaning when it is, will match itself when it isn't. Which is 
which depends on the 'magic' option, and on whether atoms in the pattern 
itself set it to very magic, magic, nomagic or very nomagic.


Best regards,
Tony.
-- 
Quidquid latine dictum sit, altum viditur.

(Whatever is said in Latin sounds profound.)

--~--~-~--~~~---~--~~
You received this message from the vim_dev maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---