comparison src/regexp_nfa.c @ 5251:2e63b6c763f7 v7.4b.002

updated for version 7.4b.002 Problem: Crash searching for \%(\%(\|\d\|-\|\.\)*\|\*\). (Marcin Szamotulski) Also for \(\)*. Solution: Do add a state for opening parenthesis, so that we can check if it was added before at the same position.
author Bram Moolenaar <bram@vim.org>
date Thu, 01 Aug 2013 15:45:52 +0200
parents a08fa2919f2b
children ea876fe91483
comparison
equal deleted inserted replaced
5250:71ba628fe723 5251:2e63b6c763f7
3908 case NFA_ZCLOSE6: 3908 case NFA_ZCLOSE6:
3909 case NFA_ZCLOSE7: 3909 case NFA_ZCLOSE7:
3910 case NFA_ZCLOSE8: 3910 case NFA_ZCLOSE8:
3911 case NFA_ZCLOSE9: 3911 case NFA_ZCLOSE9:
3912 #endif 3912 #endif
3913 case NFA_MOPEN:
3913 case NFA_ZEND: 3914 case NFA_ZEND:
3914 case NFA_SPLIT: 3915 case NFA_SPLIT:
3915 case NFA_NOPEN:
3916 case NFA_SKIP_CHAR: 3916 case NFA_SKIP_CHAR:
3917 /* These nodes are not added themselves but their "out" and/or 3917 /* These nodes are not added themselves but their "out" and/or
3918 * "out1" may be added below. */ 3918 * "out1" may be added below. */
3919 break; 3919 break;
3920 3920
3921 case NFA_MOPEN: 3921 case NFA_BOL:
3922 case NFA_BOF:
3923 /* "^" won't match past end-of-line, don't bother trying.
3924 * Except when at the end of the line, or when we are going to the
3925 * next line for a look-behind match. */
3926 if (reginput > regline
3927 && *reginput != NUL
3928 && (nfa_endp == NULL
3929 || !REG_MULTI
3930 || reglnum == nfa_endp->se_u.pos.lnum))
3931 goto skip_add;
3932 /* FALLTHROUGH */
3933
3922 case NFA_MOPEN1: 3934 case NFA_MOPEN1:
3923 case NFA_MOPEN2: 3935 case NFA_MOPEN2:
3924 case NFA_MOPEN3: 3936 case NFA_MOPEN3:
3925 case NFA_MOPEN4: 3937 case NFA_MOPEN4:
3926 case NFA_MOPEN5: 3938 case NFA_MOPEN5:
3938 case NFA_ZOPEN6: 3950 case NFA_ZOPEN6:
3939 case NFA_ZOPEN7: 3951 case NFA_ZOPEN7:
3940 case NFA_ZOPEN8: 3952 case NFA_ZOPEN8:
3941 case NFA_ZOPEN9: 3953 case NFA_ZOPEN9:
3942 #endif 3954 #endif
3955 case NFA_NOPEN:
3943 case NFA_ZSTART: 3956 case NFA_ZSTART:
3944 /* These nodes do not need to be added, but we need to bail out 3957 /* These nodes need to be added so that we can bail out when it
3945 * when it was tried to be added to this list before. */ 3958 * was added to this list before at the same position to avoid an
3946 if (state->lastlist[nfa_ll_index] == l->id) 3959 * endless loop for "\(\)*" */
3947 goto skip_add;
3948 state->lastlist[nfa_ll_index] = l->id;
3949 break;
3950
3951 case NFA_BOL:
3952 case NFA_BOF:
3953 /* "^" won't match past end-of-line, don't bother trying.
3954 * Except when at the end of the line, or when we are going to the
3955 * next line for a look-behind match. */
3956 if (reginput > regline
3957 && *reginput != NUL
3958 && (nfa_endp == NULL
3959 || !REG_MULTI
3960 || reglnum == nfa_endp->se_u.pos.lnum))
3961 goto skip_add;
3962 /* FALLTHROUGH */
3963 3960
3964 default: 3961 default:
3965 if (state->lastlist[nfa_ll_index] == l->id) 3962 if (state->lastlist[nfa_ll_index] == l->id)
3966 { 3963 {
3967 /* This state is already in the list, don't add it again, 3964 /* This state is already in the list, don't add it again,
6023 add_state = t->state->out; 6020 add_state = t->state->out;
6024 } 6021 }
6025 #endif 6022 #endif
6026 break; 6023 break;
6027 6024
6025 case NFA_MOPEN1:
6026 case NFA_MOPEN2:
6027 case NFA_MOPEN3:
6028 case NFA_MOPEN4:
6029 case NFA_MOPEN5:
6030 case NFA_MOPEN6:
6031 case NFA_MOPEN7:
6032 case NFA_MOPEN8:
6033 case NFA_MOPEN9:
6034 #ifdef FEAT_SYN_HL
6035 case NFA_ZOPEN:
6036 case NFA_ZOPEN1:
6037 case NFA_ZOPEN2:
6038 case NFA_ZOPEN3:
6039 case NFA_ZOPEN4:
6040 case NFA_ZOPEN5:
6041 case NFA_ZOPEN6:
6042 case NFA_ZOPEN7:
6043 case NFA_ZOPEN8:
6044 case NFA_ZOPEN9:
6045 #endif
6046 case NFA_NOPEN:
6047 case NFA_ZSTART:
6048 /* These states are only added to be able to bail out when
6049 * they are added again, nothing is to be done. */
6050 break;
6051
6028 default: /* regular character */ 6052 default: /* regular character */
6029 { 6053 {
6030 int c = t->state->c; 6054 int c = t->state->c;
6031 6055
6032 /* TODO: put this in #ifdef later */ 6056 #ifdef DEBUG
6033 if (c < 0) 6057 if (c < 0)
6034 EMSGN("INTERNAL: Negative state char: %ld", c); 6058 EMSGN("INTERNAL: Negative state char: %ld", c);
6059 #endif
6035 result = (c == curc); 6060 result = (c == curc);
6036 6061
6037 if (!result && ireg_ic) 6062 if (!result && ireg_ic)
6038 result = MB_TOLOWER(c) == MB_TOLOWER(curc); 6063 result = MB_TOLOWER(c) == MB_TOLOWER(curc);
6039 #ifdef FEAT_MBYTE 6064 #ifdef FEAT_MBYTE