summaryrefslogtreecommitdiff
path: root/source/ap/vim/patches/7.4.037
blob: 3c6369b721c0fd900a10c50b222e6b72f62f4636 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
To: vim_dev@googlegroups.com
Subject: Patch 7.4.037
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------

Patch 7.4.037
Problem:    Using "\ze" in a sub-pattern does not result in the end of the
	    match to be set. (Axel Bender)
Solution:   Copy the end of match position when a recursive match was
	    successful.
Files:	    src/regexp_nfa.c, src/testdir/test64.in, src/testdir/test64.ok


*** ../vim-7.4.036/src/regexp_nfa.c	2013-09-25 16:41:50.000000000 +0200
--- src/regexp_nfa.c	2013-09-25 18:09:59.000000000 +0200
***************
*** 3822,3827 ****
--- 3822,3828 ----
  static void clear_sub __ARGS((regsub_T *sub));
  static void copy_sub __ARGS((regsub_T *to, regsub_T *from));
  static void copy_sub_off __ARGS((regsub_T *to, regsub_T *from));
+ static void copy_ze_off __ARGS((regsub_T *to, regsub_T *from));
  static int sub_equal __ARGS((regsub_T *sub1, regsub_T *sub2));
  static int match_backref __ARGS((regsub_T *sub, int subidx, int *bytelen));
  static int has_state_with_pos __ARGS((nfa_list_T *l, nfa_state_T *state, regsubs_T *subs, nfa_pim_T *pim));
***************
*** 3909,3914 ****
--- 3910,3938 ----
  }
  
  /*
+  * Like copy_sub() but only do the end of the main match if \ze is present.
+  */
+     static void
+ copy_ze_off(to, from)
+     regsub_T	*to;
+     regsub_T	*from;
+ {
+     if (nfa_has_zend)
+     {
+ 	if (REG_MULTI)
+ 	{
+ 	    if (from->list.multi[0].end.lnum >= 0)
+ 		to->list.multi[0].end = from->list.multi[0].end;
+ 	}
+ 	else
+ 	{
+ 	    if (from->list.line[0].end != NULL)
+ 		to->list.line[0].end = from->list.line[0].end;
+ 	}
+     }
+ }
+ 
+ /*
   * Return TRUE if "sub1" and "sub2" have the same start positions.
   */
      static int
***************
*** 5308,5313 ****
--- 5332,5338 ----
   * When "nfa_endp" is not NULL it is a required end-of-match position.
   *
   * Return TRUE if there is a match, FALSE otherwise.
+  * When there is a match "submatch" contains the positions.
   * Note: Caller must ensure that: start != NULL.
   */
      static int
***************
*** 5633,5638 ****
--- 5658,5666 ----
  			    if (nfa_has_zsubexpr)
  				copy_sub_off(&t->subs.synt, &m->synt);
  #endif
+ 			    /* If the pattern has \ze and it matched in the
+ 			     * sub pattern, use it. */
+ 			    copy_ze_off(&t->subs.norm, &m->norm);
  
  			    /* t->state->out1 is the corresponding
  			     * END_INVISIBLE node; Add its out to the current
*** ../vim-7.4.036/src/testdir/test64.in	2013-09-25 16:41:50.000000000 +0200
--- src/testdir/test64.in	2013-09-25 18:09:16.000000000 +0200
***************
*** 425,430 ****
--- 425,431 ----
  :"
  :" complicated look-behind match
  :call add(tl, [2, '\(r\@<=\|\w\@<!\)\/', 'x = /word/;', '/'])
+ :call add(tl, [2, '^[a-z]\+\ze \&\(asdf\)\@<!', 'foo bar', 'foo'])
  :"
  :""""" \@>
  :call add(tl, [2, '\(a*\)\@>a', 'aaaa'])
*** ../vim-7.4.036/src/testdir/test64.ok	2013-09-25 16:41:50.000000000 +0200
--- src/testdir/test64.ok	2013-09-25 18:10:05.000000000 +0200
***************
*** 983,988 ****
--- 983,991 ----
  OK 0 - \(r\@<=\|\w\@<!\)\/
  OK 1 - \(r\@<=\|\w\@<!\)\/
  OK 2 - \(r\@<=\|\w\@<!\)\/
+ OK 0 - ^[a-z]\+\ze \&\(asdf\)\@<!
+ OK 1 - ^[a-z]\+\ze \&\(asdf\)\@<!
+ OK 2 - ^[a-z]\+\ze \&\(asdf\)\@<!
  OK 0 - \(a*\)\@>a
  OK 1 - \(a*\)\@>a
  OK 2 - \(a*\)\@>a
*** ../vim-7.4.036/src/version.c	2013-09-25 16:41:50.000000000 +0200
--- src/version.c	2013-09-25 18:14:36.000000000 +0200
***************
*** 740,741 ****
--- 740,743 ----
  {   /* Add new patch number below this line */
+ /**/
+     37,
  /**/

-- 
MAN:     You don't frighten us, English pig-dog!  Go and boil your bottoms,
         son of a silly person.  I blow my nose on you, so-called Arthur-king,
         you and your silly English K...kaniggets.
   He puts hands to his ears and blows a raspberry.
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// Bram Moolenaar -- Bram@Moolenaar.net -- 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    ///