This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perl5.git
12 years agoMake coreamp.t pass with PERL_UNICODE set
Father Chrysostomos [Mon, 29 Aug 2011 00:49:40 +0000 (17:49 -0700)]
Make coreamp.t pass with PERL_UNICODE set

12 years agoThinko in vms.c:copy_expand_unix_filename_escape().
Craig A. Berry [Sun, 28 Aug 2011 20:42:58 +0000 (15:42 -0500)]
Thinko in vms.c:copy_expand_unix_filename_escape().

Turns out comparing a signed byte to values above 0x7f doesn't make
sense.  *All* signed byte integers are less than or equal to 0x9f,
so the other two branches of the if could never be taken.

This code probably needs more review and testing, but we might as
well make it do what it intends to do before reviewing those
intentions and factoring out some of the copy-and-paste verbosity.

12 years agoBackport XS_(IN|EX)TERNAL, be explicit about linkage
Steffen Mueller [Sun, 28 Aug 2011 15:51:06 +0000 (17:51 +0200)]
Backport XS_(IN|EX)TERNAL, be explicit about linkage

With XS(name) defaulting to exporting symbols again since the
previous commit, ExtUtils::ParseXS will now instead use explicit
XS_EXTERNAL/XS_INTERNAL in its place. This allows backporting
of the linkage changes to perls as old as 5.10.0 (and possibly
further).

12 years agoRevert back to making XS(name) expose XSUB symbols
Steffen Mueller [Sun, 28 Aug 2011 15:45:37 +0000 (17:45 +0200)]
Revert back to making XS(name) expose XSUB symbols

Instead, as Zefram recommended, ExtUtils::ParseXS will be patched
to not export XSUB symbols by default that are generated through
the module itself. As Zefram said, this has the advantage of
allowing older perls to benefit from the non-exporting of symbols.

12 years ago&CORE::substr()
Father Chrysostomos [Sun, 28 Aug 2011 06:29:13 +0000 (23:29 -0700)]
&CORE::substr()

This commit makes &CORE::substr callable through references and via
&ampersand syntax.

It’s a bit awkward, as we need a substr op that is flagged as hav-
ing 4 arguments *and* possibly returning an lvalue.   The code in
op_lvalue_flags wasn’t really set up for that, so I needed to flag
the op with OPpMAYBE_LVSUB in coresub_op before it gets passed to
op_lvalue_flags.  It turned out that only that was necessary, as
op_lvalue_flags does an op_private == 4 check (rather than (op_private
& 7) == 4 or some such) when checking for the 4-arg case and croak-
ing.  When the op arrives in op_lvalue_flags, it’s already flagged
OPpMAYBE_LVSUB|4 which != 4.

pp_substr is also modified to check for nulls and, if necessary,
adjust its count of how many arguments were actually passed.)

12 years ago&CORE::srand()
Father Chrysostomos [Sun, 28 Aug 2011 01:50:19 +0000 (18:50 -0700)]
&CORE::srand()

This commit allows &CORE::srand to be called through references and
via ampersand syntax.  pp_srand is modified to take into account the
nulls pushed on to the stack in pp_coreargs, which happens because
pp_coreargs has no other way to tell srand how many arguments it’s
actually getting.  See commit 0163043a for details.

12 years ago&CORE::sleep()
Father Chrysostomos [Sun, 28 Aug 2011 01:40:05 +0000 (18:40 -0700)]
&CORE::sleep()

This commit allows &CORE::sleep to be called through references and
via ampersand syntax.  pp_sleep is modified to take into account the
nulls pushed on to the stack in pp_coreargs, which happens because
pp_coreargs has no other way to tell sleep how many arguments it’s
actually getting.  See commit 0163043a for details.

Unfortunately, sleep with no args is nearly impossible to test porta-
bly.  But I have checked that it works.

12 years agoClose some unclosed comments in vms/vms.c.
Craig A. Berry [Sun, 28 Aug 2011 03:20:16 +0000 (22:20 -0500)]
Close some unclosed comments in vms/vms.c.

Clearly this code is not well-tested.  Especially the parts that
the compiler couldn't see because it was hidden by unclosed
comment blocks.  Ouch.

I'm not going to name names or look too deep in the blame log, but
suffice it to say that this is why patches that add hundreds of
lines of new code without tests should not be accepted.

12 years agoFix miscellaneous compiler warnings in vms/vms.c.
Craig A. Berry [Sun, 28 Aug 2011 03:12:24 +0000 (22:12 -0500)]
Fix miscellaneous compiler warnings in vms/vms.c.

A couple of empty parameter lists and a couple of unsigned -1
error statuses.  Brought to you by

   -Duser_c_flags=/WARN=(ENABLE=LEVEL4,INFORMATIONAL=ALL)

which is only the third highest warning level.

12 years agoRemove unnecessary includes from vms/vms.c.
Craig A. Berry [Sun, 28 Aug 2011 03:07:43 +0000 (22:07 -0500)]
Remove unnecessary includes from vms/vms.c.

A couple are only needed for the homegrown utime() replacement on
older systems.  rmsdef.h is apparently not needed at all.

12 years ago&CORE::send() and &CORE::syswrite()
Father Chrysostomos [Sat, 27 Aug 2011 18:13:48 +0000 (11:13 -0700)]
&CORE::send() and &CORE::syswrite()

This commit makes &CORE::send and &CORE::syswrite callable through references and & syntax.

All this commit has to do is remove them from the exception list in
gv.c, as previous commits happen to have made them work.  (I didn’t
realise originally that these use pushmark.)

