Karsten Hopp fbcfc8
To: vim_dev@googlegroups.com
Karsten Hopp fbcfc8
Subject: Patch 7.3.1119
Karsten Hopp fbcfc8
Fcc: outbox
Karsten Hopp fbcfc8
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp fbcfc8
Mime-Version: 1.0
Karsten Hopp fbcfc8
Content-Type: text/plain; charset=UTF-8
Karsten Hopp fbcfc8
Content-Transfer-Encoding: 8bit
Karsten Hopp fbcfc8
------------
Karsten Hopp fbcfc8
Karsten Hopp fbcfc8
Patch 7.3.1119
Karsten Hopp fbcfc8
Problem:    Flags in 'cpo' are searched for several times.
Karsten Hopp fbcfc8
Solution:   Store the result and re-use the flags.
Karsten Hopp fbcfc8
Files:	    src/regexp.c, src/regexp_nfa.c
Karsten Hopp fbcfc8
Karsten Hopp fbcfc8
Karsten Hopp fbcfc8
*** ../vim-7.3.1118/src/regexp.c	2013-06-04 21:27:33.000000000 +0200
Karsten Hopp fbcfc8
--- src/regexp.c	2013-06-05 12:37:30.000000000 +0200
Karsten Hopp fbcfc8
***************
Karsten Hopp fbcfc8
*** 365,370 ****
Karsten Hopp fbcfc8
--- 365,371 ----
Karsten Hopp fbcfc8
  static char_u e_z_not_allowed[] = N_("E66: \\z( not allowed here");
Karsten Hopp fbcfc8
  static char_u e_z1_not_allowed[] = N_("E67: \\z1 et al. not allowed here");
Karsten Hopp fbcfc8
  #endif
Karsten Hopp fbcfc8
+ static char_u e_missing_sb[] = N_("E69: Missing ] after %s%%[");
Karsten Hopp fbcfc8
  
Karsten Hopp fbcfc8
  #define NOT_MULTI	0
Karsten Hopp fbcfc8
  #define MULTI_ONE	1
Karsten Hopp fbcfc8
***************
Karsten Hopp fbcfc8
*** 1173,1178 ****
Karsten Hopp fbcfc8
--- 1174,1189 ----
Karsten Hopp fbcfc8
      return 0;
Karsten Hopp fbcfc8
  }
Karsten Hopp fbcfc8
  
Karsten Hopp fbcfc8
+ static void get_cpo_flags __ARGS((void));
Karsten Hopp fbcfc8
+ static int reg_cpo_lit; /* 'cpoptions' contains 'l' flag */
Karsten Hopp fbcfc8
+ static int reg_cpo_bsl; /* 'cpoptions' contains '\' flag */
Karsten Hopp fbcfc8
+ 
Karsten Hopp fbcfc8
+     static void
Karsten Hopp fbcfc8
+ get_cpo_flags()
Karsten Hopp fbcfc8
+ {
Karsten Hopp fbcfc8
+     reg_cpo_lit = vim_strchr(p_cpo, CPO_LITERAL) != NULL;
Karsten Hopp fbcfc8
+     reg_cpo_bsl = vim_strchr(p_cpo, CPO_BACKSL) != NULL;
Karsten Hopp fbcfc8
+ }
Karsten Hopp fbcfc8
  
Karsten Hopp fbcfc8
  /*
Karsten Hopp fbcfc8
   * Skip over a "[]" range.
Karsten Hopp fbcfc8
***************
Karsten Hopp fbcfc8
*** 1183,1197 ****
Karsten Hopp fbcfc8
  skip_anyof(p)
Karsten Hopp fbcfc8
      char_u	*p;
Karsten Hopp fbcfc8
  {
Karsten Hopp fbcfc8
-     int		cpo_lit;	/* 'cpoptions' contains 'l' flag */
Karsten Hopp fbcfc8
-     int		cpo_bsl;	/* 'cpoptions' contains '\' flag */
Karsten Hopp fbcfc8
  #ifdef FEAT_MBYTE
Karsten Hopp fbcfc8
      int		l;
Karsten Hopp fbcfc8
  #endif
Karsten Hopp fbcfc8
  
Karsten Hopp fbcfc8
-     cpo_lit = vim_strchr(p_cpo, CPO_LITERAL) != NULL;
Karsten Hopp fbcfc8
-     cpo_bsl = vim_strchr(p_cpo, CPO_BACKSL) != NULL;
Karsten Hopp fbcfc8
- 
Karsten Hopp fbcfc8
      if (*p == '^')	/* Complement of range. */
