Father Chrysostomos [Thu, 11 Aug 2016 06:59:07 +0000]
[perl #24342] Mortalize elems in array slice
Father Chrysostomos [Mon, 8 Aug 2016 20:45:10 +0000]
[perl #22312] Mortalize elems in array assignment
Father Chrysostomos [Mon, 1 Aug 2016 05:46:17 +0000]
[perl #8358] Mortalize pkg ary elems on stack
and also those returned by any array dereference, since it’s the same
op (rv2av).
This also apparently fixes:
#18489
but slows things down and uses more memory.
Father Chrysostomos [Fri, 29 Jul 2016 05:28:52 +0000]
[perl #3451] Mortalize lex ary elems on stack
This also fixes perl #104074.
Karl Williamson [Mon, 8 Aug 2016 17:00:03 +0000]
perlop: Clarify tr/// casing statement
Karl Williamson [Mon, 8 Aug 2016 16:03:32 +0000]
perlop: Fix important typo
The text is saying don't mix case, and this typo was mixing case.
Chris 'BinGOs' Williams [Mon, 8 Aug 2016 12:00:30 +0000]
Update Archive-Tar to CPAN version 2.10
[DELTA]
2.10 27/07/2016 (TONYC)
- CVE-2016-1238: avoid loading optional modules from default .
Chris 'BinGOs' Williams [Mon, 8 Aug 2016 11:58:53 +0000]
Fix M::CL version
Chris 'BinGOs' Williams [Mon, 8 Aug 2016 11:56:21 +0000]
Update IPC-Cmd to CPAN version 0.96
[DELTA]
0.96 Thu Jul 28 11:17:12 BST 2016
Bug fixes:
* Require Module::Load::Conditional 0.66 to resolve
CVE-2016-1238: avoid loading optional modules from default .
David Mitchell [Mon, 8 Aug 2016 11:35:55 +0000]
Document -DDEBUGGING better
RT #128671 and http://nntp.perl.org/group/perl.perl5.porters/238127.
In particular, perlhacktips and perlrun contained out-of-date information
that setting -g would automatically set DEBUGGING too.
I've also improved the description of -DDEBUGGING in INSTALL, and
tried to make it clearer when the text is referring to the Configure
switch -DDEBUGGING and when to the C compiler switch -DDEBUGGING.
Chris 'BinGOs' Williams [Mon, 8 Aug 2016 11:12:30 +0000]
Update ExtUtils-MakeMaker to CPAN version 7.22
[DELTA]
7.22 Mon Aug 8 09:29:02 BST 2016
No changes since 7.21_01
7.21_01 Sun Aug 7 10:37:53 BST 2016
Bug fixes:
- CVE-2016-1238: instmodsh sanitise @INC
7.20 Fri Aug 5 09:39:56 BST 2016
No changes since 7.19_08
7.19_08 Thu Jul 28 12:31:13 BST 2016
Bug fixes:
- CVE-2016-1238: avoid loading VMS::Feature from the default .
7.19_07 Sun Jul 3 15:11:40 BST 2016
Bug fixes:
- Restore ordering issue involving OTHERLDFLAGS
7.19_06 Mon Jun 27 12:32:06 BST 2016
Test fixes:
- Skip subdirscomplex test on VMS
7.19_05 Mon Jun 20 15:21:52 BST 2016
Doc fixes:
- fix typos and add subdirs text to MakeMaker.pm
7.19_04 Tue Jun 14 11:16:19 BST 2016
Bug fixes:
- prevent EUMM::Locale from warning with old Win32.pm
Doc fixes:
- added examples for running tests in subdirs
7.19_03 Mon Jun 13 14:22:46 BST 2016
Bug fixes:
- Fix test warnings in MM_Unix.pm when in core
7.19_02 Mon Jun 13 09:57:37 BST 2016
Bug fixes:
- Check for ascii locale using normalized name
7.19_01 Thu Jun 2 14:26:20 BST 2016
Bug fixes:
- Cygwin: avoid libperl.dll.dll.a
- Fix basic.t tests on Win32 in core
David Mitchell [Mon, 8 Aug 2016 10:31:13 +0000]
perldelta for OP_SIGELEM work
Steve Hay [Mon, 8 Aug 2016 07:30:49 +0000]
Upgrade libnet from version 3.09_01 to 3.10
Lukas Mai [Mon, 8 Aug 2016 01:09:54 +0000]
INCMARK is a statement now; don't cast it
Father Chrysostomos [Sun, 7 Aug 2016 22:53:40 +0000]
Unify mark macros
Use static inline functions to avoid having different code paths
for GCC and non-GCC. INCMARK is unused on CPAN and only used as
a statement in core, so it can become a statement.
Karl Williamson [Sun, 7 Aug 2016 00:55:23 +0000]
perlvar: Emphasize that $] has unchanged behavior forever
Also add a link
Shlomi Fish [Sat, 2 Apr 2016 22:43:37 +0000]
Correct spelling errors: lib/unicore/mktables
All tests appear to pass. I hereby disclaim any explicit or implicit
ownership of my changes and place them under the
public-domain/CC0/X11L/same-terms-as-Perl/any-other-license-of-your-choice
multi-license.
Thanks to Vim's ":help spell" for helping a lot.
James E Keenan [Sat, 13 Feb 2016 01:36:25 +0000]
Document that return value of pos(), by default, expresses characters.
When 'use bytes' is in effect, the return value expresses bytes.
Revise documentation and add some tests exemplifying this.
On recommendation of Jason Gibson.
For: RT # 127518
Father Chrysostomos [Sat, 6 Aug 2016 04:28:39 +0000]
toke.c: Clarify comment
Karl Williamson [Fri, 5 Aug 2016 22:47:03 +0000]
handy.h: Clarify comment
Karl Williamson [Fri, 5 Aug 2016 22:46:28 +0000]
Improve isOCTAL() definition
This potentially saves a branch
Karl Williamson [Fri, 5 Aug 2016 20:19:31 +0000]
APItest: Add tests for isOCTAL
James E Keenan [Fri, 5 Aug 2016 23:43:47 +0000]
Note upgrade of NEXT to version 0.67.
Neil Bowers [Fri, 5 Aug 2016 23:42:15 +0000]
Update NEXT to CPAN version 0.67.
Karl Williamson [Fri, 5 Aug 2016 18:50:43 +0000]
t/op/tr.t: Fix to pass in EBCDIC
I forgot to do this in
3a34ca0bce7835211b45e070373cf653c253636a
Karl Williamson [Thu, 4 Aug 2016 20:07:53 +0000]
PATCH: [perl #128738] Large code pt as string delim
The bug here is simply an I32 was used when an IV was needed.
One could argue that there should be that the parser should refuse to
accept something larger than an IV. I chose not to do that, as this is
a deprecated usage, which generates a warning by default and will be a
syntax error anyway in a future release.
Father Chrysostomos [Fri, 5 Aug 2016 18:28:08 +0000]
XSLoader Makefile.PL: Note a possible pitfall
Karen Etheridge [Fri, 5 Aug 2016 17:16:40 +0000]
add "provides" metadata for XSLoader (RT#138836)
This avoids confusing tools like cpanm and carton which use 'provides'
metadata, and are not able to infer the correct data here because
XSLoader_pm.PL is used to generate XSLoader.pm, but then XSLoader.pm is
deleted before cpanm can see it.
Father Chrysostomos [Fri, 5 Aug 2016 07:30:02 +0000]
Consistent spaces after dots in perldiag
Father Chrysostomos [Fri, 5 Aug 2016 07:18:51 +0000]
Sort perldiag
Father Chrysostomos [Fri, 5 Aug 2016 07:09:10 +0000]
AUTHORS: consistent indent
Father Chrysostomos [Fri, 5 Aug 2016 07:06:21 +0000]
Rmv duplicate AUTHORS entry for Stéphane Payrard
Father Chrysostomos [Fri, 5 Aug 2016 07:02:05 +0000]
Remove duplicate Mark Fisher AUTHORS entry
Father Chrysostomos [Fri, 5 Aug 2016 07:00:46 +0000]
AUTHORS: some sorting
Father Chrysostomos [Fri, 5 Aug 2016 06:24:18 +0000]
Add Chris Travers to AUTHORS
Father Chrysostomos [Fri, 5 Aug 2016 06:23:09 +0000]
[perl #128769] Improve base.pm @INC . message
The new version is based on one written by Chris Travers, polished
up a bit by yours truly.
Father Chrysostomos [Fri, 5 Aug 2016 00:45:42 +0000]
gv.c:require_tie_mod: Create namesv only when needed
We only need it as an SV when we are going to load a module. We can-
not share the SV with Perl_load_module, is ck_require mangles it
("Errno" → "Errno.pm"). The other uses of the SV are unnecessary, as
we have pv interfaces available.
Father Chrysostomos [Thu, 4 Aug 2016 21:29:48 +0000]
Rationalise gv.c:gv_magicalize
This code is confusing, and confusion has resulted in bugs. So rework
the code a bit to make it more comprehensible.
gv_magicalize no longer has such an arcane return value. What it does
now is simply add appropriate magic to (or do appropriate vivification
in) the GV passed as its argument. It returns true if magic or vivi-
fication was applicable.
The caller (gv_fetchpvn_flags) uses that return value to determine
whether to install the GV in the symbol table, if the caller has
requested that a symbol only be added if it is a magical one
(GV_ADDMG).
This reworking does mean that the GV is now checked for content even
when it would make no difference, but I think the resulting clarity
(ahem, *relative* clarity) of the code is worth it.
James E Keenan [Thu, 4 Aug 2016 22:47:15 +0000]
Revert "gv.c:require_tie_mod: Create namesv only when needed"
This reverts commit
e167a7177da799ca1757dc382b386abd3ae29491.
Observed to cause many test failures on Linux and FreeBSD. See message on
list with subject "Many test failures in blead".
Father Chrysostomos [Thu, 4 Aug 2016 21:09:57 +0000]
gv.c:require_tie_mod: Create namesv only when needed
We only need it as an SV when we are going to load a module. Also,
there is no need for two separate SVs; we can use the same one for
Perl_load_module as we use subsequently in gv_stashsv.
Father Chrysostomos [Thu, 4 Aug 2016 20:59:32 +0000]
gv.c: comment typeo
Father Chrysostomos [Thu, 4 Aug 2016 20:55:41 +0000]
gv.c:require_tie_mod: Accept pvn params
All the callers create the SV on the fly. We might as well put the
SV creation into the function itself. (A forthcoming commit will
refactor things to avoid the SV when possible.)
Daniel Dragan [Thu, 4 Aug 2016 05:37:46 +0000]
#126041 preserve systemroot env var during env wipe for Win32 in magic.t
This fixes a test fail with VC 2005 on WinXP in magic.t. See perl #126041
for an example of the failure. Systemroot env var is required on WinXP to
load SXS tracked DLLs, VC 2005 and 2008's MS libc's are SXS tracked
(before and after are not), so once %ENV is wipe and systemroot is deleted
the require Win32; cant load the XS DLL because the XS DLL is linked
against the SXS tracked libc specific to 2005/2008.
Father Chrysostomos [Thu, 4 Aug 2016 20:17:32 +0000]
[perl #126041] Only clear LS_COLORS for glob
When miniperl calls csh to implement glob(), we clear %ENV temporarily
to avoid csh dying on invalid values for things like LS_COLORS. That
has proven to have far too many problems, since many system-dependent
env vars are necessary for calling an external process. See the RT
ticket for details.
A better solution is temporarily to clear only those vars that are
known to be problematic and make csh possibly fail. There only hap-
pens to be one of those at present, namely LS_COLORS.
Father Chrysostomos [Thu, 4 Aug 2016 20:06:12 +0000]
Increase $Errno::VERSION to 1.26
Father Chrysostomos [Thu, 4 Aug 2016 20:05:41 +0000]
Increase $Tie::Hash::NamedCapture::VERSION to 0.10
Father Chrysostomos [Thu, 4 Aug 2016 20:05:06 +0000]
Increase $arybase::VERSION to 0.12
Father Chrysostomos [Thu, 4 Aug 2016 20:00:18 +0000]
Rework mod loading for %- and %!; fix mem leak
There are many built-in variables that perl creates on demand for
efficiency’s sake. gv_fetchpvn_flags (which is responsible for sym-
bol lookup) will fill in those variables automatically when add-
ing a symbol.
The special GV_ADDMG flag passed to this function by a few code paths
(such as defined *{"..."}) tells gv_fetchpvn_flags to add the symbol,
but only if it is one of the ‘magical’ built-in variables that we pre-
tend already exist.
To accomplish this, when the GV_ADDMG flag is passed,
gv_fetchpvn_flags, if the symbol does not already exist, creates a new
GV that is not attached to the stash. It then runs it through its
magicalization code and checks afterward to see whether the GV
changed. If it did, then it gets added to the stash. Otherwise, it
is discarded.
Three of the variables, %-, %!, and $], are problematic, in that they
are implemented by external modules. gv_fetchpvn_flags loads those
modules, which tie the variable in question, and then control is
returned to gv_fetchpvn_flags. If it has a GV that has not been
installed in the symbol table yet, then the module will vivify that GV
on its own by a recursive call to gv_fetchpvn_flags (with the GV_ADD
flag, which does none of this temporary-dangling-GV stuff), and
gv_fetchpvn_flags will have a separate one which, when installed,
would clobber the one with the tied variable.
We solved that by having the GV installed right before calling the
module, for those three variables (in perl 5.16).
The implementation changed in commit v5.19.3-437-g930867a, which was
supposed to clean up the code and make it easier to follow. Unfortun-
ately there was a bug in the implementation. It tries to install the
GV for those cases *before* the magicalization code, but the logic is
wrong. It checks to see whether we are adding only magical symbols
(addmg) and whether the GV has anything in it, but before anything has
been added to the GV. So the symbol never gets installed. Instead,
it just leaks, and the one that the implementing module vivifies
gets used.
This leak can be observed with XS::APItest::sv_count:
$ ./perl -Ilib -MXS::APItest -e 'for (1..10){ defined *{"!"}; delete $::{"!"}; warn sv_count }'
3833 at -e line 1.
4496 at -e line 1.
4500 at -e line 1.
4504 at -e line 1.
4508 at -e line 1.
4512 at -e line 1.
4516 at -e line 1.
4520 at -e line 1.
4524 at -e line 1.
4528 at -e line 1.
Perl 5.18 does not exhibit the leak.
So in this commit I am finally implementing something that was dis-
cussed about the time that v5.19.3-437-g930867a was introduced. To
avoid the whole problem of recursive calls to gv_fetchpvn_flags vying
over whose GV counts, I have stopped the implementing modules from
tying the variables themselves. Instead, whichever gv_fetchpvn_flags
call is trying to create the glob is now responsible for seeing that
the variable is tied after the module is loaded. Each module now pro-
vides a _tie_it function that gv_fetchpvn_flags can call.
One remaining infelicity is that Errno mentions $! in its source, so
*! will be vivified when it is loading, only to be clobbered by the
GV subsequently installed by gv_fetch_pvn_flags. But at least it
will not leak.
One test that failed as a result of this (in t/op/magic.t) was try-
ing to undo the loading of Errno.pm in order to test it afresh with
*{"!"}. But it did not remove *! before the test. The new logic in
the code happens to work in such a way that the tiedness of the vari-
able determines whether the module needs to be loaded (which is neces-
sary, now that the module does not tie the variable). Since the test
is by no means normal code, it seems reasonable to change it.
Father Chrysostomos [Wed, 3 Aug 2016 20:53:40 +0000]
Use parser, not PL_parser, in perly.y
The code snippets in perly.y are #included in a C function that has a
‘parser’ local variable. Local variables require less machine code
(especially under threads).
Father Chrysostomos [Wed, 3 Aug 2016 20:46:34 +0000]
parser.h: comment typo
Father Chrysostomos [Wed, 3 Aug 2016 20:34:16 +0000]
Finish reordering the parser struct (again!)
This is meant to be a more correct version of
d64e121b07.
Father Chrysostomos [Wed, 3 Aug 2016 20:31:06 +0000]
Revert "Um, finish reordering the parser struct"
This reverts commit
d64e121b07bda895f7f3a5d0e449fc948986e2f1.
It contained stupid blunders. See
<
20160803202545[email protected]>.
David Mitchell [Thu, 4 Aug 2016 10:47:02 +0000]
remove most 'a' flags from embed.fnc
From: http://nntp.perl.org/group/perl.perl5.porters/237910:
In embed.fnc, we mark about 80 functions with the a flag, which we
document as meaning:
: a Allocates memory a la malloc/calloc. Also implies "R":
:
: proto.h: add __attribute__malloc__
Now, the current gcc docs for the malloc attribute states:
This tells the compiler that a function is malloc-like, i.e., that the
pointer P returned by the function cannot alias any other pointer
valid when the function returns, and moreover no pointers to valid
objects occur in any storage addressed by P.
Using this attribute can improve optimization. Functions like malloc
and calloc have this property because they return a pointer to
uninitialized or zeroed-out storage. However, functions like realloc
do not have this property, as they can return a pointer to storage
containing pointers.
This implies to me that we should only flag functions as 'a' if both:
1) it returns a pointer to memory that isn't pointed to from elsewhere;
2) that the block of memory itself contains no pointers.
I think we are failing condition (2) for many 'a' functions; for example
the op.c newXXXOP() functions return an alloced op struct (condition 1
probably satisfied), but which contain pointers (condition 2 fails).
David Mitchell [Wed, 3 Aug 2016 19:55:39 +0000]
[MERGE] add OP_ARGELEM etc
this branch:
* moves the parsing of subroutine signatures into perly.y rather than
using a custom mini-parser in toke.c;
* adds 3 new ops, OP_ARGELEM, OP_ARGDEFELEM, OPARGCHECK to handle
the checking and processing of subroutine arguments;
* fixes up Deparse.pm to handle the new ops and to handle
'use feature "signatures"' better.
David Mitchell [Mon, 1 Aug 2016 16:20:27 +0000]
silence compiler warning in perly.y
assigning a char from an I32 gives a warning. Add an explicit cast
as we know the int only ever holds a char.
David Mitchell [Mon, 1 Aug 2016 11:41:06 +0000]
Deparse.pm - avoid deep recursion warning
also add some basic descriptions to a few functions.
David Mitchell [Mon, 1 Aug 2016 11:08:09 +0000]
enable warnings+strict in t/op/signatures.t
David Mitchell [Mon, 1 Aug 2016 10:41:42 +0000]
duplicate signature vars gave wrong warning
RT #128719. This:
sub f ($x, $x) {}
gave
"state" variable $x masks earlier declaration in same scope
This commit changes that to '"my" variable'
David Mitchell [Mon, 1 Aug 2016 10:06:14 +0000]
peephole optimise op_other branch in OP_ARGDEFELEM
I forgot to do this earlier.
David Mitchell [Thu, 28 Jul 2016 09:18:26 +0000]
pessimise pp_argelem, pp_argdefelem
These two ops assumed that, since they occur at the start of a
function, weird tricks with goto and closures can't be used to
cause the new lexical vars to already have a value, so the assign code
can be simpler and quicker than that found in pp_sassign and pp_aassign.
However Father Chrysostomos demonstrated that this wasn't the case,
using e.g. code that does strange things in signature default expressions.
In particular we can not assume:
* that scalar lexicals will be undef
* that array and hash lexicals will be empty
* that lexicals and @_ can't be magical or tied;
* that @_ remains unchanged (especially in relation to its number of
elements)
* that there are no common elements, since with aliases and closures,
my @a = @_ can be equivalent to my @a = (...); @a = ($a_[0],...)
So this commit removes the short-cuts, and for aggregates, if the
new lexical array or hash may be non-empty, makes a copy of each @_
element first.
It is intended in the near future that normal runs of OP_ARGELEM
will be replaced by OP_SIGNATURE, which will be able to do a better job of
knowing when its safe to optimise.
David Mitchell [Mon, 25 Jul 2016 11:24:39 +0000]
signatures: make param and optional param count IV
During the course of parsing end exection, these values get stored
as ints and UVs, then used as SSize_t.
Standardise on IVs instead. Technically they can never be negative, but
their final use is as indices into AVs, which is SSize_t, so it's
easier to standardise on a signed value throughout.
David Mitchell [Mon, 25 Jul 2016 10:37:37 +0000]
ucfirst() new signature diagnostic messages
e.g.
a slurpy parameter may not have a default value
=>
A slurpy parameter may not have a default value
Also, split the "Too %s arguments for subroutine" diagnostic into
separate "too few" and "too many" entries in perldiag.
Based on suggestions by Father Chrysostomos.
David Mitchell [Fri, 22 Jul 2016 20:26:44 +0000]
more pruning of Porting/deparse-skips.txt
In the summary output of
cd t; ./perl TEST -deparse
it doesn't distinguish between test scripts expected to pass that fail,
and those expected to fail that succeed. They're all listed as failures.
So I've just removed 5 further entries from deparse-skips.txt that I
hadn't noticed were passing. I don't know when they first started
unexpectedly passing.
It's down to 78 unexpected failures now. Not good, since a couple of
years ago there were no unexpected failures, but at least its down from
the 194 at the start of this branch. The entries in deparse-skips.txt
have also reduced by about 28 over the course of this branch.
David Mitchell [Fri, 22 Jul 2016 17:25:08 +0000]
deparse subroutine signatures
If 'use feature "signatures"' is in scope, deparse subs using the
sub foo ($a,$b) { ... }
syntax rather than
sub foo {
my $a = $_[0];
my $b = $_[0];
...
}
Only do this where the sequence of OP_SIGCHECK and OP_SIGELEM etc ops
make up a consistent signature. Otherwise (e.g. someone's modified
it with a parser hook), fall back to 'my $a = $_[0]' syntax.
David Mitchell [Fri, 22 Jul 2016 13:24:33 +0000]
fix deparsing of Test::More's use_ok()
Code like
BEGIN {use_ok 'Net::Ping'};
got deparsed as:
BEGIN {use_ok 'Net::Ping'};
use Net::Ping (@{$args[0];});
This is due to the tricks it plays faking up and evaling a use statement.
This commit filters out these spurious 'use's in the Deparse output.
With this commit, 109 'TEST -deparse' tests that were expected to pass
but had been failing for some time, now pass; and 22 tests that were
expected to fail, now pass.
I also removed the entry for lib/Switch/t/ in Porting/deparse-skips.txt,
since Switch is no longer bundled.
David Mitchell [Fri, 22 Jul 2016 12:12:17 +0000]
OP_MULTIDEREF: remove ghost entry in op_aux list
In the case where a multideref expression ends with an index that initially
looks simple (e.g. const or var) but turns out to be complex, the code
which optimises a sequence of aelem etc into a single multideref backs off
from including that last index expression in the multideref, but still
allocates a slot in the op_aux array for that ghost index.
For example in
$expr->{foo}[0][1+$x]
it allocates a slot for the "1" constant but then doesn't use it.
This isn't an issue for multideref itself, but when running Deparse or
otherwise inspecting the op tree, the $op->aux_list() method returns a
list of the elements of the op_aux array with an extra garbage element at
the end, which can cause Deparse to crash.
David Mitchell [Fri, 22 Jul 2016 11:19:03 +0000]
fix up exists etc deparsing
a general multideref expression like
exists +($r//{})->{foo}
was being deparsed without the '+', meaning it was being interpreted
as
(exists ($r//{}))->{foo}
David Mitchell [Fri, 22 Jul 2016 09:08:50 +0000]
handle deparsing of sub prototypes with sigs
when 'use feature "signatures"' is in scope, subroutine prototypes
should be deparsed as ':prototype($$)' rather than '($$)'
I've also tweaked the sub in question slightly to make adding
signature deparsing easier later on.
David Mitchell [Thu, 21 Jul 2016 14:11:50 +0000]
Deparse: emit pragmas *before* each sub
Before deparsing a sub, emit any pragma changes associated with the
first nextstate in the sub *before* emitting the sub itself.
So this:
use strict;
sub f { ...}
doesn't get deparsed as
sub f { use strict; ...}
There was already a partial fix for this in pp_nextstate. Making
next_todo() always emit pragmas catches more cases and makes pp_nextstate
simpler.
This is in preparation for deparsing 'use feature "signatures"'.
David Mitchell [Thu, 21 Jul 2016 13:21:01 +0000]
Deparse: use more local vars in next_todo()
assign @$ent to some local vars rather than directly using $ent->[2] etc:
makes the code more self-documenting.
Should be no functional changes.
David Mitchell [Thu, 21 Jul 2016 13:01:17 +0000]
Deparse: move pragma deparsing into separate sub
Currently this is done in pp_nextstate(). Move it out into a separate
method called pragmata() so in the next commit it can be used elsewhere.
Should be no functional changes.
David Mitchell [Wed, 20 Jul 2016 16:31:00 +0000]
deparse pragmas before subs
Currently something like this:
use strict;
sub f {
print;
}
print;
deparses as:
sub f {
use strict;
print $_;
}
use strict;
print $_;
(Note where the 'strict's appear). Although ugly, this is semantically
correct for most pragmas. However, it breaks down for "use feature
'signatures'", since that needs to appear before the sub if the
deparsing of the sub's header is altered to reflect signature syntax or
not, based on whether the pragma is in scope.
This commit changes the deparsing of each nextstate op so that it outputs
any pragmas which reflect changes since the last nextstate's hints etc,
*before* deparsing any subs whose COP is less than that of the new
nextstate. After this commit, the code above deparses as:
use strict;
sub f {
print $_;
}
print $_;
It also allows some hacky code to be removed from Deparse.pm that
ensured that "no warnings experimental::lexical_subs" appeared before
each lexical sub was deparsed.
[ This fix is not comprehensive; a fuller fix comes in a few commits time ]
David Mitchell [Sat, 9 Jul 2016 09:41:08 +0000]
add OP_ARGELEM, OP_ARGDEFELEM, OP_ARGCHECK ops
Currently subroutine signature parsing emits many small discrete ops
to implement arg handling. This commit replaces them with a couple of ops
per signature element, plus an initial signature check op.
These new ops are added to the OP tree during parsing, so will be visible
to hooks called up to and including peephole optimisation. It is intended
soon that the peephole optimiser will take these per-element ops, and
replace them with a single OP_SIGNATURE op which handles the whole
signature in a single go. So normally these ops wont actually get executed
much. But adding these intermediate-level ops gives three advantages:
1) it allows the parser to efficiently generate subtrees containing
individual signature elements, which can't be done if only OP_SIGNATURE
or discrete ops are available;
2) prior to optimisation, it provides a simple and straightforward
representation of the signature;
3) hooks can mess with the signature OP subtree in ways that make it
no longer possible to optimise into an OP_SIGNATURE, but which can
still be executed, deparsed etc (if less efficiently).
This code:
use feature "signatures";
sub f($a, $, $b = 1, @c) {$a}
under 'perl -MO=Concise,f' now gives:
d <1> leavesub[1 ref] K/REFC,1 ->(end)
- <@> lineseq KP ->d
1 <;> nextstate(main 84 foo:6) v:%,
469762048 ->2
2 <+> argcheck(3,1,@) v ->3
3 <;> nextstate(main 81 foo:6) v:%,
469762048 ->4
4 <+> argelem(0)[$a:81,84] v/SV ->5
5 <;> nextstate(main 82 foo:6) v:%,
469762048 ->6
8 <+> argelem(2)[$b:82,84] vKS/SV ->9
6 <|> argdefelem(other->7)[2] sK ->8
7 <$> const(IV 1) s ->8
9 <;> nextstate(main 83 foo:6) v:%,
469762048 ->a
a <+> argelem(3)[@c:83,84] v/AV ->b
- <;> ex-nextstate(main 84 foo:6) v:%,
469762048 ->b
b <;> nextstate(main 84 foo:6) v:%,
469762048 ->c
c <0> padsv[$a:81,84] s ->d
The argcheck(3,1,@) op knows the number of positional params (3), the
number of optional params (1), and whether it has an array / hash slurpy
element at the end. This op is responsible for checking that @_ contains
the right number of args.
A simple argelem(0)[$a] op does the equivalent of 'my $a = $_[0]'.
Similarly, argelem(3)[@c] is equivalent to 'my @c = @_[3..$#_]'.
If it has a child, it gets its arg from the stack rather than using $_[N].
Currently the only used child is the logop argdefelem.
argdefelem(other->7)[2] is equivalent to '@_ > 2 ? $_[2] : other'.
[ These ops currently assume that the lexical var being introduced
is undef/empty and non-magival etc. This is an incorrect assumption and
is fixed in a few commits' time ]
David Mitchell [Thu, 14 Jul 2016 09:47:01 +0000]
make op.c:S_alloc_LOGOP() non-static
This is principally so that it can be accessed from perly.y too.
David Mitchell [Thu, 28 Jan 2016 15:14:57 +0000]
sub signatures: use parser rather than lexer
Currently the signature of a sub (i.e. the '($a, $b = 1)' bit) is parsed
in toke.c using a roll-your-own mini-parser. This commit makes
the signature be part of the general grammar in perly.y instead.
In theory it should still generate the same optree as before, except
that an OP_STUB is no longer appended to each signature optree: it's
unnecessary, and I assume that was a hangover from early development of
the original signature code.
Error messages have changed somewhat: the generic 'Parse error' has
changed to the generic 'syntax error', with the addition of ', near "xyz"'
now appended to each message.
Also, some specific error messages have been added; for example
(@a=1) now says that slurpy params can't have a default vale, rather than
just giving 'Parse error'.
It introduces a new lexer expect state, XSIGVAR, since otherwise when
the lexer saw something like '($, ...)' it would see the identifier
'$,' rather than the tokens '$' and ','.
Since it no longer uses parse_termexpr(), it is no longer subject to the
bug (#123010) associated with that; so sub f($x = print, $y) {}
is no longer mis-interpreted as sub f($x = print($_, $y)) {}
Father Chrysostomos [Wed, 3 Aug 2016 13:36:24 +0000]
Um, finish reordering the parser struct
Follow-up to
25e092d6d, which left some gaping holes. I committed it
too soon.
Father Chrysostomos [Wed, 3 Aug 2016 07:17:58 +0000]
Reorder parser struct for alignment
We still have a 16-bit hole, which I have noted. There’s no point in
moving the two U8s near the end of the struct (lex_fakeeof and lex_flags)
to fill that hole, as we would just have a bigger hole at the end.
Father Chrysostomos [Wed, 3 Aug 2016 06:58:52 +0000]
Empty sublex_info into the parser struct
sublex_info is never validly copied or set* all at once and no pointer
is ever taken to it. It seems to be left over from the time when
PL_sublex_info was a global variable. (Indeed, the struct is still
defined in perl.h, an odd place for something used only by parser.h.)
It will be easier to eliminate alignment holes in the parser struct if
we just empty it out.
* The one instance of sublex_info being copied, in
sv.c:Perl_parser_dup, ended up potentially sharing an SV between
threads, which is a no-no. I say potentially, because I can’t see how
it could be non-null during thread cloning, which would have to happen
between sublex_start and sublex_push.
Father Chrysostomos [Wed, 3 Aug 2016 06:26:46 +0000]
parser.h: Remove lex_expect
In commit
8f0d8652cd, I mentioned that PL_parser->lex_expect is
still assigned to by Data::Alias. That is no longer the case as
of Data::Alias 1.19. So there is no need to keep this member
around.
Father Chrysostomos [Wed, 3 Aug 2016 00:57:52 +0000]
parser.h: Make nexttoke a U8
As mentioned in the commit message for
a2867f88735d4, this can
only contain numbers from 0 to 5.
Karl Williamson [Sun, 31 Jul 2016 09:34:47 +0000]
locale.c: Add some DEBUG statements
This also involves moving some complicated debugging statements to a
separate function so that it can be called from more than one place
Karl Williamson [Sun, 31 Jul 2016 09:26:33 +0000]
locale.c: Use %zu to print size_t values.
Previously these were printed with %"UVuf", but not all parameters were
cast to a UV, thus causing problems on certain platforms and
configurations. All these were in DEBUG statements.
Karl Williamson [Tue, 26 Jul 2016 20:09:46 +0000]
locale.c: Some systems include NUL in strxfrm() return
strxfrm() is supposed to not include the trailing NUL in the length
returned, but we have run into a Windows system that does include it
(some Windows ones don't), so test for and compensate for this
possibility.
Karl Williamson [Wed, 3 Aug 2016 01:21:43 +0000]
locale.c: White-space only
This indents code that the previous commit formed a block around, and a
couple of other white-space changes to fit in a terminal-sized window.
Karl Williamson [Tue, 26 Jul 2016 19:35:18 +0000]
locale.c: Improve embedded NUL collation handling
When collating a Perl string that contains NUL characters, these are
replaced by the lowest collating non-NUL control. However, if something
goes wrong with the calculation, until this commit \001 is arbitrarily
used. But \001 is likely to be one of the characters that didn't work,
so we shouldn't arbitrarily choose it. Instead, what this commit does
is to repeat the calculation a second time, allowing any character, not
just controls. If that fails, something is seriously wrong, and an
error is returned. This will cause the comparison that called this
function to fall back to using a raw string compare, instead of locale
collation.
Also, previously an empty transformed string was considered an error,
but that actually should be allowable. This commit also changes a
similar finding of the highest collating character to not error on an
empty string, and to return an error if no such character is found.
Also, some comments were deleted that suggested that all this might not
be necessary. But since those were written, real world experience shows
that it is.
And finally, debug outputting the transformation of the found
replacements is deleted, as these come from a recursive call, and the
transformation will have already been output in that call.
Karl Williamson [Mon, 1 Aug 2016 21:32:33 +0000]
sv.c: Use raw cmp if error in locale collation
Prior to this commit, if there is an error in the generation of locale
collation information for a string, the string would always sort before
any string that had no such error. That's suboptimal, as it throws away
information. It would be better to fall back to using a raw compare
between the operands, as is already done for other errors in the
comparison process. And that is what this commit does.
Normally this doesn't come up, but it can if there is a buggy locale
implementation of the libc function strxfrm(), or if memory was at the
edge and got exhausted by this operation.
This was discovered on an HP machine which doesn't work properly for
UTF-8 locales in its current configuration. I've added the output of
perl -V of it in case someone ever wants to look at it, and I lazily
used the whole thing so as to not omit something crucial.
Summary of my perl5 (revision 5 version 25 subversion 4) configuration:
Derived from:
863ca36a1db803bdd82e88ef0e862696379ba681
Platform:
osname=hpux
osvers=11.23
archname=PA-RISC2.0-thread-multi-64int-ld
uname='hp-ux p5p-hpux b.11.23 u 9000800
701987621 unlimited-user license '
config_args='-des -Uversiononly -Dprefix=/home/khw/devel -Dusedevel -D'optimize=-ggdb3' -A'optimize=-ggdb3' -A'optimize=-O0' -Accflags='-DPERL_BOOL_AS_CHAR' -Accflags='-DPERL_EXTERNAL_GLOB' -Dman1dir=none -Dman3dir=none -DDEBUGGING -Dusemorebits -Dusethreads -Accflags='-Werror=declaration-after-statement' -Accflags='-DNO_MATHOMS''
hint=recommended
useposix=true
d_sigaction=define
useithreads=define
usemultiplicity=define
use64bitint=define
use64bitall=undef
uselongdouble=undef
usemymalloc=n
bincompat5005=undef
Compiler:
cc='cc'
ccflags =' -D_POSIX_C_SOURCE=199506L -D_REENTRANT -Ae -D_HPUX_SOURCE -Wl,+vnocompatwarnings -DPERL_BOOL_AS_CHAR -DPERL_EXTERNAL_GLOB -Werror=declaration-after-statement -DNO_MATHOMS -DDEBUGGING -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 '
optimize=' -ggdb3 '
cppflags='-Aa -D__STDC_EXT__ -D_HPUX_SOURCE -D_POSIX_C_SOURCE=199506L -D_REENTRANT -Ae -D_HPUX_SOURCE -Wl,+vnocompatwarnings -DPERL_BOOL_AS_CHAR -DPERL_EXTERNAL_GLOB -Werror=declaration-after-statement -DNO_MATHOMS -DDEBUGGING -I/usr/local/include'
ccversion='B.11.11.22'
gccversion=''
gccosandvers=''
intsize=4
longsize=4
ptrsize=4
doublesize=8
byteorder=
87654321
doublekind=4
d_longlong=define
longlongsize=8
d_longdbl=define
longdblsize=16
longdblkind=2
ivtype='long long'
ivsize=8
nvtype='double'
nvsize=8
Off_t='off_t'
lseeksize=8
alignbytes=8
prototype=define
Linker and Libraries:
ld='/usr/bin/ld'
ldflags =' -L/usr/local/lib'
libpth=/usr/local/lib /lib /usr/lib /usr/ccs/lib
libs=-lcl -lpthread -lnsl -lndbm -ldb -lmalloc -lm -lcrypt -lsec -lc
perllibs=-lcl -lpthread -lnsl -lmalloc -lm -lcrypt -lsec -lc
libc=/lib/libc.sl
so=sl
useshrplib=false
libperl=libperl.a
gnulibc_version=''
Dynamic Linking:
dlsrc=dl_hpux.xs
dlext=sl
d_dlsymun=undef
ccdlflags='-Wl,-E -Wl,-B,deferred '
cccdlflags='+Z'
lddlflags='-b +vnocompatwarnings -L/usr/local/lib'
Characteristics of this binary (from libperl):
Compile-time options:
DEBUGGING
HAS_TIMES
MULTIPLICITY
NO_MATHOMS
PERLIO_LAYERS
PERL_BOOL_AS_CHAR
PERL_COPY_ON_WRITE
PERL_DONT_CREATE_GVSV
PERL_EXTERNAL_GLOB
PERL_HASH_FUNC_ONE_AT_A_TIME_HARD
PERL_IMPLICIT_CONTEXT
PERL_MALLOC_WRAP
PERL_OP_PARENT
PERL_PRESERVE_IVUV
PERL_TRACK_MEMPOOL
PERL_USE_DEVEL
USE_64_BIT_INT
USE_ITHREADS
USE_LARGE_FILES
USE_LOCALE
USE_LOCALE_COLLATE
USE_LOCALE_CTYPE
USE_LOCALE_NUMERIC
USE_LOCALE_TIME
USE_PERLIO
USE_PERL_ATOF
USE_REENTRANT_API
Locally applied patches:
uncommitted-changes
Built under hpux
Compiled at Aug 1 2016 22:44:23
%ENV:
PERL5OPT="-w"
PERL_POD_PEDANTIC="1"
@INC:
/perl/usr/khw/perl/cc_working/lib
/home/khw/devel/lib/perl5/site_perl/5.25.4/PA-RISC2.0-thread-multi-LP64-ld
/home/khw/devel/lib/perl5/site_perl/5.25.4
/home/khw/devel/lib/perl5/5.25.4/PA-RISC2.0-thread-multi-LP64-ld
/home/khw/devel/lib/perl5/5.25.4
.
Karl Williamson [Mon, 1 Aug 2016 21:45:11 +0000]
lib/locale.t: Better debug output
This output an array that was hopefully sorted, but the function it
calls sorts things itself, so the array looked sorted even if it
weren't.
Karl Williamson [Mon, 1 Aug 2016 21:41:13 +0000]
lib/locale.t: Add note() function, for future use
Karl Williamson [Mon, 1 Aug 2016 03:46:05 +0000]
utf8.h: Add comment clarification
Karl Williamson [Wed, 20 Jul 2016 22:06:08 +0000]
perlapi: Add a clarification.
Father Chrysostomos [Tue, 2 Aug 2016 05:07:07 +0000]
MANIFEST description typo
James E Keenan [Tue, 2 Aug 2016 02:34:22 +0000]
Correct 3 bad email addresses for 'perlbug'.
For: RT #128808
Father Chrysostomos [Tue, 2 Aug 2016 04:59:57 +0000]
[perl #128769] base.pm: Localize @INC unconditionally
As Zefram pointed out in
<https://rt.perl.org/Ticket/Display.html?id=128769#txn-1414015>,
having inconsistent behaviour is going to cause more problems
than solves.
Karl Williamson [Tue, 26 Jul 2016 19:28:51 +0000]
lib/locale.t: Clarify debug output
Father Chrysostomos [Mon, 1 Aug 2016 02:21:02 +0000]
[perl #128740] Check for null in pp_ghostent et al.
Specifically in the S_space_join_names_mortal static function that
several pp functions call. On some platforms (such as Gentoo Linux
with torsocks), hent->h_aliases (where hent is a struct hostent *) may
be null after a gethostent call.
Dan Collins [Thu, 14 Jul 2016 01:50:28 +0000]
[RT #128574] Missed one incorrect usage of fresh_perl_
Dan Collins [Mon, 11 Jul 2016 02:05:40 +0000]
[RT #128574] Fix use of fresh_perl in tests
Tony Cook [Mon, 1 Aug 2016 01:37:39 +0000]
(perl #128685) generate dependency rules for perlmain$(OBJ_EXT)
Without these rules changes to files like config.sh might not
result in perlmain.o being rebuilt.
Aristotle Pagaltzis improved this.
Father Chrysostomos [Sun, 31 Jul 2016 21:02:31 +0000]
MANIFEST typo
Sorry for the smoke.
Father Chrysostomos [Sun, 31 Jul 2016 20:51:36 +0000]
[perl #128769] Improve base.pm @INC '.' handling
• Localise @INC only if necessary.
• Don’t mention '.' in the @INC list in the error message, since it
was not in the @INC that was searched (this is accomplished by local-
ising @INC in the same scope as the error).
• If a file exists that would have been loaded had '.' not been
ignored, mention it and suggest ‘use lib’.
• Use the same number of closing as opening parentheses in the
error message.