platform/upstream/perl.git
13 years agoMove PL_runops_{std,dbg} to perl.h, and make them const.
Nicholas Clark [Mon, 2 May 2011 14:02:57 +0000 (15:02 +0100)]
Move PL_runops_{std,dbg} to perl.h, and make them const.

They exist solely to ensure that Perl_runops_standard and Perl_runops_debug
are linked in - nothing assigns to either variable, and nothing reads them.

13 years agoMove PL_global_struct_size, PL_interp_size{,_5_16_0} to perl.h
Nicholas Clark [Sun, 1 May 2011 21:12:15 +0000 (22:12 +0100)]
Move PL_global_struct_size, PL_interp_size{,_5_16_0} to perl.h

Make them const U16 - they should have been const from the start.

13 years agoIn perlvar.h, move the always-present globals above those conditionally compiled
Nicholas Clark [Sun, 1 May 2011 20:13:01 +0000 (21:13 +0100)]
In perlvar.h, move the always-present globals above those conditionally compiled

Rename PL_interp_size_5_10_0 to PL_interp_size_5_16_0, as it is only intended to
track interpreter size within (forwards) binary compatible maintenance branches.

13 years agoMove PL_{revision,version,subversion} to perl.h, making them const U8.
Nicholas Clark [Sun, 1 May 2011 13:39:31 +0000 (14:39 +0100)]
Move PL_{revision,version,subversion} to perl.h, making them const U8.

To get the initialisation to work, the location of #include patchlevel.h needs
to be moved.

13 years agoMove PL_sh_path to perl.h (except for OS/2), as it's const char[]
Nicholas Clark [Sun, 1 May 2011 11:25:58 +0000 (12:25 +0100)]
Move PL_sh_path to perl.h (except for OS/2), as it's const char[]

On OS/2, keep it in perlvars.h, as it's not const there. makedef.pl doesn't
pay attention to C pre-processor symbols, so it will always see the declaration
in perlvars.h, and add the symbol to the linker file, so no need to mention
sh_path in globvar.sym. Add special case logic in regen/embed.pl to make the
embedvar.h macros for PL_sh_path defined only on OS/2.

13 years agoMove PL_{No,Yes,hexdigit} from perlvars.h to perl.h, as all are const char[]
Nicholas Clark [Sat, 30 Apr 2011 22:01:07 +0000 (23:01 +0100)]
Move PL_{No,Yes,hexdigit} from perlvars.h to perl.h, as all are const char[]

They were converted in perl.h from const char[] to #define in 31fb120917c4f65d,
then re-instated as const char[], but in perlvars.h, in 3fe35a814d0a98f4.
There's no need for compile-time constants to jump through the hoops of
perlvars.h, even for Symbian, as the various "EXTCONST" variables already in
perl.h demonstrate.

These were the only 3 users of the the PERLVARISC macro, so eliminate that, and
all related code.

13 years agoEliminate PL_patleave, unused since perl 5.0 alpha 2.
Nicholas Clark [Sat, 30 Apr 2011 20:49:03 +0000 (21:49 +0100)]
Eliminate PL_patleave, unused since perl 5.0 alpha 2.

patleave was added in perl 3.0 patch #35 patch #29 -- 395c379347344a50,
used in scanpat(). scanpat() was refactored and renamed to scan_pat() in
5.0 alpha 2, "commented" out with the C pre-processor in 5.000, and removed in
5.001.

13 years agoMove the temporary definitions for PERLVAR* macros inside #ifdef MULTIPLICITY
Nicholas Clark [Sat, 30 Apr 2011 15:10:20 +0000 (16:10 +0100)]
Move the temporary definitions for PERLVAR* macros inside #ifdef MULTIPLICITY

Under MULTIPLICITY, intrpvar.h is included "early", as:

struct interpreter {
#  include "intrpvar.h"
};

with local definitions of PERLVAR{,A,I,IS,ISC} that generate output text for the
"variables" as structure members. Additionally, under PERL_GLOBAL_STRUCT
"perlvars.h" is included within struct perl_vars { ... }.

Move the definition/undefining of these 5 macros to within the
#ifdef MULTIPLICITY block, to clarify the limited intent of their scope.

Move some additional related PERL_GLOBAL_STRUCT setup to within the block.

13 years agoUpdate Porting/checkURL.pl to not verify secure hostnames and add many updates
Leon Brocard [Sun, 12 Jun 2011 13:53:29 +0000 (14:53 +0100)]
Update Porting/checkURL.pl to not verify secure hostnames and add many updates

13 years agoFix broken URL in dist/threads/lib/threads.pm for the itheads mailing list
Leon Brocard [Sun, 12 Jun 2011 13:21:00 +0000 (14:21 +0100)]
Fix broken URL in dist/threads/lib/threads.pm for the itheads mailing list

13 years agoFix broken URLs in dist/Net-Ping/Changes from perlbrowse to git
Leon Brocard [Sun, 12 Jun 2011 13:20:30 +0000 (14:20 +0100)]
Fix broken URLs in dist/Net-Ping/Changes from perlbrowse to git

