This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
David Mitchell [Wed, 24 May 2017 15:29:16 +0000 (16:29 +0100)]
Perl_sv_vcatpvfn_flags: add %n code comment
point out thngs like "%-4.5n" don't currently warn
David Mitchell [Wed, 24 May 2017 15:09:25 +0000 (16:09 +0100)]
Perl_sv_vcatpvfn_flags: make %n missing arg fatal
Normally sprintf et al just warn if there aren't enough args; but since %n
wants to write the current string length to the next arg, make it fatal.
Formerly it would croak anyway, but with a spurious "Modification of a
read-only value" error as it as it tried to set &PL_sv_no
David Mitchell [Wed, 24 May 2017 14:58:06 +0000 (15:58 +0100)]
Perl_sv_vcatpvfn_flags: comment %n deficiency
This should be fixed sometime:
/* XXX if sv was originally non-utf8 with a char in the
* range 0x80-0xff, then if it got upgraded, we should
* calculate char len rather than byte len here */
David Mitchell [Sat, 20 May 2017 15:01:26 +0000 (16:01 +0100)]
Perl_sv_vcatpvfn_flags: skip IN_LC(LC_NUMERIC)
In a couple of places it does
if (PL_numeric_radix_sv && IN_LC(LC_NUMERIC)) { ... }
But PL_numeric_radix_sv is set to NULL unless we have a non-standard
radix point (i.e. not "."), and this can only happen when we're in the
scope of 'use locale'. So the IN_LC() should be a redundant (and
expensive) test. Replace it with an assert.
David Mitchell [Sat, 20 May 2017 14:51:31 +0000 (15:51 +0100)]
Perl_sv_vcatpvfn_flags: set locale at most once
Calls to external snprintf-ish functions or that directly access
PL_numeric_radix_sv are supposed to sandwich this access within
STORE_LC_NUMERIC_SET_TO_NEEDED();
....
RESTORE_LC_NUMERIC();
The code in Perl_sv_vcatpvfn_flags() seems to have gotten a bit confused
as to whether its trying to only set STORE_LC_NUMERIC_SET_TO_NEEDED()
once, then handle one of more %[aefh] format elements, then only
restore on exit. There is code at the end of the function which says:
RESTORE_LC_NUMERIC(); /* Done outside loop, so don't have to save/restore
each iteration. */
but in practice various places within this function (and its helper
function S_format_hexfp() inconsistently repeatedly do
STORE_LC_NUMERIC_SET_TO_NEEDED(); and sometime do RESTORE_LC_NUMERIC().
This commit changes it so that STORE_LC_NUMERIC_SET_TO_NEEDED() is called
at most once, the first time a % format involving a radix point is
encountered, and does RESTORE_LC_NUMERIC(); exactly once at the end of the
function.
Note that while calling STORE_LC_NUMERIC_SET_TO_NEEDED() multiple times
is harmless, its quite expensive, as each time it has to check whether
it's in the scope of 'use locale'. RESTORE_LC_NUMERIC() is cheap if
STORE_LC_NUMERIC_SET_TO_NEEDED() earlier determined that there was nothing
to do.
David Mitchell [Sat, 20 May 2017 12:01:02 +0000 (13:01 +0100)]
Perl_sv_vcatpvfn_flags: remove redundant code
At the start of the function, it marks the output as being utf8 if the
first arg is utf8. But this should be taken care of when the individual
args (including the first one are processed). So its redundant code.
In fact it would sometimes cause the resultant string to be unnecessarily
upgraded to utf8, e.g.:
my $precis = "9";
utf8::upgrade($precis);
my $s = sprintf "%.*f\n", $precis, 1.1;
# whoops, $s is now utf8
David Mitchell [Sat, 20 May 2017 11:07:23 +0000 (12:07 +0100)]
Perl_sv_vcatpvfn_flags: remove "%.Ng" special-case
This function has special-case handling for the formats "%.0f" and
"%.NNg", to speed things up. This special-casing appears twice,
once near the top of the function for where the format matches exactly
"%.0f" or "%.Ng" (N is 1..99), and once again in the main loop of the
function, where it handles those format elements embedded in the larger
format: "....%.0f..." and "....%.Ng..." (N > 0).
The problem with the "%.Ng" code is that it isn't as robust as the more
general "....%.Ng..." code - in particular the latter checks for a
locale-dependent radix-point when determining needed buffer size.
This commit removes the "%.Ng" special-cased code but leaves the
"....%.Ng..." special-cased code. It makes the former about 7% slower
compared to the situation at the start of this branch. (Part of the effort
in this branch has been to make the "....%.Ng..." code faster, so that
there's less of an overall performance hit by removing "%.Ng").
David Mitchell [Fri, 19 May 2017 15:15:31 +0000 (16:15 +0100)]
Perl_sv_vcatpvfn_flags: handle %.NNNg case earlier
In the main loop, we look for %.NNNg and handle it specially.
Change it so that the special-case is only used when precis is small
enough to that it fits in the local ebuf[] rather than the malloced
PL_efloatbuf. This allows the check for this special case to be done
earlier with less redundant calculations.
David Mitchell [Fri, 19 May 2017 14:45:51 +0000 (15:45 +0100)]
Perl_sv_vcatpvfn_flags: use quick concat for %.0f
Most floating-point formats now use the quick concat path. But the
"%.0f" shortcut was accidentally bypassing that path. This commit fixes
that.
David Mitchell [Thu, 18 May 2017 11:47:51 +0000 (12:47 +0100)]
Perl_sv_vcatpvfn_flags: simplify concat of f/p str
Since floating-point formats do their own formatting and padding, skip the
block of code at the end of the main loop which handles appending eptr to
sv, and do our own stripped-down version.
David Mitchell [Thu, 18 May 2017 10:44:17 +0000 (11:44 +0100)]
Perl_sv_vcatpvfn_flags: s/gconverts/Gconvert's/
fix a comment, so that a search for the word 'Gconvert' gets a match.
So that a later comment 'See earlier comment about buggy Gconvert' makes
sense.
David Mitchell [Thu, 18 May 2017 10:32:27 +0000 (11:32 +0100)]
Perl_sv_vcatpvfn_flags: tighten hexfp var scope
Only have the 'hexfp' var declared within the innermost scope it is
actually needed for.
David Mitchell [Thu, 18 May 2017 10:17:32 +0000 (11:17 +0100)]
Perl_sv_vcatpvfn_flags: rename 'is_simple' var
the definition of 'simple' required the format to have a precision.
David Mitchell [Thu, 18 May 2017 10:03:28 +0000 (11:03 +0100)]
Perl_sv_vcatpvfn_flags: move pod closer
Several static functions etc had been added between the pod and the
main function. Move the pod to be just above it.
Also incorporate a comment into the pod about utf8ness of pattern and SV
needing to match.
David Mitchell [Thu, 18 May 2017 09:45:56 +0000 (10:45 +0100)]
Perl_sv_vcatpvfn_flags: eliminate utf8buf[] var
%c for a >255 char generates its utf8 byte representation and stores it in
thiis temporarly buffer:
U8 utf8buf[UTF8_MAXBYTES+1]
But we already have another temporary buffer, ebuf, for creating floating
point strings, which is big enough. So use that instead.
David Mitchell [Thu, 18 May 2017 09:37:42 +0000 (10:37 +0100)]
Perl_sv_vcatpvfn_flags: reorganise loop vars
There are a big chunk of local vars declared at the top of the main loop.
Reorder the declarations to group similar vars together, and add a comment
to each var explaining what its for.
No functional changes.
David Mitchell [Thu, 18 May 2017 08:49:08 +0000 (09:49 +0100)]
Perl_sv_vcatpvfn_flags: move vars to inner scope
Add a new scope around the floating-point code, then move some
locals var declarations into that scope.
David Mitchell [Thu, 18 May 2017 08:41:15 +0000 (09:41 +0100)]
Perl_sv_vcatpvfn_flags: extract hex f/p code
There is a large block of code (nearly 300 lines) in
Perl_sv_vcatpvfn_flags(), which handles the %a/%A hexadecimal
floating-point format. Move it into new static function,
S_format_hexfp().
No functional changes.
David Mitchell [Thu, 18 May 2017 08:03:20 +0000 (09:03 +0100)]
Perl_sv_vcatpvfn_flags: move some macros earlier
There are some macro definitions in the body of Perl_sv_vcatpvfn_flags()
which handle some possible differences between double and long double.
Move these to before the function as they will shortly need to be visible
to a new helper function. At the same time, prefix their names with with
VCATPVFN_ to make clear what they're for.
For the same reason I've also added a new typedef, vcatpvfn_long_double_t.
I also eliminated the FV_ISFINITE macro definition as its no longer used.
David Mitchell [Wed, 17 May 2017 12:36:27 +0000 (13:36 +0100)]
remove HAS_LDBL_SPRINTF_BUG code
This code was added in 2002 to work round an Irix 6 rounding bug in
long double sprintfs.
I strongly suspect that any such OS bug has long been fixed and/or such
machines have been retired or are unlikely to have new perls installed on
them.
Part of the motivation for removing this code is that following the
previous commit, that block of code's use of the float_need variable
is likely to be wrong (since it now includes exponent etc), but I have no
way of testing it.
I've left the probe code in hints/irix_6.sh, so if anyone ever reports
sprintf.t failures on an old Irix platform, perl -V should show if their
system still has the bug. At that point someone brave could resurrect this
block of code.
David Mitchell [Wed, 17 May 2017 11:27:18 +0000 (12:27 +0100)]
Perl_sv_vcatpvfn_flags: better calc f/p buf size
How it works out the needed buffer size for the various floating point
formats is a bit opaque. This commit extensively documents and
rationalises the process. In particular it will no longer allocate a very
large buffer for %g printing a large number (%g switches to %e style
format rather than %f in cases like this). Also it no longer relies on a
+40 fudge factor to accommodate exponents - this is now factored in
properly.
It still includes a +20 safety fudge factor for production builds, but
this is disabled under DEBUGGING so that ASAN and the like are likely to
more quickly spot issues during development.
David Mitchell [Tue, 16 May 2017 15:30:13 +0000 (16:30 +0100)]
sprintf: handle sized int-ish formats with Inf/Nan
The code path taken when int-ish formats saw an Inf/Nan was to jump to the
floating-point handler, but then that would warn about (valid) size
qualifiers. For example before:
$ perl -we'printf "[%hi]\n", Inf'
Invalid conversion in printf: "%hi" at -e line 1.
Redundant argument in printf at -e line 1.
[%hi]
$
After this commit:
$ perl -we'printf "[%hi]\n", Inf'
[Inf]
$
It also makes the code simpler.
David Mitchell [Tue, 16 May 2017 07:53:19 +0000 (08:53 +0100)]
Perl_sv_vcatpvfn_flags: handle Inf/Nan in 1 place
At the start of the float section, check whether the value if Inf/Nan
and handle directly. This stops later blocks of code having to test for it
too. Also simplify the formatting of Inf/Nan - let the general code at the
end of the block do any pre/post padding.
David Mitchell [Mon, 15 May 2017 17:59:54 +0000 (18:59 +0100)]
Perl_sv_vcatpvfn_flags: sort PL_numeric_radix_sv
Under locales the radix point may not be just a simple '.' but a Unicode
string like "\N{ARABIC DECIMAL SEPARATOR}". Currently the hex f/p code
explicitly takes account of the length of this string when calculating the
buffer length, but the other branches don't - they just rely on the
"add 40 fudge factor" to protect them.
Instead, handle its length for all branches, and simplify utf8 handling.
Currently it checks post-format whether the radix point was utf8, and if
so marks the resulting buffer as utf8. Instead, check for utf8-ness at the
same time we check for length.
This new approach doesn't check whether the resulting string actually
contains the radix point string, so in principle the string could be
marked utf8 but not have any >127 chars. I think this is harmless.
David Mitchell [Mon, 15 May 2017 19:42:12 +0000 (20:42 +0100)]
Perl_sv_vcatpvfn_flags() split %.0f and %.Ng
The format elements "%.0f" and "%.NNNg" are handled specially in the main
loop. Split the code block which handles them and process %.0f earlier. It
doesn't need to allocate a variable-length buffer or worry about the
length of the radix string.
David Mitchell [Mon, 15 May 2017 13:49:50 +0000 (14:49 +0100)]
S_F0convert(): remove Nan/Inf handling
This function handles sprintf "%.0f". It also handles Inf/Nan, but neither
of its callers will call it with such an nv. Its code for handling them is
also broken - it returns the \0 following the "Inf" or "Nan! string.
So just remove this unneeded and broken functionality.
At the same time document what S_F0convert() does.
David Mitchell [Mon, 15 May 2017 12:54:17 +0000 (13:54 +0100)]
Perl_sv_vcatpvfn_flags: fix arg to SNPRINTF_G()
One of the callers of SNPRINTF_G() passes 'size' as its third arg - but
there is no such variable. This code happens only to be used in the
!USE_QUADMATH branch, and the SNPRINTF_G macro only uses that arg under
USE_QUADMATH. So it doesn't matter. But replace 'size' with 'sizeof(ebuf)'
in case that changes in future.
David Mitchell [Mon, 15 May 2017 11:51:56 +0000 (12:51 +0100)]
Perl_sv_vcatpvfn_flags: reduce scope of local var
fix_ldbl_sprintf_bug is only used in one block of code so declare it in
that block.
Given that that block is only compiled under HAS_LDBL_SPRINTF_BUG,
which seems only to be for some obscure Irix issues from 2002,
I haven't actually tested this.
David Mitchell [Mon, 15 May 2017 10:59:49 +0000 (11:59 +0100)]
use SvCUR(PL_numeric_radix_sv) not SvLEN()
When determining the length of buffer needed to output the decimal point
in the current locale, use SvCUR(PL_numeric_radix_sv) rather than
SvLEN(PL_numeric_radix_sv). I presume this was a thinko in the original
commit. Using SvLEN currently seems harmless, since typically SvCUR <
SvLEN, but one could conceive a future scenario where locale info is set
using alien string buffers with SvLEN(sv) == 0.
David Mitchell [Thu, 11 May 2017 08:06:05 +0000 (09:06 +0100)]
Perl_sv_vcatpvfn_flags: reindent block
whitespace only
David Mitchell [Thu, 11 May 2017 08:00:30 +0000 (09:00 +0100)]
Perl_sv_vcatpvfn_flags: reduce scope of 'int i'
Declare an 'i' var wherever needed for local use, rather than being in
scope for 1600 lines.
David Mitchell [Wed, 10 May 2017 16:23:51 +0000 (17:23 +0100)]
Perl_sv_vcatpvfn_flags: get rid of an (int) cast
harmless in this case, but there really shouldn't be (int) casts
on string length and ptr diff calculations
David Mitchell [Wed, 10 May 2017 15:58:58 +0000 (16:58 +0100)]
Perl_sv_vcatpvfn_flags: calc (width - elen) once
There's a couple of blocks of code which repeat the expression
(width - elen). Calculate this once at the top. This makes it slightly
easier to audit the code for signed/unsigned wrap etc.
Should be no functional change.
David Mitchell [Wed, 10 May 2017 15:17:18 +0000 (16:17 +0100)]
Perl_sv_vcatpvfn_flags: avoid 1-byte buf overrun
This only occurs on the "%a" (hex) format, and only happens when
processing a denormalised value whose bit pattern is 0xf....f or similar,
and when rounding up it needs to insert a '1' at the head of the number
and shift the rest of the digits down one.
In practice this never seems to happen - the top nybble of a denormalised
float value always seems to be 0x1 (presumably because that's implicit) so
there's never any carry to a higher digit. Maybe other platforms do it
differently.
Also VHEX_SIZE seems to be rounded up, so in practice there's no overrun.
But better safe than sorry.
David Mitchell [Wed, 10 May 2017 14:27:49 +0000 (15:27 +0100)]
Perl_sv_vcatpvfn_flags: avoid a potential wrap
In the floating-point hex (%a) code, it checks whether the requested
precision is smaller than the hex buf size. It does this by casting
(precis + 1) to signed. Since precis can be any user-supplied value,
this can wrap. Instead, cast the (buffer_length - 1) to unsigned, since
this is bounded to a small constant value > 1.
In practise this makes no difference currently, as a large precis will
have caused a malloc panic earlier anyway. But that might change in
future.
David Mitchell [Wed, 10 May 2017 13:03:25 +0000 (14:03 +0100)]
Perl_sv_vcatpvfn_flags: simplify an expression
In the hex floating/point code, (subnormal ? vfnz : vhex) is equivalent to
v0, which we just set to the same value.
So keep things simple.
David Mitchell [Wed, 10 May 2017 10:19:38 +0000 (11:19 +0100)]
sprintf(): handle mangled formats better with utf8
Currently if sprintf() detects an error in the format while processing
a %.... entry, it copies the bytes as-is from the % to the point the
error was detected, then continues, If the output string and format string
don't have the same utf8-ness, this can result in badly-formed utf8
output.
This commit changes the code so that it just appends a '%' then restarts
processing from the character following the %. Most of the time this just
again results with the characters following the % being output as-is,
expect this time the 'normal' character-copying code path is taken, which
handles utf8 mismatches correctly.
By doing this, it also removes a block of code which contained a "roll
your own" string appender which used SvGROW() and Copy(). This was one
further place which was potentially open to wrapping and block overrun
bugs.
This commit may cause occasional changes in behaviour, depending on
whether there are any further '%' characters within the bad section of the
format. Now these will be reprocessed, possibly triggering further
'Invalid conversion' type warnings.
David Mitchell [Tue, 9 May 2017 14:55:07 +0000 (15:55 +0100)]
Perl_sv_vcatpvfn_flags: simplify wrap checking
The main SvGROW() has a new-length arg roughly equivalent to
(SvCUR(sv) + elen + zeros + esignlen + dotstrlen + 1);
Rationalise the overflow/wrap checking by doing each individual addition
separately with its own check. This is slightly redundant as some of the
values are interdependent, but this way it's easier to see whether all
possible overflows are being checked for.
`
David Mitchell [Tue, 9 May 2017 14:32:49 +0000 (15:32 +0100)]
Perl_sv_vcatpvfn_flags: reduce scope of 'gap' var
shouldn't make any functional difference
David Mitchell [Tue, 9 May 2017 14:29:25 +0000 (15:29 +0100)]
Perl_sv_vcatpvfn_flags: reindent a block of code
(whitespace-only change)
indent a chunk of code ready for the next commit.
David Mitchell [Tue, 9 May 2017 13:48:59 +0000 (14:48 +0100)]
Perl_sv_vcatpvfn_flags: reduce scope of 'have' var
Just declare this var in the small block where its needed, rather than
being in scope for 500+ lines.
Should be no functional changes.
David Mitchell [Tue, 9 May 2017 13:36:40 +0000 (14:36 +0100)]
Perl_sv_vcatpvfn_flags: split the 'need' local var
The 'need' local var has a wide scope (over 500 lines), and is used for
two separate purposes. Split it into two separate vars. One remains wide
scope, but is just used to calculate the new value of PL_efloatsize. Rename
that one to 'float_need'.
For the second use, introduce a new scope of just 6 lines with its own
'need' variable'.
This should make no functional difference but makes the code slightly
easier to understand and analyse.
David Mitchell [Tue, 9 May 2017 13:29:11 +0000 (14:29 +0100)]
sprintf(): add memory wrap tests
In various places Perl_sv_vcatpvfn_flags() does croak_memory_wrap()
(including a couple added by the previous commit to fix RT #131260),
but there don't appear to be any tests for them.
So this commit adds some tests.
Steve Hay [Wed, 7 Jun 2017 07:39:20 +0000 (08:39 +0100)]
Fix dmake build breakage when using Visual C++
This was introduced by commit
1f664ef531. dmake with VC++ is not a common
combination, but I should have tested it :-(
Tony Cook [Wed, 7 Jun 2017 05:17:44 +0000 (15:17 +1000)]
perldelta for
1097da16b21f
Tony Cook [Wed, 7 Jun 2017 05:00:26 +0000 (15:00 +1000)]
[perl #131263] clear the UTF8 flag on a glob if it isn't UTF8
Previously sv_2pv_flags() would set the UTF8 flag on a glob if it
had a UTF8 name, but wouldn't clear tha flag if it didn't.
This meant a name change, eg. if assigned another glob, from a UTF8
name to a non-UTF8 name would leave the flag set.
Tony Cook [Thu, 1 Jun 2017 05:11:27 +0000 (15:11 +1000)]
[perl #131221] improve duplication of :via handles
Previously duplication (as with open ... ">&...") would fail
unless the user supplied a GETARG, which wasn't documented, and
resulted in an attempt to free and unreferened scalar if supplied.
Cloning on thread creation was simply broken.
We now handle GETARG correctly, and provide a useful default if it
returns nothing.
Cloning on thread creation now duplicates the appropriate parts of the
parent thread's handle.
Abigail [Tue, 6 Jun 2017 23:27:47 +0000 (01:27 +0200)]
Fatalize the use of code points above 0xFF for bitwise operators.
This commit removes quite a number of tests, mostly from t/op/bop.t,
which test the behaviour of such code points in combination of
bitwise operators. Since it's now fatal, the tests are no longer useful.
Lukas Mai [Tue, 6 Jun 2017 23:00:58 +0000 (01:00 +0200)]
enforce size constraint via STATIC_ASSERT, not just a comment
Lukas Mai [Tue, 6 Jun 2017 22:55:34 +0000 (00:55 +0200)]
rename STATIC_ASSERT_GLOBAL to STATIC_ASSERT_DECL
There's nothing that stops you from using it in a local scope and doing
so can be useful occasionally.
I believe this change in names is harmless because there are no direct
users of STATIC_ASSERT_GLOBAL in core or on CPAN; they all go through
STATIC_ASSERT_STMT.
Abigail [Tue, 6 Jun 2017 21:16:30 +0000 (23:16 +0200)]
Fatalize inheriting AUTOLOAD for non-methods.
This was deprecated in 5.004.
Lukas Mai [Tue, 6 Jun 2017 21:01:35 +0000 (23:01 +0200)]
buildtoc: explicitly accept -q (RT #131520)
Normally the default behavior of Getopt::Long is to enable auto_abbrev,
which allows '--quiet' to be spelled as '-q', but not when
POSIXLY_CORRECT is set:
$ POSIXLY_CORRECT=1 make
...
./perl -Ilib -I. -f pod/buildtoc -q
Unknown option: q
pod/buildtoc: Usage: pod/buildtoc [--quiet]
make: *** [makefile:405: pod/perltoc.pod] Error 255
Abigail [Tue, 6 Jun 2017 18:59:59 +0000 (20:59 +0200)]
Remove B::OP:terse
This method was deprecated, and, according to the comments, didn't
work correctly anyway.
Abigail [Tue, 6 Jun 2017 18:00:04 +0000 (20:00 +0200)]
Abigail [Tue, 6 Jun 2017 17:50:47 +0000 (19:50 +0200)]
Remove diag entry about comma-less format variable list.
Commit
c7321345b8729a0b98040be0b0b96e41f6a13ba8 removed accepting
comma-less format variables, so this entry can go.
Abigail [Tue, 6 Jun 2017 17:40:11 +0000 (19:40 +0200)]
Out of range Unicode code point is now fatal.
Followup on
13f4dd346e6f3b61534a20f246de3a80b3feb743. This commit patch
pod/perldiag, to change the "Use of code point 0x%s is deprecated"
deprecation message into the "Use of code point 0x%s is not allowed"
fatal error.
Adjusted the wording of the description accordingly.
Abigail [Tue, 6 Jun 2017 16:51:37 +0000 (18:51 +0200)]
Forbid out of range Unicode code points.
Unicode allows code points up to 0x10FFFF, but Perl allows much more.
However, code points above IV_MAX may not always work correctly, and
may even cause the interpreter to hang. Code points exceeding IV_MAX
have been deprecated since 5.24, and will be illegal in 5.28.
This commit removes many tests (without replacing them) as they were
testing behaviour of code points exceeding IV_MAX.
Thomas Sibley [Tue, 6 Jun 2017 12:11:58 +0000 (13:11 +0100)]
[PATCH] corelist: Provide access to info on utilities via Module::CoreList::Utils
Signed-off-by: Chris 'BinGOs' Williams <chris@bingosnet.co.uk>
David Mitchell [Mon, 5 Jun 2017 16:14:15 +0000 (17:14 +0100)]
Porting/bench.pl: typo in error message
David Mitchell [Mon, 5 Jun 2017 15:45:32 +0000 (16:45 +0100)]
remove -DH (DEBUG_H) misfeature
RT# 129300
This hash-dumping debugging flag corrupted hash values and has probably
not been used by anyone in 20 years.
David Mitchell [Mon, 5 Jun 2017 15:36:08 +0000 (16:36 +0100)]
sv.c: move some pod blocks
The S_sv_uncow() definition, and a forward declaration of it, both get
between some pod and the function that pod describes. Move the pod around
a bit to be next their functions.
David Mitchell [Fri, 6 Jan 2017 14:59:54 +0000 (14:59 +0000)]
make OP_REF support boolean context
RT #78288
When ref() is used in a boolean context, it's not necessary to return
the name of the package which an object is blessed into; instead a simple
truth value can be returned, which is faster.
Note that it has to cope with the subtlety of an object blessed into the
class "0", which should return false.
Porting/bench.pl shows for the expression !ref($r), approximately:
unchanged for a non-reference $r
doubling of speed for a reference $r
tripling of speed for a blessed reference $r
This commit builds on the mechanism already used to set the OPpTRUEBOOL
and OPpMAYBE_TRUEBOOL flags on padhv and rv2hv ops when used in boolean
context.
Dagfinn Ilmari Mannsåker [Thu, 1 Jun 2017 16:33:15 +0000 (17:33 +0100)]
Forbid setting $/ to a reference to a non-postive integer
This used to work like setting it to 'undef', but has been deprecated
since Perl 5.20.
In passing, avoid duplicate duplicate uninitialized warning by reusing
the SvIV() result already stored in 'val'.
Dagfinn Ilmari Mannsåker [Fri, 2 Jun 2017 09:45:32 +0000 (10:45 +0100)]
Fix inconsistent whitespace in mg.c
A handful of assignments are lacking a space on the left-hand side,
which is not consistent with the rest of the project style
(perlstyle mandates «Space around most operators»).
Also, a comment was mis-aligned.
Dagfinn Ilmari Mannsåker [Fri, 2 Jun 2017 14:47:02 +0000 (15:47 +0100)]
Forbid use of bare << to mean <<""
It has ben deprecated since perl 5.000.
Dagfinn Ilmari Mannsåker [Fri, 2 Jun 2017 16:30:22 +0000 (17:30 +0100)]
Disallow opening the same symbol as both a file and directory handle
This has been deprecated since Perl 5.10
Chris 'BinGOs' Williams [Mon, 5 Jun 2017 13:13:36 +0000 (14:13 +0100)]
Update ExtUtils-Install to CPAN version 2.14
[DELTA]
2.14
- Fix tests for when perl path contains a space
2.12
- Fix win32 check
2.10
- 'make -s' support: set $INSTALL_QUIET automatically
2.08
- Optimisations:
* use our instead of vars
* lazy load modules
* make OS variables into constants
* move some calculations out of a loop
2.06
- Removed instructions using Build.PL from README
- Load Win32API::File for _move_file_at_boot only when needed
- Allow disabling autosplit by omitting autosplit dir
David Mitchell [Mon, 5 Jun 2017 14:33:42 +0000 (15:33 +0100)]
closure.t: fix typo
David Mitchell [Mon, 5 Jun 2017 14:32:10 +0000 (15:32 +0100)]
perldata.pod: clarify hash in scalar context.
RT ##131166
David Mitchell [Mon, 22 Aug 2016 08:50:43 +0000 (09:50 +0100)]
FREETMPS when leaving eval, even when void/dying
[ This commit was originally added as v5.25.2-77-g214949f then reverted
by v5.25.2-89-gcc040a9, since it broke Variable::Magic. That distribution
has since been fixed, so this fix can be re-applied to blead ]
When a scope is exited normally (e.g. pp_leavetry, pp_leavesub),
we do a FREETMPS only in scalar or list context; in void context
we don't bother for efficiency reasons. Similarly, when there's an
exception and we unwind to (and then pop) an EVAL context, we haven't
been bothering to FREETMPS.
The problem with this in try/eval (exiting normally or via an exception)
is that it can delay some SVs getting freed until *after* $@ has been
set. If that freeing calls a destructor which happens to set $@,
then that overwrites the "real" value of $@.
For example
sub DESTROY { eval { die "died in DESTROY"; } }
eval { bless []; };
is ($@, "");
Before this commit, that test would fail because $@ is "died in DESTROY".
This commit ensures that leaving an eval/try by whatever means always
clears the tmps stack before setting $@.
See http://nntp.perl.org/group/perl.perl5.porters/237380.
For now, I haven't added a FREETMPS to the other pp_leavefoo()
void context cases, since I can't think of a case where it would
matter.
David Mitchell [Tue, 14 Mar 2017 09:19:15 +0000 (09:19 +0000)]
S_require_tie_mod(): use a new stack
RT #130861
This function is used to load a module associated with various magic vars,
like $[ and %+. Since it can be called 'unexpectedly', it should use a new
stack. The issue in this ticket was equivalent to
my $var = '[';
$$var;
where the symbolic dereference triggered a run-time load of arybase.pm,
which grew the stack, invalidating the SP in pp_rv2sv.
Note that most of the stuff which S_require_tie_mod() calls, such as
load_module(), will do its own PUSHSTACK(); but S_require_tie_mod() also
does a bit of stack manipulation itself.
The test case includes a magic number, 125, which happens to be the exact
size necessary to trigger a stack realloc in S_require_tie_mod(). In later
perl versions this value may well change. But it seemed too expensive
to call fresh_perl_is() 100's of times with different values of $n.
This commit also adds a SPAGAIN to pp_rv2sv on the 'belt and braces'
principle.
This commit is based on an earlier effort by Aaron Crane.
David Mitchell [Mon, 5 Jun 2017 13:33:09 +0000 (14:33 +0100)]
[MERGE] lots of Deparse.pm fixups
As of this point,
./TEST -deparse op/delete.t
passes all tests (that are no on its exclude list)/
David Mitchell [Mon, 5 Jun 2017 13:29:51 +0000 (14:29 +0100)]
Deparse: support delete %h{foo bar}
Key/value slicing was recently extended to delete too. Make Deparse
support this.
David Mitchell [Mon, 27 Feb 2017 08:45:08 +0000 (08:45 +0000)]
Porting/deparse-skips.txt: add failing tests
Add the 27 currently unexpected failing tests to the 'known failing' list
in deparse-skips.txt. These most likely represent newer or modified test
scripts which tickle existing Deparse issues rather than regressions in
Deparse, but I haven't examined them to check.
By adding them in, we're kind of resetting the clock - perhaps in future
we won't allow new failures to appear.
There are now 174 known failing scripts out of 2555. At the start of this
branch there were 178 known failing and 84 unexpectedly failing scripts.
In 5.24.0 there were 207 known failing and 174 unexpectedly failing scripts.
Also, re-sort the list.
The following were added to to deparse-skips.txt by this commit:
../cpan/Module-Metadata/t/metadata.t
../cpan/Scalar-List-Utils/t/subname.t
../cpan/Scalar-List-Utils/t/uniq.t
../cpan/Term-Cap/test.pl
../cpan/Test-Simple/t/Test2/behavior/run_subtest_inherit.t
../cpan/Test-Simple/t/regression/684-nested_todo_diag.t
../cpan/autodie/t/basic_exceptions.t
../cpan/autodie/t/binmode.t
../cpan/autodie/t/fileno.t
../cpan/autodie/t/mkdir.t
../cpan/autodie/t/read.t
../cpan/autodie/t/truncate.t
../cpan/autodie/t/unlink.t
../cpan/bignum/t/biinfnan.t
../cpan/bignum/t/bninfnan.t
../cpan/bignum/t/brinfnan.t
../dist/Data-Dumper/t/trailing_comma.t
../dist/threads/t/blocks.t
../ext/XS-APItest/t/synthetic_scope.t
../lib/Benchmark.t
../lib/dumpvar.t
mro/basic_01_c3_utf8.t
mro/basic_01_dfs_utf8.t
mro/complex_c3_utf8.t
op/hexfp.t
op/lvref.t
uni/variables.t
David Mitchell [Fri, 24 Feb 2017 20:25:18 +0000 (20:25 +0000)]
purge Porting/deparse-skips.txt
Many excluded files have since been removed, and some have been
renamed. Update Porting/deparse-skips.txt accordingly.
David Mitchell [Fri, 24 Feb 2017 20:15:48 +0000 (20:15 +0000)]
t/TEST: warn about unknown files deparse-skips.txt
In ./TEST -deparse, when reading Porting/deparse-skips.txt, emit a warning
for each excluded file which no longer exists.
Also, move the scope of $in to just the sub that uses it.
David Mitchell [Fri, 24 Feb 2017 20:00:34 +0000 (20:00 +0000)]
deparse-skips.txt: remove cpan/File-Path/t/taint.t
This was fixed a few commits ago, but I forgot to mark it fixed.
David Mitchell [Fri, 24 Feb 2017 17:37:31 +0000 (17:37 +0000)]
deparse-skips.txt: add Archive-Tar/t/03_file.t
This test script uses constant anon subs, which get deparsed back
into real subs and fail; e.g.
use strict;
{ my $x; use constant FOO => sub { $x = 1 }; }
FOO->();
which gets deparsed as
use strict;
{ my $x; use constant FOO => sub { $x = 1 }; }
sub { $x = 1 }->();
and croaks with 'Global symbol "$x" requires explicit package name'
Since the name of the constant ('FOO') has been folded away, there's
no way to correctly deparse this unless more info is saved in the op tree.
David Mitchell [Fri, 24 Feb 2017 17:35:57 +0000 (17:35 +0000)]
sort Porting/deparse-skips.txt
have core test first, then cpan/dist etc. Sort alphabetically
within each category
David Mitchell [Fri, 24 Feb 2017 16:11:34 +0000 (16:11 +0000)]
Deparse: better handle BEGIN { use_ok() }
Commit v5.25.3-111-g8071973 added handling for the bad deparsing of
BEGIN { use_ok() }
Basically by stripping out the bad code text *after* it had been deparsed.
However, this didn't catch all bad cases - in particular, where #line
directives got added:
use Socket (@{
#line 10 "t/000_load.t"
$args[0];});
Under TEST -deparse, this fixes the following unexpectedly failing
scripts:
../cpan/Term-ANSIColor/t/taint/basic.t
../cpan/autodie/t/00-load.t
../dist/Locale-Maketext/t/01_about_verbose.t
../dist/Locale-Maketext/t/10_make.t
../dist/Locale-Maketext/t/20_get.t
../dist/Locale-Maketext/t/40_super.t
../dist/Locale-Maketext/t/50_super.t
../dist/Locale-Maketext/t/60_super.t
../dist/Locale-Maketext/t/70_fail_auto.t
../dist/Locale-Maketext/t/91_backslash.t
../ext/File-Glob/t/taint.t
../ext/Hash-Util/t/Util.t
../lib/DB.t
../lib/File/Basename.t
and fixes the following expected-to-fail script:
../dist/Net-Ping/t/000_load.t
David Mitchell [Fri, 24 Feb 2017 14:32:28 +0000 (14:32 +0000)]
Deparse my var attributes correctly
Formerly this:
my $x :foo;
deparsed as
'attributes'->import('main', \$x, 'foo'), my $x;
it now deparses as:
my $x :foo;
It handles all the common forms, such as
my Foo::Bar ($s, @a, %h) :foo(foo1) bar(bar1);
but doesn't yet handle an attribute declaration that's not a statement,
e.g.
f(1, $x :foo);
Under TEST -deparse, this fixes the following unexpectedly failing
scripts:
../dist/IO/t/io_file_export.t
../dist/IO/t/io_multihomed.t
../dist/IO/t/io_udp.t
../dist/Thread-Queue/t/02_refs.t
../dist/Thread-Semaphore/t/01_basic.t
../dist/Thread-Semaphore/t/04_nonblocking.t
../dist/Thread-Semaphore/t/05_force.t
../dist/Thread-Semaphore/t/06_timed.t
../dist/threads-shared/t/av_refs.t
../dist/threads-shared/t/blessed.t
../dist/threads-shared/t/clone.t
../dist/threads-shared/t/cond.t
../dist/threads-shared/t/dualvar.t
../dist/threads-shared/t/hv_refs.t
../dist/threads-shared/t/object.t
../dist/threads-shared/t/object2.t
../dist/threads-shared/t/shared_attr.t
../dist/threads-shared/t/sv_refs.t
../dist/threads-shared/t/utf8.t
../dist/threads-shared/t/wait.t
../dist/threads-shared/t/waithires.t
../dist/threads/t/err.t
../dist/threads/t/free.t
../dist/threads/t/join.t
../dist/threads/t/kill.t
../dist/threads/t/kill2.t
../dist/threads/t/libc.t
../dist/threads/t/problems.t
../dist/threads/t/state.t
op/threads-dirh.t
and fixes the following expected-to-fail scripts:
../dist/Thread-Queue/t/08_nothreads.t
../dist/threads/t/exit.t
../dist/threads/t/thread.t
op/attrs.t
op/getpid.t
David Mitchell [Thu, 23 Feb 2017 14:33:05 +0000 (14:33 +0000)]
Deparse.pm: handle BEGIN { require expr }
Deparse examines BEGIN subs to see if they look like
BEGIN { require Foo; ... }
and if so deparses them as 'use Foo' instead.
However, it can't cope when Foo is an expression rather than a constant,
such as
BEGIN {
require($ENV{PERL_CORE} ? '../../t/test.pl' : './t/test.pl');
}
and crashes.
This commit makes it instead recognise such op trees as not being part of
a 'use'.
Under TEST -deparse, this fixes the following unexpectedly failing
script:
dist/threads/t/kill3.t
and fixes the following expected-to-fail scripts:
dist/IO/t/io_file_export.t
dist/IO/t/io_multihomed.t
dist/IO/t/io_udp.t
dist/threads/t/err.t
dist/threads/t/kill2.t
dist/threads/t/libc.t
David Mitchell [Thu, 23 Feb 2017 13:41:35 +0000 (13:41 +0000)]
Deparse: avoid deep recursion warning
sub _pessimise_walk_exe() recursively walks the optree, so can easily
exceed a depth of 100.
David Mitchell [Thu, 23 Feb 2017 12:52:09 +0000 (12:52 +0000)]
t/TEST -deparse: list unexpectedly passing scripts
Currently Porting/deparse-skips.txt maintains a list of test scripts
that are expected fail when run after deparsing. If a script unexpectedly
passes, its listed as a failure in the summary at the end of the run.
Make the summary include a list of unexpected passes too to make it
easier to distinguish from failures.
David Mitchell [Thu, 23 Feb 2017 10:53:10 +0000 (10:53 +0000)]
Deparse: don't remove escapes for tabs in patterns
In the following, the T represents a literal tab character.
/\T/ and /\T/x were being deparsed as /T/ and /T/x.
In the particular case of /\T/x that actually changed the pattern's
meaning.
So don't do that: leave the backslashes alone.
This makes
./TEST -deparse t/re/keep_tabs.t
pass.
David Mitchell [Thu, 23 Feb 2017 10:30:42 +0000 (10:30 +0000)]
Deparse: make a complex pattern readable with /x
In sub re_unback().
It shouldn't change its functionality, but just add whitespace
and comments for readability.
David Mitchell [Wed, 22 Feb 2017 16:54:51 +0000 (16:54 +0000)]
Deparse: handle OP_PADRANGE in regex code blocks
Deparse handles the OP_PADRANGE op by overlaying the view of the optree
with the original pad ops (as if they had never been optimised into a
single OP_PADRANGE op).
However, the op treewalk to pessimise such ops wasn't walking into
the op subtrees of code blocks in patterns. So for example
/(?{ my ($x, $y) = @a; })/
was being deparsed (with a warning) as
/(?{ (XXX) = @a; })/
With this commit, this passes again:
./TEST -deparse re/pat_re_eval.t
David Mitchell [Wed, 22 Feb 2017 16:53:50 +0000 (16:53 +0000)]
Deparse.t: diag full code that failed to compile
makes it easier to debug when adding new tests that it doesn't like
David Mitchell [Mon, 5 Jun 2017 11:32:12 +0000 (12:32 +0100)]
make porting/cmp_version.t clearer what happens
Add some code comments, and include the version number its comparing
against in the output.
David Mitchell [Mon, 5 Jun 2017 11:13:20 +0000 (12:13 +0100)]
Module-CoreList/t/maintainer.t: silence warning
../dist/Module-CoreList/t/maintainer.t .. Name
"Module::CoreList::released" used only once: possible typo
Eugen Konkov [Mon, 5 Jun 2017 08:07:54 +0000 (09:07 +0100)]
XPUSH*: reuse code from mPUSH* macros
H.Merijn Brand [Sun, 4 Jun 2017 09:16:09 +0000 (11:16 +0200)]
Entware released perl-5.24.1
James E Keenan [Tue, 23 May 2017 01:25:18 +0000 (21:25 -0400)]
When building with g++ on FreeBSD, explicitly set 'usedl' and 'dlsrc'.
For: https://rt.perl.org/Ticket/Display.html?id=131337
Signed-off-by: James E Keenan <jkeenan@cpan.org>
James E Keenan [Mon, 22 May 2017 02:16:23 +0000 (22:16 -0400)]
Patch suggested by Craig Berry for RT 131337.
David Mitchell [Sat, 3 Jun 2017 07:54:01 +0000 (08:54 +0100)]
Update Module::CoreList for 5.27.1
David Mitchell [Sat, 3 Jun 2017 07:24:12 +0000 (08:24 +0100)]
Bump the perl version in various places for 5.27.1
Karl Williamson [Thu, 20 Apr 2017 16:16:11 +0000 (10:16 -0600)]
Use new paradigm for hdr file double inclusion guard
We changed to use symbols not likely to be used by non-Perl code that
could conflict, and which have trailing underbars, so they don't look
like a regular Perl #define.
See https://rt.perl.org/Ticket/Display.html?id=131110
There are many more header files which are not guarded.
Dagfinn Ilmari Mannsåker [Fri, 31 Mar 2017 14:04:15 +0000 (15:04 +0100)]
Define and use symbolic constants for LvFLAGS
Yves Orton [Sun, 26 Mar 2017 17:12:51 +0000 (19:12 +0200)]
do not overallocate in zaphod32_hash
We don't use it, but it should be fixed regardless to sync
with upstream which might.
Yves Orton [Fri, 24 Mar 2017 13:33:36 +0000 (14:33 +0100)]
remove unneeded an unwelcome dependency
I added this when debugging the load average change and forgot to remove it
afterwards, and it upsets Jarkkos test suite.