Karsten Hopp fbcfc8
  	++p;
Karsten Hopp fbcfc8
      if (*p == ']' || *p == '-')
Karsten Hopp fbcfc8
--- 1194,1203 ----
Karsten Hopp fbcfc8
***************
Karsten Hopp fbcfc8
*** 1210,1218 ****
Karsten Hopp fbcfc8
  		    mb_ptr_adv(p);
Karsten Hopp fbcfc8
  	    }
Karsten Hopp fbcfc8
  	else if (*p == '\\'
Karsten Hopp fbcfc8
! 		&& !cpo_bsl
Karsten Hopp fbcfc8
  		&& (vim_strchr(REGEXP_INRANGE, p[1]) != NULL
Karsten Hopp fbcfc8
! 		    || (!cpo_lit && vim_strchr(REGEXP_ABBR, p[1]) != NULL)))
Karsten Hopp fbcfc8
  	    p += 2;
Karsten Hopp fbcfc8
  	else if (*p == '[')
Karsten Hopp fbcfc8
  	{
Karsten Hopp fbcfc8
--- 1216,1224 ----
Karsten Hopp fbcfc8
  		    mb_ptr_adv(p);
Karsten Hopp fbcfc8
  	    }
Karsten Hopp fbcfc8
  	else if (*p == '\\'
Karsten Hopp fbcfc8
! 		&& !reg_cpo_bsl
Karsten Hopp fbcfc8
  		&& (vim_strchr(REGEXP_INRANGE, p[1]) != NULL
Karsten Hopp fbcfc8
! 		    || (!reg_cpo_lit && vim_strchr(REGEXP_ABBR, p[1]) != NULL)))
Karsten Hopp fbcfc8
  	    p += 2;
Karsten Hopp fbcfc8
  	else if (*p == '[')
