]> granicus.if.org Git - vim/commitdiff
updated for version 7.4b.004 v7.4b.004
authorBram Moolenaar <Bram@vim.org>
Thu, 1 Aug 2013 16:38:26 +0000 (18:38 +0200)
committerBram Moolenaar <Bram@vim.org>
Thu, 1 Aug 2013 16:38:26 +0000 (18:38 +0200)
Problem:    Regexp crash on pattern "@\%[\w\-]*". (Axel Kielhorn)
Solution:   Add \%(\) around \%[] internally.

src/regexp_nfa.c
src/testdir/test64.in
src/testdir/test64.ok
src/version.c

index 738ac3bb0982e197489758008717413e09dc67e9..35b42ef9cf1c239b4fcf4a817525dce8ee619325 100644 (file)
@@ -1166,6 +1166,15 @@ nfa_regatom()
                                                      reg_magic == MAGIC_ALL);
                        EMIT(NFA_OPT_CHARS);
                        EMIT(n);
+
+                       /* Emit as "\%(\%[abc]\)" to be able to handle
+                        * "\%[abc]*" which would cause the empty string to be
+                        * matched an unlimited number of times. NFA_NOPEN is
+                        * added only once at a position, while NFA_SPLIT is
+                        * added multiple times.  This is more efficient than
+                        * not allowsing NFA_SPLIT multiple times, it is used
+                        * a lot. */
+                       EMIT(NFA_NOPEN);
                        break;
                    }
 
@@ -1641,7 +1650,7 @@ nfa_regpiece()
             * engine interprets the plus as "try matching one more time", and
             * a* matches a second time at the end of the input, the empty
             * string.
-            * The submatch will the empty string.
+            * The submatch will be the empty string.
             *
             * In order to be consistent with the old engine, we replace
             * <atom>+ with <atom><atom>*
@@ -2242,13 +2251,13 @@ nfa_postfix_dump(expr, retval)
        else if (retval == OK)
            fprintf(f, ">>> NFA engine succeeded !\n");
        fprintf(f, "Regexp: \"%s\"\nPostfix notation (char): \"", expr);
-       for (p = post_start; *p && p < post_end; p++)
+       for (p = post_start; *p && p < post_ptr; p++)
        {
            nfa_set_code(*p);
            fprintf(f, "%s, ", code);
        }
        fprintf(f, "\"\nPostfix notation (int): ");
-       for (p = post_start; *p && p < post_end; p++)
+       for (p = post_start; *p && p < post_ptr; p++)
                fprintf(f, "%d ", *p);
        fprintf(f, "\n\n");
        fclose(f);
@@ -3005,7 +3014,18 @@ post2nfa(postfix, end, nfa_calc_size)
          {
            int    n;
 
-           /* \%[abc] */
+           /* \%[abc] implemented as:
+            *    NFA_SPLIT
+            *    +-CHAR(a)
+            *    | +-NFA_SPLIT
+            *    |   +-CHAR(b)
+            *    |   | +-NFA_SPLIT
+            *    |   |   +-CHAR(c)
+            *    |   |   | +-next
+            *    |   |   +- next
+            *    |   +- next
+            *    +- next
+            */
            n = *++p; /* get number of characters */
            if (nfa_calc_size == TRUE)
            {
index e666ab95a864f6a7ef073585bd2a52fee09df895..b0b1c911a344e8ac7c13a6a7dbf952f075f73a38 100644 (file)
@@ -373,6 +373,7 @@ STARTTEST
 :call add(tl, [2, '\%[bar]x', 'xxx', 'x'])
 :call add(tl, [2, 'b\%[[ao]r]', 'bar bor', 'bar'])
 :call add(tl, [2, 'b\%[[]]r]', 'b]r bor', 'b]r'])
+:call add(tl, [2, '@\%[\w\-]*', '<http://john.net/pandoc/>[@pandoc]', '@pandoc'])
 :"
 :"""" Alternatives, must use first longest match
 :call add(tl, [2, 'goo\|go', 'google', 'goo'])
index c778e9eef7417c1a5cac174fca06323f09ae60f2..2df568d9b0dff92acb6c9b760190e6cfc810bd2e 100644 (file)
@@ -857,6 +857,9 @@ OK 2 - b\%[[ao]r]
 OK 0 - b\%[[]]r]
 OK 1 - b\%[[]]r]
 OK 2 - b\%[[]]r]
+OK 0 - @\%[\w\-]*
+OK 1 - @\%[\w\-]*
+OK 2 - @\%[\w\-]*
 OK 0 - goo\|go
 OK 1 - goo\|go
 OK 2 - goo\|go
index 069c172ddc105d14d9376da6f9a0b3f76bfc6ac1..7ccb9315399731210ee3cd2e9dd004d929e64ebe 100644 (file)
@@ -727,6 +727,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    4,
 /**/
     3,
 /**/