This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perl5.git
11 years agoAdd Rhesa Rozendaal to AUTHORS
Father Chrysostomos [Fri, 15 Jun 2012 16:37:41 +0000 (09:37 -0700)]
Add Rhesa Rozendaal to AUTHORS

11 years agoop.c:utilize: don't allocate pegop if !PL_madskills
Father Chrysostomos [Thu, 14 Jun 2012 20:16:40 +0000 (13:16 -0700)]
op.c:utilize: don't allocate pegop if !PL_madskills

Just following what the FIXME note says. :-)

This shaves off a few CPU cycles.

11 years agoLet hints.t run at the top level
Father Chrysostomos [Thu, 14 Jun 2012 15:42:11 +0000 (08:42 -0700)]
Let hints.t run at the top level

11 years agoTests for perl #94476
Father Chrysostomos [Thu, 14 Jun 2012 06:43:14 +0000 (23:43 -0700)]
Tests for perl #94476

11 years agoconfigpm: comment typo
Father Chrysostomos [Thu, 14 Jun 2012 06:11:26 +0000 (23:11 -0700)]
configpm: comment typo

11 years agoDon’t call mro_method_changed_in after newCONSTSUB
Father Chrysostomos [Thu, 14 Jun 2012 06:10:46 +0000 (23:10 -0700)]
Don’t call mro_method_changed_in after newCONSTSUB

newCONSTSUB already does it itself (by calling newXS_len_flags,
which does it).

11 years agoDon’t create pads for sub stubs
Father Chrysostomos [Thu, 14 Jun 2012 05:46:40 +0000 (22:46 -0700)]
Don’t create pads for sub stubs

Two code paths, sv_2cv (for \&name) and get_cvn_flags (for
&{"name"}()) were using start_subparse and newATTRSUB to create a
subroutine stub, which is what usually happens for Perl subs (with
op trees).

This resulted in subs with unused pads attached to them, because
start_subparse sets up the pad, which must be accessible dur-
ing parsing.

One code path, gv_init, which (among other things) reifies a GV after
a sub declaration (like ‘sub foo;’, which for efficiency doesn’t
create a CV), created the subroutine stub itself, without using
start_subparse/newATTRSUB.

This commit takes the code from gv_init, makes it more generic so it
can apply to the other two cases, puts it in a new function called
newSTUB, and makes all three locations call it.

Now stub creation should be faster and use less memory.

Additionally, this commit causes sv_2cv and get_cvn_flags to bypass
bug #107370 (glob stringification not round-tripping properly).  They
used to stringify the GV and pass the string to newATTRSUB (wrapped in
an op, of all things) for it to look up the GV again.  While bug
been fixed, as it was a side effect of sv_2cv triggering bug #107370.

11 years agoop.c:newPROG: Remove questionable comment
Father Chrysostomos [Wed, 13 Jun 2012 20:58:13 +0000 (13:58 -0700)]
op.c:newPROG: Remove questionable comment

This thing about PL_eval_root going through an expensive function call
had already ceased to be the case before commit 5983a79d, which added
it.  And I think it was only ever valid for non-core code.

11 years agoUse assertions for /* NOT REACHED */
Father Chrysostomos [Wed, 13 Jun 2012 15:45:16 +0000 (08:45 -0700)]
Use assertions for /* NOT REACHED */

to make sure it really is never reached.

11 years agosv.h: Move comment just before struct it describes
Father Chrysostomos [Wed, 13 Jun 2012 06:03:23 +0000 (23:03 -0700)]
sv.h: Move comment just before struct it describes

It was divorced therefrom in commit 20f4945e.

11 years agoperl.c: Clarify comment
Father Chrysostomos [Wed, 13 Jun 2012 05:47:07 +0000 (22:47 -0700)]
perl.c: Clarify comment

This comment was added by commit 17fbfdf.  Without looking at the
diff, it’s not clear that ‘Do this now’ refers to setting PL_curcop,
rather than destroying the main CV.  Also, there was a missing verb,
leading to confusion.  (I first inferred ‘cause’ when reading it,
but it is actually ‘expect’, based on inspecting the code in
sv.c:S_new_SV.)

11 years agoRmv mro_method_changed_in call on stub upgraded to const
Father Chrysostomos [Mon, 11 Jun 2012 05:39:44 +0000 (22:39 -0700)]
Rmv mro_method_changed_in call on stub upgraded to const

If a subroutine stub exists and a new subroutine is defined with the
same name, that new subroutine’s body is attached to the stub.  So
there are no changes from the point of view of method lookup.

For most subs, mro_method_changed_in is not called in this case.

For constant subs, it was being called.

In the case where a new sub is being created, we know that
cv == GvCV(gv) and GvSTASH(gv) is set, so checking CvSTASH is
unnecessary.

11 years agogv.c: Don’t repeat GvSVn
Father Chrysostomos [Mon, 11 Jun 2012 03:12:33 +0000 (20:12 -0700)]
gv.c: Don’t repeat GvSVn

GvSVn checks whether there is a scalar present and creates one if there
is not.  So doing GvSVn twice in a row results in a redundant check.

It has been this way since c69033f2.

11 years agoperl.c:get_cvn_flags: Move a comment where it belongs
Father Chrysostomos [Mon, 11 Jun 2012 01:00:04 +0000 (18:00 -0700)]
perl.c:get_cvn_flags: Move a comment where it belongs

The PERL_ARGS_ASSERT_GET_CVN_FLAGS got inserted between a
comment and the code it described.

11 years agogv.c: Remove mro_method_changed_in() from gv_init
Father Chrysostomos [Sun, 10 Jun 2012 23:21:59 +0000 (16:21 -0700)]
gv.c: Remove mro_method_changed_in() from gv_init

gv_init(_pvn) does not conceptually change anything.  There was
already a subroutine there before the stub was upgraded to a gv with
a real cv.

The example in the comment:

 sub Foo::bar($) { (shift) } sub ASDF::baz($); *ASDF::baz = \&Foo::bar

suggests that this was put in the wrong place to begin with.  Glob
assignment already takes care of mro_method_changed_in, so calling
it beforehand when reifying the glob is redundant.

11 years agogv.c: Don’t ENTER/LEAVE unnecessarily
Father Chrysostomos [Sun, 10 Jun 2012 18:17:40 +0000 (11:17 -0700)]
gv.c: Don’t ENTER/LEAVE unnecessarily

Commit 756cb47730 added an if/else block in between ENTER/LEAVE, mov-
ing the existing code into the else block.  But the if code (consist-
ing of newCONSTSUB) never needed to be surrounded by ENTER/LEAVE.

