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.3 / 7.3.636 < prev    next >
Encoding:
Internet Message Format  |  2012-11-20  |  4.4 KB

  1. To: vim_dev@googlegroups.com
  2. Subject: Patch 7.3.636
  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.3.636 (after 7.3.625)
  11. Problem:    Not all zero-width matches handled correctly for "gn".
  12. Solution:   Move zero-width detection to a separate function. (Christian
  13.         Brabandt)
  14. Files:        src/search.c
  15.  
  16.  
  17. *** ../vim-7.3.635/src/search.c    2012-08-08 15:27:54.000000000 +0200
  18. --- src/search.c    2012-08-23 15:52:50.000000000 +0200
  19. ***************
  20. *** 4526,4531 ****
  21. --- 4526,4533 ----
  22.   #endif /* FEAT_TEXTOBJ */
  23.   
  24.   #if defined(FEAT_VISUAL) || defined(PROTO)
  25. + static int is_zerowidth __ARGS((char_u *pattern));
  26.   /*
  27.    * Find next search match under cursor, cursor at end.
  28.    * Used while an operator is pending, and in Visual mode.
  29. ***************
  30. *** 4546,4556 ****
  31.       int        visual_active = FALSE;
  32.       int        flags = 0;
  33.       pos_T    save_VIsual;
  34. -     regmmatch_T    regmatch;
  35. -     int        nmatched = 0;
  36.       int        zerowidth = FALSE;
  37.   
  38.       /* wrapping should not occur */
  39.       p_ws = FALSE;
  40.   
  41. --- 4548,4555 ----
  42. ***************
  43. *** 4583,4606 ****
  44.       else
  45.       orig_pos = pos = start_pos = curwin->w_cursor;
  46.   
  47. !     /*
  48. !      * Check for zero-width pattern.
  49. !      */
  50. !     if (search_regcomp(spats[last_idx].pat, RE_SEARCH, RE_SEARCH,
  51. !                  ((SEARCH_HIS + SEARCH_KEEP)), ®match) == FAIL)
  52.       return FAIL;
  53.   
  54. -     /* Zero-width pattern should match somewhere, then we can check if start
  55. -      * and end are in the same position. */
  56. -     nmatched = vim_regexec_multi(®match, curwin, curbuf,
  57. -                      curwin->w_cursor.lnum, (colnr_T)0, NULL);
  58. -     if (called_emsg)
  59. -     return FAIL;
  60. -     if (nmatched && regmatch.startpos[0].lnum == regmatch.endpos[0].lnum
  61. -          && regmatch.endpos[0].col == regmatch.startpos[0].col)
  62. -     zerowidth = TRUE;
  63. -     vim_free(regmatch.regprog);
  64.       /*
  65.        * The trick is to first search backwards and then search forward again,
  66.        * so that a match at the current cursor position will be correctly
  67. --- 4582,4592 ----
  68.       else
  69.       orig_pos = pos = start_pos = curwin->w_cursor;
  70.   
  71. !     /* Is the pattern is zero-width? */
  72. !     zerowidth = is_zerowidth(spats[last_idx].pat);
  73. !     if (zerowidth == -1)
  74.       return FAIL;
  75.   
  76.       /*
  77.        * The trick is to first search backwards and then search forward again,
  78.        * so that a match at the current cursor position will be correctly
  79. ***************
  80. *** 4693,4698 ****
  81. --- 4679,4721 ----
  82.   
  83.       return OK;
  84.   }
  85. + /*
  86. +  * Check if the pattern is zero-width.
  87. +  * Returns TRUE, FALSE or -1 for failure.
  88. +  */
  89. +     static int
  90. + is_zerowidth(pattern)
  91. +     char_u    *pattern;
  92. + {
  93. +     regmmatch_T    regmatch;
  94. +     int        nmatched = 0;
  95. +     int        result = -1;
  96. +     pos_T       pos;
  97. +     if (search_regcomp(pattern, RE_SEARCH, RE_SEARCH,
  98. +                           SEARCH_KEEP, ®match) == FAIL)
  99. +     return -1;
  100. +     /* move to match */
  101. +     clearpos(&pos);
  102. +     if (searchit(curwin, curbuf, &pos, FORWARD, spats[last_idx].pat, 1,
  103. +                      SEARCH_KEEP, RE_SEARCH, 0, NULL) != FAIL)
  104. +     {
  105. +     /* Zero-width pattern should match somewhere, then we can check if
  106. +      * start and end are in the same position. */
  107. +     nmatched = vim_regexec_multi(®match, curwin, curbuf,
  108. +                           pos.lnum, (colnr_T)0, NULL);
  109. +     if (!called_emsg)
  110. +         result = (nmatched != 0
  111. +             && regmatch.startpos[0].lnum == regmatch.endpos[0].lnum
  112. +             && regmatch.startpos[0].col == regmatch.endpos[0].col);
  113. +     }
  114. +     vim_free(regmatch.regprog);
  115. +     return result;
  116. + }
  117.   #endif /* FEAT_VISUAL */
  118.   
  119.   #if defined(FEAT_LISP) || defined(FEAT_CINDENT) || defined(FEAT_TEXTOBJ) \
  120. *** ../vim-7.3.635/src/version.c    2012-08-23 13:28:50.000000000 +0200
  121. --- src/version.c    2012-08-23 15:25:23.000000000 +0200
  122. ***************
  123. *** 721,722 ****
  124. --- 721,724 ----
  125.   {   /* Add new patch number below this line */
  126. + /**/
  127. +     636,
  128.   /**/
  129.  
  130. -- 
  131. Edison's greatest achievement came in 1879, when he invented the
  132. electric company.  Edison's design was a brilliant adaptation of the
  133. simple electrical circuit: the electric company sends electricity
  134. through a wire to a customer, then immediately gets the electricity
  135. back through another wire
  136.  
  137.  /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
  138. ///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
  139. \\\  an exciting new programming language -- http://www.Zimbu.org        ///
  140.  \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///
  141.