home *** CD-ROM | disk | FTP | other *** search
/ vim.ftp.fu-berlin.de / 2015-02-03.vim.ftp.fu-berlin.de.tar / vim.ftp.fu-berlin.de / patches / 7.4 / 7.4.184 < prev    next >
Encoding:
Internet Message Format  |  2014-02-21  |  5.5 KB

  1. To: vim_dev@googlegroups.com
  2. Subject: Patch 7.4.184
  3. Fcc: outbox
  4. From: Bram Moolenaar <Bram@moolenaar.net>
  5. Mime-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. ------------
  9.  
  10. Patch 7.4.184
  11. Problem:    match() does not work properly with a {count} argument.
  12. Solution:   Compute the length once and update it.  Quit the loop when at the
  13.             end. (Hirohito Higashi)
  14. Files:      src/eval.c, src/testdir/test53.in, src/testdir/test53.ok
  15.  
  16.  
  17. *** ../vim-7.4.183/src/eval.c    2014-02-05 22:13:02.366556787 +0100
  18. --- src/eval.c    2014-02-22 22:13:26.644906020 +0100
  19. ***************
  20. *** 8014,8020 ****
  21.       {"log10",        1, 1, f_log10},
  22.   #endif
  23.   #ifdef FEAT_LUA
  24. !     {"luaeval",         1, 2, f_luaeval},
  25.   #endif
  26.       {"map",        2, 2, f_map},
  27.       {"maparg",        1, 4, f_maparg},
  28. --- 8014,8020 ----
  29.       {"log10",        1, 1, f_log10},
  30.   #endif
  31.   #ifdef FEAT_LUA
  32. !     {"luaeval",        1, 2, f_luaeval},
  33.   #endif
  34.       {"map",        2, 2, f_map},
  35.       {"maparg",        1, 4, f_maparg},
  36. ***************
  37. *** 13905,13910 ****
  38. --- 13905,13911 ----
  39.       int        type;
  40.   {
  41.       char_u    *str = NULL;
  42. +     long    len = 0;
  43.       char_u    *expr = NULL;
  44.       char_u    *pat;
  45.       regmatch_T    regmatch;
  46. ***************
  47. *** 13944,13950 ****
  48. --- 13945,13954 ----
  49.       li = l->lv_first;
  50.       }
  51.       else
  52. +     {
  53.       expr = str = get_tv_string(&argvars[0]);
  54. +     len = (long)STRLEN(str);
  55. +     }
  56.   
  57.       pat = get_tv_string_buf_chk(&argvars[1], patbuf);
  58.       if (pat == NULL)
  59. ***************
  60. *** 13968,13974 ****
  61.       {
  62.           if (start < 0)
  63.           start = 0;
  64. !         if (start > (long)STRLEN(str))
  65.           goto theend;
  66.           /* When "count" argument is there ignore matches before "start",
  67.            * otherwise skip part of the string.  Differs when pattern is "^"
  68. --- 13972,13978 ----
  69.       {
  70.           if (start < 0)
  71.           start = 0;
  72. !         if (start > len)
  73.           goto theend;
  74.           /* When "count" argument is there ignore matches before "start",
  75.            * otherwise skip part of the string.  Differs when pattern is "^"
  76. ***************
  77. *** 13976,13982 ****
  78. --- 13980,13989 ----
  79.           if (argvars[3].v_type != VAR_UNKNOWN)
  80.           startcol = start;
  81.           else
  82. +         {
  83.           str += start;
  84. +         len -= start;
  85. +         }
  86.       }
  87.   
  88.       if (argvars[3].v_type != VAR_UNKNOWN)
  89. ***************
  90. *** 14026,14031 ****
  91. --- 14033,14044 ----
  92.   #else
  93.           startcol = (colnr_T)(regmatch.startp[0] + 1 - str);
  94.   #endif
  95. +         if (startcol > (colnr_T)len
  96. +                       || str + startcol <= regmatch.startp[0])
  97. +         {
  98. +             match = FALSE;
  99. +             break;
  100. +         }
  101.           }
  102.       }
  103.   
  104. *** ../vim-7.4.183/src/testdir/test53.in    2013-10-02 21:54:57.000000000 +0200
  105. --- src/testdir/test53.in    2014-02-22 22:08:24.260906501 +0100
  106. ***************
  107. *** 4,9 ****
  108. --- 4,11 ----
  109.   
  110.   Also test match() and matchstr()
  111.   
  112. + Also test the gn command and repeating it.
  113.   STARTTEST
  114.   :so small.vim
  115.   /^start:/
  116. ***************
  117. *** 28,33 ****
  118. --- 30,57 ----
  119.   :put =matchstr(\"abcd\", \".\", 0, -1) " a
  120.   :put =match(\"abcd\", \".\", 0, 5) " -1
  121.   :put =match(\"abcd\", \".\", 0, -1) " 0
  122. + :put =match('abc', '.', 0, 1) " 0
  123. + :put =match('abc', '.', 0, 2) " 1
  124. + :put =match('abc', '.', 0, 3) " 2
  125. + :put =match('abc', '.', 0, 4) " -1
  126. + :put =match('abc', '.', 1, 1) " 1
  127. + :put =match('abc', '.', 2, 1) " 2
  128. + :put =match('abc', '.', 3, 1) " -1
  129. + :put =match('abc', '$', 0, 1) " 3
  130. + :put =match('abc', '$', 0, 2) " -1
  131. + :put =match('abc', '$', 1, 1) " 3
  132. + :put =match('abc', '$', 2, 1) " 3
  133. + :put =match('abc', '$', 3, 1) " 3
  134. + :put =match('abc', '$', 4, 1) " -1
  135. + :put =match('abc', '\zs', 0, 1) " 0
  136. + :put =match('abc', '\zs', 0, 2) " 1
  137. + :put =match('abc', '\zs', 0, 3) " 2
  138. + :put =match('abc', '\zs', 0, 4) " 3
  139. + :put =match('abc', '\zs', 0, 5) " -1
  140. + :put =match('abc', '\zs', 1, 1) " 1
  141. + :put =match('abc', '\zs', 2, 1) " 2
  142. + :put =match('abc', '\zs', 3, 1) " 3
  143. + :put =match('abc', '\zs', 4, 1) " -1
  144.   /^foobar
  145.   gncsearchmatch/one\_s*two\_s
  146.   :1
  147. ***************
  148. *** 49,54 ****
  149. --- 73,84 ----
  150.   :" Make sure there is no other match y uppercase.
  151.   /x59
  152.   gggnd
  153. + :" test repeating dgn
  154. + /^Johnny
  155. + ggdgn.
  156. + :" test repeating gUgn
  157. + /^Depp
  158. + gggUgn.
  159.   :/^start:/,/^end:/wq! test.out
  160.   ENDTEST
  161.   
  162. ***************
  163. *** 81,84 ****
  164. --- 111,123 ----
  165.   Y
  166.   text
  167.   Y
  168. + --1
  169. + Johnny
  170. + --2
  171. + Johnny
  172. + --3
  173. + Depp
  174. + --4
  175. + Depp
  176. + --5
  177.   end:
  178. *** ../vim-7.4.183/src/testdir/test53.ok    2013-10-02 21:54:57.000000000 +0200
  179. --- src/testdir/test53.ok    2014-02-22 22:08:24.264906501 +0100
  180. ***************
  181. *** 18,23 ****
  182. --- 18,45 ----
  183.   a
  184.   -1
  185.   0
  186. + 0
  187. + 1
  188. + 2
  189. + -1
  190. + 1
  191. + 2
  192. + -1
  193. + 3
  194. + -1
  195. + 3
  196. + 3
  197. + 3
  198. + -1
  199. + 0
  200. + 1
  201. + 2
  202. + 3
  203. + -1
  204. + 1
  205. + 2
  206. + 3
  207. + -1
  208.   SEARCH:
  209.   searchmatch
  210.   abcdx |  | abcdx
  211. ***************
  212. *** 30,33 ****
  213. --- 52,64 ----
  214.   
  215.   text
  216.   Y
  217. + --1
  218. + --2
  219. + --3
  220. + DEPP
  221. + --4
  222. + DEPP
  223. + --5
  224.   end:
  225. *** ../vim-7.4.183/src/version.c    2014-02-15 19:47:46.685882910 +0100
  226. --- src/version.c    2014-02-22 22:10:49.604906270 +0100
  227. ***************
  228. *** 740,741 ****
  229. --- 740,743 ----
  230.   {   /* Add new patch number below this line */
  231. + /**/
  232. +     184,
  233.   /**/
  234.  
  235. -- 
  236. WOMAN:   I didn't know we had a king. I thought we were an autonomous
  237.          collective.
  238. DENNIS:  You're fooling yourself.  We're living in a dictatorship.  A
  239.          self-perpetuating autocracy in which the working classes--
  240. WOMAN:   Oh there you go, bringing class into it again.
  241. DENNIS:  That's what it's all about if only people would--
  242.                                   The Quest for the Holy Grail (Monty Python)
  243.  
  244.  /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
  245. ///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
  246. \\\  an exciting new programming language -- http://www.Zimbu.org        ///
  247.  \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///
  248.