From 4ed9aa638088a3dd4865453746330ce239723802 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 31 Dec 2013 15:05:34 +0530 Subject: [PATCH] Merge upstream bugfix for regex engine https://code.google.com/p/mrab-regex-hg/source/detail?r=69cdaa98c25506c226717967be7131d06f1d54dd --- src/regex/_regex.c | 48 ++++++++++++++++------------------------------ 1 file changed, 16 insertions(+), 32 deletions(-) diff --git a/src/regex/_regex.c b/src/regex/_regex.c index f0a4f9a187..43f2135920 100644 --- a/src/regex/_regex.c +++ b/src/regex/_regex.c @@ -11767,15 +11767,7 @@ backtrack: ch = test->values[0]; - /* The tail is a character. We don't want to go off the end - * of the slice. - */ - limit = RE_MAX(limit, slice_start + 1); - for (;;) { - if (pos <= limit) - break; - --pos; if ((char_at(text, pos) == ch) == m && @@ -11784,6 +11776,10 @@ backtrack: match = TRUE; break; } + + if (pos == limit) + break; + } break; } @@ -11793,15 +11789,7 @@ backtrack: ch = test->values[0]; - /* The tail is a character. We don't want to go off the end - * of the slice. - */ - limit = RE_MAX(limit, slice_start + 1); - for (;;) { - if (pos <= limit) - break; - --pos; if (same_char_ign(encoding, char_at(text, pos), ch) == @@ -11810,6 +11798,10 @@ backtrack: match = TRUE; break; } + + if (pos == limit) + break; + } break; } @@ -11819,15 +11811,7 @@ backtrack: ch = test->values[0]; - /* The tail is a character. We don't want to go off the end - * of the slice. - */ - limit = RE_MIN(limit, slice_end - 1); - for (;;) { - if (pos >= limit) - break; - ++pos; if (same_char_ign(encoding, char_at(text, pos - 1), ch) @@ -11836,6 +11820,10 @@ backtrack: match = TRUE; break; } + + if (pos == limit) + break; + } break; } @@ -11845,15 +11833,7 @@ backtrack: ch = test->values[0]; - /* The tail is a character. We don't want to go off the end - * of the slice. - */ - limit = RE_MIN(limit, slice_end - 1); - for (;;) { - if (pos >= limit) - break; - ++pos; if ((char_at(text, pos - 1) == ch) == m && @@ -11862,6 +11842,10 @@ backtrack: match = TRUE; break; } + + if (pos == limit) + break; + } break; }