Patch 7.4.045
Problem:    substitute() does not work properly when the pattern starts with
            "\ze".
Solution:   Detect an empty match. (Christian Brabandt)
Files:      src/eval.c, src/testdir/test80.in, src/testdir/test80.ok


*** ../vim-7.4.044/src/eval.c   2013-09-25 21:00:24.000000000 +0200
--- src/eval.c  2013-09-29 21:03:22.000000000 +0200
***************
*** 24301,24306 ****
--- 24301,24307 ----
      garray_T  ga;
      char_u    *ret;
      char_u    *save_cpo;
+     int               zero_width;
  
      /* Make 'cpoptions' empty, so that the 'l' flag doesn't work here */
      save_cpo = p_cpo;
***************
*** 24339,24358 ****
            (void)vim_regsub(&regmatch, sub, (char_u *)ga.ga_data
                                          + ga.ga_len + i, TRUE, TRUE, FALSE);
            ga.ga_len += i + sublen - 1;
!           /* avoid getting stuck on a match with an empty string */
!           if (tail == regmatch.endp[0])
            {
!               if (*tail == NUL)
!                   break;
                *((char_u *)ga.ga_data + ga.ga_len) = *tail++;
                ++ga.ga_len;
            }
-           else
-           {
-               tail = regmatch.endp[0];
-               if (*tail == NUL)
-                   break;
-           }
            if (!do_all)
                break;
        }
--- 24340,24356 ----
            (void)vim_regsub(&regmatch, sub, (char_u *)ga.ga_data
                                          + ga.ga_len + i, TRUE, TRUE, FALSE);
            ga.ga_len += i + sublen - 1;
!           zero_width = (tail == regmatch.endp[0]
!                                   || regmatch.startp[0] == regmatch.endp[0]);
!           tail = regmatch.endp[0];
!           if (*tail == NUL)
!               break;
!           if (zero_width)
            {
!               /* avoid getting stuck on a match with an empty string */
                *((char_u *)ga.ga_data + ga.ga_len) = *tail++;
                ++ga.ga_len;
            }
            if (!do_all)
                break;
        }
*** ../vim-7.4.044/src/testdir/test80.in        2013-03-19 17:30:51.000000000 
+0100
--- src/testdir/test80.in       2013-09-29 20:59:00.000000000 +0200
***************
*** 142,147 ****
--- 142,149 ----
  :$put =\"\n\nTEST_7:\"
  :$put =substitute('A 
A', 'A.', '\=submatch(0)', '')
  :$put =substitute(\"B\nB\", 'B.', '\=submatch(0)', '')
+ :$put =substitute('-bb', '\zeb', 'a', 'g')
+ :$put =substitute('-bb', '\ze', 'c', 'g')
  /^TEST_8
  ENDTEST
  
*** ../vim-7.4.044/src/testdir/test80.ok        2013-03-19 17:31:45.000000000 
+0100
--- src/testdir/test80.ok       2013-09-29 20:59:35.000000000 +0200
***************
*** 103,108 ****
--- 103,110 ----
  A
A
  B
  B
+ -abab
+ c-cbcbc
  
  
  TEST_8:
*** ../vim-7.4.044/src/version.c        2013-09-29 19:05:17.000000000 +0200
--- src/version.c       2013-09-29 21:04:50.000000000 +0200
***************
*** 740,741 ****
--- 740,743 ----
  {   /* Add new patch number below this line */
+ /**/
+     45,
  /**/

-- 
Just think of all the things we haven't thought of yet.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Raspunde prin e-mail lui