From b4e5145598341ced0fedbde3d9ca13db26e5c8eb Mon Sep 17 00:00:00 2001 From: Karsten Hopp Date: Jun 04 2013 10:06:05 +0000 Subject: - patchlevel 1025 --- diff --git a/7.3.1025 b/7.3.1025 new file mode 100644 index 0000000..04af5e4 --- /dev/null +++ b/7.3.1025 @@ -0,0 +1,218 @@ +To: vim_dev@googlegroups.com +Subject: Patch 7.3.1025 +Fcc: outbox +From: Bram Moolenaar +Mime-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit +------------ + +Patch 7.3.1025 +Problem: New regexp: not matching newline in string. (Marc Weber) +Solution: Check for "\n" character. +Files: src/regexp_nfa.c, src/testdir/test64.in, src/testdir/test64.ok + + +*** ../vim-7.3.1024/src/regexp_nfa.c 2013-05-26 16:57:23.000000000 +0200 +--- src/regexp_nfa.c 2013-05-26 17:38:27.000000000 +0200 +*************** +*** 165,173 **** + static int *post_end; + static int *post_ptr; + +! static int nstate; /* Number of states in the NFA. */ + static int istate; /* Index in the state vector, used in new_state() */ +- static int nstate_max; /* Upper bound of estimated number of states. */ + + + static int nfa_regcomp_start __ARGS((char_u*expr, int re_flags)); +--- 165,173 ---- + static int *post_end; + static int *post_ptr; + +! static int nstate; /* Number of states in the NFA. Also used when +! * executing. */ + static int istate; /* Index in the state vector, used in new_state() */ + + + static int nfa_regcomp_start __ARGS((char_u*expr, int re_flags)); +*************** +*** 219,228 **** + int re_flags; /* see vim_regcomp() */ + { + size_t postfix_size; + + nstate = 0; + istate = 0; +! /* A reasonable estimation for size */ + nstate_max = (int)(STRLEN(expr) + 1) * NFA_POSTFIX_MULTIPLIER; + + /* Some items blow up in size, such as [A-z]. Add more space for that. +--- 219,229 ---- + int re_flags; /* see vim_regcomp() */ + { + size_t postfix_size; ++ int nstate_max; + + nstate = 0; + istate = 0; +! /* A reasonable estimation for maximum size */ + nstate_max = (int)(STRLEN(expr) + 1) * NFA_POSTFIX_MULTIPLIER; + + /* Some items blow up in size, such as [A-z]. Add more space for that. +*************** +*** 1968,1977 **** + * Frag_T.out is a list of places that need to be set to the + * next state for this fragment. + */ + typedef union Ptrlist Ptrlist; + struct Frag + { +! nfa_state_T *start; + Ptrlist *out; + }; + typedef struct Frag Frag_T; +--- 1969,1988 ---- + * Frag_T.out is a list of places that need to be set to the + * next state for this fragment. + */ ++ ++ /* Since the out pointers in the list are always ++ * uninitialized, we use the pointers themselves ++ * as storage for the Ptrlists. */ + typedef union Ptrlist Ptrlist; ++ union Ptrlist ++ { ++ Ptrlist *next; ++ nfa_state_T *s; ++ }; ++ + struct Frag + { +! nfa_state_T *start; + Ptrlist *out; + }; + typedef struct Frag Frag_T; +*************** +*** 1999,2015 **** + } + + /* +- * Since the out pointers in the list are always +- * uninitialized, we use the pointers themselves +- * as storage for the Ptrlists. +- */ +- union Ptrlist +- { +- Ptrlist *next; +- nfa_state_T *s; +- }; +- +- /* + * Create singleton list containing just outp. + */ + static Ptrlist * +--- 2010,2015 ---- +*************** +*** 3358,3365 **** + #endif + + case NFA_NEWL: +! if (!reg_line_lbr && REG_MULTI +! && curc == NUL && reglnum <= reg_maxline) + { + go_to_nextline = TRUE; + /* Pass -1 for the offset, which means taking the position +--- 3358,3365 ---- + #endif + + case NFA_NEWL: +! if (curc == NUL && !reg_line_lbr && REG_MULTI +! && reglnum <= reg_maxline) + { + go_to_nextline = TRUE; + /* Pass -1 for the offset, which means taking the position +*************** +*** 3367,3372 **** +--- 3367,3378 ---- + addstate(nextlist, t->state->out, &t->sub, -1, + listid + 1, &match); + } ++ else if (curc == '\n' && reg_line_lbr) ++ { ++ /* match \n as if it is an ordinary character */ ++ addstate(nextlist, t->state->out, &t->sub, 1, ++ listid + 1, &match); ++ } + break; + + case NFA_CLASS_ALNUM: +*************** +*** 3832,3838 **** +--- 3838,3849 ---- + * (and count its size). */ + postfix = re2post(); + if (postfix == NULL) ++ { ++ /* TODO: only give this error for debugging? */ ++ if (post_ptr >= post_end) ++ EMSGN("Internal error: estimated max number of states insufficient: %ld", post_end - post_start); + goto fail; /* Cascaded (syntax?) error */ ++ } + + /* + * In order to build the NFA, we parse the input regexp twice: +*** ../vim-7.3.1024/src/testdir/test64.in 2013-05-26 16:57:23.000000000 +0200 +--- src/testdir/test64.in 2013-05-26 17:37:51.000000000 +0200 +*************** +*** 250,255 **** +--- 250,258 ---- + :call add(tl, [2, 'abc[0-9]*ddd', 'adf abc44482ddd oijs', 'abc44482ddd']) + :call add(tl, [2, '\_[0-9]\+', 'asfi9888u', '9888']) + :call add(tl, [2, '[0-9\n]\+', 'asfi9888u', '9888']) ++ :call add(tl, [2, '\_[0-9]\+', "asfi\n9888u", "\n9888"]) ++ :call add(tl, [2, '\_f', " \na ", "\n"]) ++ :call add(tl, [2, '\_f\+', " \na ", "\na"]) + :" + :" + :"""" Test recognition of some character classes +*** ../vim-7.3.1024/src/testdir/test64.ok 2013-05-26 16:57:23.000000000 +0200 +--- src/testdir/test64.ok 2013-05-26 17:38:51.000000000 +0200 +*************** +*** 576,581 **** +--- 576,590 ---- + OK 0 - [0-9\n]\+ + OK 1 - [0-9\n]\+ + OK 2 - [0-9\n]\+ ++ OK 0 - \_[0-9]\+ ++ OK 1 - \_[0-9]\+ ++ OK 2 - \_[0-9]\+ ++ OK 0 - \_f ++ OK 1 - \_f ++ OK 2 - \_f ++ OK 0 - \_f\+ ++ OK 1 - \_f\+ ++ OK 2 - \_f\+ + OK 0 - [0-9] + OK 1 - [0-9] + OK 2 - [0-9] +*** ../vim-7.3.1024/src/version.c 2013-05-26 16:57:23.000000000 +0200 +--- src/version.c 2013-05-26 17:44:16.000000000 +0200 +*************** +*** 730,731 **** +--- 730,733 ---- + { /* Add new patch number below this line */ ++ /**/ ++ 1025, + /**/ + +-- +Every engineer dreams about saving the universe and having sex with aliens. +This is much more glamorous than the real life of an engineer, which consists +of hiding from the universe and having sex without the participation of other +life forms. (Scott Adams - The Dilbert principle) + + /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ +/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ +\\\ an exciting new programming language -- http://www.Zimbu.org /// + \\\ help me help AIDS victims -- http://ICCF-Holland.org ///