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 / old / 5.6.040 < prev    next >
Encoding:
Internet Message Format  |  2000-03-29  |  3.3 KB

  1. To: vim-dev@vim.org
  2. Subject: Patch 5.6.040
  3. Fcc: outbox
  4. From: Bram Moolenaar <Bram@moolenaar.net>
  5. ------------
  6.  
  7. Patch 5.6.040
  8. Problem:    When using ":s" command, matching the regexp is done twice.
  9. Solution:   After copying the matched line, adjust the pointers instead of
  10.         finding the match again. (Loic Grenie)  Added vim_regnewptr().
  11. Files:        src/ex_cmds.c, src/regexp.c, src/proto/regexp.pro
  12.  
  13.  
  14. *** ../vim-5.6.39/src/ex_cmds.c    Sat Mar 25 18:13:49 2000
  15. --- src/ex_cmds.c    Thu Mar 30 09:46:28 2000
  16. ***************
  17. *** 3185,3197 ****
  18.           unsigned    len, needed_len;
  19.           unsigned    new_start_len = 0;
  20.   
  21. !         /* make a copy of the line, so it won't be taken away when updating
  22. !         the screen */
  23.           if ((old_line = vim_strsave(ptr)) == NULL)
  24.           continue;
  25. !         vim_regexec(prog, old_line, TRUE);    /* match again on this line to
  26. !                          * update the pointers. TODO:
  27. !                          * remove extra vim_regexec() */
  28.           if (!got_match)
  29.           {
  30.           setpcmark();
  31. --- 3185,3197 ----
  32.           unsigned    len, needed_len;
  33.           unsigned    new_start_len = 0;
  34.   
  35. !         /* Make a copy of the line, so it won't be taken away when
  36. !          * updating the screen. */
  37.           if ((old_line = vim_strsave(ptr)) == NULL)
  38.           continue;
  39. !         /* Adjust the pointers in "prog" for the copied string. */
  40. !         vim_regnewptr(prog, ptr, old_line);
  41.           if (!got_match)
  42.           {
  43.           setpcmark();
  44. *** ../vim-5.6.39/src/regexp.c    Sat May 15 15:48:51 1999
  45. --- src/regexp.c    Thu Mar 30 09:59:23 2000
  46. ***************
  47. *** 2954,2959 ****
  48. --- 2954,2982 ----
  49.   }
  50.   
  51.   /*
  52. +  * Adjust the pointers in "prog" for moving the matches text from "old_ptr" to
  53. +  * "new_ptr".  Used when saving a copy of the matched text and want to use
  54. +  * vim_regsub().
  55. +  */
  56. +     void
  57. + vim_regnewptr(prog, old_ptr, new_ptr)
  58. +     vim_regexp    *prog;
  59. +     char_u    *old_ptr;
  60. +     char_u    *new_ptr;
  61. + {
  62. +     int        j;
  63. +     long    off = new_ptr - old_ptr;
  64. +     for (j = 0; j < NSUBEXP; ++j)
  65. +     {
  66. +     if (prog->startp[j] != NULL)
  67. +         prog->startp[j] += off;
  68. +     if (prog->endp[j] != NULL)
  69. +         prog->endp[j] += off;
  70. +     }
  71. + }
  72. + /*
  73.    * vim_regsub() - perform substitutions after a regexp match
  74.    *
  75.    * If copy is TRUE really copy into dest.
  76. *** ../vim-5.6.39/src/proto/regexp.pro    Sun Jan 16 14:22:52 2000
  77. --- src/proto/regexp.pro    Thu Mar 30 10:02:07 2000
  78. ***************
  79. *** 4,7 ****
  80. --- 4,8 ----
  81.   int vim_regcomp_had_eol __ARGS((void));
  82.   int vim_regexec __ARGS((vim_regexp *prog, char_u *string, int at_bol));
  83.   char_u *regtilde __ARGS((char_u *source, int magic));
  84. + void vim_regnewptr __ARGS((vim_regexp *prog, char_u *old_ptr, char_u *new_ptr));
  85.   int vim_regsub __ARGS((vim_regexp *prog, char_u *source, char_u *dest, int copy, int magic));
  86. *** ../vim-5.6.39/src/version.c    Wed Mar 29 12:35:54 2000
  87. --- src/version.c    Thu Mar 30 15:59:30 2000
  88. ***************
  89. *** 420,421 ****
  90. --- 420,423 ----
  91.   {   /* Add new patch number below this line */
  92. + /**/
  93. +     40,
  94.   /**/
  95.  
  96. -- 
  97. CONCORDE:  Quickly, sir, come this way!
  98. LAUNCELOT: No!  It's not right for my idiom.  I must escape more  ... more ...
  99. CONCORDE:  Dramatically, sir?
  100. LAUNCELOT: Dramatically.
  101.                  "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
  102.  
  103. /-/-- Bram Moolenaar --- Bram@moolenaar.net --- http://www.moolenaar.net --\-\
  104. \-\-- Vim: http://www.vim.org ---- ICCF Holland: http://www.vim.org/iccf --/-/
  105.