• R/O
  • SSH

vim: Commit

Mirror of the Vim source from https://github.com/vim/vim


Commit MetaInfo

Révision25bc02d83cf438d5794ce106edad2959e2f89454 (tree)
l'heure2008-04-09 19:16:02
Auteurvimboss
Commitervimboss

Message de Log

updated for version 7.1-292

Change Summary

Modification

diff -r 9e0174515abb -r 25bc02d83cf4 src/regexp.c
--- a/src/regexp.c Tue Apr 01 18:59:07 2008 +0000
+++ b/src/regexp.c Wed Apr 09 10:16:02 2008 +0000
@@ -3039,6 +3039,15 @@
30393039 } se_u;
30403040 } save_se_T;
30413041
3042+/* used for BEHIND and NOBEHIND matching */
3043+typedef struct regbehind_S
3044+{
3045+ regsave_T save_after;
3046+ regsave_T save_behind;
3047+ save_se_T save_start[NSUBEXP];
3048+ save_se_T save_end[NSUBEXP];
3049+} regbehind_T;
3050+
30423051 static char_u *reg_getline __ARGS((linenr_T lnum));
30433052 static long vim_regexec_both __ARGS((char_u *line, colnr_T col, proftime_T *tm));
30443053 static long regtry __ARGS((regprog_T *prog, colnr_T col));
@@ -3046,6 +3055,8 @@
30463055 #ifdef FEAT_SYN_HL
30473056 static void cleanup_zsubexpr __ARGS((void));
30483057 #endif
3058+static void save_subexpr __ARGS((regbehind_T *bp));
3059+static void restore_subexpr __ARGS((regbehind_T *bp));
30493060 static void reg_nextline __ARGS((void));
30503061 static void reg_save __ARGS((regsave_T *save, garray_T *gap));
30513062 static void reg_restore __ARGS((regsave_T *save, garray_T *gap));
@@ -3166,19 +3177,12 @@
31663177 save_se_T sesave;
31673178 regsave_T regsave;
31683179 } rs_un; /* room for saving reginput */
3169- short rs_no; /* submatch nr */
3180+ short rs_no; /* submatch nr or BEHIND/NOBEHIND */
31703181 } regitem_T;
31713182
31723183 static regitem_T *regstack_push __ARGS((regstate_T state, char_u *scan));
31733184 static void regstack_pop __ARGS((char_u **scan));
31743185
3175-/* used for BEHIND and NOBEHIND matching */
3176-typedef struct regbehind_S
3177-{
3178- regsave_T save_after;
3179- regsave_T save_behind;
3180-} regbehind_T;
3181-
31823186 /* used for STAR, PLUS and BRACE_SIMPLE matching */
31833187 typedef struct regstar_S
31843188 {
@@ -4888,6 +4892,10 @@
48884892 status = RA_FAIL;
48894893 else
48904894 {
4895+ /* Need to save the subexpr to be able to restore them
4896+ * when there is a match but we don't use it. */
4897+ save_subexpr(((regbehind_T *)rp) - 1);
4898+
48914899 rp->rs_no = op;
48924900 reg_save(&rp->rs_un.regsave, &backpos);
48934901 /* First try if what follows matches. If it does then we
@@ -5118,15 +5126,20 @@
51185126 reg_restore(&(((regbehind_T *)rp) - 1)->save_after,
51195127 &backpos);
51205128 else
5121- /* But we didn't want a match. */
5129+ {
5130+ /* But we didn't want a match. Need to restore the
5131+ * subexpr, because what follows matched, so they have
5132+ * been set. */
51225133 status = RA_NOMATCH;
5134+ restore_subexpr(((regbehind_T *)rp) - 1);
5135+ }
51235136 regstack_pop(&scan);
51245137 regstack.ga_len -= sizeof(regbehind_T);
51255138 }
51265139 else
51275140 {
5128- /* No match: Go back one character. May go to previous
5129- * line once. */
5141+ /* No match or a match that doesn't end where we want it: Go
5142+ * back one character. May go to previous line once. */
51305143 no = OK;
51315144 if (REG_MULTI)
51325145 {
@@ -5160,6 +5173,13 @@
51605173 /* Advanced, prepare for finding match again. */
51615174 reg_restore(&rp->rs_un.regsave, &backpos);
51625175 scan = OPERAND(rp->rs_scan);
5176+ if (status == RA_MATCH)
5177+ {
5178+ /* We did match, so subexpr may have been changed,
5179+ * need to restore them for the next try. */
5180+ status = RA_NOMATCH;
5181+ restore_subexpr(((regbehind_T *)rp) - 1);
5182+ }
51635183 }
51645184 else
51655185 {
@@ -5172,7 +5192,16 @@
51725192 status = RA_MATCH;
51735193 }
51745194 else
5175- status = RA_NOMATCH;
5195+ {
5196+ /* We do want a proper match. Need to restore the
5197+ * subexpr if we had a match, because they may have
5198+ * been set. */
5199+ if (status == RA_MATCH)
5200+ {
5201+ status = RA_NOMATCH;
5202+ restore_subexpr(((regbehind_T *)rp) - 1);
5203+ }
5204+ }
51765205 regstack_pop(&scan);
51775206 regstack.ga_len -= sizeof(regbehind_T);
51785207 }
@@ -5820,6 +5849,55 @@
58205849 #endif
58215850
58225851 /*
5852+ * Save the current subexpr to "bp", so that they can be restored
5853+ * later by restore_subexpr().
5854+ */
5855+ static void
5856+save_subexpr(bp)
5857+ regbehind_T *bp;
5858+{
5859+ int i;
5860+
5861+ for (i = 0; i < NSUBEXP; ++i)
5862+ {
5863+ if (REG_MULTI)
5864+ {
5865+ bp->save_start[i].se_u.pos = reg_startpos[i];
5866+ bp->save_end[i].se_u.pos = reg_endpos[i];
5867+ }
5868+ else
5869+ {
5870+ bp->save_start[i].se_u.ptr = reg_startp[i];
5871+ bp->save_end[i].se_u.ptr = reg_endp[i];
5872+ }
5873+ }
5874+}
5875+
5876+/*
5877+ * Restore the subexpr from "bp".
5878+ */
5879+ static void
5880+restore_subexpr(bp)
5881+ regbehind_T *bp;
5882+{
5883+ int i;
5884+
5885+ for (i = 0; i < NSUBEXP; ++i)
5886+ {
5887+ if (REG_MULTI)
5888+ {
5889+ reg_startpos[i] = bp->save_start[i].se_u.pos;
5890+ reg_endpos[i] = bp->save_end[i].se_u.pos;
5891+ }
5892+ else
5893+ {
5894+ reg_startp[i] = bp->save_start[i].se_u.ptr;
5895+ reg_endp[i] = bp->save_end[i].se_u.ptr;
5896+ }
5897+ }
5898+}
5899+
5900+/*
58235901 * Advance reglnum, regline and reginput to the next line.
58245902 */
58255903 static void
diff -r 9e0174515abb -r 25bc02d83cf4 src/version.c
--- a/src/version.c Tue Apr 01 18:59:07 2008 +0000
+++ b/src/version.c Wed Apr 09 10:16:02 2008 +0000
@@ -667,6 +667,8 @@
667667 static int included_patches[] =
668668 { /* Add new patch number below this line */
669669 /**/
670+ 292,
671+/**/
670672 291,
671673 /**/
672674 290,
Afficher sur ancien navigateur de dépôt.