Karsten Hopp fbcfc8
  	{
Karsten Hopp fbcfc8
***************
Karsten Hopp fbcfc8
*** 1251,1256 ****
Karsten Hopp fbcfc8
--- 1257,1263 ----
Karsten Hopp fbcfc8
  	mymagic = MAGIC_ON;
Karsten Hopp fbcfc8
      else
Karsten Hopp fbcfc8
  	mymagic = MAGIC_OFF;
Karsten Hopp fbcfc8
+     get_cpo_flags();
Karsten Hopp fbcfc8
  
Karsten Hopp fbcfc8
      for (; p[0] != NUL; mb_ptr_adv(p))
Karsten Hopp fbcfc8
      {
Karsten Hopp fbcfc8
***************
Karsten Hopp fbcfc8
*** 1462,1467 ****
Karsten Hopp fbcfc8
--- 1469,1475 ----
Karsten Hopp fbcfc8
  	reg_magic = MAGIC_OFF;
Karsten Hopp fbcfc8
      reg_string = (re_flags & RE_STRING);
Karsten Hopp fbcfc8
      reg_strict = (re_flags & RE_STRICT);
Karsten Hopp fbcfc8
+     get_cpo_flags();
Karsten Hopp fbcfc8
  
Karsten Hopp fbcfc8
      num_complex_braces = 0;
Karsten Hopp fbcfc8
      regnpar = 1;
Karsten Hopp fbcfc8
***************
Karsten Hopp fbcfc8
*** 1909,1923 ****
Karsten Hopp fbcfc8
  {
Karsten Hopp fbcfc8
      char_u	    *ret;
Karsten Hopp fbcfc8
      int		    flags;
Karsten Hopp fbcfc8
-     int		    cpo_lit;	    /* 'cpoptions' contains 'l' flag */
Karsten Hopp fbcfc8
-     int		    cpo_bsl;	    /* 'cpoptions' contains '\' flag */
Karsten Hopp fbcfc8
      int		    c;
Karsten Hopp fbcfc8
      char_u	    *p;
Karsten Hopp fbcfc8
      int		    extra = 0;
Karsten Hopp fbcfc8
  
Karsten Hopp fbcfc8
      *flagp = WORST;		/* Tentatively. */
Karsten Hopp fbcfc8
-     cpo_lit = vim_strchr(p_cpo, CPO_LITERAL) != NULL;
Karsten Hopp fbcfc8
-     cpo_bsl = vim_strchr(p_cpo, CPO_BACKSL) != NULL;
Karsten Hopp fbcfc8
  
Karsten Hopp fbcfc8
      c = getchr();
Karsten Hopp fbcfc8
      switch (c)
Karsten Hopp fbcfc8
--- 1917,1927 ----
Karsten Hopp fbcfc8
***************
Karsten Hopp fbcfc8
*** 2207,2213 ****
Karsten Hopp fbcfc8
  			      while ((c = getchr()) != ']')
Karsten Hopp fbcfc8
  			      {
Karsten Hopp fbcfc8
  				  if (c == NUL)
Karsten Hopp fbcfc8
! 				      EMSG2_RET_NULL(_("E69: Missing ] after %s%%["),
Karsten Hopp fbcfc8
  						      reg_magic == MAGIC_ALL);
Karsten Hopp fbcfc8
  				  br = regnode(BRANCH);
Karsten Hopp fbcfc8
  				  if (ret == NULL)
Karsten Hopp fbcfc8
--- 2211,2217 ----
Karsten Hopp fbcfc8
  			      while ((c = getchr()) != ']')
Karsten Hopp fbcfc8
  			      {
Karsten Hopp fbcfc8
  				  if (c == NUL)
Karsten Hopp fbcfc8
! 				      EMSG2_RET_NULL(_(e_missing_sb),
Karsten Hopp fbcfc8
  						      reg_magic == MAGIC_ALL);
Karsten Hopp fbcfc8
  				  br = regnode(BRANCH);
Karsten Hopp fbcfc8
  				  if (ret == NULL)
Karsten Hopp fbcfc8
***************
Karsten Hopp fbcfc8
*** 2410,2416 ****
Karsten Hopp fbcfc8
  			    }
Karsten Hopp fbcfc8
  
Karsten Hopp fbcfc8
  			    /* Handle \o40, \x20 and \u20AC style sequences */
Karsten Hopp fbcfc8
! 			    if (endc == '\\' && !cpo_lit && !cpo_bsl)
Karsten Hopp fbcfc8
  				endc = coll_get_char();
Karsten Hopp fbcfc8
  
Karsten Hopp fbcfc8
  			    if (startc > endc)
Karsten Hopp fbcfc8
--- 2414,2420 ----
Karsten Hopp fbcfc8
  			    }
Karsten Hopp fbcfc8
  
Karsten Hopp fbcfc8
  			    /* Handle \o40, \x20 and \u20AC style sequences */
Karsten Hopp fbcfc8
! 			    if (endc == '\\' && !reg_cpo_lit && !reg_cpo_bsl)
Karsten Hopp fbcfc8
  				endc = coll_get_char();
Karsten Hopp fbcfc8
  
Karsten Hopp fbcfc8
  			    if (startc > endc)
Karsten Hopp fbcfc8
***************
Karsten Hopp fbcfc8
*** 2452,2460 ****
Karsten Hopp fbcfc8
  		     * Posix doesn't recognize backslash at all.
Karsten Hopp fbcfc8
  		     */
Karsten Hopp fbcfc8
  		    else if (*regparse == '\\'
Karsten Hopp fbcfc8
! 			    && !cpo_bsl
Karsten Hopp fbcfc8
  			    && (vim_strchr(REGEXP_INRANGE, regparse[1]) != NULL
Karsten Hopp fbcfc8
! 				|| (!cpo_lit
Karsten Hopp fbcfc8
  				    && vim_strchr(REGEXP_ABBR,
Karsten Hopp fbcfc8
  						       regparse[1]) != NULL)))
Karsten Hopp fbcfc8
  		    {
Karsten Hopp fbcfc8
--- 2456,2464 ----
Karsten Hopp fbcfc8
  		     * Posix doesn't recognize backslash at all.
Karsten Hopp fbcfc8
  		     */
Karsten Hopp fbcfc8
  		    else if (*regparse == '\\'
Karsten Hopp fbcfc8
! 			    && !reg_cpo_bsl
Karsten Hopp fbcfc8
  			    && (vim_strchr(REGEXP_INRANGE, regparse[1]) != NULL
Karsten Hopp fbcfc8
! 				|| (!reg_cpo_lit
Karsten Hopp fbcfc8
  				    && vim_strchr(REGEXP_ABBR,
Karsten Hopp fbcfc8
  						       regparse[1]) != NULL)))
Karsten Hopp fbcfc8
  		    {
Karsten Hopp fbcfc8
*** ../vim-7.3.1118/src/regexp_nfa.c	2013-06-05 11:46:22.000000000 +0200
Karsten Hopp fbcfc8
--- src/regexp_nfa.c	2013-06-05 12:38:03.000000000 +0200
Karsten Hopp fbcfc8
***************
Karsten Hopp fbcfc8
*** 686,698 ****
Karsten Hopp fbcfc8
      int		startc = -1;
Karsten Hopp fbcfc8
      int		endc = -1;
Karsten Hopp fbcfc8
      int		oldstartc = -1;
Karsten Hopp fbcfc8
-     int		cpo_lit;	/* 'cpoptions' contains 'l' flag */
Karsten Hopp fbcfc8
-     int		cpo_bsl;	/* 'cpoptions' contains '\' flag */
Karsten Hopp fbcfc8
      int		glue;		/* ID that will "glue" nodes together */
Karsten Hopp fbcfc8
  
Karsten Hopp fbcfc8
-     cpo_lit = vim_strchr(p_cpo, CPO_LITERAL) != NULL;
Karsten Hopp fbcfc8
-     cpo_bsl = vim_strchr(p_cpo, CPO_BACKSL) != NULL;
Karsten Hopp fbcfc8
- 
Karsten Hopp fbcfc8
      c = getchr();
Karsten Hopp fbcfc8
      switch (c)
Karsten Hopp fbcfc8
      {
Karsten Hopp fbcfc8
--- 686,693 ----
Karsten Hopp fbcfc8
***************
Karsten Hopp fbcfc8
*** 1224,1233 ****
Karsten Hopp fbcfc8
  		     * Posix doesn't recognize backslash at all.
Karsten Hopp fbcfc8
  		     */
Karsten Hopp fbcfc8
  		    if (*regparse == '\\'
Karsten Hopp fbcfc8
! 			    && !cpo_bsl
Karsten Hopp fbcfc8
  			    && regparse + 1 <= endp
Karsten Hopp fbcfc8
  			    && (vim_strchr(REGEXP_INRANGE, regparse[1]) != NULL
Karsten Hopp fbcfc8
! 				|| (!cpo_lit
Karsten Hopp fbcfc8
  				    && vim_strchr(REGEXP_ABBR, regparse[1])
Karsten Hopp fbcfc8
  								      != NULL)
Karsten Hopp fbcfc8
  			    )
Karsten Hopp fbcfc8
--- 1219,1228 ----
Karsten Hopp fbcfc8
  		     * Posix doesn't recognize backslash at all.
Karsten Hopp fbcfc8
  		     */
Karsten Hopp fbcfc8
  		    if (*regparse == '\\'
Karsten Hopp fbcfc8
! 			    && !reg_cpo_bsl
Karsten Hopp fbcfc8
  			    && regparse + 1 <= endp
Karsten Hopp fbcfc8
  			    && (vim_strchr(REGEXP_INRANGE, regparse[1]) != NULL
Karsten Hopp fbcfc8
! 				|| (!reg_cpo_lit
Karsten Hopp fbcfc8
  				    && vim_strchr(REGEXP_ABBR, regparse[1])
Karsten Hopp fbcfc8
  								      != NULL)
Karsten Hopp fbcfc8
  			    )
Karsten Hopp fbcfc8
*** ../vim-7.3.1118/src/version.c	2013-06-05 11:46:22.000000000 +0200
Karsten Hopp fbcfc8
--- src/version.c	2013-06-05 12:40:57.000000000 +0200
Karsten Hopp fbcfc8
***************
Karsten Hopp fbcfc8
*** 730,731 ****
Karsten Hopp fbcfc8
--- 730,733 ----
Karsten Hopp fbcfc8
  {   /* Add new patch number below this line */
Karsten Hopp fbcfc8
+ /**/
Karsten Hopp fbcfc8
+     1119,
Karsten Hopp fbcfc8
  /**/
Karsten Hopp fbcfc8
Karsten Hopp fbcfc8
-- 
Karsten Hopp fbcfc8
From "know your smileys":
Karsten Hopp fbcfc8
 :-O>-o   Smiley American tourist (note big mouth and camera)
Karsten Hopp fbcfc8
Karsten Hopp fbcfc8
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp fbcfc8
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp fbcfc8
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp fbcfc8
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///