12 years ago&CORE::select()
Father Chrysostomos [Sat, 27 Aug 2011 16:50:22 +0000 (09:50 -0700)]
&CORE::select()

This commit allows CORE::select to be called through references and
via &ampersand syntax.

This is a tricky case, as the select keyword represents two distinct
operators.  ck_select replaces the OP_SELECT with an OP_SSELECT if
there is more that one argument.

So what we do here is create an if(@_>1)/else block with the usual
op-with-coreargs-child inside each branch.

The op tree looks like this:

$ ./perl -Ilib -mO=Concise,CORE::select -e 'BEGIN{\&CORE::select}
'
CORE::select:
8  <1> leavesub[1 ref] K/REFC,1 ->(end)
-     <1> null K/1 ->8
5        <|> cond_expr(other->6) K/1 ->9
4           <2> gt sK/2 ->5
2              <1> rv2av[t4] sK/1 ->3
1                 <#> gv[*_] s ->2
3              <$> const[IV 1] s ->4
7           <@> sselect[t2] K ->8
-              <0> ex-pushmark s ->6
6              <$> coreargs(IV 218) ->7
a           <@> select[t1] sK/1 ->8
-              <0> ex-pushmark s ->9
9              <$> coreargs(IV 219) s/DREF1 ->a
-e syntax OK

There was no need to modify pp_select to handle a null when there is
no argument, as it can already handle it.

12 years agoDocument getprotobynumber’s precedence
Father Chrysostomos [Sun, 28 Aug 2011 00:39:40 +0000 (17:39 -0700)]
Document getprotobynumber’s precedence

12 years ago perlfunc/gethostbyname: Add missing C in C<>
Father Chrysostomos [Sun, 28 Aug 2011 00:33:46 +0000 (17:33 -0700)]
 perlfunc/gethostbyname: Add missing C in C<>

12 years agoTesting deparsing of CORE::not
Father Chrysostomos [Sat, 27 Aug 2011 12:46:25 +0000 (05:46 -0700)]
Testing deparsing of CORE::not

12 years agoGet coreamp.t passing on VMS.
Craig A. Berry [Sat, 27 Aug 2011 22:26:25 +0000 (17:26 -0500)]
Get coreamp.t passing on VMS.

The last record in a file ends with a newline willy nilly, so we
might as well write (and test for) one explicitly.

The name of a directory file ends with .DIR, so we need to allow
for that.

File::Temp panics when trying to delete the directory that is the
current working directory, so save where we were and restore to it
before clean-up.

12 years agopp.c: Use built-in case tables for ords < 256
Karl Williamson [Mon, 22 Aug 2011 15:26:09 +0000 (09:26 -0600)]
pp.c: Use built-in case tables for ords < 256

Previously, all case changing on utf8-encoded strings used the tables on
disk, under the off-chance that there was a user-defined case change
override in effect.  Now that that feature has been removed, this can't
happen, so we can use the existing built-in tables.

This code has been present and ifdef'd out since 5.10.1.  New compiler
warnings forced a few other changes besides removing the #if statements

Running some primitive benchmarks showed that this sped up upper-casing of
utf8 strings in the latin1 range by 2 orders of magnitude.

12 years agopp.c: Change comment
Karl Williamson [Mon, 22 Aug 2011 15:25:11 +0000 (09:25 -0600)]
pp.c: Change comment

This now reflects Tom Christiansen's and my current thinking about Greek
Final Sigma

12 years agoMake pod2html a regular script without substitutions
Florian Ragwitz [Thu, 25 Aug 2011 15:50:26 +0000 (17:50 +0200)]
Make pod2html a regular script without substitutions

This will make the CPAN dist easier. For the perl core, we still need
substitutions to get the right she-bang as we don't go through EU::MM to fix it
for us. For that, we add utils/pod2html.PL.

12 years agoGive Pod-Html a more modern dist layout
Florian Ragwitz [Thu, 25 Aug 2011 15:00:07 +0000 (17:00 +0200)]
Give Pod-Html a more modern dist layout

12 years ago&CORE::reset()
Father Chrysostomos [Sat, 27 Aug 2011 06:50:06 +0000 (23:50 -0700)]
&CORE::reset()

This commit allows &CORE::reset to be called through references and
via ampersand syntax.  pp_reset is modified to take into account the
nulls pushed on to the stack in pp_coreargs, which happens because
pp_coreargs has no other way to tell reset how many arguments it’s
actually getting.  See commit 0163043a for details.

12 years agoGVs of localised arrays and hashes should be refcounted
Father Chrysostomos [Sat, 27 Aug 2011 06:31:36 +0000 (23:31 -0700)]
GVs of localised arrays and hashes should be refcounted

Otherwise the GV can be freed before the scope-popping code can put
the old entry back in it:

$ perl -le 'local @{"x"}; delete $::{x}'
Bus error
$ perl -le 'local %{"x"}; delete $::{x}'
Bus error

12 years ago&CORE::foo() for (sys)read and recv
Father Chrysostomos [Sat, 27 Aug 2011 05:28:52 +0000 (22:28 -0700)]
&CORE::foo() for (sys)read and recv

These are grouped together because they all have \$ in their
prototypes.

This commit allows the subs in the CORE package under those names to
be called through references and via &ampersand syntax.

The coreargs op in the subroutine is marked with the OPpSCALARMOD
flag.  (scalar_mod_type in op.c returns true for these three ops,
indicating that the OA_SCALARREF parameter is \$, not \[$@%(&)*].)

