| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
| |
Make Carp portable to older Perl versions:
* check minimum Perl version (5.6) at load time
* use || instead of //
* attempt downgrading to avoid loading Unicode tables when that might fail
* check whether utf8::is_utf8() exists before calling it
* lower IPC::Open3 version requirement in Carp tests
|
|
|
|
|
|
|
| |
pp_rv2gv has already called get-magic, so pp_sassign should not do
it at all.
This is a regression from 5.8.8.
|
|
|
|
|
|
|
|
|
|
|
| |
L_ is an old, discouraged but not deprecated, synonym for LC, cased
letters. It was improperly being converted to simply L, all letters,
because it is supposed to match loosely, and the trailing underscore was
being stripped. It needs a special case.
Tests passed for this, as the machine generated test case happened to
choose code points that are in both L and LC. Also some tests were
testing L instead of LC because of a similar flaw.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
If the tied variable holds a reference, but changes to something else
when FETCH is called, perl crashes, as of commit 9d0f7ed75
(5.10.1/5.12.0):
sub ::72 { 73 };
sub TIESCALAR {bless[]}
sub STORE{}
sub FETCH { 72 }
tie my $x, "main";
$x = \$y;
\&$x;
That’s because commit 7a5fd60d4 caused double magic for one branch of
an if/else chain in sv_2cv (by using gv_fetchsv), so commit 9d0f7ed75
removed the SvGETMAGIC preceding the if/else, putting it inside each
branch. That meant that the type would be checked before get-magic
was called. So the type could change unexpectedly.
Due to another bug, this did not affect globs returned from tied array
elements, which got stringified, and hence worked in sv_2cv. But that
bug was fixed in 5.14.0 by commit 13be902ce, which allowed typeglobs
to be returned unflattened through elements of tied aggregates, caus-
ing this to stop working (‘Not a CODE reference’ instead of 73):
sub ::72 { 73 };
sub TIEARRAY {bless[]}
sub STORE{}
sub FETCH { 72 }
tie my @x, "main";
my $elem = \$x[0];
$$elem = *bar;
print &{\&$$elem}, "\n";
This commit fixes both issues by putting the SvGETMAGIC call
back where it belongs, above the if/else chain, and by using
SvPV_nomg_const and gv_fetchpvn_flags instead of gv_fetchsv, to avoid
an extra magic call.
|
| |
|
|
|
|
|
|
|
| |
instead of deriving it from the opchain.
Also contains a test where using the opchain to determine the deref
type fails.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Magical variables usually get autovivified, even in rvalue context,
because Perl is trying to pretend they have been there all along.
That means defined(${"."}) will autovivify $. and return true.
Until CORE subs were introduced, there were no subroutines that popped
into existence when looked at.
This commit makes rv_2cv use the GV_ADDMG flag added in commit
23496c6ea. When this flag is passed, gv_fetchpvn_flags creates a GV
but does not add it to the stash until it finds out that it is creat-
ing a magical one. The CORE sub code calls newATTRSUB, which expects
to add the CV to the stash itself. So the gv has to be added there
and then. So gv_fetchpvn_flags is also adjusted to add the gv to the
stash right before calling newATTRSUB, and to tell itself that the
GV_ADDMG flag is actually off.
It might be better to move the CV-creation code into op.c and inline
parts of newATTRSUB, to avoid fiddling with the addmg variable (and
avoid prototype checks on CORE subs), but that refactoring should
probably come in separate commits.
|
|
|
|
|
| |
(actually doing so the quick way, by skipping the last test, that tests
for -CS on the shebang line)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This resolves perl bug #97978.
Many built-in variables, like $], are actually created on the fly
when first accessed. Perl likes to pretend that these variables have
always existed, so it autovivifies the *] glob even in rvalue context
(e.g., defined *{"]"}, close "]").
The list of variables that were autovivified was maintained separ-
ately (in is_gv_magical_sv) from the code that actually creates
them (gv_fetchpvn_flags). ‘Maintained’ is not actually precise: it
*wasn’t* being maintained, and there were new variables that never
got added to is_gv_magical_sv and one deleted variable that was
never removed.
There are only two pieces of code that call is_gv_magical_sv, both in
pp.c: S_rv2gv (called by *{} and also the implicit *{} that functions
like close() provide) and Perl_softrefxv (called by ${}, @{}, %{}).
In both cases, the glob is immediately autovivified if
is_gv_magical_sv returns true.
So this commit eliminates the extra maintenance burden by extirpat-
ing is_gv_magical_sv altogether, and replacing it with a new flag to
gv_fetchpvn_flags, GvADDMG, which will autovivify a glob *if* it’s a
magical one.
It does make defined(*{"frobbly"}) slightly slower, in that it creates
a temporary glob and then frees it when it sees nothing magical has
been done with it. But this case is rare enough it should not matter.
At least I got rid of the bugginess.
|
|
|
|
|
|
| |
This commit allows &CORE::write to be called through references and
via ampersand syntax. No change to pp_enterwrite was necessary, as it
can already handle nulls.
|
|
|
|
|
|
|
|
|
|
|
| |
This commit allows &CORE::unpack to be called through references and
via ampersand syntax.
It moves the $_-handling code in pp_coreargs inside the parameter
loop, so it can apply to the second parameter, not just the first.
Consequently, a mkdir test has been added that ensures implicit $_
is not used for mkdir’s second argument; i.e., that the $_-handling
code’s if() condition is correct.
|
|
|
|
|
|
|
|
| |
This commit allows &CORE::umask to be called through references and
via ampersand syntax. pp_umask 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 umask how many arguments it’s
actually getting. See commit 0163043a for details.
|
|
|
|
|
|
|
| |
This commit allows the tie, tied and untie subroutines in the CORE
namespace to be called through references and via &ersand() syntax.
pp_coreargs is modified to handle the functions with \[$@%*] in their
prototypes (which happen to be just the tie functions).
|
|
|
|
|
|
|
|
| |
This commit allows &CORE::tell to be called through references and
via ampersand syntax. pp_tell 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_tell how many arguments it’s
actually getting. See commit 0163043a for details.
|
|
|
|
|
|
|
|
| |
This commit allows &CORE::setpgrp to be called through references and
via ampersand syntax. pp_setpgrp 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 setpgrp how many arguments it’s
actually getting. See commit 0163043a for details.
|
|
|
|
|
| |
Prior to this commit, setpgrp(27) was equivalent to (27, setpgrp),
because it ignored the argument on the stack when there was only one.
|
| |
|
|
|
|
|
|
|
|
| |
8ca8a454f60a417f optimised the implementation of s///r by avoiding an
unconditional copy of the original value. However, it introduced a behaviour
regression where if original value happened to be one of a few particular
types, it could be modified by being forced to a string using SvPV_force().
The substitution was (correctly) performed on a copy of this string.
|
| |
|
|
|
|
|
|
|
|
| |
This commit allows &CORE::sysopen to be called through references and
via ampersand syntax. pp_sysopen 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 sysopen how many arguments it’s
actually getting. See commit 0163043a for details.
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This commit makes &CORE::substr callable through references and via
&ersand 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.)
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
| |
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.)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This commit allows CORE::select to be called through references and
via &ersand 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.
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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 &ersand 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.
|
| |
|
|
|
|
|
|
|
|
| |
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
&ersand() calls. So this commits renames coresubs.t to coreamp.t
and coreinline.t to coresubs.t.
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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 $_.
|