summaryrefslogtreecommitdiffstats
path: root/source/ap/vim/patches/7.3.636
blob: 453a7fc992def60c8fcc52410a4e1e5becae900e (plain) (blame)
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
To: vim_dev@googlegroups.com
Subject: Patch 7.3.636
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.3.636 (after 7.3.625)
Problem:    Not all zero-width matches handled correctly for "gn".
Solution:   Move zero-width detection to a separate function. (Christian
	    Brabandt)
Files:	    src/search.c


*** ../vim-7.3.635/src/search.c	2012-08-08 15:27:54.000000000 +0200
--- src/search.c	2012-08-23 15:52:50.000000000 +0200
***************
*** 4526,4531 ****
--- 4526,4533 ----
  #endif /* FEAT_TEXTOBJ */
  
  #if defined(FEAT_VISUAL) || defined(PROTO)
+ static int is_zerowidth __ARGS((char_u *pattern));
+ 
  /*
   * Find next search match under cursor, cursor at end.
   * Used while an operator is pending, and in Visual mode.
***************
*** 4546,4556 ****
      int		visual_active = FALSE;
      int		flags = 0;
      pos_T	save_VIsual;
-     regmmatch_T	regmatch;
-     int		nmatched = 0;
      int		zerowidth = FALSE;
  
- 
      /* wrapping should not occur */
      p_ws = FALSE;
  
--- 4548,4555 ----
***************
*** 4583,4606 ****
      else
  	orig_pos = pos = start_pos = curwin->w_cursor;
  
!     /*
!      * Check for zero-width pattern.
!      */
!     if (search_regcomp(spats[last_idx].pat, RE_SEARCH, RE_SEARCH,
! 			     ((SEARCH_HIS + SEARCH_KEEP)), &regmatch) == FAIL)
  	return FAIL;
  
-     /* Zero-width pattern should match somewhere, then we can check if start
-      * and end are in the same position. */
-     nmatched = vim_regexec_multi(&regmatch, curwin, curbuf,
- 				     curwin->w_cursor.lnum, (colnr_T)0, NULL);
-     if (called_emsg)
- 	return FAIL;
-     if (nmatched && regmatch.startpos[0].lnum == regmatch.endpos[0].lnum
- 		 && regmatch.endpos[0].col == regmatch.startpos[0].col)
- 	zerowidth = TRUE;
-     vim_free(regmatch.regprog);
- 
      /*
       * The trick is to first search backwards and then search forward again,
       * so that a match at the current cursor position will be correctly
--- 4582,4592 ----
      else
  	orig_pos = pos = start_pos = curwin->w_cursor;
  
!     /* Is the pattern is zero-width? */
!     zerowidth = is_zerowidth(spats[last_idx].pat);
!     if (zerowidth == -1)
  	return FAIL;
  
      /*
       * The trick is to first search backwards and then search forward again,
       * so that a match at the current cursor position will be correctly
***************
*** 4693,4698 ****
--- 4679,4721 ----
  
      return OK;
  }
+ 
+ /*
+  * Check if the pattern is zero-width.
+  * Returns TRUE, FALSE or -1 for failure.
+  */
+     static int
+ is_zerowidth(pattern)
+     char_u	*pattern;
+ {
+     regmmatch_T	regmatch;
+     int		nmatched = 0;
+     int		result = -1;
+     pos_T       pos;
+ 
+     if (search_regcomp(pattern, RE_SEARCH, RE_SEARCH,
+ 					      SEARCH_KEEP, &regmatch) == FAIL)
+ 	return -1;
+ 
+     /* move to match */
+     clearpos(&pos);
+     if (searchit(curwin, curbuf, &pos, FORWARD, spats[last_idx].pat, 1,
+ 				     SEARCH_KEEP, RE_SEARCH, 0, NULL) != FAIL)
+     {
+ 	/* Zero-width pattern should match somewhere, then we can check if
+ 	 * start and end are in the same position. */
+ 	nmatched = vim_regexec_multi(&regmatch, curwin, curbuf,
+ 						  pos.lnum, (colnr_T)0, NULL);
+ 
+ 	if (!called_emsg)
+ 	    result = (nmatched != 0
+ 		    && regmatch.startpos[0].lnum == regmatch.endpos[0].lnum
+ 		    && regmatch.startpos[0].col == regmatch.endpos[0].col);
+     }
+ 
+     vim_free(regmatch.regprog);
+     return result;
+ }
  #endif /* FEAT_VISUAL */
  
  #if defined(FEAT_LISP) || defined(FEAT_CINDENT) || defined(FEAT_TEXTOBJ) \
*** ../vim-7.3.635/src/version.c	2012-08-23 13:28:50.000000000 +0200
--- src/version.c	2012-08-23 15:25:23.000000000 +0200
***************
*** 721,722 ****
--- 721,724 ----
  {   /* Add new patch number below this line */
+ /**/
+     636,
  /**/

-- 
Edison's greatest achievement came in 1879, when he invented the
electric company.  Edison's design was a brilliant adaptation of the
simple electrical circuit: the electric company sends electricity
through a wire to a customer, then immediately gets the electricity
back through another wire

 /// 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    ///