11 years agoFix small Pod error introduced by commit c5e3e317152223ae.
Nicholas Clark [Fri, 15 Jun 2012 18:21:54 +0000 (20:21 +0200)]
Fix small Pod error introduced by commit c5e3e317152223ae.

Spotted by t/porting/podcheck.t

11 years agoclean up documentation for sync-with-cpan
Jesse Luehrs [Fri, 15 Jun 2012 16:36:40 +0000 (11:36 -0500)]
clean up documentation for sync-with-cpan

11 years agoadd Abigail to the release schedule
Ricardo Signes [Fri, 15 Jun 2012 16:30:19 +0000 (11:30 -0500)]
add Abigail to the release schedule

11 years agoUpdated Test-Harness to CPAN version 3.25
Chris 'BinGOs' Williams [Sun, 3 Jun 2012 20:35:21 +0000 (21:35 +0100)]
Updated Test-Harness to CPAN version 3.25

  [DELTA]

  3.25    2012-06-05
        - Rereleased to fix CPAN permission problem. No functional change.

  3.24    2012-06-03
        - RT #74393: corrected typo in M::B integration docs.
        - RT #63473: fix typo.
        - RT #49732: Attempt to load File::Glob::Windows to get correct
          glob semantics on Win32.
        - RT #47890: Don't use Win32::GetShortPathName.
        - RT #64404: Ignore textness ('-T') of script when reading shebang.
        - Handle the case where we don't know the wait status of the
          test more gracefully.
        - Make the test summary 'ok' line overrideable so that it can be
          changed to a plugin to make the output of prove idempotent.
        - Apply upstream patch:

            http://perl5.git.perl.org/perl.git/commit \
              /6359c64336d99060952232e7e300bd3c31afead8

          In testargs.t in Test::Harness, don't run a world-writable file.

          The test writes a file, then changes the mode, then executes it. The file needs
          to be +x to be executable (on many platforms). The file will need to be +w to
          be deletable on some platforms. But setting the file world writable just before
          running it feels like a bad idea, given that the file's name is as predictable
          as process IDs, as there's a race condition to break into the account running
          perl's tests.

11 years agoUpdated CPAN-Meta to CPAN version 2.120921
Chris 'BinGOs' Williams [Thu, 31 May 2012 19:08:13 +0000 (20:08 +0100)]
Updated CPAN-Meta to CPAN version 2.120921

  [DELTA]

  2.120921  2012-04-01 15:20:24 Europe/Paris

  [REMOVED]

  - CPAN::Meta::Requirements has been split out into its own distribution
    so it can be used by CPAN.pm without requiring all of CPAN::Meta

  2.120920  2012-04-01 11:30:43 Europe/Paris

  [ADDED]

  - CPAN::Meta::Requirements now has a 'requirements_for_module' method
    to retrieve a version requirements string for a specific module
    [Leon Timmermans]

  [OTHER]

  - Parse::CPAN::Meta prerequisite bumped to 1.4403
  - JSON::PP prerequisites bumped to 2.27200
  - CPAN::Meta::YAML prerequisite bumped to 0.008

  2.120900  2012-03-30 13:15:15 Europe/Paris

  [BUGFIX]

  - CPAN::Meta::Requirements now treats undef requirements given to
    from_string_hash() as '0' and warns about it; add_string_requirements()
    dies if it does not get a requirements string to parse

11 years agoDual lifed CPAN-Meta-Requirements 2.122 as a prereq for CPAN-Meta
Chris 'BinGOs' Williams [Thu, 31 May 2012 19:05:36 +0000 (20:05 +0100)]
Dual lifed CPAN-Meta-Requirements 2.122 as a prereq for CPAN-Meta

11 years agoUpdate Module-Build to CPAN version 0.40
Chris 'BinGOs' Williams [Thu, 31 May 2012 11:47:36 +0000 (12:47 +0100)]
Update Module-Build to CPAN version 0.40

  [DELTA]

  0.40 - Fri Feb 24 18:47:48 CET 2012

  - Released 0.39_02 as 0.40 without any code changes

  0.39_02 - Thu Feb 17 00:33:18 MET 2012

  [BUG FIXES]

  - Fixed bug where modules without $VERSION might have a version of '0'
    listed in 'provides' metadata, which will be rejected by PAUSE
    [David Golden, reported by Christopher Fields]

  - Fixed bug in PodParser to allow numerals in module names
    [Tokuhirom]

  - Fixed bug where giving arguments twice led to them becoming arrays,
    resulting in install paths like "ARRAY(0xdeadbeef)/lib/Foo.pm"
    [Leon Timmermans]

  [DOCUMENTATION]

  - Fixed deviance from alphabetical order in documentation of
    constructor parameters. [Eric Brine]

  - Add documentation for configure_requires constructor parameter.
    [Eric Brine]

  - Change some of the docs' language describing relationship to
    MakeMaker. [Ken Williams]

  [OTHER]

    - List Perl-Toolchain-Gang repo as official repo

11 years agoUpdated CPANPLUS to CPAN version 0.9130
Chris 'BinGOs' Williams [Thu, 31 May 2012 11:37:46 +0000 (12:37 +0100)]
Updated CPANPLUS to CPAN version 0.9130

  [DELTA]

Changes for 0.9130      Thu May 24 22:04:10 2012
================================================
* Always re-fetch CHECKSUMS if fetchdir is set
  (Torsten Schoenfeld)

Changes for 0.9129      Wed May  9 21:22:41 2012
================================================
* Handle multiple makemakerargs and makeflags
  arguments better.
* Use File::HomeDir for home directory location
  if it is available, thanks to kmx
* Added PERL5_CPANPLUS_HOME for altering where
  the .cpanplus directory is located

Changes for 0.9128      Sat Apr 28 21:27:06 2012
================================================
* Fix the previous fix

Changes for 0.9127      Sat Apr 28 20:34:44 2012
================================================
* Silenced annoying warnings related to older
  perls and the progress indicators

Changes for 0.9126      Sat Apr 28 00:49:43 2012
================================================
* More speed enhancements to module indexing,
  thanks to Vincent Pit

Changes for 0.9125      Wed Apr 25 14:28:34 2012
================================================
* Speed enhancements to module indexing, thanks
  to Vincent Pit

Changes for 0.9124      Fri Apr  6 19:24:55 2012
================================================
* Save the history between invocations of the
  shell.

Changes for 0.9123      Fri Mar 30 16:46:52 2012
================================================
* Added support for adding blib/script to PATH