13 years agoFix broken URLs in dist/Locale-Maketext/lib/Locale/Maketext/TPJ13.pod for RFCs
Leon Brocard [Sun, 12 Jun 2011 13:19:53 +0000 (14:19 +0100)]
Fix broken URLs in dist/Locale-Maketext/lib/Locale/Maketext/TPJ13.pod for RFCs

13 years agoFix broken URLs in ExtUtils-Install/Changes from perlbrowse to git
Leon Brocard [Sun, 12 Jun 2011 13:19:27 +0000 (14:19 +0100)]
Fix broken URLs in ExtUtils-Install/Changes from perlbrowse to git

13 years agoFix broken URL in threads/shared.pm for the itheads mailing list
Leon Brocard [Sun, 12 Jun 2011 13:18:32 +0000 (14:18 +0100)]
Fix broken URL in threads/shared.pm for the itheads mailing list

13 years agoFix broken URLs for RFCs, bump version and document in perldelta
Leon Brocard [Sun, 12 Jun 2011 13:17:01 +0000 (14:17 +0100)]
Fix broken URLs for RFCs, bump version and document in perldelta

13 years agoFix two broken URLs in mro.pm, bump version and document in perldelta
Leon Brocard [Sun, 12 Jun 2011 13:11:54 +0000 (14:11 +0100)]
Fix two broken URLs in mro.pm, bump version and document in perldelta

13 years agoGenerate the table of core magic types in perlguts.pod using mg_vtable.pl
Nicholas Clark [Sun, 12 Jun 2011 12:23:30 +0000 (14:23 +0200)]
Generate the table of core magic types in perlguts.pod using mg_vtable.pl

This fixes a couple of errors and omissions, and resorts the table in the same
case insensitive order as the header files. It eliminates 1 overlong verbatim
line of pod.

As there's no good way to include component files into the core pods, and the
regen scripts aren't designed to modify in place, generate this to STDOUT (if
-g is added to the command line), to be hand edited into place. It would be
nice to be able to automate this fully.

13 years agoIn regen/mg_vtable.pl, move $longest inside the only block that uses it.
Nicholas Clark [Sun, 12 Jun 2011 10:46:18 +0000 (11:46 +0100)]
In regen/mg_vtable.pl, move $longest inside the only block that uses it.

13 years agoReorder ops so that trans{,r} and aelemfast{,_lex} are adjacent.
Nicholas Clark [Sun, 12 Jun 2011 09:24:46 +0000 (11:24 +0200)]
Reorder ops so that trans{,r} and aelemfast{,_lex} are adjacent.

13 years agoSplit OP_AELEMFAST_LEX out from OP_AELEMFAST.
Nicholas Clark [Sun, 24 Apr 2011 15:37:17 +0000 (16:37 +0100)]
Split OP_AELEMFAST_LEX out from OP_AELEMFAST.

6a077020aea1c5f0 extended the OP_AELEMFAST optimisation to lexical arrays.
Previously OP_AELEMFAST was only used as an optimisation for OP_GV, which is a
PADOP/SVOP.

However, by reusing the same opcode, and signalling (pad) lexical vs package,
it introduced a myriad of special cases, because OP_PADAV is a BASEOP (not a
PADOP), whilst OP_AELEMFAST is a PADOP/SVOP (which is larger).

Using two OP numbers allows each variant to have the correct OP flags in
PL_opargs. Both can continue to share the same C code.

13 years agoFix some broken URLs found by Porting/checkURL.pl
Leon Brocard [Sun, 12 Jun 2011 07:45:13 +0000 (08:45 +0100)]
Fix some broken URLs found by Porting/checkURL.pl

13 years agoShrink struct am_table.
Nicholas Clark [Sun, 12 Jun 2011 07:27:06 +0000 (09:27 +0200)]
Shrink struct am_table.

Two members, flags and fallback, were using integer types considerably larger
than the range of values that they needed to store.

