diff options
author | Yves Orton <demerphq@gmail.com> | 2007-01-31 00:58:31 +0100 |
---|---|---|
committer | H.Merijn Brand <h.m.brand@xs4all.nl> | 2007-01-31 10:29:59 +0000 |
commit | bcdf74043c1fd4b60b7764f5cd7d87525cf77e74 (patch) | |
tree | 0a3acc4337796c1ed8e000810e9ecaa82ec42e5a /ext | |
parent | 57b84237ab396aa1e1efe3b629c2b636d4869d93 (diff) | |
download | perl-bcdf74043c1fd4b60b7764f5cd7d87525cf77e74.tar.gz |
Improve regex stringification code
Message-ID: <9b18b3110701301458k2f6a8254hea6c6db28489c38b@mail.gmail.com>
p4raw-id: //depot/perl@30084
Diffstat (limited to 'ext')
-rw-r--r-- | ext/re/re.xs | 7 | ||||
-rw-r--r-- | ext/re/t/re_funcs.t | 17 |
2 files changed, 11 insertions, 13 deletions
diff --git a/ext/re/re.xs b/ext/re/re.xs index aa601cf67d..1bc20fc2bc 100644 --- a/ext/re/re.xs +++ b/ext/re/re.xs @@ -120,7 +120,7 @@ PPCODE: modifiers" in this scenario. */ - char *fptr = "msix"; + char *fptr = INT_PAT_MODS; char ch; U16 match_flags = (U16)((re->extflags & PMf_COMPILETIME) >> 12); @@ -140,11 +140,8 @@ PPCODE: XSRETURN(2); } else { /* Scalar, so use the string that Perl would return */ - if (!mg->mg_ptr) - CALLREG_STRINGIFY(mg,0,0); - /* return the pattern in (?msix:..) format */ - pattern = sv_2mortal(newSVpvn(mg->mg_ptr,mg->mg_len)); + pattern = sv_2mortal(newSVpvn(re->wrapped,re->wraplen)); if (re->extflags & RXf_UTF8) SvUTF8_on(pattern); XPUSHs(pattern); diff --git a/ext/re/t/re_funcs.t b/ext/re/t/re_funcs.t index 736829cbc4..bf8202aa44 100644 --- a/ext/re/t/re_funcs.t +++ b/ext/re/t/re_funcs.t @@ -16,14 +16,15 @@ use Test::More; # test count at bottom of file use re qw(is_regexp regexp_pattern regmust regname regnames regnames_count regnames_iterinit regnames_iternext); -my $qr=qr/foo/i; - -ok(is_regexp($qr),'is_regexp($qr)'); -ok(!is_regexp(''),'is_regexp("")'); -is((regexp_pattern($qr))[0],'foo','regexp_pattern[0]'); -is((regexp_pattern($qr))[1],'i','regexp_pattern[1]'); -is(regexp_pattern($qr),'(?i-xsm:foo)','scalar regexp_pattern'); -ok(!regexp_pattern(''),'!regexp_pattern("")'); +{ + my $qr=qr/foo/ki; + ok(is_regexp($qr),'is_regexp($qr)'); + ok(!is_regexp(''),'is_regexp("")'); + is((regexp_pattern($qr))[0],'foo','regexp_pattern[0]'); + is((regexp_pattern($qr))[1],'ik','regexp_pattern[1]'); + is(regexp_pattern($qr),'(?ki-xsm:foo)','scalar regexp_pattern'); + ok(!regexp_pattern(''),'!regexp_pattern("")'); +} { my $qr=qr/here .* there/x; my ($anchored,$floating)=regmust($qr); |