summaryrefslogtreecommitdiff
path: root/regexec.c
diff options
context:
space:
mode:
authorKarl Williamson <public@khwilliamson.com>2010-10-31 12:36:49 -0600
committerFather Chrysostomos <sprout@cpan.org>2010-10-31 16:10:54 -0700
commita5a291f55baf01a6b4b1013e2d3c722a0ad77432 (patch)
tree61b017f595cbc3e384746d86e8a0c9d3ff853baa /regexec.c
parentf7ab54c630d4ff497dfc2435654b5aee46420b17 (diff)
downloadperl-a5a291f55baf01a6b4b1013e2d3c722a0ad77432.tar.gz
reginclass: Make explicit the length assumptions
reginclass assumes that can match always at least one character. Make that explicit, and now that we have that length always saved, don't recalculate it.
Diffstat (limited to 'regexec.c')
-rw-r--r--regexec.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/regexec.c b/regexec.c
index f6f743584f..5192899aa2 100644
--- a/regexec.c
+++ b/regexec.c
@@ -6220,18 +6220,20 @@ S_reginclass(pTHX_ const regexp * const prog, register const regnode * const n,
if (c_len == (STRLEN)-1)
Perl_croak(aTHX_ "Malformed UTF-8 character (fatal)");
}
+ else {
+ c_len = 1;
+ }
- /* Use passed in max length, or one character if none passed in. And
- * assume will match just one character. This is overwritten later if
- * matched more. (Note that the code makes an implicit assumption that any
- * passed in max is at least one character) */
+ /* Use passed in max length, or one character if none passed in or less
+ * than one character. And assume will match just one character. This is
+ * overwritten later if matched more. */
if (lenp) {
- maxlen = *lenp;
- *lenp = UNISKIP(NATIVE_TO_UNI(c));
+ maxlen = (*lenp > c_len) ? *lenp : c_len;
+ *lenp = c_len;
}
else {
- maxlen = UNISKIP(NATIVE_TO_UNI(c));
+ maxlen = c_len;
}
if (utf8_target || (flags & ANYOF_UNICODE)) {