Changes for 0.9122      Wed Mar 28 21:52:38 2012
================================================
* Don't spawn a process to check whether perl
  version prereqs are satisfied

11 years agoUpdated HTTP-Tiny to CPAN version 0.021
Chris 'BinGOs' Williams [Thu, 31 May 2012 11:20:57 +0000 (12:20 +0100)]
Updated HTTP-Tiny to CPAN version 0.021

  [DELTA]

  0.021     2012-05-15 22:38:57 America/New_York

  [TESTING]

  - Skip live SSL testing if $ENV{http_proxy} is set

  0.020     2012-05-14 15:24:37 America/New_York

  [TESTING]

  - Capture prerequisite versions under AUTOMATED_TESTING to help
    chase down some failures from CPAN Testers

  0.019     2012-05-14 07:14:00 America/New_York

  [ADDED]

  - Require IO::Socket::SSL 1.56 (which added SSL_hostname support) when
    doing HTTPS.  [Mike Doherty]

  [TESTING]

  - Provide better diagnostic output in t/210_live_ssl.t [Mike
    Doherty]

  0.018     2012-04-18 09:39:50 America/New_York

  [ADDED]

  - Add verify_SSL option to do more secure SSL operations, incl.
    attempting to validate against a CA bundle (Mozilla::CA
    recommended, but will attempt to find some OS bundles). Also
    add SSL_opts, which passes through IO::Socket::SSL's SSL_*
    options to control SSL verification. (GH #6, #9) [Mike Doherty]

  - Reponse hashref includes final URL (including any redirections)
    [Lukas Eklund]

11 years agoUpdated Parse-CPAN-Meta to CPAN version 1.4404
Chris 'BinGOs' Williams [Thu, 31 May 2012 11:00:34 +0000 (12:00 +0100)]
Updated Parse-CPAN-Meta to CPAN version 1.4404

  [DELTA]

  1.4404 Sun Apr 05 2012
      - Protected tests from user PERL_YAML/JSON_BACKEND

  1.4403 Sun Apr 01 2012
      - Bumped prereqs: JSON::PP to 2.27200 and CPAN::Meta::YAML to 0.008

11 years agoUpdated CPAN-Meta-YAML to CPAN version 0.008
Chris 'BinGOs' Williams [Thu, 31 May 2012 10:58:16 +0000 (11:58 +0100)]
Updated CPAN-Meta-YAML to CPAN version 0.008

  [DELTA]

  0.008     2012-03-14 17:13:24 EST5EDT

    - Generated from ADAMK/YAML-Tiny-1.51.tar.gz

    - Updated from YAML-Tiny to fix compatibility with older Scalar::Utils

11 years agoUpdated IPC-Cmd to CPAN version 0.78
Chris 'BinGOs' Williams [Thu, 31 May 2012 10:53:48 +0000 (11:53 +0100)]
Updated IPC-Cmd to CPAN version 0.78

  [DELTA]

  Changes for 0.78    Mon Apr 30 19:45:00 BST 2012
  =================================================
  * Use POSIX::_exit() instead of exit() in
    run_forked(). Reported by Mithun Ayachit
    [RT 76901]

11 years agoUpdated File-Fetch to CPAN version 0.34
Chris 'BinGOs' Williams [Thu, 31 May 2012 10:51:52 +0000 (11:51 +0100)]
Updated File-Fetch to CPAN version 0.34

  [DELTA]

  Changes for 0.34        Thu Apr 12 22:25:01 2012
  =================================================
  * Added heuristics to skip tests when no
    Internet access

11 years agoUpdated Module-Load-Conditional to CPAN version 0.50
Chris 'BinGOs' Williams [Thu, 31 May 2012 10:49:00 +0000 (11:49 +0100)]
Updated Module-Load-Conditional to CPAN version 0.50

  [DELTA]

  Changes for 0.50    Fri Apr 27 22:22:13 BST 2012
  =================================================
  * Speed enhancements with thanks to Vincent Pit

  Changes for 0.48    Thu Mar 15 13:55:50 GMT 2012
  =================================================
  * Wrap $^X in "" to foil paths with spaces
    Reported by Samuel Ferencik (via email)

11 years agoUpdated Object-Accessor to CPAN version 0.44
Chris 'BinGOs' Williams [Thu, 31 May 2012 10:46:40 +0000 (11:46 +0100)]
Updated Object-Accessor to CPAN version 0.44

  [DELTA]

  Changes for 0.44    Wed Apr 25 14:08:30 BST  2012
  =================================================
  * can() is now fasteh thanks to Vincent Pit

11 years agoUpdate Params-Check to CPAN version 0.36
Chris 'BinGOs' Williams [Thu, 31 May 2012 10:45:07 +0000 (11:45 +0100)]
Update Params-Check to CPAN version 0.36

  [DELTA]

  Changes for 0.36    Fri Apr 27 22:57:02 2012
  ============================================
  * More speed enhancements by Vincent Pit

  Changes for 0.34    Wed Apr 25 13:51:31 2012
  ============================================
  * check() now works fasteh thanks to
    Vincent Pit

11 years agoUpdate Archive-Extract to CPAN version 0.60
Chris 'BinGOs' Williams [Thu, 31 May 2012 10:42:36 +0000 (11:42 +0100)]
Update Archive-Extract to CPAN version 0.60

  [DELTA]

  Changes for 0.60    Mon Feb 20 22:28:10 2012
  ============================================
  * Work around an edge-case on Linux with
    Busybox's unzip

11 years agoUpdate Archive-Tar to CPAN version 1.86
Chris 'BinGOs' Williams [Thu, 31 May 2012 10:39:34 +0000 (11:39 +0100)]
Update Archive-Tar to CPAN version 1.86

  [DELTA]

  * important changes in version 1.86 24/05/2012 (Mark Allen)
  - don't use tell on IO::Zlib handles RT#64339

  * important changes in version 1.84 02/03/2012 (HMBRAND)
  - ptar now supports -T option [rt#75473]
  - ptar now supports dashless options [rt#75475]
  - auto-encode filenames marked as UTF-8 [rt#75474]

11 years agoperldelta: tweak minor thinko
David Mitchell [Fri, 15 Jun 2012 10:40:18 +0000 (11:40 +0100)]
perldelta: tweak minor thinko

11 years agopoint out another use for //o
David Mitchell [Fri, 15 Jun 2012 10:37:55 +0000 (11:37 +0100)]
point out another use for //o

Sometimes patterns with embedded code are recompiled each time even
if the pattern string hasn't changed.

11 years agoRemove RXf_UTF8 from perlreapi
David Mitchell [Fri, 15 Jun 2012 10:16:05 +0000 (11:16 +0100)]
Remove RXf_UTF8 from perlreapi

This flag was removed 4 years ago by 8f6ae13c. Update docs to match.

11 years agoProperly restore PL_curcop after /(?{})/
David Mitchell [Fri, 15 Jun 2012 09:58:40 +0000 (10:58 +0100)]
Properly restore PL_curcop after /(?{})/

C</$code/ or die> was reporting the place of dying as being in
an eval rather than in the main body of the code. This was because
when calling the code, we were setting PL_curcop to the inner code block
*before* doing the PUSH_MULTICALL, which happens to save PL_curcop;
the wrong value was then  being restored at the end of the function with
the POP_MULTICALL.

The fix is easy: just swap the two blocks of code that set PL_curcop and
do the PUSH_MULTICALL.

11 years agoAdd TODO note about unresolved aspects of RT #113536
Steve Hay [Fri, 15 Jun 2012 07:52:52 +0000 (08:52 +0100)]
Add TODO note about unresolved aspects of RT #113536

Commit 4f46e52b00 fixed the ANSI case but the wider UTF-16 case
remains a problem (already known about in perltodo.pod).

11 years agoUpdate checkAUTHORS.pl for 4f46e52b00
Steve Hay [Fri, 15 Jun 2012 07:19:30 +0000 (08:19 +0100)]
Update checkAUTHORS.pl for 4f46e52b00

11 years agoMinor fix-ups to 4f46e52b00
Steve Hay [Fri, 15 Jun 2012 07:18:22 +0000 (08:18 +0100)]
Minor fix-ups to 4f46e52b00

11 years agoUse GetEnvironmentStringsW(..) instead of GetEnvironmentStringsA(..).
Karthik Rajagopalan [Thu, 14 Jun 2012 16:16:15 +0000 (12:16 -0400)]
Use GetEnvironmentStringsW(..) instead of GetEnvironmentStringsA(..).

GetEnvironmentStringsA(..) return strings in the OEM code page. This
can actually mangle the environment strings if it contain special characters.
A better approach would be to get the utf-16 strings through GetEnvironmentStringsW(..)
and convert them to ANSI code page. This is now done by win32_getenvironmentstrings(..).
To free the block, you can use win32_freeenvironmentstrings(..).

11 years agorun-time /(?{})/: fix an buffer overrun
David Mitchell [Thu, 14 Jun 2012 12:10:08 +0000 (13:10 +0100)]
run-time /(?{})/: fix an buffer overrun

String length calculation didn't allow for trailing nul.
(spotted by Nicholas)

11 years agoMerge re_eval jumbo fix branch into blead
David Mitchell [Thu, 14 Jun 2012 08:21:29 +0000 (09:21 +0100)]
Merge re_eval jumbo fix branch into blead

This re_eval branch contains around 130 commits that collectively
reimplement the /(?{})/ mechanism. See the individual commits
and the changes to pod/* for more details, but the main highlights are:

=item *

Code blocks within patterns are now parsed in the same pass as the
surrounding code; in particular it is no longer necessary to have balanced
braces: this now works:

    /(?{  $x='{'  })/

This means that this error message is longer generated:

    Sequence (?{...}) not terminated or not {}-balanced in regex

but a new error may be seen:

    Sequence (?{...}) not terminated with ')'

In addition, literal code blocks within run-time patterns are only
compiled once, at perl compile-time:

    for my $p (...) {
        # this 'FOO' block of code is compiled once, at the same time as
        # the surrounding 'for' loop
        /$p{(?{FOO;})/;
    }

=item *

Lexical variables are now sane as regards scope, recursion and closure
behaviour. In particular, C</A(?{B})C/> behaves (from a closure viewpoint)
exactly like C</A/ && do { B } && /C/>, while  C<qr/A(?{B})C/> is like
C<sub {/A/ && do { B } && /C/}>. So this code now works how you might
expect, creating three regexes that match 1,2, and 3:

    for my $i (0..2) {
        push @r, qr/^(??{$i})$/;
    }
    "1" =~ $r[1]; # matches

=item *

The C<use re 'eval'> pragma is now strictly only required for code blocks
defined at runtime; in particular in the following, the text of the $r
pattern is still interpolated into the new pattern and recompiled, but
the individual compiled code-blocks within $r are reused rather than being
recompiled, and C<use re 'eval'> isn't needed any more:

    my $r = qr/abc(?{....})def/;
    /xyz$r/;

=item *

Flow control operators no longer crash. Each code block runs in a new
dynamic scope, so C<next> etc. will not see any enclosing loops and
C<caller> will not see any calling subroutines. C<return> returns a value
from the code block, not from any enclosing subroutine.

=item *

Perl normally caches the compilation of run-time patterns, and doesn't
recompile if the pattern hasn't changed; but this is now disabled if
required for the correct behaviour of closures; for example:

    my $code = '(??{$x})';
    for my $x (1..3) {
        $x =~ /$code/; # recompile to see fresh value of $x each time
    }

=item *

C</msix> and C<(?msix)> etc. flags are now propagated into the return
value from C<(??{})>; this now works:

    "AB" =~ /a(??{'b'})/i;

=item *

Warnings and errors will appear to come from the surrounding code (or for
run-time code blocks, from an eval) rather than from an C<re_eval>:

    use re 'eval'; $c = '(?{ warn "foo" })'; /$c/;
    /(?{ warn "foo" })/;

formerly gave:

    foo at (re_eval 1) line 1.
    foo at (re_eval 2) line 1.

and now gives:

    foo at (eval 1) line 1.
    foo at /tmp/foo line 2.

=item *

In the pluggable regex API, the regexp_engine struct has acquired a new
field C<op_comp>, which is currently just for perl's internal use, and
should be initialised to NULL by other regexp plugin modules.

11 years agosilence picky C compiler warning
David Mitchell [Thu, 14 Jun 2012 08:10:37 +0000 (09:10 +0100)]
silence picky C compiler warning

and add assert that a (U32 & mask) value can fit in a U8.

11 years agoupdate docs for (?{}) jumbo fix
David Mitchell [Wed, 13 Jun 2012 16:29:27 +0000 (17:29 +0100)]
update docs for (?{}) jumbo fix

Update the docs and add perldelta entries summarising the changes and
fixes related to (?{}) and (??{}) accumulated over the 120 or so commits
in this branch.

11 years agolet B know about new op_code_list field
David Mitchell [Tue, 12 Jun 2012 14:33:34 +0000 (15:33 +0100)]
let B know about new op_code_list field

11 years agoregmatch(): avoid 'may be used uninitialized' msg
David Mitchell [Sun, 10 Jun 2012 21:29:08 +0000 (22:29 +0100)]
regmatch(): avoid 'may be used uninitialized' msg

Hoist a NULL assignment into a wider scope than is strictly necessary,
in order to avoid a spurious compiler warning.

11 years agopropagate /msix and (?msix) etc flags into (??{})
David Mitchell [Wed, 6 Jun 2012 16:16:19 +0000 (17:16 +0100)]
propagate /msix and (?msix) etc flags into (??{})

In  /.........(??{ some_string_value; }).../flags
and /(?flags).(??{ some_string_value; }).../,

use flags when compiling the inner /some_string_value/ pattern.

Achieve this by storing the compile-time modifier flags in the
(apparently) unused 'flags' field of the EVAL node in the (??{})
case.

11 years agotest that code within /(?{})/ etc is optimised
David Mitchell [Wed, 6 Jun 2012 10:28:40 +0000 (11:28 +0100)]
test that code within /(?{})/ etc is optimised

11 years agoadd tests for (?{ return foo })
David Mitchell [Wed, 6 Jun 2012 09:39:26 +0000 (10:39 +0100)]
add tests for (?{ return foo })

All types of code blocks make use of the return value from the code
block. Check they all work, with and without an explicit 'return'.

11 years agoun-TODO recursive split test
David Mitchell [Mon, 4 Jun 2012 20:30:16 +0000 (21:30 +0100)]
un-TODO recursive split test

This test has been disabled for ages. It *should* work now, but I
cauldn't reproduce the failure in older perls, so I don't know for sure.

Also, the test appeared in two files due to the historical splitting of
pat.t into multiple test files. Remove the duplicate.

11 years agoadd test for /(??{exit})/
David Mitchell [Mon, 4 Jun 2012 20:11:34 +0000 (21:11 +0100)]
add test for /(??{exit})/

11 years agoavoid 'unescaped left brace' warnings
David Mitchell [Mon, 4 Jun 2012 17:45:49 +0000 (18:45 +0100)]
avoid 'unescaped left brace' warnings

11 years agoAvoid braces warning in regen_perly.pl
David Mitchell [Mon, 4 Jun 2012 17:41:07 +0000 (18:41 +0100)]
Avoid braces warning in regen_perly.pl

11 years agore-apply temporarily remove overload.t changes
David Mitchell [Mon, 4 Jun 2012 14:47:59 +0000 (15:47 +0100)]
re-apply temporarily remove overload.t changes

re-apply commits done to lib/overload.t on the blead branch between
2012/03/31 and 2012/06/04, which were removed to make rebasing the
re_eval branch easier.

11 years agoadd tests for $1 modified compiling code block
David Mitchell [Mon, 4 Jun 2012 13:57:56 +0000 (14:57 +0100)]
add tests for $1 modified compiling code block

When compiling a run-time code-block, $1 etc should be protected against
any modifications that happen during compilation, e.g. via BEGIN

11 years agoadd tests that (?{}) etc called in scalar context
David Mitchell [Mon, 4 Jun 2012 13:32:55 +0000 (14:32 +0100)]
add tests that (?{}) etc called in scalar context

11 years agohandle (??{}) returning an overloaded value
David Mitchell [Mon, 4 Jun 2012 12:52:05 +0000 (13:52 +0100)]
handle (??{}) returning an overloaded value

In this case, always pass the object to the regex compiler, which
knows how handle this.

(The diff looks more complex than it actually is: it just wraps
the whole (logical == 2) branch with an 'if (!SvAMAGIC(ret))'.)

11 years agohandle weird/undef (?{}), (??{}) return value
David Mitchell [Mon, 4 Jun 2012 12:24:23 +0000 (13:24 +0100)]
handle weird/undef (?{}), (??{}) return value

All three code block variants: (?{}), (??{}), (?(?{}X|Y)),
make use of the return value of the block, either to set $^R, determine
truth, or to interpret as a pattern.  Evaluating this value may trigger
magic calls, uninitialized var warnings etc. Make sure that this
processing happens in the right environment; specifically, before we've
restored vars and paren indices, and we set PL_op temporarily to NULL so
that uninit var warnings don't try to look in the wrong place: neither the
outer op (eg OP_MATCH) nor the inner op (the last op of the code block:
currently happens to be OP_NULL, but that's a bug; will eventually be last
*real* op, e.g. padsv) are suitable for identifying where the warning came
from.

For the (??{}) case, if we can't extract a pre-compiled regex from it,
we force it to a PV, making a temp copy if necessary.

11 years agosimply 'use bytes' handling of (??{})
David Mitchell [Sun, 3 Jun 2012 18:21:43 +0000 (19:21 +0100)]
simply 'use bytes' handling of (??{})

make it slightly more readable without changing code logic.

11 years agofurther simplify (??{}) return code
David Mitchell [Sun, 3 Jun 2012 17:45:13 +0000 (18:45 +0100)]
further simplify (??{}) return code

This does two things. First, it conflates the RV and non-RV cases; i.e.

    if (ROK) {
        sv = RV(sv)
        if (REGEXP)  rx = sv;
        else if (PERL_MAGIC_qr) rx = mg_obj;
    }
    else {
        if (REGEXP)  rx = sv;
        else if (PERL_MAGIC_qr) rx = mg_obj;
    }

becomes

    if (ROK)
        sv = RV(sv)
    if (REGEXP)  rx = sv;
    else if (PERL_MAGIC_qr) rx = mg_obj;

Secondly, elmininate the intermediate rx var; it's only point in life is
to be assigned to re_sv, so just use re_sv throughout.

11 years agosimplify the return code in (??{})
David Mitchell [Sun, 3 Jun 2012 17:05:36 +0000 (18:05 +0100)]
simplify the return code in (??{})

In the case where (??{...}) returns a non-reference with SMG,
there are two branches: if it has GMG too, we assert it hasn't got
PERL_MAGIC_qr, thus (intentionally) making redundant the following
sv_unmagic(ret, PERL_MAGIC_qr); otherwise we mg_find(ret, PERL_MAGIC_qr)
it.

This can all be reduced to a single mg_find() with no change in code
logic.

11 years agoremove invalid assertion in (??{}) return code
David Mitchell [Sun, 3 Jun 2012 16:56:22 +0000 (17:56 +0100)]
remove invalid assertion in (??{}) return code

11 years agopropagate 'use re eval' into return from (??{})
David Mitchell [Thu, 31 May 2012 10:46:23 +0000 (11:46 +0100)]
propagate 'use re eval' into  return from (??{})

(??{}) returns a string which needs to be put through the regex compiler,
and which may also contain (?{...}) - so any 'use re eval' in scope needs
to be propagated into the inner environment. Achieve this by adding a new
private flag - PREGf_USE_RE_EVAL - to the regex to indicate the use is in
scope, and modify how the call to compile the inner pattern is done,
to allow the use state to be passed in.

11 years agosave paren positions when running (?{}) code
David Mitchell [Mon, 28 May 2012 15:44:38 +0000 (16:44 +0100)]
save paren positions when running (?{}) code

Currently, all paren positions are saved before and after executing the
regops returned by (??{}); but not while the perl ops are being executed
beforehand. If the code happens to do a pattern match against the same
regex that's being currently run, then all iuts oparen positions will be
overwritten. So save them before entering the RUNOPS loop too.

11 years agofix refcount of rex attached to PL_reg_curpm
David Mitchell [Sun, 27 May 2012 09:54:23 +0000 (10:54 +0100)]
fix refcount of rex attached to PL_reg_curpm

There were two mistakes; firstly, refcounts weren't consistently managed,
leading to premature frees when recursively calling a rex via (??{}).
It should be that PL_reg_curpm holds a single ref count for the rex it
points to, and that nothing else should hold a count.

Secondly, when making PL_reg_curpm point to a new rex, increment the new
*before* decrementing the old, in case they are both the same rex.

Both of these are now enforced by doing it within the SET_reg_curpm
(formerly SETREX) macro.

Tests will come in the next commit. I can't add them yet because they
also fail for other reasons (paren related).

11 years agoperlreapi: fix documentation on last(close)?paren
David Mitchell [Sat, 26 May 2012 15:51:15 +0000 (16:51 +0100)]
perlreapi: fix documentation on last(close)?paren

lastparen was described as being last open paren; it's actually highest
close paren. Also make it clear these correspond to $+ and $^N

11 years agoRemove redundant comment.
David Mitchell [Sat, 26 May 2012 15:32:46 +0000 (16:32 +0100)]
Remove redundant comment.

PL_reglastparen and PL_reglastcloseparen have been removed

11 years agoremove some redundant code from CURLY rex ops
David Mitchell [Sat, 26 May 2012 15:25:05 +0000 (16:25 +0100)]
remove some redundant code from CURLY rex ops

CURLY_B_*_fail all currently do:

    if (ST.paren && ST.count)
        rex->offs[ST.paren].end = -1;

but this is unnecessary. If B has just failed in the pattern /...(A)*B/,
then we will either adjust the amount of matched A, update rex->offs
(overwriting that -1) then call B again; or fail completely, do sayNO, and
backtrack to an op somewhere in the '...' before A. In this latter case,
the "somewhere else" op is the one responsible for unwinding the matched
parentheses, not us.

11 years ago$+ and $^N not always correct on backtracking
David Mitchell [Fri, 25 May 2012 14:03:29 +0000 (15:03 +0100)]
$+ and $^N not always correct on backtracking

Certain ops (TRIE, BRANCH, CURLYM, CURLY and related) didn't always
correctly restore or update lastcloseparen ($^N) - and sometimes lastparen
($+) - when backtracking, or doing a zero-length match (i.e. A* matching
zero times).

Fix this by saving lastcloseparen and lastparen in the relevant
regmatch_state union sub structs, then restoring as necessary.

11 years agoreduce size of struct regmatch_state
David Mitchell [Thu, 24 May 2012 11:23:44 +0000 (12:23 +0100)]
reduce size of struct regmatch_state

Currently the trie struct is the largest sub-struct in the union;
reduce its size by 2 x 8 bytes (on a 64-bit system) by
    1) aligning a bool better
    2) eliminating ST.B, which can be trivially derived as
       ST.me + NEXT_OFF(ST.me)

(I'm going to partially spoil this by adding a new field in the next commit)

11 years agoregcppush(): don't bother saving each paren number
David Mitchell [Wed, 23 May 2012 11:19:55 +0000 (12:19 +0100)]
regcppush(): don't bother saving each paren number

regcppush() saves a contiguous range of slots in rex->offs[].
Currently it saves the index (paren number) along with each slot's data.
Since we know the top index (the saved PL_regsize) and the number of
elements, on restoring we can deduce each paren number without saving it.

11 years agoset PL_reg_starttry correctly
David Mitchell [Wed, 23 May 2012 10:39:28 +0000 (11:39 +0100)]
set PL_reg_starttry correctly

PL_reg_starttry is only used for debugging, and S_regtry only set it
within DEBUG_EXECUTE_r; however, its value is also used within
DEBUG_STACK_r. So always set it when debugging, not just when
execute-debugging is enabled.

11 years agopp_match(): clarify intuit parens behaviour
David Mitchell [Tue, 22 May 2012 09:40:55 +0000 (10:40 +0100)]
pp_match(): clarify intuit parens behaviour

There was some dodgy code, (flagged by dmq), that as well
as setting RX_LASTPAREN(rx),  RX_LASTCLOSEPAREN(rx) to zero,
also set RX_NPARENS(rx) to zero.

The actual logic is that if we reach that point, the pattern shouldn't
have any capturing parentheses, so instead of assigning zero to it, assert
that RX_NPARENS(rx) is zero.

11 years agoS_regcppush/pop : don't save PL_reginput
David Mitchell [Mon, 21 May 2012 19:44:50 +0000 (20:44 +0100)]
S_regcppush/pop : don't save PL_reginput

currently, S_regcppush() pushes PL_reginput, then S_regcppop() pops its
value and returns it. However, all calls to S_regcppop() are currently in
void context, so nothing actually uses this value. So don't save it in the
first place.

11 years agoimprove -Mre=Debug,BUFFERS debugging
David Mitchell [Fri, 18 May 2012 11:40:39 +0000 (12:40 +0100)]
improve -Mre=Debug,BUFFERS debugging

as well as showing save/restore of capture buffer contents,
also show buffer swaps and setting of individual elements
(at least for the common OPEN/CLOSE ops; I've skipped all the
harder CURLY stuff for now).

11 years agomake regexp_paren_pair.start_tmp an offset
David Mitchell [Wed, 16 May 2012 09:06:30 +0000 (10:06 +0100)]
make regexp_paren_pair.start_tmp an offset

Currently the start_tmp field is a pointer into the string, whereas the
the start and end fields are offsets within that string. Make start_tmp
an offset too for consistency.

11 years agoeliminate PL_reg_start_tmp, PL_reg_start_tmpl
David Mitchell [Tue, 15 May 2012 20:01:39 +0000 (21:01 +0100)]
eliminate PL_reg_start_tmp, PL_reg_start_tmpl

PL_reg_start_tmp is a global array of temporary parentheses start
positions. An element is set when a '(' is first encountered,
while when a ')' is seen, the per-regex offs array is updated with the
start and end position: the end derived from the position where the ')'
was encountered, and the start position derived from PL_reg_start_tmp[n].
This allows us to differentiate between pending and fully-processed
captures.

Change it so that the tmp start value becomes a third field in the offs
array (.start_tmp), along with the existing .start and .end fields. This
makes the value now per regex rather than global. Although it uses a bit
more memory (the start_tmp values aren't needed after the match has
completed), it simplifies the code, and will make it easier to make a
(??{}) switch to the new regex without having to dump everything on the
save stack.

11 years agoeliminate PL_reglast(close)?paren, PL_regoffs
David Mitchell [Tue, 15 May 2012 11:55:22 +0000 (12:55 +0100)]
eliminate PL_reglast(close)?paren, PL_regoffs

eliminate the three vars
    PL_reglastcloseparen
    PL_reglastparen
    PL_regoffs
(which are actually aliases to PL_reg_state struct elements).

These three vars always point to the corresponding fields within the
currently executing regex; so just access those fields directly instead.

This makes switching between regexes with (??{}) simpler: just update
rex, and everything automatically references the new fields.

11 years agomake Perl_... and my_re_op_compile sigs match
David Mitchell [Tue, 5 Jun 2012 21:50:03 +0000 (22:50 +0100)]
make Perl_... and my_re_op_compile sigs match

11 years agomake perl build again on non-DEBUGGING builds
David Mitchell [Tue, 5 Jun 2012 21:29:23 +0000 (22:29 +0100)]
make perl build again on non-DEBUGGING builds

The PL_block_type debugging-only array is now used indeirectly in
ext/re/re-exec.c, which enables debugging even on non-debugging builds

11 years agomake calling of /(?{}) code blocks correct
David Mitchell [Fri, 4 May 2012 15:34:01 +0000 (16:34 +0100)]
make calling of /(?{}) code blocks correct

Formerly, it just updated PL_comppad, set PL_op to the first op of the
code block, and did CALLRUNOPS().

This had a lot of problems, e.g. depth of recursion, and not having
anything on the context stack for die/caller/next/goto etc to see, usually
leading to segfaults.

Make it so that it uses the MULTICALL API instead. This makes it push a
new stack and a CxSUB context stack frame; it also makes us share code
rather than rolling our own.

MULTICALL had to be extended in two ways to make this work; but these have
not yet been made part of the public API. First, it had to allow changing
of the current CV while leaving the current CxSUB frame in place, and
secondly it had to allow pushing a CV with a zero increment of CvDEPTH.
This latter is to handle direct literal blocks:

    /(?{...})/

which are compiled into the same CV as the surrounding scope; therefore we
need to push the same sub twice at the same depth (usually 1), i.e.

    $ ./perl -Dstv -e'sub f { /(?{$x})/ } f'
    ...
    (29912:-e:1) gvsv(main::x)

    STACK 0: MAIN
      CX 0: BLOCK  =>
      CX 1: SUB    =>           <=== the same sub ...
      retop=leave
    STACK 1: SORT
      CX 0: SUB    => UNDEF     <==== ... as this
      retop=(null)

(note that stack 1 is misidentified as SORT; this is a bug in MULTICALl
to be fixed later).

One has to be very careful with the save stack; /(?{})/ is designed
not to introduce a new scope, so that the effects of 'local' etc
accumulate across multiple block invocations (but get popped on
backtracking). This is why we couldn't just do a POP_MULTICALL/PUSH_MULTICALL
pair to change the current CV; the former would pop the save stack too.

Note that in the current implementation, after calling out to the first
code block, we leave the CxSUB and PL_comppad value in place, on the
assumption that it may be soon re-used, and only pop the CxSUB at the end
of S_regmatch(). However, when popping the savestack on backtracking, this
will restore PL_comppad to its original value; so when calling a new code
block with the same CV, we can't rely on PL_comppad still being correct.

Also, this means that outside of a code block call, the context stack and
PL_comppad are wrong; I can't think of anything within the regex code
that could be using these; but it if it turns out not to be the case,
then we'd have to change it so that after each code block call, we pop the
CxSUB off the stack and restore PL_comppad, but without popping the save
stack.

11 years agomake is_bare_re bool. not int in re_op_compile
David Mitchell [Sat, 21 Apr 2012 19:25:33 +0000 (20:25 +0100)]
make is_bare_re bool. not int in re_op_compile

This flag pointer only stores truth, so make it a pointer to a bool rather
than to an int.

11 years agomake OP_REGCRESET only for taint handling
David Mitchell [Sun, 1 Apr 2012 09:21:22 +0000 (10:21 +0100)]
make OP_REGCRESET only for taint handling

The OP_REGCRESET op, which is sometimes prepended to the chain of ops
leading to OP_REGCOMP, currently serves two purposes; first to reset the
taint flag, and second to initialise PL_reginterp_cnt. The second purpose
is no longer needed, and the first has a bug, in that the op isn't
prepended when "use re 'eval'" is in scope.

Fix this by prepending the op solely when PL_tainting is in effect.
This also makes run-time regexes slightly more efficient in the
non-tainting case.

11 years agoS_doeval(): saveop can never be null now
David Mitchell [Sun, 1 Apr 2012 13:29:33 +0000 (14:29 +0100)]
S_doeval(): saveop can never be null now

11 years agoreindent S_doeval() following a code purge.
David Mitchell [Sun, 1 Apr 2012 13:26:37 +0000 (14:26 +0100)]
reindent S_doeval() following a code purge.

Only whitespace changes.

11 years agoeliminate sv_compile_2op, sv_compile_2op_is_broken
David Mitchell [Sun, 1 Apr 2012 13:21:18 +0000 (14:21 +0100)]
eliminate sv_compile_2op, sv_compile_2op_is_broken

These two functions, which have been a pimple on the face of perl for
far too long, are no longer needed, now that regex code blocks are
compiled in a sensible manner.

This also allows S_doeval() to be simplified, now that it is no longer
called from sv_compile_2op_is_broken().

11 years agoeliminate OP_4tree type
David Mitchell [Sun, 1 Apr 2012 12:59:58 +0000 (13:59 +0100)]
eliminate OP_4tree type

This was an alias to OP, and formerly used by the old re_eval mechanism

11 years agorename and simplify PL_reg_eval_set
David Mitchell [Sun, 1 Apr 2012 12:32:24 +0000 (13:32 +0100)]
rename and simplify PL_reg_eval_set

These days PL_reg_eval_set is actually aliased to
PL_reg_state.re_state_reg_eval_set.

Rename this field to re_state_eval_setup_done to make it clearer what it
represents; remove the PL_ backcompat macro; make it boolean;
and remove the two redundant macros RS_init and RS_set.

11 years agoeliminate RExC_seen_evals and RExC_rx->seen_evals
David Mitchell [Sun, 1 Apr 2012 12:22:14 +0000 (13:22 +0100)]
eliminate RExC_seen_evals and RExC_rx->seen_evals

these were used as part of the old "use re 'eval'" security
mechanism used by the now-eliminated PL_reginterp_cnt

11 years agoeliminate PL_reginterp_cnt
David Mitchell [Sun, 1 Apr 2012 12:14:09 +0000 (13:14 +0100)]
eliminate PL_reginterp_cnt

This used to be the mechanism to determine whether "use re 'eval'" needed
to be in scope; but now that we make a clear distinction between literal
and runtime code blocks, it's no longer needed.

11 years agoeliminate REG_SEEN_EVAL
David Mitchell [Sun, 1 Apr 2012 12:04:05 +0000 (13:04 +0100)]
eliminate REG_SEEN_EVAL

This flag was set during pattern compilation if a (?{}) was encountered;
but is redundant now that we have pRExC_state->num_code_blocks.

11 years agoadd some more tests for PL_cv_has_eval
David Mitchell [Sun, 1 Apr 2012 10:37:33 +0000 (11:37 +0100)]
add some more tests for PL_cv_has_eval

In particular, the use re 'eval' case wasn't tested for

11 years agopat_re_eval.t; test "use re 'eval'"
David Mitchell [Sat, 31 Mar 2012 14:47:04 +0000 (15:47 +0100)]
pat_re_eval.t; test "use re 'eval'"

In this test file, firstly reduce all "use re 'eval'"s into the smallest
scope possible, and secondly, for each pattern which still requires this
in scope, also test that pattern without it in scope, but under eval, and
check that it dies.

Note that during the course of this branch, much that formerly needed
"use re "eval'" no longer does, which is the main reason we can dispense
with it so much in this commit.

11 years agobump re.pm version number
David Mitchell [Sat, 31 Mar 2012 12:43:12 +0000 (13:43 +0100)]
bump re.pm version number

11 years agoensure regex evals report the right location
David Mitchell [Fri, 30 Mar 2012 15:30:26 +0000 (16:30 +0100)]
ensure regex evals report the right location

make sure that PL_curcop is set correctly on entry to a regex code block,
since (unlike a normal eval) there isn't always an initial OP_NEXTSTATE to
cause it to get set.  Otherwise, warning messages etc in the first
statement of the code block will appear to come from the wrong place.

11 years agoFix up runtime regex codeblocks.
David Mitchell [Sun, 18 Mar 2012 15:53:40 +0000 (15:53 +0000)]
Fix up runtime regex codeblocks.

The previous commits in this branch have brought literal code blocks
into the New World Order; now do the same for runtime blocks, i.e. those
needing "use re 'eval'".

The main user-visible changes from this commit are that:

* the code is now fully parsed, rather than needing balanced {}'s; i.e.
  this now works:
      my $code = q[  (?{ $a = '{' })  ];
      use re 'eval';
      /$code/

* warnings and errors are now reported as coming from "(eval NNN)" rather
 than "(re_eval NNN)" (although see the next commit for some fixups to
 that). Indeed, the string "re_eval" has been expunged from the source
 and documentation.

The big internal difference is that the sv_compile_2op() and
sv_compile_2op_is_broken() functions are no longer used, and will be
removed shorty.

It works by the regex compiler detecting the presence of run-time code
blocks, and feeding the whole pattern string back into the parser (where
the run-time blocks are now seen as compile-time), then extracting out
any compiled code blocks and adding them to the mix.

For example, in the following:

    $c = '(?{"runtime"})d';
    use re 'eval';
    /a(?{"literal"})\b'$c/

At the point the regex compiler is called, the perl parser will already
have compiled the literal code block and presented it to the regex engine.
The engine examines the pattern string, sees two '(?{', but only one
accounted for by the parser, and so constructs a short string to be
evalled: based on the pattern, but with literal code-blocks blanked out,
and \ and ' escaped. In the above example, the pattern string is

       a(?{"literal"})\b'(?{"runtime"})d

and we call eval_sv() with an SV containing the text

    qr'a              \\b\'(?{"runtime"})d'

The returned qr will contain the new code-block (and associated CV and
pad) which can be extracted and added to the list of compiled code blocks
of the original pattern.

Note that with this scheme, the requirement for "use re 'eval'" is easily
determined, and no longer requires all the pp_regcreset / PL_reginterp_cnt
machinery, which will be removed shortly.

Two subtleties of this scheme are that normally, \\ isn't collapsed into \
for literal regexes (unlike literal strings), and hints aren't inherited
when using eval_sv(). We get round both of these by adding and setting a
new flag, PL_reg_state.re_reparsing, which indicates that we are refeeding
a pattern into the perl parser.

11 years agopmruntime: make more use of Perl_re_op_compile
David Mitchell [Wed, 28 Mar 2012 08:44:01 +0000 (09:44 +0100)]
pmruntime: make more use of Perl_re_op_compile

In the compile-time, non-code branch of pmruntime(), rather than
assembling the pattern string ourselves from the list of constant strings,
just pass the whole thing to Perl_re_op_compile() (or whatever eng->op_comp
is in scope) to assemble.

This has two benefits. First it avoids duplicating the concatenation code
(which already has to be present in Perl_re_op_compile), and it provides
more information to that function; in particular so that we can identify
a late-bound compile-time pattern, i.e. $foo =~ 'string-not-regex'.

11 years agofree PL_regex_padav later
David Mitchell [Thu, 29 Mar 2012 10:20:32 +0000 (11:20 +0100)]
free PL_regex_padav later

At the point where formerly it was freed, instead just free the individual
regexes and put &PL_sv_undef placeholders in the vacated PL_regex_padav
slots. Then free the actual array a lot later.

This is because at the point where PL_regex_padav used to be freed,
regexes can still hold pointers to CVs that have PMOPs that index into
PL_regex_padav; and while the array is being freed, it's state is
inconsistent (jn particular, sv_clear temporarily stores old indexes in
the top slot.)

This is a band-aid really; the proper solution is to get rid of
PL_regex_padav altogether and store the regexps in the pad.