13 years ago[perl #90130] Allow CORE::* without feature.pm
Father Chrysostomos [Sat, 11 Jun 2011 21:44:32 +0000 (14:44 -0700)]
[perl #90130] Allow CORE::* without feature.pm

This commit allows feature.pm-enabled keywords to work with CORE::*
even outside the scope of ‘use feature’.

13 years agoCorrect file references in switch.t
Father Chrysostomos [Sat, 11 Jun 2011 21:11:35 +0000 (14:11 -0700)]
Correct file references in switch.t

13 years agoRemove TODO markers from Devel::Peek tests
Father Chrysostomos [Sat, 11 Jun 2011 20:40:59 +0000 (13:40 -0700)]
Remove TODO markers from Devel::Peek tests

These all pass now as of commit b56985536ef7.

13 years agoRemove x bit from rt-16221.t
Father Chrysostomos [Sat, 11 Jun 2011 20:22:45 +0000 (13:22 -0700)]
Remove x bit from rt-16221.t

13 years agoIncrease Math::BigInt’s version
Father Chrysostomos [Sat, 11 Jun 2011 20:21:49 +0000 (13:21 -0700)]
Increase Math::BigInt’s version

13 years agoIncrease Math::BigFloat’s version
Father Chrysostomos [Sat, 11 Jun 2011 20:20:39 +0000 (13:20 -0700)]
Increase Math::BigFloat’s version

13 years ago[perl #85026] Iterate hashes by hand during do_sv_dump
Ton Hospel [Sat, 11 Jun 2011 19:28:00 +0000 (12:28 -0700)]
[perl #85026] Iterate hashes by hand during do_sv_dump

A further note: while debugging this issue it was annoying that
Devel::Peek::Dump doesb't actually dump the HASH elements when an
iterator is active. Also added is a patch that does the iteration to
dump the HASH contents by iterating over it by hand (not disturbing
any active iterator). With that it also doesn't activate hash magic
during iteration, which I think is a feature

13 years agoRevert "Perl_do_sv_dump: alert when skipping elements"
Father Chrysostomos [Sat, 11 Jun 2011 19:22:52 +0000 (12:22 -0700)]
Revert "Perl_do_sv_dump: alert when skipping elements"

This reverts commit 002beaef76a1595af2e39ffd4cd55c595bd6c271.

I am about to apply the manual-iteration patch from ticket #85026.
It conflicts with 002beaef, but it also renders 002beaef unnecessary.

13 years agoallow features inside interactive debugger
Salvador Fandino [Sat, 11 Jun 2011 19:20:56 +0000 (12:20 -0700)]
allow features inside interactive debugger

13 years agoAdd dist/Math-BigInt/t/rt-16221.t to MANIFEST
Father Chrysostomos [Sat, 11 Jun 2011 19:26:35 +0000 (12:26 -0700)]
Add dist/Math-BigInt/t/rt-16221.t to MANIFEST

13 years agoFix Math::BigFloat->numify().
Peter John Acklam [Mon, 7 Mar 2011 10:45:38 +0000 (11:45 +0100)]
Fix Math::BigFloat->numify().

Math::BigFloat->numify() shall, according to the documentation and to be
consistent with Math::BigInt->numify() and Math::BigRat->numify(),
return a Perl scalar number, not a string.

- dist/Math-BigInt/lib/Math/BigFloat.pm:
  - Fix objectify().
- dist/Math-BigInt/t/bigfltpm.inc:
   - Remove no longer relevant tests.
   - Modify existing tests and add new tests to verify correct behaviour.

This fix closes RT #66732.

13 years agoFix objectify()'s handling of "foreign objects".
Peter John Acklam [Mon, 7 Mar 2011 10:45:38 +0000 (11:45 +0100)]
Fix objectify()'s handling of "foreign objects".

- Fix handling of "foreign objects" so they are converted to the
  appropriate class (Math::BigInt or Math::BigFloat).
- Avoid code duplication by using only one loop.
- Loop over indexes rather than array elements to make code cleaner.
- Fix incorrect code comments, add more code comments and clearify
  existing ones.
- Correct handling of undefs to make the code consistent. objectify()
  gave different output when the initial "shortcut" was removed.
- Add test file verifying that RT#16221 is fixed.

This fix closes RT #16221 and RT #52124. This patch supersedes Perl #86146.

13 years agoAdd sign function bsgn() as a complement to babs().
Peter John Acklam [Mon, 7 Mar 2011 10:45:38 +0000 (11:45 +0100)]
Add sign function bsgn() as a complement to babs().

This is the standard mathematical signum function. It sets the
invocand to -1, 0, or 1, if it is real, and NaN otherwise.

Documentation and tests are included.

13 years agoRemove another bug workaround
Father Chrysostomos [Fri, 13 May 2011 15:32:24 +0000 (08:32 -0700)]
Remove another bug workaround

13 years agoRemove workaround for fixed bug
Father Chrysostomos [Fri, 13 May 2011 15:31:16 +0000 (08:31 -0700)]
Remove workaround for fixed bug

13 years agoRevert "Revert "Make untie check the FAKE flag on globs""
Father Chrysostomos [Fri, 13 May 2011 15:30:50 +0000 (08:30 -0700)]
Revert "Revert "Make untie check the FAKE flag on globs""

This reverts commit 84b9ac853508aaff52254b6cf2b95a2a6783ff00.

13 years agoRevert "Revert "[perl #77688] tie $scalar can tie a handle""
Father Chrysostomos [Fri, 13 May 2011 15:30:25 +0000 (08:30 -0700)]
Revert "Revert "[perl #77688] tie $scalar can tie a handle""

This reverts commit 7850f4d6b732ab5f426cd3bcd9757c70a46cfda1.

13 years agoRevert "Revert "[perl #77496] tied gets scalars and globs confused""
Father Chrysostomos [Fri, 13 May 2011 15:29:42 +0000 (08:29 -0700)]
Revert "Revert "[perl #77496] tied gets scalars and globs confused""

This reverts commit b029825916bf29623e00b45fa4226fab0d52d217.

13 years agoRevert ‘Deprecate tie $handle without *’
Father Chrysostomos [Fri, 13 May 2011 15:24:16 +0000 (08:24 -0700)]
Revert ‘Deprecate tie $handle without *’

This reverts commit 7c7df8124bbdd7a0091f8ed82589548c8182f624,
except for the perldiag entry, which we still need for splain’s sake.

13 years agoAdd Porting/make_modlib_cpan.pl to MANIFEST.
Nicholas Clark [Sat, 11 Jun 2011 17:21:01 +0000 (19:21 +0200)]
Add Porting/make_modlib_cpan.pl to MANIFEST.

Also -x it, as it doesn't have a suitable #! line, and its peers are all -x.

13 years agoregexec.c: Remvove unnecessary special handling for \xDF
Karl Williamson [Wed, 4 May 2011 15:03:43 +0000 (09:03 -0600)]
regexec.c: Remvove unnecessary special handling for \xDF

regcomp.c has been changed, so the case that this handled no longer
comes up.

13 years agoTypo in VMS-specific realclean target from 6f83ef0e5a45c465f83de3304c5818ba44492250.
Craig A. Berry [Sat, 11 Jun 2011 16:25:30 +0000 (11:25 -0500)]
Typo in VMS-specific realclean target from 6f83ef0e5a45c465f83de3304c5818ba44492250.

13 years agoAdded Alan Haggai Alavi to AUTHORS
David Golden [Sat, 11 Jun 2011 16:24:57 +0000 (12:24 -0400)]
Added Alan Haggai Alavi to AUTHORS

13 years agoperlvar.pod: fixed typo
Alan Haggai Alavi [Sat, 11 Jun 2011 15:14:48 +0000 (20:44 +0530)]
perlvar.pod: fixed typo

Signed-off-by: David Golden <dagolden@cpan.org>
13 years agoCorrect errors in the use of multiple targets, which could break parallel make.
Nicholas Clark [Sun, 15 May 2011 16:20:42 +0000 (17:20 +0100)]
Correct errors in the use of multiple targets, which could break parallel make.

This was fixed in Makefile.SH in commit 0f13ebd5d71f8177.

13 years agoSort magic and magic vtable names in files generated by mg_vtable.pl
Nicholas Clark [Sun, 15 May 2011 15:33:02 +0000 (16:33 +0100)]
Sort magic and magic vtable names in files generated by mg_vtable.pl

Magic is sorted case insensitively, with upper case before lower case.
vtable names are all lowercase letters.

13 years agoGenerate magic_names in dump.c using mg_vtable.pl.
Nicholas Clark [Sun, 15 May 2011 15:25:34 +0000 (16:25 +0100)]
Generate magic_names in dump.c using mg_vtable.pl.

13 years agoGenerate the PERL_MAGIC_* defines using mg_vtable.pl.
Nicholas Clark [Sun, 15 May 2011 14:53:08 +0000 (15:53 +0100)]
Generate the PERL_MAGIC_* defines using mg_vtable.pl.

13 years agoIn PL_magic_data flag whether magic can be added to a readonly value.
Nicholas Clark [Sun, 15 May 2011 13:45:53 +0000 (14:45 +0100)]
In PL_magic_data flag whether magic can be added to a readonly value.

Use this to simplify the logic in Perl_sv_magic().

This introduces a small change of behaviour for error cases involving unknown
magic types. Previously, if Perl_sv_magic() was passed a magic type unknown to
it, it would

1: Croak "Modification of a read-only value attempted" if read only
2: Return without error if the SV happened to already have this magic
3: otherwise croak "Don't know how to handle magic of type \\%o"

Now it will always croak "Don't know how to handle magic of type \\%o", even
on read only values, or SVs which already have the unknown magic type.

13 years agoStore a flag for container/value magic in PL_magic_data.
Nicholas Clark [Sun, 15 May 2011 12:54:19 +0000 (13:54 +0100)]
Store a flag for container/value magic in PL_magic_data.

Use this to replace S_is_container_magic() in mg.c with a direct lookup.

13 years agoCreate a lookup table for magic vtables from magic type, PL_magic_data.
Nicholas Clark [Sun, 15 May 2011 12:21:09 +0000 (13:21 +0100)]
Create a lookup table for magic vtables from magic type, PL_magic_data.

Use it to eliminate the large switch statement in Perl_sv_magic().

As the table needs to be keyed on magic type, which is expressed as C character
constants, the order depends on the compiler's character set. Frustratingly,
EBCDIC variants don't agree on the code points for '~' and ']', which we use
here. Instead of having (at least) 4 tables, get the local runtime to sort the
table for us. Hence the regen script writes out the (unsorted) mg_raw.h, which
generate_uudmap sorts to generate mg_data.h

13 years agoRefactor generate_uudmap.c to use a helper function to output init blocks.
Nicholas Clark [Sun, 15 May 2011 11:02:28 +0000 (12:02 +0100)]
Refactor generate_uudmap.c to use a helper function to output init blocks.

In future, this will allow it to generate other output formats without
duplicating code.

13 years agoProvide the names of the magic vtables in PL_magic_vtable_names[].
Nicholas Clark [Sat, 14 May 2011 11:26:37 +0000 (12:26 +0100)]
Provide the names of the magic vtables in PL_magic_vtable_names[].

As it's a 1 to 1 mapping with the vtables in PL_magic_vtables[], refactor
Perl_do_magic_dump() to index into it directly to find the name for an
arbitrary mg_virtual, avoiding a long switch statement.

13 years agoReplace references to PL_vtbl_{bm,fm} in the code with PL_vtbl_regexp.
Nicholas Clark [Sat, 14 May 2011 08:41:18 +0000 (09:41 +0100)]
Replace references to PL_vtbl_{bm,fm} in the code with PL_vtbl_regexp.

Also, in Perl_sv_magic() merge the case for PERL_MAGIC_dbfile with the others
that return a NULL vtable.

13 years agoPL_vtbl_{bm,fm} can be aliases to PL_vtbl_regexp, instead of copies.
Nicholas Clark [Sat, 14 May 2011 08:16:30 +0000 (09:16 +0100)]
PL_vtbl_{bm,fm} can be aliases to PL_vtbl_regexp, instead of copies.

They became copies in 488344d27a84a21a, which merged Perl_magic_setbm() and
Perl_magic_setfm() into Perl_magic_setregexp().

13 years agoRefactor Perl_get_vtbl() to a small array lookup from a large switch statement.
Nicholas Clark [Fri, 13 May 2011 20:21:49 +0000 (21:21 +0100)]
Refactor Perl_get_vtbl() to a small array lookup from a large switch statement.

Provide magic_vtable_max, the number of elements in PL_magic_vtables[].

13 years agoTests for Perl_get_vtbl()
Nicholas Clark [Fri, 13 May 2011 20:06:29 +0000 (21:06 +0100)]
Tests for Perl_get_vtbl()

13 years agoReplace PL_vtbl_* with an array PL_magic_vtables.
Nicholas Clark [Fri, 13 May 2011 19:24:34 +0000 (20:24 +0100)]
Replace PL_vtbl_* with an array PL_magic_vtables.

Define each PL_vtbl_* name as a macro which expands to the correct array
element. Using a single array instead of multiple named variables will allow
the simplification of various pieces of code.

13 years agoGenerate the enum for want_vtbl_* with regen/mg_vtable.pl
Nicholas Clark [Fri, 13 May 2011 17:02:08 +0000 (18:02 +0100)]
Generate the enum for want_vtbl_* with regen/mg_vtable.pl

13 years agoRemove want_vtbl_{glob,symtab}, which aren't used and don't do anything useful.
Nicholas Clark [Fri, 13 May 2011 16:29:09 +0000 (17:29 +0100)]
Remove want_vtbl_{glob,symtab}, which aren't used and don't do anything useful.

Nothing visible on CPAN uses either. Passing either to Perl_get_vtbl() will
currently return NULL (as a runtime error, rather than a compile time error).

The case for want_vtbl_glob was removed from the switch in Perl_get_vtbl() in
c0c446747ad6c5bd (which eliminated the need for magic on typeglobs).
want_vtbl_symtab was added to the enum in perl.h with 8d2f45362e368d7d, but
no code was added to Perl_get_vtbl() as there is no corresponding vtable.

13 years agoMove the work of MGVTBL_SET() from the C pre-processor to mg_vtable.pl
Nicholas Clark [Fri, 13 May 2011 15:50:51 +0000 (16:50 +0100)]
Move the work of MGVTBL_SET() from the C pre-processor to mg_vtable.pl

Generating mg_vtable.h with MGVTBL_SET() effectively pre-expanded makes things
clearer. This eliminates use of the macro MGVTBL_SET(), which can be deleted
as nothing outside the core is relying on it.

13 years agoMove the cast for a magic vtable with const get into mg_vtable.h
Nicholas Clark [Fri, 13 May 2011 15:35:59 +0000 (16:35 +0100)]
Move the cast for a magic vtable with const get into mg_vtable.h

Putting the cast inside the initialiser (the only initialiser using it)
eliminates use of the macro MGVTBL_SET_CONST_MAGIC_GET(), which can be deleted
as nothing outside the core is relying on it.

13 years agoGenerate the definitions for magic vtables from data in a regen script.
Nicholas Clark [Fri, 13 May 2011 13:17:22 +0000 (14:17 +0100)]
Generate the definitions for magic vtables from data in a regen script.

Previously perl.h contained a long section of MGVTBL_SET() macros declaring
the core's various magic vtables. Convert the information into data structures
in a new script regen/mg_table.pl, and use this to generate a new file
mg_vtable.h, included by perl.h

This is the first step in reducing the number of places that data relating to
magic vtables is declared (and has to be kept in sync), and will allow more
flexibility in parts of the core's implementation.

13 years agoAbolish PL_vtbl_sig. It's been all 0s since it was added in 5.0 alpha 2.
Nicholas Clark [Fri, 13 May 2011 11:36:44 +0000 (12:36 +0100)]
Abolish PL_vtbl_sig. It's been all 0s since it was added in 5.0 alpha 2.

Magic with a NULL vtable is equivalent to magic with a vtable of all 0s.
On CPAN, only Apache::Peek's code for 5.005 is referencing it.

13 years agoDon't even declare PL_vtbl_sigelem under -DPERL_MICRO
Nicholas Clark [Fri, 13 May 2011 10:39:18 +0000 (11:39 +0100)]
Don't even declare PL_vtbl_sigelem under -DPERL_MICRO

This turns out to be a simpler solution than 9ba75e3cf905a6e6.

13 years agoStore FBMs in PVMGs, instead of GVs.
Nicholas Clark [Tue, 24 May 2011 14:11:53 +0000 (15:11 +0100)]
Store FBMs in PVMGs, instead of GVs.

This should reduce the complexity of code dealing with GVs, as they no longer
try to play several different incompatible roles.

(As suggested by Ben Morrow. However, it didn't turn out to be as
straightforward as one might have hoped).

13 years agoStore the BM table in mg_ptr instead of after SvCUR().
Nicholas Clark [Wed, 18 May 2011 10:45:22 +0000 (11:45 +0100)]
Store the BM table in mg_ptr instead of after SvCUR().

Previously the 256 byte Boyer-Moore table was stored in the buffer of SvPVX()
after the raw string by extending the buffer.

Given that the scalar is alway upgraded to add PERL_MAGIC_bm magic, to clear
the table and other flags, there's no extra memory cost in using mg_ptr in the
MAGIC struct to point directly to the table.

I believe that this removes the last place in the core that stores data beyond
SvCUR().

13 years agoExit early from Perl_fbm_compile() if the SV is already "compiled".
Nicholas Clark [Wed, 18 May 2011 09:49:43 +0000 (10:49 +0100)]
Exit early from Perl_fbm_compile() if the SV is already "compiled".

I believe that this can only happen if a constant subroutine is used more than
once as the second argument to index.

13 years agoIn Perl_fbm_instr(), use a switch() statement for the special case code.
Nicholas Clark [Tue, 17 May 2011 12:16:57 +0000 (13:16 +0100)]
In Perl_fbm_instr(), use a switch() statement for the special case code.

Previously the special-case code for lengths 0, 1 and 2 was in a nested set
of if() statements, which was slightly cryptic to read.

13 years agoIn Perl_fbm_compile(), use STRLEN instead of U32 to calculate BmPREVIOUS().
Nicholas Clark [Tue, 17 May 2011 11:28:36 +0000 (12:28 +0100)]
In Perl_fbm_compile(), use STRLEN instead of U32 to calculate BmPREVIOUS().

This should fix a theoretical bug on strings longer than 2**32 bytes where the
byte referenced by BmRARE() is at an offset beyond 2**32. I'm not sure how to
test this, as I think to trigger it one would need to have one of

a: the second argument to index as a string literal, longer than 2**32 bytes
b: a fixed string in a regex, longer than 2**32 bytes

13 years agoAbolish xbm_rare. Move BmUSEFUL() to union _xnvu and BmPREVIOUS() to the UV.
Nicholas Clark [Tue, 17 May 2011 09:26:49 +0000 (10:26 +0100)]
Abolish xbm_rare. Move BmUSEFUL() to union _xnvu and BmPREVIOUS() to the UV.

This reduces the complexity of the union declarations in sv.h.

As B.xs is accessing the structures/unions directly, instead of using the
macros, it needs a patch too.

13 years agoUse SvTAIL() instead of BmFLAGS(). The core no longer uses BmFLAGS().
Nicholas Clark [Mon, 9 May 2011 15:53:28 +0000 (16:53 +0100)]
Use SvTAIL() instead of BmFLAGS(). The core no longer uses BmFLAGS().

13 years agoEmulate the value of BmFLAGS() using SvTAIL().
Nicholas Clark [Mon, 9 May 2011 11:07:17 +0000 (12:07 +0100)]
Emulate the value of BmFLAGS() using SvTAIL().

Don't set BmFLAGS() in Perl_fbm_compile()

Originally fbm_compile() had an I32 flags argument, which seems to have been
part of case folding/locale improvements. bbce6d69784bf43b removed this.
SvTAIL() was only used in once place until c277df42229d99fe2779dcf1a3ceec16
added the U32 flags argument to fbm_compile(), not used until cf93c79d660ae36c.
That commit also added FBMcf_TAIL and FBMcf_TAIL{z,Z,DOLLAR} but didn't use the
last three. Additionally, it stored the BmFLAGS as part of the compiled table:

+       table[-1] = flags;              /* Not used yet */

f722798beaa43749 added FBMcf_TAIL_DOLLARM, renumbered FBMcf_TAIL{z,Z,DOLLAR},
but still didn't use anything other than FBMcf_TAIL.

The core, nothing on CPAN, and nothing visible to Google codesearch, has ever
used the 4 specialist flags. The only use is 0 or FBMcf_TAIL, which is in
lockstep with SvTAIL() of 0 or non-0.

13 years agoUse 0x40008000 in SvFLAGS() for SVpad_NAME, not 0x40000000
Nicholas Clark [Tue, 24 May 2011 10:17:13 +0000 (11:17 +0100)]
Use 0x40008000 in SvFLAGS() for SVpad_NAME, not 0x40000000

This eliminates potential confusion between SVpad_NAME and SVpbm_VALID.

13 years agoTest that SvFLAGS() & SVpad_NAME is SVpad_NAME, not just non-zero.
Nicholas Clark [Tue, 24 May 2011 09:59:01 +0000 (10:59 +0100)]
Test that SvFLAGS() & SVpad_NAME is SVpad_NAME, not just non-zero.

In Perl_find_rundefsv() and PAD_COMPNAME_FLAGS_isOUR(), replace longhand flags
test with SvPAD_OUR().

13 years agoDon't fbm_compile() studied scalars, to give more flexibility in SV flag usage.
Nicholas Clark [Mon, 23 May 2011 20:52:40 +0000 (21:52 +0100)]
Don't fbm_compile() studied scalars, to give more flexibility in SV flag usage.

No real-world code would ever end up using a studied scalar as a compile-time
second argument to index, so this isn't a real pessimisation.

13 years agoDon't allow study on an FBM scalar, to give more flexibility in SV flag usage.
Nicholas Clark [Mon, 23 May 2011 20:36:06 +0000 (21:36 +0100)]
Don't allow study on an FBM scalar, to give more flexibility in SV flag usage.

No real-world code would ever end up studying an FBM scalar, so this isn't a
real pessimisation.

13 years agoTest dumping studied scalars.
Nicholas Clark [Mon, 23 May 2011 20:18:51 +0000 (21:18 +0100)]
Test dumping studied scalars.

13 years agoPerl_do_sv_dump() shouldn't show "IV" for a FBM, as it's not valid.
Nicholas Clark [Mon, 23 May 2011 20:01:37 +0000 (21:01 +0100)]
Perl_do_sv_dump() shouldn't show "IV" for a FBM, as it's not valid.

The memory is used for part of the FBM state.

Tidy the order of conditions in the if() determining whether the IV/UV should
be shown.

13 years agoIn Perl_sv_2[inu]v_flags(), use the non-caching code whenever SvVALID() is true
Nicholas Clark [Mon, 23 May 2011 17:14:45 +0000 (18:14 +0100)]
In Perl_sv_2[inu]v_flags(), use the non-caching code whenever SvVALID() is true

Previous the non-caching code was only used when SvVALID() was true on a PVGV.
However, PVLVs can also perform all the roles of a PVGV, so could conceivably
be acting as FBMs. As it's safe to test SvVALID() on any scalar SV, do so, as
the compiler can combine the flag test for SvVALID() with that for
SvGMAGICAL(), producing tighter object code.

13 years agoIn IPC::Open3, inline xfork() and xclose_on_exec(), and delete xpipe_anon().
Nicholas Clark [Tue, 7 Jun 2011 11:17:40 +0000 (13:17 +0200)]
In IPC::Open3, inline xfork() and xclose_on_exec(), and delete xpipe_anon().

All three functions are private, undocumented, unexported, and un(ab)used by
any code on CPAN. The first two are used in only one place, so inline them.
The third was added in 8960aa876f446ad2, without adding any code which used it,
and it has remained unused ever since.

13 years agoIn IPC::Open3::_open(), refactor the DO_SPAWN code to loop over @handles.
Nicholas Clark [Tue, 7 Jun 2011 11:00:33 +0000 (13:00 +0200)]
In IPC::Open3::_open(), refactor the DO_SPAWN code to loop over @handles.

13 years agoIn IPC::Open3::_open(), refactor the fork/exec code to loop over @handles.
Nicholas Clark [Tue, 7 Jun 2011 10:37:28 +0000 (12:37 +0200)]
In IPC::Open3::_open(), refactor the fork/exec code to loop over @handles.

13 years agoIn IPC::Open3::_open(), refactor the common code into loops over @handles.
Nicholas Clark [Mon, 6 Jun 2011 18:45:13 +0000 (20:45 +0200)]
In IPC::Open3::_open(), refactor the common code into loops over @handles.

As fh_is_fd() is now used in only one location, inline it. (This function isn't
exported, isn't documented, and isn't (ab)used by anything on CPAN.)

13 years agoIn IPC::Open3::_open(), switch from 'r' and 'w' to '<' and '>'.
Nicholas Clark [Mon, 6 Jun 2011 17:48:03 +0000 (19:48 +0200)]
In IPC::Open3::_open(), switch from 'r' and 'w' to '<' and '>'.

IO::Handle accepts either, but open only accepts the latter.

In spawn_with_handles(), hoist the C<require Fcntl> into the only block that
needs it - this avoids loading Fcntl on Win32.

13 years agoUse $handles[2]{dup_of_out} for the special case code for shared STD{OUT,ERR}.
Nicholas Clark [Mon, 6 Jun 2011 17:19:29 +0000 (19:19 +0200)]
Use $handles[2]{dup_of_out} for the special case code for shared STD{OUT,ERR}.

As C<dup_of_out> is never set on the other two members of @handles, this will
allow code simplification.

13 years agoIn IPC::Open3::_open3(), move $kid_{rdr,wtr,err} to @handles.
Nicholas Clark [Mon, 6 Jun 2011 16:26:35 +0000 (18:26 +0200)]
In IPC::Open3::_open3(), move $kid_{rdr,wtr,err} to @handles.

Switch to 3-arg open where code is changing.

13 years agoIn IPC::Open3::_open3(), move $dup_{wtr,rdr,err} to @handles.
Nicholas Clark [Mon, 6 Jun 2011 16:02:33 +0000 (18:02 +0200)]
In IPC::Open3::_open3(), move $dup_{wtr,rdr,err} to @handles.

13 years agoIn IPC::Open3::_open3(), move $dad_{wtr,rdr,err} to @handles.
Nicholas Clark [Mon, 6 Jun 2011 15:11:35 +0000 (17:11 +0200)]
In IPC::Open3::_open3(), move $dad_{wtr,rdr,err} to @handles.

Switch to 3-arg open where code is changing. Additionally, @_ can now be used
in place of @cmd.

13 years agoMove the table describing file handles near to the top of IPC::Open::open3().
Nicholas Clark [Mon, 6 Jun 2011 13:02:22 +0000 (15:02 +0200)]
Move the table describing file handles near to the top of IPC::Open::open3().

Also convert fileno BAREWORD to fileno \*BAREWORD. These will aid future
refactoring.

13 years agoMove the autovivification emulation code to the top of IPC::Open3::_open3().
Nicholas Clark [Mon, 6 Jun 2011 12:43:56 +0000 (14:43 +0200)]
Move the autovivification emulation code to the top of IPC::Open3::_open3().

This avoids having to re-assign to the scalars $dad_wtr and $dad_rdr.

13 years agoRefactor IPC::Open3::_open3() to find the caller's package itself.
Nicholas Clark [Mon, 6 Jun 2011 12:29:19 +0000 (14:29 +0200)]
Refactor IPC::Open3::_open3() to find the caller's package itself.

Previously it was passed in as a parameter by IPC::Open2::open2() and
IPC::Open3::open3(), each of which used C<calller> to find it. Move the use of
caller to one place.

It would also be possible to use C<caller> to eliminate the first parameter to
_open3(), but this would add more code than it removes, so doesn't seem wise.

13 years agoIPC::Open3::open3() couldn't duplicate numeric file descriptors on Windows.
Nicholas Clark [Sun, 5 Jun 2011 17:47:32 +0000 (19:47 +0200)]
IPC::Open3::open3() couldn't duplicate numeric file descriptors on Windows.

13 years agoAvoid an uninitialized hash key in IPC::Open::spawn_with_handles().
Nicholas Clark [Sun, 5 Jun 2011 14:31:02 +0000 (16:31 +0200)]
Avoid an uninitialized hash key in IPC::Open::spawn_with_handles().

13 years agoIPC::Open3::open3() shouldn't fail if any of *STD{IN,OUT,ERR} are localized.
Nicholas Clark [Sun, 5 Jun 2011 13:58:39 +0000 (15:58 +0200)]
IPC::Open3::open3() shouldn't fail if any of *STD{IN,OUT,ERR} are localized.

Previously it would fail on Win32, because spawn_with_handles() would attempt
to duplicate all three, ignoring failures at this point, but then report
failure to close any as a fatal error, even if this was because the earlier
dup-ing had failed.

Also avoid a warning in the *nix code path in open3() if STDERR is localized
(and hence fileno STDERR is undefined).

13 years agoAdd debug code to test IPC::Open3::spawn_with_handles() on *nix.
Nicholas Clark [Sun, 5 Jun 2011 13:01:13 +0000 (15:01 +0200)]
Add debug code to test IPC::Open3::spawn_with_handles() on *nix.

This allows testing of the (normally) Win32 and OS/2 specific code paths in
IPC::Open3::open3().

13 years agoIn IPC::Open3::_open(), use 3 argument open to avoid a special case for STDERR.
Nicholas Clark [Mon, 6 Jun 2011 20:45:46 +0000 (22:45 +0200)]
In IPC::Open3::_open(), use 3 argument open to avoid a special case for STDERR.

The code for STDIN and STDOUT never ends up needing to duplicate a reference.
The code for STDERR can, because of the earlier special case code to save
STDOUT. It was special-cased to use fileno in commit 8b3e92c60014b4e7, in 1998.
This was before 3 argument open. With 3 argument open the special case can be
avoided.

13 years agoGeneralise IPC::Open3::xopen() to $n-argument open.
Nicholas Clark [Mon, 6 Jun 2011 14:16:37 +0000 (16:16 +0200)]
Generalise IPC::Open3::xopen() to $n-argument open.

Previously it could only perform 2 argument open.