pp_coreargs uses that flag to decide what arguments to reject.

12 years agoAdd OPpCOREARGS_SCALARMOD flag
Father Chrysostomos [Sat, 27 Aug 2011 05:05:40 +0000 (22:05 -0700)]
Add OPpCOREARGS_SCALARMOD flag

pp_coreargs will use this to distinguish between the \$ and \[$@%*]
prototypes.

12 years agoUpdate the comments at the top of t/op/core*.t
Father Chrysostomos [Sat, 27 Aug 2011 04:57:59 +0000 (21:57 -0700)]
Update the comments at the top of t/op/core*.t

12 years agoRename t/op/core*.t
Father Chrysostomos [Sat, 27 Aug 2011 04:48:47 +0000 (21:48 -0700)]
Rename t/op/core*.t

Originally, coresubs.t was going to be for generic tests and
coreinline.t was going to be for inlining.  But the latter ended
up testing other things than inlining, the former testing just
&ampersand() calls.  So this commits renames coresubs.t to coreamp.t
and coreinline.t to coresubs.t.

12 years ago&CORE::rand()
Father Chrysostomos [Fri, 26 Aug 2011 17:12:01 +0000 (10:12 -0700)]
&CORE::rand()

This commit allows &CORE::rand to be called through references and
via ampersand syntax.  pp_rand is modified to take into account the
nulls pushed on to the stack in pp_coreargs, which happens because
pp_coreargs has no other way to tell rand how many arguments it’s
actually getting.  See commit 0163043a for details.

12 years ago&CORE::open()
Father Chrysostomos [Sat, 27 Aug 2011 01:19:14 +0000 (18:19 -0700)]
&CORE::open()

This commit allows &CORE::open to be called through references or with
ampersand syntax.  It modifies pp_coreargs not to push nulls for ops
that require a pushmark.

12 years agoReverse the order of two tests in gv.t
Father Chrysostomos [Fri, 26 Aug 2011 21:52:06 +0000 (14:52 -0700)]
Reverse the order of two tests in gv.t

so that the first does not make the second always pass.
The bug that 99fc7eca4 fixed would never had occurred if
they had been that way to begin with.

12 years ago&CORE::mkdir()
Father Chrysostomos [Thu, 25 Aug 2011 16:52:13 +0000 (09:52 -0700)]
&CORE::mkdir()

This commit allows &CORE::mkdir to be called through references and
via ampersand syntax.  pp_mkdir is modified to take into account the
nulls pushed on to the stack in pp_coreargs, which happens because
pp_coreargs has no other way to tell mkdir how many arguments it’s
actually getting.

12 years ago&CORE::lock()
Father Chrysostomos [Wed, 24 Aug 2011 16:09:58 +0000 (09:09 -0700)]
&CORE::lock()

This commit allows &CORE::lock to be called through references and
via ampersand syntax.  It adds code to pp_coreargs for handling the
OA_SCALARREF case, though what it adds is currently lock-specific.
(Subsequent commits will address that.)  Since lock returns the scalar
passed to it, not a copy, &CORE::lock needs to use op_leavesublv,
rather than op_leavesub.  But it can’t be an lvalue sub, as
&CORE::lock = 3 should be disallowed.  So we use the sneaky trick of
turning on the lvalue flag before attaching the op tree to the sub
(which causes newATTRSUB to use op_leavesublv), and then turning it
off afterwards.

12 years ago&CORE::index() and &CORE::rindex()
Father Chrysostomos [Fri, 26 Aug 2011 19:40:13 +0000 (12:40 -0700)]
&CORE::index() and &CORE::rindex()

This commit allows &CORE::index and &CORE::rindex to be called through
references and via ampersand syntax.  pp_index is modified to take
into account the nulls pushed on to the stack in pp_coreargs, which
happens because pp_coreargs has no other way to tell pp_index how many
arguments it’s actually getting.  See commit 0163043a for details.

12 years agoUpdate UNIVERSAL::VERSION docs following 9bf41c1
Father Chrysostomos [Fri, 26 Aug 2011 17:00:13 +0000 (10:00 -0700)]
Update UNIVERSAL::VERSION docs following 9bf41c1

12 years ago&CORE::gmtime() and &CORE::localtime()
Father Chrysostomos [Fri, 26 Aug 2011 16:49:37 +0000 (09:49 -0700)]
&CORE::gmtime() and &CORE::localtime()

This commit allows &CORE::gmtime and &CORE::localtime to be called
through references and via ampersand syntax.  pp_gmtime is modified
to take into account the nulls pushed on to the stack in pp_coreargs,
which happens because pp_coreargs has no other way to tell pp_gmtime
how many arguments it’s actually getting.

I was going to say ‘see commit f6a1686942 for more details’, but found
out, to my horror, that most of the commit message was cut off.  I
don’t know which commit-munging part of git is responsible, but I’ve
had similar problems with git am and git commit --amend.  But, then,
this could have been sloppy copy and paste.  Anyway, here is the
missing part:

Usually, an op that has optional arguments has the number of arguments
indicated with flags on the op itself:

$ ./perl -Ilib -MO=Concise -e 'binmode 1'
6  <@> leave[1 ref] vKP/REFC ->(end)
1     <0> enter ->2
2     <;> nextstate(main 1 -e:1) v:{ ->3
5     <@> binmode vK/1 ->6
-        <0> ex-pushmark s ->3
4        <1> rv2gv sK*/1 ->5
3           <$> gv(*1) s ->4
-e syntax OK
$ ./perl -Ilib -MO=Concise -e 'binmode 1,2'
7  <@> leave[1 ref] vKP/REFC ->(end)
1     <0> enter ->2
2     <;> nextstate(main 1 -e:1) v:{ ->3
6     <@> binmode vK/2 ->7
-        <0> ex-pushmark s ->3
4        <1> rv2gv sK*/1 ->5
3           <$> gv(*1) s ->4
5        <$> const(IV 2) s ->6
-e syntax OK

Notice the /1 vs /2 on the binmode op.

With a CORE sub, we have a single op for both cases.  So, what this
commit does is set the number of arguments to the maximum, push nulls
on to the stack in pp_coreargs (actually, it was already set up to
do it, so there is no change there), and have the pp_ functions for
each op that has optional arguments do a null check after popping
the stack.

pp_binmode already does a null check, but other pp_ functions will
need to be modified.  Since each one is different, those will come in
separate commits.

This is what &CORE::binmode’s op tree looks like:

$ ./perl -Ilib -MO=Concise,CORE::binmode -e 'BEGIN{\&CORE::binmode}'
CORE::binmode:
3  <1> leavesub[1 ref] K/REFC,1 ->(end)
2     <@> binmode sK/2 ->3
-        <0> ex-pushmark s ->1
1        <$> coreargs(IV 212) s ->2
-e syntax OK

12 years agoperldelta for f132ae69 (*{undef})
Father Chrysostomos [Fri, 26 Aug 2011 16:26:46 +0000 (09:26 -0700)]
perldelta for f132ae69 (*{undef})

12 years agoRemove now-unnecessary len check from pp.c:S_rv2gv
Father Chrysostomos [Fri, 26 Aug 2011 15:25:45 +0000 (08:25 -0700)]
Remove now-unnecessary len check from pp.c:S_rv2gv

This check, added by ed996e63f6, is no longer necessary as of commit
f132ae694c, since PL_sv_undef takes a different path.

12 years agoMake *{undef} self-consistent
Father Chrysostomos [Fri, 26 Aug 2011 13:20:01 +0000 (06:20 -0700)]
Make *{undef} self-consistent

Commit afd1915d made filehandle vivification work on hash and array
elements, but in doing so it accidentally changed

    *{;undef} = 3;

to do the same thing as

    *{""} = 3;

while leaving

    *{$some_undefined_variable}

an error.

This commit adjusts the if() conditions in S_rv2gv (formerly in
pp_rv2gv) in pp.c to make PL_sv_undef follow the same path as before.

It also removes the uninit tests from lib/warnings/pp, since they
are now errors.  The uninit warning in rv2gv is only triggered now
when it is implicit, as in close().  That is already tested in
lib/warnings/9uninit.

12 years agoperlop: Minor consistency tweak
Father Chrysostomos [Fri, 26 Aug 2011 12:55:34 +0000 (05:55 -0700)]
perlop: Minor consistency tweak

Make the indentation in this example match the surrounding
examples.

12 years ago[perl #93358] Clarify => quoting
Father Chrysostomos [Fri, 26 Aug 2011 12:54:58 +0000 (05:54 -0700)]
[perl #93358] Clarify => quoting

The perlop manpage was stating ‘the left operand’, which was
not entirely correct, as ‘time.shift =>’ quotes just the shift,
not the time (nor does it see the whole as not being an ident-
ifier and refuse to quote anything).

12 years agoRe-generate uconfig.h
Florian Ragwitz [Fri, 26 Aug 2011 13:26:38 +0000 (15:26 +0200)]
Re-generate uconfig.h

This makes porting/regen.t pass again.

12 years agoBump the perlfaq version for a new cpan release
Florian Ragwitz [Fri, 26 Aug 2011 12:35:51 +0000 (14:35 +0200)]
Bump the perlfaq version for a new cpan release

12 years agoRemove unwanted space in comments
H.Merijn Brand [Fri, 26 Aug 2011 11:02:23 +0000 (13:02 +0200)]
Remove unwanted space in comments

12 years agoRevert "Fix Configure's csym test for gcc's link time optimisation"
H.Merijn Brand [Fri, 26 Aug 2011 10:14:53 +0000 (12:14 +0200)]
Revert "Fix Configure's csym test for gcc's link time optimisation"

There are too many related problems arising from this change

This reverts commit e820c6d6a6d0a8828aa68a6895696b659c471f2f.

12 years agoCorrect mro_get_linear_isa’s docs
Father Chrysostomos [Fri, 26 Aug 2011 04:36:12 +0000 (21:36 -0700)]
Correct mro_get_linear_isa’s docs

This has been out of date since the MRO plugin API was added
(5.10.1, I think).

12 years ago&CORE::getpgrp()
Father Chrysostomos [Fri, 26 Aug 2011 01:12:35 +0000 (18:12 -0700)]
&CORE::getpgrp()

This commit allows &CORE::getpgrp to be called through references and
via ampersand syntax.  pp_getpgrp is modified to take into account the
nulls pushed on to the stack in pp_coreargs, since pp_coreargs has no
other way to tell getpgrp how many arguments it’s actually getting.

12 years ago&CORE::exit()
Father Chrysostomos [Fri, 26 Aug 2011 01:10:53 +0000 (18:10 -0700)]
&CORE::exit()

This commit allows &CORE::exit to be called through references and
via ampersand syntax.  pp_exit is modified to take into account the
nulls pushed on to the stack in pp_coreargs, since pp_coreargs has no
other way to tell exit how many arguments it’s actually getting.

12 years agopp.c: Suppress stupid compiler warning
Father Chrysostomos [Fri, 26 Aug 2011 03:02:58 +0000 (20:02 -0700)]
pp.c: Suppress stupid compiler warning

12 years ago&CORE::foo() for dbmopen and dbmclose
Father Chrysostomos [Fri, 26 Aug 2011 01:06:23 +0000 (18:06 -0700)]
&CORE::foo() for dbmopen and dbmclose

This commit allows the subs in the CORE package for close, getc and
readline to be called through references and via ampersand syntax.  A
special case for each of them is added to pp_coreargs to deal with
calls with no arguments.  Pushing a null on to the stack (which I’m
doing for other ops) won’t work, as a null already means something for
these cases: close($f) won’t vivify a typeglob if $f is a string, so
the implicit rv2gv pushes a null on to the stack.

12 years ago&CORE::foo() for close, getc and readline
Father Chrysostomos [Fri, 26 Aug 2011 00:59:12 +0000 (17:59 -0700)]
&CORE::foo() for close, getc and readline

This commit allows the subs in the CORE package for close, getc and
readline to be called through references and via ampersand syntax. The
pp functions are modified to take into account the nulls that coreargs
pushes on to the stack to indicate that there is no argument.

12 years agovoid rather than empty parameter for Perl___notused.
Craig A. Berry [Thu, 25 Aug 2011 22:16:13 +0000 (17:16 -0500)]
void rather than empty parameter for Perl___notused.

Without this, the VMS compiler, with warnings cranked up to level 4,
emits pages and pages of things like:

    dVAR;
....^
%CC-I-NOPARMLIST, The declaration of the function Perl___notused has
an empty parameter list.  If the function has parameters, they should
be declared here; if it has no parameters, "void" should be specified
in the parameter list.
at line number 100 in file MDA0:[SMOKE.blead]perl.c;1

Over 2,000 of these plus other warnings yields a smoke report of 750K,
which is quite a bit over the 400K limit of the perl.org mailing lists,
not to mention being a slow read.

12 years ago[perl #92376] Change - to : in time template
Father Chrysostomos [Thu, 25 Aug 2011 21:46:55 +0000 (14:46 -0700)]
[perl #92376] Change - to : in time template

12 years ago&CORE::foo() for @ and $@ prototypes, except unlink
Father Chrysostomos [Thu, 25 Aug 2011 21:33:03 +0000 (14:33 -0700)]
&CORE::foo() for @ and $@ prototypes, except unlink

This commit allows the CORE subroutines for functions with @
and $@ prototypes to be called through references and via amper-
sand syntax.

unlink is not included in this commit, as it requires special casing
due to its use of implicit $_.

Since these functions require a pushmark, and since it has to come
between two things that pp_coreargs does, it’s easiest to flag the
coreargs op (with the OPpCOREARGS_PUSHMARK flag added in the previous
commit) and call pp_pushmark directly from pp_coreargs.

12 years agoAdd OPpCOREARGS_PUSHMARK flag
Father Chrysostomos [Mon, 22 Aug 2011 00:27:58 +0000 (17:27 -0700)]
Add OPpCOREARGS_PUSHMARK flag

This will be used to tell pp_coreargs when it needs to call
pp_pushmark.

For those functions that need a pushmark, it has to come between
two things that pp_coreargs does; so the easiest way is to use
this flag.

12 years ago&CORE::caller()
Father Chrysostomos [Sun, 21 Aug 2011 18:59:44 +0000 (11:59 -0700)]
&CORE::caller()

This commit allows &CORE::caller to be called through references and
via ampersand syntax.  pp_caller is modified to take into account
two things:
1) pp_coreargs pushes a null on to the stack, since it has no other
   way to tell caller whether it has an argument.
2) The value coming from pp_coreargs (when not null) is off by
   one.  The OPpOFFYBONE flag was added in commit 93f0bc4935 for
   this purpose.

pp_coreargs is also modified, since it assumed till now that an
optional first argument was an implicit $_.

12 years ago&CORE::bless()
Father Chrysostomos [Sun, 21 Aug 2011 17:57:34 +0000 (10:57 -0700)]
&CORE::bless()

This commit allows &CORE::bless to be called through references and
via ampersand syntax.  pp_bless is modified to take into account the
nulls pushed on to the stack in pp_coreargs, since pp_coreargs has no
other way to tell bless how many arguments it’s actually getting.

12 years ago&CORE::binmode()
Father Chrysostomos [Thu, 25 Aug 2011 19:43:54 +0000 (12:43 -0700)]
&CORE::binmode()

This commit allows &CORE::binmode to be called through references and
via ampersand syntax.

Usually, an op that has optional arguments has the number of arguments
indicated with flags on the op itself:

12 years ago[perl #93320] localising @DB::args leads to coredump
Father Chrysostomos [Thu, 25 Aug 2011 19:38:15 +0000 (12:38 -0700)]
[perl #93320] localising @DB::args leads to coredump

This script, from the RT ticket, crashes:

#!/usr/bin/perl
sub cl{
    package DB;
    @DB::args = ();
    return caller(shift);
}

sub f{
    local @DB::args;
    my @z = cl($_) for (1..3);
}

f(1,2,3); f(1,2,3);
__END__

PL_dbargs is not refcounted, and it’s not set until pp_caller first
tries to write to it.  If that happens when @DB::args is localised,
then the array will be freed on scope exit, leaving PL_dbargs pointing
to a freed SV.

This crash can be reproduced more simply this way:

sub {
  package DB;
  ()=caller(0);
  undef *DB::args;
  ()=caller(0);
}->();

So, basically, pp_caller has to re-fetch PL_dbargs from the %DB::
stash each time it sets it.  It cannot rely on the cached value.

(So now I’m wondering whether we even need PL_dbargs.)

12 years agoAllow ampersand calls for CORE subs with $*$$**$ protos
Father Chrysostomos [Thu, 25 Aug 2011 16:50:02 +0000 (09:50 -0700)]
Allow ampersand calls for CORE subs with $*$$**$ protos

This enables ampersand calls and calls through references for CORE
subs that have * and $ in their prototypes and a fixed number of
arguments.

Usually, the *-prototyped ops have their child ops wrapped in rv2gv’s
(*{}) implicitly.  The rv2gv op is sometimes flagged as an autoviv-
ificatory op, such as the first argument to accept() or open().
S_is_handle_constructor contains the list of ops that turn on
that flag.

This commit makes the coreargs op use a couple of flags to serve the
same purpose.  pp_coreargs itself calls S_rv2gv (split out from
pp_rv2gv recently for precisely this purpose) with arguments based on
its own flags.

Currently the autovivified glob gets a name like main::_GEN_0 instead
of main::$a.  I think we can live with that.

12 years agoAdd private coreargs flags for vivifying GVs
Father Chrysostomos [Sat, 20 Aug 2011 06:04:04 +0000 (23:04 -0700)]
Add private coreargs flags for vivifying GVs

12 years agoMove most of pp_rv2gv into a static function
Father Chrysostomos [Sat, 20 Aug 2011 01:11:23 +0000 (18:11 -0700)]
Move most of pp_rv2gv into a static function

This allows the glob-deref logic to be use by other functions in pp.c,
like pp_coreargs.

12 years agoAdd Frederic Briere to AUTHORS
Father Chrysostomos [Thu, 25 Aug 2011 16:36:29 +0000 (09:36 -0700)]
Add Frederic Briere to AUTHORS

12 years agoAttribute::Handlers: "my" should be "till"
Frederic Briere [Thu, 25 Aug 2011 16:35:26 +0000 (09:35 -0700)]
Attribute::Handlers: "my" should be "till"

12 years agoAttribute::Handlers: correct spelling
Father Chrysostomos [Thu, 25 Aug 2011 16:33:48 +0000 (09:33 -0700)]
Attribute::Handlers: correct spelling

12 years agoDumper.xs: Suppress compiler warning
Father Chrysostomos [Thu, 25 Aug 2011 16:25:21 +0000 (09:25 -0700)]
Dumper.xs: Suppress compiler warning

12 years agocoresubs.t: Minor clean-up
Father Chrysostomos [Thu, 25 Aug 2011 15:43:22 +0000 (08:43 -0700)]
coresubs.t: Minor clean-up

This fixes some infelicities in the new tests I added to this
file recently.

12 years agoInvert the list of &-able functions in gv.c
Father Chrysostomos [Fri, 19 Aug 2011 17:57:41 +0000 (10:57 -0700)]
Invert the list of &-able functions in gv.c

The list of those that do not support &CORE::foo() syntax is now
shorter than the list of those that do.  In subsequent commits
it will get even shorter.

12 years agoMake sure coresubs.t tests all &-able funcs
Father Chrysostomos [Thu, 25 Aug 2011 15:34:15 +0000 (08:34 -0700)]
Make sure coresubs.t tests all &-able funcs

12 years agoreplace old bookmarks.cpan link with www.perl.org and learn.perl.org
Leo Lapworth [Thu, 25 Aug 2011 10:08:23 +0000 (11:08 +0100)]
replace old bookmarks.cpan link with perl.org and learn.perl.org

12 years agoMerge the refactored makedef.pl into blead.
Nicholas Clark [Thu, 25 Aug 2011 10:06:53 +0000 (12:06 +0200)]
Merge the refactored makedef.pl into blead.

This eliminates global.sym

12 years agoNote the demise of global.sym in perldelta.
Nicholas Clark [Thu, 25 Aug 2011 10:04:23 +0000 (12:04 +0200)]
Note the demise of global.sym in perldelta.

12 years agoIn embed.pl, inline walk_table() into its only caller.
Nicholas Clark [Sun, 21 Aug 2011 15:50:26 +0000 (17:50 +0200)]
In embed.pl, inline walk_table() into its only caller.

12 years agoEliminate global.sym, as makedef.pl can generate it internally.
Nicholas Clark [Sun, 21 Aug 2011 15:37:41 +0000 (17:37 +0200)]
Eliminate global.sym, as makedef.pl can generate it internally.

global.sym was a file listing the exported symbols, generated by regen/embed.pl
from embed.fnc and regen/opcodes, which was only used by makedef.pl

Move the code that generates global.sym from regen/embed.pl to makedef.pl,
and thereby eliminate the need to ship a 907 line generated file.

12 years agoAdd regen/embed_lib.pl, for the code that processes embed.fnc and regen/opcodes
Nicholas Clark [Sun, 21 Aug 2011 14:48:51 +0000 (16:48 +0200)]
Add regen/embed_lib.pl, for the code that processes embed.fnc and regen/opcodes

Move setup_embed() and the helper functions add_level() and current_group()
to it from regen/embed.pl

12 years agoIn embed.pl, move processing embed.fnc and regen/opcodes into a function.
Nicholas Clark [Sun, 21 Aug 2011 14:27:15 +0000 (16:27 +0200)]
In embed.pl, move processing embed.fnc and regen/opcodes into a function.

12 years agoIn embed.pl, refactor the handling of varargs *_nocontext wrappers.
Nicholas Clark [Sun, 21 Aug 2011 13:47:56 +0000 (15:47 +0200)]
In embed.pl, refactor the handling of varargs *_nocontext wrappers.

This is what commit 125218eb5a6d12e7 should have been. :-)

12 years agoIn makedef.pl, move handling of $ARGS{TARG_DIR} to the open statements.
Nicholas Clark [Sun, 21 Aug 2011 12:58:21 +0000 (14:58 +0200)]
In makedef.pl, move handling of $ARGS{TARG_DIR} to the open statements.

This simplifies the code, and eliminates 5 lexicals used solely to hold
filename constants.

12 years agoIn makedef.pl, defaulting $ARGS{TARG_DIR} to '' simplifies the code.
Nicholas Clark [Sun, 21 Aug 2011 12:30:14 +0000 (14:30 +0200)]
In makedef.pl, defaulting $ARGS{TARG_DIR} to '' simplifies the code.

12 years agoTest the TARG_DIR argument to makedef.pl too.
Nicholas Clark [Sun, 21 Aug 2011 12:06:33 +0000 (14:06 +0200)]
Test the TARG_DIR argument to makedef.pl too.

12 years agoIn makedef.pl, no need to store 'config.h' in a variable.
Nicholas Clark [Sun, 21 Aug 2011 11:40:33 +0000 (13:40 +0200)]
In makedef.pl, no need to store 'config.h' in a variable.

Unlike the other files opened by makedef.pl, config.h is always opened in the
current directory, so the filename doesn't modifying if $ARGS{TARG_DIR} is set.

12 years agoIn embed.pl, simplify the code that parses regen/opcodes.
Nicholas Clark [Sun, 21 Aug 2011 11:29:26 +0000 (13:29 +0200)]
In embed.pl, simplify the code that parses regen/opcodes.

As @embed is sorted later, the order that we add entries to it doesn't matter.
Hence add them immediately, avoiding the need to iterate over the "seen" hash.

12 years agoembed.pl was relying on embed.fnc starting with a pre-processor directive.
Nicholas Clark [Sun, 21 Aug 2011 11:09:46 +0000 (13:09 +0200)]
embed.pl was relying on embed.fnc starting with a pre-processor directive.

Fix this subtle bug, and add comments.

12 years agoExtUtils::ParseXS: Accept overridden input typemaps
Steffen Mueller [Thu, 25 Aug 2011 06:19:40 +0000 (08:19 +0200)]
ExtUtils::ParseXS: Accept overridden input typemaps

This restores the ability to have code like this:

ret_type*
foo(bar, baz)
    int bar
    ThereIsNoTypemapForThisType* baz = somefunc($arg);
  CODE:
  ...

Looks strange and indeed, it is. But it's documented in perlxs
to work, so we can't get away with breaking it. The heuristics
for determining whether to allow this use case is checking for
ST\( or \$arg being found in the initialization. That should take
care of all valid use of this feature and still die horribly in
cases where this is used by mistake (instead of a PREINIT block, etc).

12 years agoExtUtils::ParseXS: Explicitly require current version of submodules
Steffen Mueller [Sun, 21 Aug 2011 20:07:50 +0000 (22:07 +0200)]
ExtUtils::ParseXS: Explicitly require current version of submodules

Since there have been certain problems with parts of ExtUtils::ParseXS
being shadowed by older installations of the module, this commit adds
an explicit $VERSION to all submodules and requires them to have the
same version as the main module. This doesn't actually fix any problem,
but makes them more apparent as early as possible instead of failing
with obscure compile errors when bad C is generated from the original
XS.

12 years agoperldelat update
Father Chrysostomos [Thu, 25 Aug 2011 07:23:48 +0000 (00:23 -0700)]
perldelat update

12 years agoperldelta: Move an entry under Testing
Father Chrysostomos [Thu, 25 Aug 2011 06:55:46 +0000 (23:55 -0700)]
perldelta: Move an entry under Testing

12 years agoEnable ampersand calls to CORE subs with $$$ prototypes
Father Chrysostomos [Fri, 19 Aug 2011 15:27:14 +0000 (08:27 -0700)]
Enable ampersand calls to CORE subs with $$$ prototypes

This applies to functions that just take plain scalar arguments, all
of which are mandatory.  Functions that take optional arguments are
not supported yet. truncate() is not supported yet, either (its $$
prototype is not entirely veracious).

This commit enables those functions to be called via &CORE::foo() syn-
tax or through references.

You can now encrypt a string like this: "string"->CORE::crypt($salt).

Each function’s op tree is like this:

$ ./perl -Ilib -MO=Concise,CORE::atan2 -e 'BEGIN{\&CORE::atan2}'
CORE::atan2:
3  <1> leavesub[1 ref] K/REFC,1 ->(end)
2     <@> atan2[t1] sK ->3
-        <0> ex-pushmark s ->1
1        <$> coreargs(IV 100) s ->2
-e syntax OK

This commit adds code to ck_fun to skip the argument check if
coresubs is present.  Otherwise we get a ‘Not enough arguments for
atan2’ error.

12 years agoSimplify the CORE::__FOO__ op-generation code
Father Chrysostomos [Fri, 19 Aug 2011 05:19:25 +0000 (22:19 -0700)]
Simplify the CORE::__FOO__ op-generation code

It just happens that the (caller)[...] offsets for file and line are
the same as the keyword numbers.  KEY___PACKAGE__ is 3 and (caller)[0]
returns the package, so keyword_number % 3 can be used for the offset
instead of an unwieldy switch block.

12 years agoMove coresub op-creation from gv.c to op.c
Father Chrysostomos [Fri, 19 Aug 2011 05:09:17 +0000 (22:09 -0700)]
Move coresub op-creation from gv.c to op.c

For functions that take handles as arguments, this code will need to
call static functions in op.c, like is_handle_constructor.

While we could make is_handle_constructor into a non-static function
and call it from gv.c, that seems backwards, as it would result in a
lot of op-manipulation code in the middle of gv.c.

So this commit creates a new function in op.c, called coresub_op,
which is only called from gv.c, from the &CORE::sub code.

12 years agoAllow ampersand calls to CORE subs with (_) proto
Father Chrysostomos [Thu, 25 Aug 2011 06:31:28 +0000 (23:31 -0700)]
Allow ampersand calls to CORE subs with (_) proto

This commit adds all subs with a (_) prototype to the list of those
that can be called with ampersand syntax or through references.  These
have bodies like this:

$ ./perl -Ilib -MO=Concise,CORE::abs -e 'BEGIN{\&CORE::abs}'
CORE::abs:
3  <1> leavesub[1 ref] K/REFC,1 ->(end)
2     <1> abs[t1] sK/1 ->3
1        <$> coreargs(IV 111) s ->2
-e syntax OK

coreargs fetches the caller’s $_ if there are no arguments passed.

12 years agoAdd find_rundefsv2 function
Father Chrysostomos [Thu, 18 Aug 2011 22:55:59 +0000 (15:55 -0700)]
Add find_rundefsv2 function

Subs in the CORE package with a (_) prototype will use this.

This accepts a CV and a sequence number, so that one can
use it to find the $_ in the caller’s scope.  It only uses
the topmost call of a subroutine that is being called recur-
sively, so it’s not really a general-purpose function.  But
it suffices for &CORE::abs and friends.

12 years agoTest CORE::break’s prototype (just that this time)
Father Chrysostomos [Thu, 25 Aug 2011 05:39:28 +0000 (22:39 -0700)]
Test CORE::break’s prototype (just that this time)

12 years agoMove making inplace sort and reverse away from the peephole optimiser to scalarvoid.
Gerard Goossen [Tue, 16 Aug 2011 07:22:14 +0000 (09:22 +0200)]
Move making inplace sort and reverse away from the peephole optimiser to scalarvoid.

Why: The in place assignment is not just an optimisation but has
significant different behaviour and thus doesn't belong in the
peephole optimiser.  Also the optree changes are unified and simpler.

12 years agoRevert "Test CORE::break’s prototype"
Father Chrysostomos [Thu, 25 Aug 2011 06:15:17 +0000 (23:15 -0700)]
Revert "Test CORE::break’s prototype"

This reverts commit e52d58aa5bea245b66786b4c9029e849a2be69d3.

I don’t quite know how I managed it, but I really screw up
this time!  Two completely unrelated commits ended up getting
merged into one, so, to avoid confusion down the road, I’m
reverting it, only to reapply it shortly....

12 years ago&CORE::break
Father Chrysostomos [Thu, 25 Aug 2011 05:48:26 +0000 (22:48 -0700)]
&CORE::break

This is another nullary function that I forgot to give a body
to make it callable via &break syntax.

12 years agoTest CORE::break’s prototype
Father Chrysostomos [Thu, 25 Aug 2011 05:39:28 +0000 (22:39 -0700)]
Test CORE::break’s prototype

12 years ago[perl #71154] undef &$coderef consistency
Father Chrysostomos [Thu, 25 Aug 2011 05:16:07 +0000 (22:16 -0700)]
[perl #71154] undef &$coderef consistency

$ perl -le' undef &{$x=sub{}}; $x->()'
Not a CODE reference at -e line 1.

undeffing an anonymous subroutine used to turn the ANON flag off,
causing it to bypass the condition apparently written for this situa-
tion in pp_entersub.

This commit stops cv_undef from turning off that flag, so now we get:

$ ./perl -le' undef &{$x=sub{}}; $x->()'
Undefined subroutine called at -e line 1.

12 years agoTrim dead code in do_kv.
Eric Brine [Thu, 25 Aug 2011 03:10:43 +0000 (20:10 -0700)]
Trim dead code in do_kv.

A small piece of code in do_kv has three bugs:

- TARG could have been returned as an lvalue, so its refcount
  could be greater than 1, resulting in data getting clobbered.
  (See RT#20933 for previously fixed occurrence of this bug).

- LvTARG is refcounted, so it's buggy to just NULL it.

- TARG is returned without being initialised.

The first two bugs disappeared recently when we stopped putting
the lvalues in TARG for that op. The third remains.

However, it seems that code is never called. It can only be
called by putting NULL (not undef) on the Perl stack. I don't
see how that's possible here. The test suite never reaches that
code, so it seems it's just dead code.

12 years agoRemove nvi (site no loger works) and put vim above Vile
Leo Lapworth [Wed, 24 Aug 2011 13:26:55 +0000 (14:26 +0100)]
Remove nvi (site no loger works) and put vim above Vile

12 years agoRemove Elvis editor as link broken
Leo Lapworth [Wed, 24 Aug 2011 13:24:21 +0000 (14:24 +0100)]
Remove Elvis editor as link broken

12 years agoFix broken link
Leo Lapworth [Wed, 24 Aug 2011 13:22:49 +0000 (14:22 +0100)]
Fix broken link