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.262 < prev    next >
Encoding:
Internet Message Format  |  2014-04-22  |  9.5 KB

  1. To: vim_dev@googlegroups.com
  2. Subject: Patch 7.4.262
  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.262
  11. Problem:    Duplicate code in regexec().
  12. Solution:   Add line_lbr flag to regexec_nl().
  13. Files:        src/regexp.c, src/regexp_nfa.c, src/regexp.h
  14.  
  15.  
  16. *** ../vim-7.4.261/src/regexp.c    2014-04-23 18:48:43.546854558 +0200
  17. --- src/regexp.c    2014-04-23 18:59:38.606838773 +0200
  18. ***************
  19. *** 3709,3733 ****
  20.   /* TRUE if using multi-line regexp. */
  21.   #define REG_MULTI    (reg_match == NULL)
  22.   
  23. ! static int  bt_regexec __ARGS((regmatch_T *rmp, char_u *line, colnr_T col));
  24.   
  25.   /*
  26.    * Match a regexp against a string.
  27.    * "rmp->regprog" is a compiled regexp as returned by vim_regcomp().
  28.    * Uses curbuf for line count and 'iskeyword'.
  29.    *
  30.    * Return TRUE if there is a match, FALSE if not.
  31.    */
  32.       static int
  33. ! bt_regexec(rmp, line, col)
  34.       regmatch_T    *rmp;
  35.       char_u    *line;    /* string to match against */
  36.       colnr_T    col;    /* column to start looking for match */
  37.   {
  38.       reg_match = rmp;
  39.       reg_mmatch = NULL;
  40.       reg_maxline = 0;
  41. !     reg_line_lbr = FALSE;
  42.       reg_buf = curbuf;
  43.       reg_win = NULL;
  44.       ireg_ic = rmp->rm_ic;
  45. --- 3709,3736 ----
  46.   /* TRUE if using multi-line regexp. */
  47.   #define REG_MULTI    (reg_match == NULL)
  48.   
  49. ! static int  bt_regexec_nl __ARGS((regmatch_T *rmp, char_u *line, colnr_T col, int line_lbr));
  50.   
  51.   /*
  52.    * Match a regexp against a string.
  53.    * "rmp->regprog" is a compiled regexp as returned by vim_regcomp().
  54.    * Uses curbuf for line count and 'iskeyword'.
  55. +  * if "line_lbr" is TRUE  consider a "\n" in "line" to be a line break.
  56.    *
  57.    * Return TRUE if there is a match, FALSE if not.
  58.    */
  59.       static int
  60. ! bt_regexec_nl(rmp, line, col, line_lbr)
  61.       regmatch_T    *rmp;
  62.       char_u    *line;    /* string to match against */
  63.       colnr_T    col;    /* column to start looking for match */
  64. +     int        line_lbr;
  65.   {
  66.       reg_match = rmp;
  67.       reg_mmatch = NULL;
  68.       reg_maxline = 0;
  69. !     reg_line_lbr = line_lbr;
  70.       reg_buf = curbuf;
  71.       reg_win = NULL;
  72.       ireg_ic = rmp->rm_ic;
  73. ***************
  74. *** 3738,3772 ****
  75.       return (bt_regexec_both(line, col, NULL) != 0);
  76.   }
  77.   
  78. - #if defined(FEAT_MODIFY_FNAME) || defined(FEAT_EVAL) \
  79. -     || defined(FIND_REPLACE_DIALOG) || defined(PROTO)
  80. - static int  bt_regexec_nl __ARGS((regmatch_T *rmp, char_u *line, colnr_T col));
  81. - /*
  82. -  * Like vim_regexec(), but consider a "\n" in "line" to be a line break.
  83. -  */
  84. -     static int
  85. - bt_regexec_nl(rmp, line, col)
  86. -     regmatch_T    *rmp;
  87. -     char_u    *line;    /* string to match against */
  88. -     colnr_T    col;    /* column to start looking for match */
  89. - {
  90. -     reg_match = rmp;
  91. -     reg_mmatch = NULL;
  92. -     reg_maxline = 0;
  93. -     reg_line_lbr = TRUE;
  94. -     reg_buf = curbuf;
  95. -     reg_win = NULL;
  96. -     ireg_ic = rmp->rm_ic;
  97. - #ifdef FEAT_MBYTE
  98. -     ireg_icombine = FALSE;
  99. - #endif
  100. -     ireg_maxcol = 0;
  101. -     return (bt_regexec_both(line, col, NULL) != 0);
  102. - }
  103. - #endif
  104.   static long bt_regexec_multi __ARGS((regmmatch_T *rmp, win_T *win, buf_T *buf, linenr_T lnum, colnr_T col, proftime_T *tm));
  105.   
  106.   /*
  107. --- 3741,3746 ----
  108. ***************
  109. *** 7985,7995 ****
  110.   {
  111.       bt_regcomp,
  112.       bt_regfree,
  113. -     bt_regexec,
  114. - #if defined(FEAT_MODIFY_FNAME) || defined(FEAT_EVAL) \
  115. -     || defined(FIND_REPLACE_DIALOG) || defined(PROTO)
  116.       bt_regexec_nl,
  117. - #endif
  118.       bt_regexec_multi
  119.   #ifdef DEBUG
  120.       ,(char_u *)""
  121. --- 7959,7965 ----
  122. ***************
  123. *** 8003,8013 ****
  124.   {
  125.       nfa_regcomp,
  126.       nfa_regfree,
  127. -     nfa_regexec,
  128. - #if defined(FEAT_MODIFY_FNAME) || defined(FEAT_EVAL) \
  129. -     || defined(FIND_REPLACE_DIALOG) || defined(PROTO)
  130.       nfa_regexec_nl,
  131. - #endif
  132.       nfa_regexec_multi
  133.   #ifdef DEBUG
  134.       ,(char_u *)""
  135. --- 7973,7979 ----
  136. ***************
  137. *** 8131,8137 ****
  138.       char_u      *line;  /* string to match against */
  139.       colnr_T     col;    /* column to start looking for match */
  140.   {
  141. !     return rmp->regprog->engine->regexec(rmp, line, col);
  142.   }
  143.   
  144.   #if defined(FEAT_MODIFY_FNAME) || defined(FEAT_EVAL) \
  145. --- 8097,8103 ----
  146.       char_u      *line;  /* string to match against */
  147.       colnr_T     col;    /* column to start looking for match */
  148.   {
  149. !     return rmp->regprog->engine->regexec_nl(rmp, line, col, FALSE);
  150.   }
  151.   
  152.   #if defined(FEAT_MODIFY_FNAME) || defined(FEAT_EVAL) \
  153. ***************
  154. *** 8145,8151 ****
  155.       char_u *line;
  156.       colnr_T col;
  157.   {
  158. !     return rmp->regprog->engine->regexec_nl(rmp, line, col);
  159.   }
  160.   #endif
  161.   
  162. --- 8111,8117 ----
  163.       char_u *line;
  164.       colnr_T col;
  165.   {
  166. !     return rmp->regprog->engine->regexec_nl(rmp, line, col, TRUE);
  167.   }
  168.   #endif
  169.   
  170. *** ../vim-7.4.261/src/regexp_nfa.c    2014-04-06 21:33:39.675363743 +0200
  171. --- src/regexp_nfa.c    2014-04-23 19:00:44.354837189 +0200
  172. ***************
  173. *** 311,317 ****
  174.   static long nfa_regexec_both __ARGS((char_u *line, colnr_T col));
  175.   static regprog_T *nfa_regcomp __ARGS((char_u *expr, int re_flags));
  176.   static void nfa_regfree __ARGS((regprog_T *prog));
  177. ! static int nfa_regexec __ARGS((regmatch_T *rmp, char_u *line, colnr_T col));
  178.   static long nfa_regexec_multi __ARGS((regmmatch_T *rmp, win_T *win, buf_T *buf, linenr_T lnum, colnr_T col, proftime_T *tm));
  179.   static int match_follows __ARGS((nfa_state_T *startstate, int depth));
  180.   static int failure_chance __ARGS((nfa_state_T *state, int depth));
  181. --- 311,317 ----
  182.   static long nfa_regexec_both __ARGS((char_u *line, colnr_T col));
  183.   static regprog_T *nfa_regcomp __ARGS((char_u *expr, int re_flags));
  184.   static void nfa_regfree __ARGS((regprog_T *prog));
  185. ! static int  nfa_regexec_nl __ARGS((regmatch_T *rmp, char_u *line, colnr_T col, int line_lbr));
  186.   static long nfa_regexec_multi __ARGS((regmmatch_T *rmp, win_T *win, buf_T *buf, linenr_T lnum, colnr_T col, proftime_T *tm));
  187.   static int match_follows __ARGS((nfa_state_T *startstate, int depth));
  188.   static int failure_chance __ARGS((nfa_state_T *state, int depth));
  189. ***************
  190. *** 7060,7078 ****
  191.    * Match a regexp against a string.
  192.    * "rmp->regprog" is a compiled regexp as returned by nfa_regcomp().
  193.    * Uses curbuf for line count and 'iskeyword'.
  194.    *
  195.    * Return TRUE if there is a match, FALSE if not.
  196.    */
  197.       static int
  198. ! nfa_regexec(rmp, line, col)
  199.       regmatch_T    *rmp;
  200.       char_u    *line;    /* string to match against */
  201.       colnr_T    col;    /* column to start looking for match */
  202.   {
  203.       reg_match = rmp;
  204.       reg_mmatch = NULL;
  205.       reg_maxline = 0;
  206. !     reg_line_lbr = FALSE;
  207.       reg_buf = curbuf;
  208.       reg_win = NULL;
  209.       ireg_ic = rmp->rm_ic;
  210. --- 7060,7080 ----
  211.    * Match a regexp against a string.
  212.    * "rmp->regprog" is a compiled regexp as returned by nfa_regcomp().
  213.    * Uses curbuf for line count and 'iskeyword'.
  214. +  * If "line_lbr" is TRUE consider a "\n" in "line" to be a line break.
  215.    *
  216.    * Return TRUE if there is a match, FALSE if not.
  217.    */
  218.       static int
  219. ! nfa_regexec_nl(rmp, line, col, line_lbr)
  220.       regmatch_T    *rmp;
  221.       char_u    *line;    /* string to match against */
  222.       colnr_T    col;    /* column to start looking for match */
  223. +     int        line_lbr;
  224.   {
  225.       reg_match = rmp;
  226.       reg_mmatch = NULL;
  227.       reg_maxline = 0;
  228. !     reg_line_lbr = line_lbr;
  229.       reg_buf = curbuf;
  230.       reg_win = NULL;
  231.       ireg_ic = rmp->rm_ic;
  232. ***************
  233. *** 7083,7117 ****
  234.       return (nfa_regexec_both(line, col) != 0);
  235.   }
  236.   
  237. - #if defined(FEAT_MODIFY_FNAME) || defined(FEAT_EVAL) \
  238. -     || defined(FIND_REPLACE_DIALOG) || defined(PROTO)
  239. - static int  nfa_regexec_nl __ARGS((regmatch_T *rmp, char_u *line, colnr_T col));
  240. - /*
  241. -  * Like nfa_regexec(), but consider a "\n" in "line" to be a line break.
  242. -  */
  243. -     static int
  244. - nfa_regexec_nl(rmp, line, col)
  245. -     regmatch_T    *rmp;
  246. -     char_u    *line;    /* string to match against */
  247. -     colnr_T    col;    /* column to start looking for match */
  248. - {
  249. -     reg_match = rmp;
  250. -     reg_mmatch = NULL;
  251. -     reg_maxline = 0;
  252. -     reg_line_lbr = TRUE;
  253. -     reg_buf = curbuf;
  254. -     reg_win = NULL;
  255. -     ireg_ic = rmp->rm_ic;
  256. - #ifdef FEAT_MBYTE
  257. -     ireg_icombine = FALSE;
  258. - #endif
  259. -     ireg_maxcol = 0;
  260. -     return (nfa_regexec_both(line, col) != 0);
  261. - }
  262. - #endif
  263.   
  264.   /*
  265.    * Match a regexp against multiple lines.
  266. --- 7085,7090 ----
  267. *** ../vim-7.4.261/src/regexp.h    2013-06-11 10:53:14.000000000 +0200
  268. --- src/regexp.h    2014-04-23 18:58:18.614840701 +0200
  269. ***************
  270. *** 149,159 ****
  271.   {
  272.       regprog_T    *(*regcomp)(char_u*, int);
  273.       void    (*regfree)(regprog_T *);
  274. !     int        (*regexec)(regmatch_T*, char_u*, colnr_T);
  275. ! #if defined(FEAT_MODIFY_FNAME) || defined(FEAT_EVAL) \
  276. !     || defined(FIND_REPLACE_DIALOG) || defined(PROTO)
  277. !     int        (*regexec_nl)(regmatch_T*, char_u*, colnr_T);
  278. ! #endif
  279.       long    (*regexec_multi)(regmmatch_T*, win_T*, buf_T*, linenr_T, colnr_T, proftime_T*);
  280.   #ifdef DEBUG
  281.       char_u    *expr;
  282. --- 149,155 ----
  283.   {
  284.       regprog_T    *(*regcomp)(char_u*, int);
  285.       void    (*regfree)(regprog_T *);
  286. !     int        (*regexec_nl)(regmatch_T*, char_u*, colnr_T, int);
  287.       long    (*regexec_multi)(regmmatch_T*, win_T*, buf_T*, linenr_T, colnr_T, proftime_T*);
  288.   #ifdef DEBUG
  289.       char_u    *expr;
  290. *** ../vim-7.4.261/src/version.c    2014-04-23 18:48:43.546854558 +0200
  291. --- src/version.c    2014-04-23 18:52:20.102849340 +0200
  292. ***************
  293. *** 736,737 ****
  294. --- 736,739 ----
  295.   {   /* Add new patch number below this line */
  296. + /**/
  297. +     262,
  298.   /**/
  299.  
  300. -- 
  301. From "know your smileys":
  302.  ~#:-(    I just washed my hair, and I can't do nuthin' with it.
  303.  
  304.  /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
  305. ///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
  306. \\\  an exciting new programming language -- http://www.Zimbu.org        ///
  307.  \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///
  308.