This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Father Chrysostomos [Sat, 30 Aug 2014 04:52:16 +0000 (21:52 -0700)]
Update B::Concise for OPpMAY_RETURN_CONSTANT
Father Chrysostomos [Sat, 30 Aug 2014 03:18:23 +0000 (20:18 -0700)]
Avoid vivifying stuff when looking up barewords
Till now, when a bareword was looked up to see whether it was a sub-
routine, an rv2cv op was created (to allow PL_check hooks to override
the process), which was then asked for its GV.
Afterwards, the GV was downgraded back to nothing if possible.
So a lot of the time a GV was autovivified and then discarded. This
has been the case since
f74617600 (5.12).
If we know there is a good chance that the rv2cv op is about to be
deleted, we can avoid that by passing a flag to the new op.
Also
f74617600 actually changed the behaviour by vivifying stashes
that used not be vivified:
sub foo { print shift, "\n" }
SUPER::foo bar if 0;
foo SUPER;
Output in 5.10:
SUPER
Output as of this commit:
SUPER
Output in 5.12 to 5.21.3:
Can't locate object method "foo" via package "SUPER" at - line 3.
Father Chrysostomos [Thu, 28 Aug 2014 20:04:32 +0000 (13:04 -0700)]
[Merge] pad_reset
This branch gets builds with pad_reset enabled working and changes the
For those who do not know what pad_reset does, pad_reset allows oper-
ators from different statements to share targets, saving memory. When
it was originally added, it never fully worked properly, so it was
disabled, since it caused bugs.
For those who do not know what operator targets are: Many operators
use the same scalar every time they return a value, to avoid having to
create a new one each time. This is known as the target.
To keep t/re/uniprops.t running in a reasonable amount of time (unfor-
tunate coincidences slowed it down signficantly), I had to add two
optimisations. See the commits entitled:
Split PL_padix into two variables
pad.c: Use PadnamelistMAXNAMED in another place
These optimisations apply even when pad_reset is disabled.
Benchmarking doesn’t show any speedup with pad_reset
enabled, so I left it disabled for now. See
<
20140828045810.19174.qmail@lists-nntp.develooper.com> for benchmark-
ing details.
(I am hoping that I can figure out why it’s slower and enable it some
future date.)
Father Chrysostomos [Thu, 28 Aug 2014 01:10:18 +0000 (18:10 -0700)]
Make Peek.t easier to run directly
e.g., ./perl -TIlib ext/Devel-Peek/t/Peek.t
Father Chrysostomos [Wed, 27 Aug 2014 20:51:06 +0000 (13:51 -0700)]
pad.c: pad_reset comments
Father Chrysostomos [Wed, 27 Aug 2014 20:18:42 +0000 (13:18 -0700)]
Fix up Peek.t
Father Chrysostomos [Wed, 27 Aug 2014 20:16:58 +0000 (13:16 -0700)]
pad.c: Remove BROKEN from USE_BROKEN_PAD_RESET
Father Chrysostomos [Wed, 27 Aug 2014 15:27:03 +0000 (08:27 -0700)]
pad.c:pad_free: Don’t reset PL_padix if using pad_reset
pad_reset causes PL_padix to be reset at the beginning of each state-
ment, so that operator targets can be reused.
If we also reset it when freeing an operator, then theoretically tar-
gets from operators later on in the same statement might be reused. I
can’t come up with a test case, but it’s better to be safe than sorry.
Father Chrysostomos [Wed, 27 Aug 2014 06:26:28 +0000 (23:26 -0700)]
pad.c:pad_findmy_pvn: Skip ‘our’ hack for subs
There is a hack that allows an ‘our’ variable to be found in the pad
in the statement in which it is declared, to avoid a warning (since
the fallback would be to look up the very same variable in the current
package anyway).
Since the warning this hack avoids doesn’t apply to subroutines, we
can just skip it for subroutine lookup.
Father Chrysostomos [Wed, 27 Aug 2014 06:21:43 +0000 (23:21 -0700)]
pad.c: Use PadnamelistMAXNAMED in another place
This will speed up pad lookup a little more. This could be considered
a follow-up to commit
7db6405c.
There is a hack that allows an ‘our’ variable to be found in the pad
in the statement in which it is declared, to avoid a warning (since
the fallback would be to look up the very same variable in the current
package anyway).
This commit applies the PadnamelistMAXNAMED optimisation to that code
path. This is how that optimisation works: When named slots are
allocated in the pad, PadnamelistMAXNAMED is set, so that, when
searching for named items in the pad, we don’t have to search the
whole thing if there are many constants or GVs at the end.
Recent commits slowed down t/re/uniprops.t considerably. This was the remaining bottleneck.
We could actually skip the whole ‘our’ hack for subroutine lookup
(since the warning it avoids doesn’t apply to subroutines anyway). In
fact, the next commit will do that. But this optimisation is worth-
while anyway.
Father Chrysostomos [Wed, 27 Aug 2014 06:05:16 +0000 (23:05 -0700)]
Split PL_padix into two variables
PL_padix keeps track of the position in the pad when pad_alloc has to
start scanning for an available slot.
The availability of a slot is determined differently for targets
(which may reuse slots that are already targets from previous state-
ments, at least when pad_reset is enabled) and constants (which may
not reuse targets).
Having the same index for both may require scanning the entire pad for
allocating a constant or GV.
t/re/uniprops.t was running far too slowly under USE_BROKEN_PAD_RESET
because of this. pad_reset would reset PL_padix to point to the
beginning of a pad with a few hundred thousand entries. pad_alloc
would then have to scan the entire pad before adding a GV to the end.
It is still too slow, even with this commit, but for other reasons.
(This is just a partial fix.)
Father Chrysostomos [Wed, 27 Aug 2014 05:37:03 +0000 (22:37 -0700)]
intrpvar.h: Correct comment
This description has been a little faulty for quite some time, not
just because of the last few commits. Any time pad_free or pad_swipe
is called, that pad slot becomes available and PL_padix is reset.
So ‘max used’ is not accurate.
Father Chrysostomos [Wed, 27 Aug 2014 02:57:27 +0000 (19:57 -0700)]
uniprops.t: Correct command line in comment
Father Chrysostomos [Wed, 27 Aug 2014 02:42:26 +0000 (19:42 -0700)]
op.c:newPADOP: Allocate GV pad slots like constants
Requesting a pad slot for a constant (and GVs in pads are like con-
stants, in that the pad slot will always hold that same value, which
is shared in recursion) will instruct pad_alloc to avoid anything
marked PADTMP; i.e., a slot used as a target by a previous statement.
Without this, under -Accflags=-DUSE_BROKEN_PAD_RESET and threads,
configpm fails an assertion, because a concat operator tries to do
sv_grow on its target, but that target has ended up becoming a GV.
With this commit, all tests pass, but t/re/uniprops.t takes ‘forever’
(cf. commits
325e1816 and
7db6405c, which caused and fixed, respec-
tively, a similar bug).
Father Chrysostomos [Wed, 27 Aug 2014 02:05:32 +0000 (19:05 -0700)]
pad.c:pad_free: Don’t turn off the PADTMP flag
When we mark a pad entry as being free, it may happen (under
USE_BROKEN_PAD_RESET) that multiple operators from different state-
ments are using the same pad entry for their targets. If we turn off
the PADTMP flag, the slot may be reused for a constant. Then an oper-
ator that tries to return a value by assigning to its target will try
to modify a read-only scalar.
Now that (as of a few commits ago) allocation of targets (in
pad_alloc) will reuse entries marked PADTMP, turning off the flag is
not necessary to make a slot available.
This gets the build for USE_BROKEN_PAD_RESET+threads a little further.
The Exporter test now passes, but configpm trips an assertion....
Father Chrysostomos [Wed, 27 Aug 2014 01:06:48 +0000 (18:06 -0700)]
op.c:ck_rvconst: Allocate GV pad slots like constants
Requesting a pad slot for a constant (and GVs in pads are like con-
stants, in that the pad slot will always hold that same value, which
is shared in recursion) will instruct pad_alloc to avoid anything
marked PADTMP; i.e., a slot used as a target by a previous statement.
Without this, we get an assertion failure from ‘miniperl -MExporter’
under -Accflags=-DUSE_BROKEN_PAD_RESET and threads.
With this commit, we get ‘Modification of a read-only value attempted’
instead, which is some progress. :-)
Father Chrysostomos [Tue, 26 Aug 2014 20:06:10 +0000 (13:06 -0700)]
pad.c: More clearly separate targ/constant allocation
pad_reset was turning off PADTMP on targets to make them ‘available’
again. But constants allocated later could then end up using those
slots. We can’t share pad slots between constants and targets,
because operators allocated earlier will trigger ‘Modification of
a read-only value’ errors when trying to assign return values to
their targets.
Under non-threaded builds, in which constants are not generally stored
in the pad, there are still ‘constants’ that are allocated as such
(with &PL_sv_no names) but are not actually read-only. Filehandle
names associated with ‘open my $fh’ are one such example. If that
filehandle name’s pad slot is shared with a target, then the file-
handle will be named using some random string from a previous
statement.
The solution here is to change the way we use the PADTMP flag when
allocating pad slots. pad_reset should *not* turn off the flag,
because we need to know that these entries are used as targets by pre-
vious statements. pad_alloc should not tread PADTMP entries as being
in use when allocating targets, but only when allocating constants.
This gets all tests passing under -Accflags=-DUSE_BROKEN_PAD_RESET
on non-threaded builds.
Father Chrysostomos [Tue, 26 Aug 2014 15:31:22 +0000 (08:31 -0700)]
pad.c:pad_reset: Also make sure the thing is not PADMY
We can’t SvPADTMP_off on just anything, because it asserts that the
thing is !SvPADMY.
A range operator has a target of sorts, but that target must not be
shared with any other operators; hence it gets allocated like a
‘my’ variable. The target thus ends up with the SvPADMY flag set. We
obviously don’t want to mark those targets as reusable in pad_reset,
so just skip them.
This gets things mostly working under USE_BROKEN_PAD_RESET without
threads, but a few tests still fail.
Father Chrysostomos [Sun, 12 Jan 2014 01:02:32 +0000 (17:02 -0800)]
pad.c:pad_reset: check the name
This code was sufficiently out-of-date to trip assertions in miniperl,
breaking the build (with -Accflags=-DUSE_BROKEN_PAD_RESET).
We can’t SvPADTMP_off on just anything, because it asserts that the
thing is !SvPADMY.
So check that it has no name first. A pad entry without a name is an
operator target (or an unallocated entry).
The build is still broken, but it gets a bit further.
Father Chrysostomos [Thu, 28 Aug 2014 19:41:05 +0000 (12:41 -0700)]
Alphabetise perldiag
Earlier in perldiag, it says:
The messages are in alphabetical order, without regard to upper or
lower-case.
Father Chrysostomos [Thu, 28 Aug 2014 19:40:03 +0000 (12:40 -0700)]
perldiag grammar
1cd88304d70 fixed one grammatical error in this sentence. This fixes
the other.
Father Chrysostomos [Thu, 28 Aug 2014 17:52:22 +0000 (10:52 -0700)]
t/porting/readme.t: Get list from MANIFEST
Otherwise we end up failing because of editor or patch droppings
in Porting/. The test was already skipping things ending with ~
but that was not sufficient.
Father Chrysostomos [Thu, 28 Aug 2014 17:41:03 +0000 (10:41 -0700)]
[Merge] Fix crashes with lexical subs
Various crashing resulting from code not taking CvGV(lexsub)==NULL
into account.
Father Chrysostomos [Thu, 28 Aug 2014 17:28:28 +0000 (10:28 -0700)]
Fix crash with lex subs under -d
Father Chrysostomos [Thu, 28 Aug 2014 14:24:53 +0000 (07:24 -0700)]
Fix crash in leave_scope when my sub has CvGV
Sub declaration can reuse an existing stub. So it is possible to define
a package sub using a stub that was originally lexical. Hence,
leave_scope needs to take into account that a my-sub may not have a
name hek any more.
Father Chrysostomos [Thu, 28 Aug 2014 13:40:29 +0000 (06:40 -0700)]
Fix crash when lex subs are used for overload
Father Chrysostomos [Thu, 28 Aug 2014 13:31:48 +0000 (06:31 -0700)]
Fix crash when lex subs are used for AUTOLOAD
Father Chrysostomos [Thu, 28 Aug 2014 13:22:04 +0000 (06:22 -0700)]
[perl #122556] Make undef $s free refs forthwith
Jarkko Hietaniemi [Wed, 27 Aug 2014 22:46:21 +0000 (18:46 -0400)]
Don't use isfinitel/isinfl/isnanl if the C99 macros exist.
Moves the C99 logic from sv.c (?) to perl.h.
Jarkko Hietaniemi [Wed, 27 Aug 2014 22:36:32 +0000 (18:36 -0400)]
Under C99 isfinite/isinf/isnan are sizeof-aware macros.
So let's not test them with inlibc.
Karl Williamson [Wed, 27 Aug 2014 23:21:59 +0000 (17:21 -0600)]
regcomp.c: Silence Win32 compiler warning
This raised a signed/unsigned warning that is essentially spurious.
Reini Urban [Wed, 27 Aug 2014 17:48:35 +0000 (12:48 -0500)]
sv_grow: performance improvement for short strings
Empty COW strings with CUR=0 ended up allocated as LEN=10.
Now they are rounded up to 4 or 8.
Timings:
+0 16.
394324103 0.27%
+2 16.
114379842 0.01%
+4 16.
305622265 1.03%
+8 16.
337438609 1.30%
+10 16.
675009468 0.59%
with LD_LIBRARY_PATH=`pwd` perf stat -r2 ./perl t/harness t/op/*.t
+2 was consistently the best number, and +10 the worst.
Jerry D. Hedden [Wed, 27 Aug 2014 22:06:39 +0000 (18:06 -0400)]
Upgrade to threads 1.96
Ricardo Signes [Thu, 28 Aug 2014 01:13:46 +0000 (21:13 -0400)]
todo: expand the list of OS access builtins to update
...taken from an IRC conversation on #p5p
Jarkko Hietaniemi [Wed, 27 Aug 2014 23:04:36 +0000 (19:04 -0400)]
De-prefix Perl_isinfnan.
Jarkko Hietaniemi [Wed, 27 Aug 2014 12:13:02 +0000 (08:13 -0400)]
pack c/C on inf/nan.
Made them return the 0xFF byte (and warn). Not necessarily the best
choice, but there's not that much room in just 256 bytes for all of
the inf/-inf/nan. This same choice will need to be made with wider
integer packs.
Jarkko Hietaniemi [Wed, 27 Aug 2014 11:45:00 +0000 (07:45 -0400)]
Make sprintf %c and chr() on inf/nan return the U+FFFD.
%c was made to produce "Inf"/"NaN" earlier, but let's
keep with the Unicode way, and make chr() agree with %c.
Jarkko Hietaniemi [Wed, 27 Aug 2014 01:05:54 +0000 (21:05 -0400)]
NVgf/NVff agree with -Duselongdouble.
Jarkko Hietaniemi [Wed, 27 Aug 2014 01:19:31 +0000 (21:19 -0400)]
Comment tweak.
Karl Williamson [Wed, 27 Aug 2014 03:15:01 +0000 (21:15 -0600)]
ext/re/t/regop.t: Use eq instead of == for strings
Interestingly, this bug has been unnoticed for almost 3 years.
Jarkko Hietaniemi [Tue, 26 Aug 2014 22:48:45 +0000 (18:48 -0400)]
Detect false infinities.
Jarkko Hietaniemi [Tue, 26 Aug 2014 02:40:17 +0000 (22:40 -0400)]
printf inf/nan should be inf/nan.
Before: printf %[ducp] for Inf/NaN produced quite surprising results:
1, 0, -1,
18446744073709551615,
9223372036854775808, -
9223372036854775807,
bogus Unicode code points, random heap addresses in hex.
Jarkko Hietaniemi [Tue, 26 Aug 2014 01:55:53 +0000 (21:55 -0400)]
Add more infnan tests.
Jarkko Hietaniemi [Mon, 25 Aug 2014 22:52:44 +0000 (18:52 -0400)]
Avoid useless warning, remove debug code.
Jarkko Hietaniemi [Tue, 26 Aug 2014 14:30:30 +0000 (10:30 -0400)]
*fp*class* comment tweaks.
Jarkko Hietaniemi [Tue, 26 Aug 2014 01:44:55 +0000 (21:44 -0400)]
Post-VAX VMS has fp_classify().
Jarkko Hietaniemi [Tue, 26 Aug 2014 16:16:36 +0000 (12:16 -0400)]
Simplify the hexfp space computation.
And prepare for the double double case being properly implemented.
Jarkko Hietaniemi [Tue, 26 Aug 2014 15:49:04 +0000 (11:49 -0400)]
Comment why hexfp is set here, not earlier.
Jarkko Hietaniemi [Tue, 26 Aug 2014 15:14:24 +0000 (11:14 -0400)]
Only one successful exit from grok_infnan().
Jarkko Hietaniemi [Tue, 26 Aug 2014 22:17:51 +0000 (18:17 -0400)]
Sprinkle the fact that long doubles aren't standardized.
Jarkko Hietaniemi [Tue, 26 Aug 2014 11:26:33 +0000 (07:26 -0400)]
Allow eg ./perl t/harness t/op/lc.t
Father Chrysostomos [Sun, 12 Jan 2014 01:03:04 +0000 (17:03 -0800)]
Typo in pad.c apidocs
Steve Hay [Tue, 26 Aug 2014 08:24:20 +0000 (09:24 +0100)]
Porting/Maintainers.pl - Fix ExtUtils-CBuilder entry
Steve Hay [Tue, 26 Aug 2014 08:22:06 +0000 (09:22 +0100)]
Upgrade version from version 0.9908 to 0.9909
This includes some blead changes, but more are still waiting to be
incorporated into the next CPAN release, namely
7738054cc9 and
dcccc8ffbf.
Father Chrysostomos [Tue, 26 Aug 2014 05:05:37 +0000 (22:05 -0700)]
constant.pm: Document fully-qualified constant names
added a few commits ago.
Father Chrysostomos [Tue, 26 Aug 2014 05:01:44 +0000 (22:01 -0700)]
constant.pm: Remove doc reference to compile-time checking
This was removed in commit
eff754733a. It was necessary, as the
feature caused bugs #69456 and #122607.
Advertising the compile-time check with version-dependent qualifi-
cations would make the documentation too verbose.
Father Chrysostomos [Tue, 26 Aug 2014 04:45:50 +0000 (21:45 -0700)]
constant.pm: Remove redundant truth checks
It is not possible to reach these without $symtab’s having been
assigned a stash reference.
Father Chrysostomos [Tue, 26 Aug 2014 04:43:31 +0000 (21:43 -0700)]
constant.pm: outdated comment
Father Chrysostomos [Tue, 26 Aug 2014 04:42:11 +0000 (21:42 -0700)]
Increase $constant::VERSION to 1.32
Father Chrysostomos [Tue, 26 Aug 2014 04:41:55 +0000 (21:41 -0700)]
Allow package name in ‘use constant’ constants
See the thread that includes
<
20140821044934.29399.qmail@lists-nntp.develooper.com>.
This provides a way for a package to define constants in another pack-
age, without having to resort to *other::const = sub () { $value }.
Now one can write constant->import("other::const" => $value).
Documentation will be added in an upcoming commit.
Father Chrysostomos [Tue, 26 Aug 2014 01:18:16 +0000 (18:18 -0700)]
toke.c: Remove unnecessary PL_expect assignment
In this code path, we know that the next token is a parenthesis. It
also happens that the lexer always emits parentheses the same way,
so there is no question as to how to interpret it. Hence, the value
of PL_expect is actually irrelevant here.
Father Chrysostomos [Tue, 26 Aug 2014 01:10:12 +0000 (18:10 -0700)]
perlfunc: consistent spaces after dots
Father Chrysostomos [Tue, 26 Aug 2014 01:05:56 +0000 (18:05 -0700)]
perldiag: reword and rewrap an entry
I think ‘portable between’ sounds better in this particular context.
The rewrapping is for the sake of splain output.
Father Chrysostomos [Mon, 25 Aug 2014 21:54:30 +0000 (14:54 -0700)]
Stop trying to disambiguate {} after $
$ ./perl -Ilib -e '${function_with_side_effects,42}'
$ ./perl -Ilib -e '${Function_with_side_effects,42}'
syntax error at -e line 1, near "${"
Execution of -e aborted due to compilation errors.
Why is the second one a syntax error?
Because the lexer is trying to disambiguate between a block and a hash
when it sees ‘{’ after ‘$’. But an anonymous hash constructor cannot
come after a funny character, so any time it chooses the hash inter-
pretation over the blocky one, a syntax error ensues.
Karl Williamson [Tue, 26 Aug 2014 00:50:16 +0000 (18:50 -0600)]
perlrecharclass: Use more common property synonym
XPerlSpace is used elsewhere in this pod, so use it everywhere.
Spotted by Andrew Rodland.
Steve Hay [Mon, 25 Aug 2014 20:39:35 +0000 (21:39 +0100)]
Update release schedule
Steve Hay [Mon, 25 Aug 2014 20:26:29 +0000 (21:26 +0100)]
Add release date of 5.20.1-RC1
Steve Hay [Mon, 25 Aug 2014 19:35:15 +0000 (20:35 +0100)]
Add epigraph for 5.20.1-RC1
Karl Williamson [Sun, 24 Aug 2014 02:50:44 +0000 (20:50 -0600)]
Improve -Dr output of bracketed char classes
I look at this output a lot to verify that patterns compiled correctly.
This commit makes them somewhat easier to read, while extending this to
also work on EBCDIC platforms (as yet untested).
In staring at these over time, I realized that punctuation literals are
mostly what contributes to being hard to read. [A-Z] is just as
readable as [A-Y], but [%!@\]~] is harder to read than if there were
fewer. Sometimes that can't be helped, but if many get output,
inverting the pattern [^...] can cause fewer to be output. This commit
employs heuristics to invert when it thinks that that would be more
legible. For example, it converts the output of [^"'] to be
ANYOF[^"'][{unicode_all}]
instead of
ANYOF[\x{00}-\x{1F} !#$%&()*+,\-./0-9:;<=>?@A-Z[\\\]\^_`a-z{|}~\x{7F}-\x{FF}][{unicode_all}]
Since it is a heuristic, it may not be the best under all circumstances,
and may need to be tweaked in the future.
If almost all the printables are to be output, it uses a hex range, as
that is probably more closely aligned with the intent of the pattern
than which individual printables are desired. Again this heuristic can
be tweaked.
And it prints a leading 0 on things it outputs as hex formerly as a
single digit \x{0A} now instead of \x{A} previously.
Karl Williamson [Sun, 24 Aug 2014 00:49:58 +0000 (18:49 -0600)]
regcomp.c: Use symbolic constant instead of number
This is in preparation for it to be used in more than one place.
Karl Williamson [Sun, 24 Aug 2014 00:40:06 +0000 (18:40 -0600)]
regcomp.c: Add 'const' to parameter
Karl Williamson [Sun, 24 Aug 2014 00:21:36 +0000 (18:21 -0600)]
perldiag: Add clarification.
Karl Williamson [Sun, 24 Aug 2014 00:10:44 +0000 (18:10 -0600)]
regen/unicode_constants.pl: Find max ascii print cp
This creates a #define that gives the highest code point that is an
ASCII printable. On ASCII-ish platforms, this is 0x7E, but on EBCDIC
platforms it varies, and can be as high as 0xFF. This is in preparation
for needing this value in a future commit in regcomp.c
Karl Williamson [Sun, 24 Aug 2014 00:07:50 +0000 (18:07 -0600)]
handy.h, regcomp.c: Add, clarify comments
Karl Williamson [Sun, 24 Aug 2014 00:01:28 +0000 (18:01 -0600)]
regcomp.c: Extract some code into a macro
This is in preparation for it to be used in more than one place
Karl Williamson [Sat, 23 Aug 2014 23:57:45 +0000 (17:57 -0600)]
regcomp.c: white-space only
Bring two case statements into line with their peers
Karl Williamson [Sat, 23 Aug 2014 23:54:20 +0000 (17:54 -0600)]
regcomp.c: Use available mnemonics for dumping regex
Perl supports \e and \b (in bracketed character classes). Use these on
outputting like we do \t and \n, instead of a hex value
Karl Williamson [Sat, 23 Aug 2014 23:50:11 +0000 (17:50 -0600)]
sv.c: Silence VMS compiler warning
The result of this must be at least 0 as the type is unsigned, so
the compiler gives a warning.
Karl Williamson [Sat, 23 Aug 2014 23:49:30 +0000 (17:49 -0600)]
embed.fnc: Clarify m flag behavior comment
Ævar Arnfjörð Bjarmason [Mon, 25 Aug 2014 16:17:11 +0000 (16:17 +0000)]
perlfunc: Improve the pointer from "elseif" to "elsif"
A co-worker pointed out that the docs for "elsif" were quite confusing
because nothing when you "perldoc -f elseif" points out that it doesn't
exist, it just directs you to perlsyn where we only document "elsif".
Ricardo Signes added this aliasing back in v5.15.7-194-g8f0d6a6.
Improve this confusion, and also add a mention of the common "elif" and
"else if" variants while I'm at it. I was originally going to just alias
them, but t/porting/perlfunc.t started failing because we're missing
cross-references, and unlike "elseif" the other two aren't keywords,
even if the "elseif" one is only here to warn you about its use.
Father Chrysostomos [Mon, 25 Aug 2014 05:42:51 +0000 (22:42 -0700)]
toke.c: Remove unnecessary condition
This code skips over a quoted string, handling escapes. And to han-
dle escapes it skips past the character following a backslash if that
character is itself a backslash or the quote character. Skipping past
the character after the backslash unconditionally, regardless of what
it is, has the same effect and uses less code.
This change shrunk the .o file.
Before:
-rw-r--r-- 1 sprout staff 671148 Aug 24 20:28 toke.o
After:
-rw-r--r-- 1 sprout staff 671100 Aug 24 22:37 toke.o
Father Chrysostomos [Mon, 25 Aug 2014 05:31:10 +0000 (22:31 -0700)]
Stop ck_rvconst from treating GV constants as strings
sub foo { 42 }
use constant bar => *foo;
BEGIN { undef *foo }
warn &{+bar};
warn bar->();
Obviously the last two lines should print the same thing, because they
both call the value of the ‘bar’ constant as a suroutine.
But op.c:ck_rvconst messes up the ‘bar->()’ at compile time, treating
the bar glob (a copy of the original *foo glob, and not the *foo glob
itself, which has since been undefined) as a string and using it to
look up a glob.
ck_rvconst should not do anything if the constant’s value is a glob.
Father Chrysostomos [Mon, 25 Aug 2014 05:12:52 +0000 (22:12 -0700)]
Remove compile-time checking of rv2?v with const kid
There was code in op.c:ck_rvconst (which runs when creating a derefer-
ence op, such as rv2sv, rv2av, etc.) that would check that a constant
kid holding a reference pointed to something of the right type. It
failed to take overloading into account.
The result was that these lines would fail to compile:
constant_reference_to_hash_with_coderef_overloading->();
constant_reference_to_sub_with_hashref_overloading->{key};
constant_reference_to_sub_with_arrayref_overloading->[0];
constant_reference_to_sub_with_scalarref_overloading->$*;
even though they should work.
Since the overloadedness could change any time, even checking for that
in op.c is incorrect. The only correct fix is to remove this compile-
time check. If something naughty gets through, it will be caught
at run time.
This fixes bugs #122607 and #69456.
Jarkko Hietaniemi [Mon, 25 Aug 2014 01:21:04 +0000 (21:21 -0400)]
Test fpclassify() with full compile.
inlibc test is no good since it is likely to be a macro.
Also fix typo in fp_classify(). Yes, both exist.
Jarkko Hietaniemi [Sun, 24 Aug 2014 22:43:29 +0000 (18:43 -0400)]
Reorder the *fp*class* in preference order, add comments.
Most importantly, try C99 fpclassify() first.
Use fp_classify() and fp_classl().
Jarkko Hietaniemi [Mon, 25 Aug 2014 00:12:16 +0000 (20:12 -0400)]
Configure scan for fp_classl().
Jarkko Hietaniemi [Sun, 24 Aug 2014 22:40:19 +0000 (18:40 -0400)]
Configure scan for fp_classify().
Jarkko Hietaniemi [Sun, 24 Aug 2014 22:34:05 +0000 (18:34 -0400)]
More is_inf() et alia dance.
Too many almost similar interfaces.
Most importantly go for isinf() and isnan() if available,
instead of going for the labyrinth of *fp*class* interfaces.
Jarkko Hietaniemi [Sun, 24 Aug 2014 02:49:04 +0000 (22:49 -0400)]
More robust inf/nan recognition and generation.
Drop INFNAN_PEEK, premature optimization and hard to get right (it
basically imitates unrolled first half of grok_infnan). Just keep
grok_infan fast. (There is one spot in grok_number_flags() where we
peek at the next byte to avoid wasted work.)
If falling back (from not having NV_INF/NV_NAN) to the native strtod
(or similar), fake the input based on the grok_infnan result.
Add last-resort ways to generate inf/nan.
Recognize explicit unary plus, like "+Inf", and "INFINITE".
In tests use cmp_ok(), fix typos, add tests.
Father Chrysostomos [Mon, 25 Aug 2014 02:03:29 +0000 (19:03 -0700)]
[Merge] Eliminate PL_lex_expect; fix one bug; other clean-up
PL_expect (PL_parser->expect) is what the lexer uses to keep track of
what type of thing to expect next. This (partly) determines whether
‘{’ begins a block, or an anonymous hash, or a subscript.
In numerous cases PL_expect was being set to the wrong value. There
were extra statements to set it back to the right value. There was
also a mechanism to save the value (force_next/PL_lex_expect) and
restore it later.
If we just set PL_expect to the correct values to begin with, we can
simplify things conceptually and reduce the amount of code.
I fixed bug #80368 in the process, since it got in the way.
I also fixed up some comments in toke.c and changed PL_parser to
parser in perly.y.
Father Chrysostomos [Fri, 22 Aug 2014 13:18:01 +0000 (06:18 -0700)]
In perly.y, change PL_parser to parser
All these code snippets are embedded inside a function
(perly.c:yyparse) that puts the current value of PL_parser in a local
variable named parser. So the two are equivalent, but the latter
only has to access a local variable.
Before:
$ ls -ld perly.o
-rw-r--r-- 1 sprout staff 94748 Aug 22 06:12 perly.o
After:
$ ls -ld perly.o
-rw-r--r-- 1 sprout staff 94340 Aug 22 06:15 perly.o
Father Chrysostomos [Fri, 22 Aug 2014 13:13:17 +0000 (06:13 -0700)]
Set PL_expect only once after curly subscripts
When curly subscripts are parsed, the lexer (toke.c:yylex) notes that
the value of PL_expect needs to be set to XSTATE (expecting a state-
ment) after the final brace. When the final brace is encountered,
PL_expect is set to that recorded value. But then the parser
(perly.y) sets it to XOPERATOR immediately thereafter.
This approach requires a plethora of identical statements in perly.y.
If we just set PL_expect to the right value to begin with, we can
avoid all those assignments.
Father Chrysostomos [Sat, 23 Aug 2014 01:15:26 +0000 (18:15 -0700)]
parser.h: Comment that lex_expect is unused
There is at least one CPAN module (Data::Alias) that assigns to this.
Removing it won’t shrink the parser struct because of alignment, so
it doesn’t gain us anything. Just leave it for now. We can remove
it later if we have to.
Father Chrysostomos [Sat, 23 Aug 2014 01:14:06 +0000 (18:14 -0700)]
toke.c: Remove PL_lex_expect define
This is no longer used.
Father Chrysostomos [Fri, 22 Aug 2014 13:02:17 +0000 (06:02 -0700)]
Stop setting PL_lex_expect
As of two commits ago, nothing uses its value any more.
Father Chrysostomos [Fri, 22 Aug 2014 13:01:45 +0000 (06:01 -0700)]
toke.c: Consolidate some PL_expect assignments
The previous commit allows these settings of PL_expect to be combined.
We no longer need one before force_next in each instance.
Father Chrysostomos [Fri, 22 Aug 2014 12:53:42 +0000 (05:53 -0700)]
Stop using the value of PL_expect
The changes in commits leading up to this one avoided unnecessary
PL_expect assignments that would soon be clobbered by this
‘PL_expect = PL_lex_expect’ that restores the previous value.
Hence, we no longer even need to read the value of PL_lex_expect since
PL_expect hasn’t changed.
Just one piece of code (KEY_package) was setting PL_lex_expect
directly instead of having force_next copy it from PL_expect, so this
commit changes it to set PL_expect to the correct value.
Father Chrysostomos [Sat, 23 Aug 2014 01:11:23 +0000 (18:11 -0700)]
toke.c: For plugins, don’t set PL_expect if PL_nexttoke
When a parsing plugin finishes parsing its stuff, the lexer may have
emitted one more token than the construct it was parsing (if the
plugin called parsing API functions like parse_fullstmt). In such
cases, yyunlex has pushed that token on to the pending token stack
with force_next.
When the lexer is about to emit the plugin’s parsed statement or
expression, if there is a pending token, then it does not need to set
PL_expect, since the previous value will be restored anyway when the
pending token is emitted.
The next commit will disable that save-and-restore mechanism for
PL_expect, so we must not assign to it here.
Father Chrysostomos [Fri, 22 Aug 2014 12:45:27 +0000 (05:45 -0700)]
toke.c: Touch PL_expect less for implicit [.,] in quotes
When emitting implicit commas and cats, there is no need to set
PL_expect at the same time, since these code paths have already set
it to the correct value. Also, the two instances of Aop would check
the current parse position for an ‘=’ to make an assignment operator.
But that could never happen in these two code paths, so the check
was a waste.
Father Chrysostomos [Fri, 22 Aug 2014 12:40:18 +0000 (05:40 -0700)]
[perl #80368] Fix implicit assignop in qq"a\U="
The bug report explains it all:
> $ perl -e 'print "a\U="'
> Can't modify constant item in concatenation (.) or string at -e line 1, near "print "a\U=""
> Execution of -e aborted due to compilation errors.
>
> The "a\U=" string constant ought to generate ops corresponding roughly to
> "a".uc("=") (which would then be constant-folded). However, the "=" is
> being interpreted by the tokeniser as part of the concatenation operator,
> producing ops corresponding to "a".=uc("") (which generates the error).
>
> This happens because the implicit concatenation operator is generated
> in toke.c via the Aop() macro, which allows an addition-type operator
> to be mutated into an assignment operator if it is immediately followed
> by an "=". It should instead be generated via one of the other macros,
> or possibly a new macro, that doesn't allow for mutation to an assignment
> operator.
This commit does the latter.
> There are multiple sites in toke.c making the same mistake.
The other two instances are harmless, but the next commit will change
them for a different reason (avoiding unnecessary PL_expect assign-
ments with a view to eventually removing PL_lex_expect).