Karl Williamson [Fri, 25 May 2012 04:14:04 +0000 (22:14 -0600)]
regcomp.c: Refactor so can remove duplicate code
This commit prepares the way for a later commit to remove a chunk of
essentially duplicate code. It does this at the cost of an extra
test of a boolean each time through the loop. But, it saves calculating
the fold unless necessary, a potentially expensive operation. When the
next input is a quantifier that calculated fold is discarded, unused.
This commit avoids doing that calculation when the next input is a
quantifier.
K.Shirakata [Fri, 6 May 2011 13:12:57 +0000 (22:12 +0900)]
Fix a perl5140delta typo in F<> markup.
(Patch predates the 5.14.0 release, but was missed at the time.)
Father Chrysostomos [Thu, 2 Aug 2012 03:45:29 +0000 (20:45 -0700)]
[perl #114020] perlvar: warn against my $_
Father Chrysostomos [Thu, 2 Aug 2012 03:36:10 +0000 (20:36 -0700)]
Update perlsyn for given aliasing $_
plus one typo fix
Father Chrysostomos [Thu, 2 Aug 2012 03:12:47 +0000 (20:12 -0700)]
perlfunc/printf: corrections, clarifications
Father Chrysostomos [Thu, 2 Aug 2012 01:08:35 +0000 (18:08 -0700)]
perlfunc: clarification
Father Chrysostomos [Thu, 2 Aug 2012 01:07:05 +0000 (18:07 -0700)]
perlvar: Document all uses of implicit $_
Father Chrysostomos [Wed, 1 Aug 2012 21:17:20 +0000 (14:17 -0700)]
perlfunc: Document implicit $_ in while(each)
Father Chrysostomos [Wed, 1 Aug 2012 21:16:21 +0000 (14:16 -0700)]
[perl #114020, #90018, #53186] Make given alias $_
This commit makes given() alias $_ to the argument, using a slot in
the lexical pad if a lexical $_ is in scope, or $'_ otherwise.
This makes it work very similarly to foreach, and eliminates the
problem of List::Util functions not working inside given().
Father Chrysostomos [Wed, 1 Aug 2012 20:04:14 +0000 (13:04 -0700)]
[perl #114368] perl -DA -e '' segfaults
Iterative freeing of hashes uses the SvMAGIC field for a different
purpose. So clear it before calling hv_undef_flags, which calls
hv_assert, which expects any non-null value fo SvMAGIC to me magic.
Tony Cook [Thu, 2 Aug 2012 00:28:02 +0000 (10:28 +1000)]
fix icmp ping tests on cygwin
Tony Cook [Fri, 27 Jul 2012 13:47:05 +0000 (23:47 +1000)]
Net-Ping: creating an icmp socket requires admin access on recent cygwin
on recent Windows.
cygwin on XP can create an icmp socket as a normal user but can't do
anything with it. On Vista or Win7 the process must be running as
an admin to create the socket.
If someone sees value in running the test on cygwin on XP, they can
provide a patch.
Tony Cook [Fri, 27 Jul 2012 13:39:39 +0000 (23:39 +1000)]
Net-Ping: add a sensible test note for the icmp ping test
Tony Cook [Fri, 27 Jul 2012 13:38:59 +0000 (23:38 +1000)]
fix the cygwin breakage introduced in
2f794ae1
All modern Win32 systems* require admin access to use ICMP sockets from
cygwin, the refactor in
2f794ae1 changed the condition for the skip,
producing a failure here when the test is run unprivileged under
cygwin.
* assuming XP can be called modern
Nicholas Clark [Thu, 28 Jun 2012 16:21:01 +0000 (18:21 +0200)]
Test that when directories in @INC are skipped, coderefs are still called.
For filenames that are absolute, or start with ./ or ../ only coderefs in
@INC are called - directories are skipped. Test this behaviour.
Nicholas Clark [Wed, 27 Jun 2012 16:25:50 +0000 (18:25 +0200)]
Avoid reading before the buffer start when generating errors from require.
In pp_require, the error reporting code treats file names ending /\.p?h\z/
specially. The detection code for this, as refactored in 2010 by commit
686c4ca09cf9d6ae, could read one or two bytes before the start of the
filename for filenames less than 3 bytes long. (Note this cannot happen with
module names given to use or require, as appending ".pm" will always make the
filename at least 3 bytes long.)
Steve Hay [Wed, 1 Aug 2012 17:16:53 +0000 (18:16 +0100)]
Add a USE_64_BIT_INT build option to the Windows makefiles.
Rather than adding more canned configurations, we dynamically set values
which differ from the standard 32-bit build options, and actually remove
the canned configurations for 64-bit builds too and do likewise for them.
The ~ARCHPREFIX~ games used by the outgoing .gc64 configuration needed
bringing into the remaining .gc configuration to maintain support for the
GCCCROSS build option.
Two tweaks to sv.c were required for the USE_64_BIT_INT option to work
with a VC++ build, allowing the I64 printf size specification. The GCC
build worked anyway since it uses ll rather than I64.
The motivation for this change came from a patch submitted by Sisyphus
<sisyphus1@optusnet.com.au>:
Message-ID: <
6AC52DD00C96415A9E919A02F12DD05F@desktop2>
Nicholas Clark [Mon, 30 Jul 2012 15:31:12 +0000 (17:31 +0200)]
Makefile.SH needs to delete the perldelta symlink before creating it.
This seemingly redundant action seems to be necessary for maximum
portability on repeat makes - certainly HP-UX make will happily assume that
the target (the symlink) is out of date, attempt to re-run the rule, and
then fail because the `ln -s` command fails due to the target already
existing.
David Mitchell [Wed, 1 Aug 2012 12:31:03 +0000 (13:31 +0100)]
stop /$unchanging/ leaking
9f141731d83a1ac6294a5580a5b11ff41490309a, part of the re_eval jumbo fix,
introduced a leak. It incremented the ref count of a run-time regex each
time it was re-used, i.e. where the pattern hadn't changed.
Fuji, Goro [Tue, 31 Jul 2012 12:56:11 +0000 (21:56 +0900)]
fix a memory leak in sv_sethek(), amending
70b71ec84
the following code reproduced this issue on perl 5.16.0:
my $o = bless {};
while (1) {
for my $r([], $o) {
ref $r;
}
}
Craig A. Berry [Sun, 15 Jul 2012 21:18:42 +0000 (16:18 -0500)]
x2p/str.c C++ clean-up.
Compiling str.c with HP C++ for OpenVMS says,
FILE_ptr(fp) = (void*)ptr; /* LHS STDCHAR* cast non-portable */
.....................^
%CXX-E-INCASSOPN, a value of type "void *" cannot be assigned to an
entity of type "char *"
at line number 213 in file D0:[craig.blead.x2p]str.c;1
FILE_ptr(fp) = (void*)ptr; /* LHS STDCHAR* cast non-portable */
.................^
%CXX-E-INCASSOPN, a value of type "void *" cannot be assigned to an
entity of type "char *"
at line number 233 in file D0:[craig.blead.x2p]str.c;1
So remove the void casts to avoid the errors. This is an exact
mirror of
d06fc7d4ca98, which also removed the void cast from an
equivalent line in perlio.c. That was almost six years ago, so if
anything especially dire were going to happen without the cast, it
likely would have happened by now.
The casts were added by
cc00df79d5 and
5faea5d5, the former of which
refers vaguely to "compiler worries" without specifying what they
were, but signedness warnings are a likely suspect. We'll get those
again now, but warnings are less bad than errors. A more robust
solution would be to add a Configure-time detection of the type of
FILE._ptr and cast everything to that.
An even more robust solution would be to eliminate all the "buffer
snooping" mechanisms and concede that maintaining an stdio
implementation is a job for stdio maintainers and not Perl
maintainers.
David Mitchell [Tue, 31 Jul 2012 13:30:47 +0000 (14:30 +0100)]
make re_compile core-engine specific
Originally, Perl_re_compile() was the entry point for perl's regex
compiler. After commit
3c13cae629d936c43bca9d992cc445d93287af8e, this
function inadvertently became a wrapper meaning "execute the comp method
of the current engine". Change it back so that it always invokes only
perl's engine.
This fixes [perl #114302] Bleadperl v5.17.0-408-g3c13cae breaks
DGL/re-engine-RE2-0.10.tar.gz
Nicholas Clark [Wed, 11 Jul 2012 18:24:14 +0000 (20:24 +0200)]
In Perl_scalarvoid(), avoid creating a temporary SV for simple messages.
If using an SV to generate a potentially UTF-8 error message, pass that SV
onward to the code that generates warnings, and use a SV-specific format.
Otherwise use a %s format and pass the char * pointer directly to
Perl_ck_warner(). This avoids creating a temporary SV just to hold a fixed
ASCII string, but retains the ability to generate clean UTF-8 error messages.
Father Chrysostomos [Tue, 31 Jul 2012 06:32:11 +0000 (23:32 -0700)]
Storable: blessed long vstrings
I made a mistake in the long vstring code. The stored blessing was
being ignored.
Father Chrysostomos [Tue, 31 Jul 2012 05:57:21 +0000 (22:57 -0700)]
[perl #114338] Misleading prototype in perlapi manpage
Father Chrysostomos [Tue, 31 Jul 2012 03:25:20 +0000 (20:25 -0700)]
[perl #113894] Storable support for vstrings
Father Chrysostomos [Tue, 31 Jul 2012 05:43:06 +0000 (22:43 -0700)]
Get Storable’s blessed.t passing again in 5.8.1-
Back then, sub {} meant sub {wantarray?@_:undef}.
Father Chrysostomos [Mon, 30 Jul 2012 23:17:59 +0000 (16:17 -0700)]
Storable.xs: Add comments to store_scalar concerning utf8
Father Chrysostomos [Mon, 30 Jul 2012 22:59:35 +0000 (15:59 -0700)]
Storable: doc typos
Father Chrysostomos [Mon, 30 Jul 2012 22:53:26 +0000 (15:53 -0700)]
Increase $Storable::VERSION to 2.38
Father Chrysostomos [Mon, 30 Jul 2012 21:27:12 +0000 (14:27 -0700)]
scope.c: Don’t stringify globs on scope exit
This is a waste:
/* Can clear pad variable in place? */
if (SvREFCNT(sv) <= 1 && !SvOBJECT(sv)) {
/*
* if a my variable that was made readonly is going out of
* scope, we want to remove the readonlyness so that it can
* go out of scope quietly
*/
if (SvPADMY(sv) && !SvFAKE(sv))
SvREADONLY_off(sv);
if (SvTHINKFIRST(sv))
sv_force_normal_flags(sv, SV_IMMEDIATE_UNREF);
We can simply drop the globness in sv_force_normal instead of flatten-
ing globs to strings. The same applies to COWs. The SV_COW_DROP_PV
flag accomplishes both.
Before and after:
$ time ./miniperl -e 'for (1..1000000) { my $x = *foo }'
real 0m2.324s
user 0m2.316s
sys 0m0.006s
$ time ./miniperl -e 'for (1..1000000) { my $x = *foo }'
real 0m0.848s
user 0m0.840s
sys 0m0.005s
Craig A. Berry [Tue, 31 Jul 2012 00:29:39 +0000 (19:29 -0500)]
Most magic.t tests can actually run on VMS.
Only the one that clears %ENV is a problem.
Craig A. Berry [Tue, 31 Jul 2012 00:26:40 +0000 (19:26 -0500)]
Correct skip count in magic.t after
613c63b465.
Jan Dubois [Tue, 31 Jul 2012 01:42:42 +0000 (18:42 -0700)]
Remove -x permission from win32/win32.h
No idea why one of my previous commits added the bit. I blame
Cygwin git and the fact that t/porting/exec-bit.t is skipped
on Windows.
Daniel Dragan [Fri, 20 Jul 2012 16:37:53 +0000 (12:37 -0400)]
Add PERL_NO_GET_CONTEXT to Win32CORE
Win32CORE is already ithreads aware, but was still making
Perl_get_context calls. This fixes that. Smaller machine code is the result.
Daniel Dragan [Thu, 19 Jul 2012 18:30:21 +0000 (14:30 -0400)]
Add MSVC noreturn to inside of the interp
12a2785c7e86f586a05cad9ff90ce673c68c3115 only turned on MSVC noreturn for
external DLL XS modules, not inside the interp (perl5**.dll). This commit
fixes that. For me (bulk88), with an -O1 build, perl517.dll dropped
from 1044KB to 1036KB after applying this.
Jan Dubois [Mon, 30 Jul 2012 23:08:01 +0000 (16:08 -0700)]
Split __declspec(dllimport,noreturn) into 2 parts
I thought I did test commit
12a2785c with VC6 and it built without
errors, but I can no longer reproduce this. Checking standard
CRT headers shows common usage (e.g. for longjmp() in setjmp.h) is
"__declspec(dllimport) __declspec(noreturn)", so let's use that
one instead.
Nicholas Clark [Mon, 30 Jul 2012 14:53:52 +0000 (16:53 +0200)]
Fix C pre-processor expression in Dumper.xs
Commit
153920a10f425609 added a second condition to an #ifdef in Dumper.xs,
but didn't change the #ifdef to #if defined. Clearly gcc can cope with the
resulting non-conformant pre-processor expression, but pickier compilers
(such as HP's) reject it. Re-write it in a way that everything accepts.
Father Chrysostomos [Sun, 29 Jul 2012 20:30:35 +0000 (13:30 -0700)]
perlvar: Correct $^S’s description
Father Chrysostomos [Sun, 29 Jul 2012 20:28:21 +0000 (13:28 -0700)]
diagnostics.t: Test BEGIN{die}
Father Chrysostomos [Sun, 29 Jul 2012 20:27:30 +0000 (13:27 -0700)]
Revert "Increase $diagnostics::VERSION to 1.31"
This reverts commit
c369a25dcc5e5c5b627a50d1c4b73c2be0b926b9.
I have just reverted the only other change to diagnostics.pm
since 5.17.2.
Father Chrysostomos [Sun, 29 Jul 2012 20:25:50 +0000 (13:25 -0700)]
Revert "Use $^S instead of caller in splain"
This reverts commit
019070c31184a4deb57cb85f7e597a789c6c5b54.
I misunderstood $^S, and thought I could simplify the code. Contrary
to what perlvar says, $^S is undefined not only during compilation of
an eval or module, but also during compilation of the main program.
Father Chrysostomos [Sun, 29 Jul 2012 20:15:25 +0000 (13:15 -0700)]
perldelta for undef(&foo) and call checkers
Father Chrysostomos [Sun, 29 Jul 2012 20:14:40 +0000 (13:14 -0700)]
Make undef &foo remove call checkers
The fact that the call checker is stored in magic is an implementation
detail. cv_undef does not free magic, so the call checker lives on.
If we were to move the parameter prototype into magic internally, we
would not want undef to stop clearing it. To me, the current situa-
tion with call checkers is similar.
Father Chrysostomos [Sun, 29 Jul 2012 20:01:27 +0000 (13:01 -0700)]
pad.c: document cv_forget_slab
Father Chrysostomos [Sun, 29 Jul 2012 05:48:27 +0000 (22:48 -0700)]
[perl #113940] Make make_ext delete Makefiles when version changes
This eliminates this annoyance:
$ ./perl -Ilib -MStorable -e0
Storable object version 2.37 does not match bootstrap parameter 2.38 at lib/XSLoader.pm line 95.
Compilation failed in require.
BEGIN failed--compilation aborted.
Father Chrysostomos [Sun, 29 Jul 2012 07:26:55 +0000 (00:26 -0700)]
Remove some redundant magical flag checks
Now that gmagical svs use the OK flags the same way as muggles,
things like SvPOK || (SvGMAGICAL && SvPOKp) are no longer necessary.
Father Chrysostomos [Sun, 29 Jul 2012 07:03:45 +0000 (00:03 -0700)]
Use $^S instead of caller in splain
Father Chrysostomos [Sun, 29 Jul 2012 06:58:44 +0000 (23:58 -0700)]
Increase $diagnostics::VERSION to 1.31
Father Chrysostomos [Sun, 29 Jul 2012 06:54:16 +0000 (23:54 -0700)]
perldelta: proto mismatch warnings
Father Chrysostomos [Sun, 29 Jul 2012 06:41:00 +0000 (23:41 -0700)]
Fix scrambled and incorrect proto mismatch error
$ ./perl -Ilib -e 'use constant foo=>bar; sub foo(@);'
Prototype mismatch:: none vs (@) at -e line 1.
$ ./perl -Ilib -e 'sub foo(); sub foo(@);'
Prototype mismatch: () vs (@) at -e line 1.
Notice the double colon and the ‘none’ in the first example?
We also have this bug, where the prototype is the same, but we get the
warning anyway:
$ ./perl -Ilib -e 'use constant foo=>bar; sub foo();'
Prototype mismatch:: none vs () at -e line 1.
When the $::{foo} = \1 constant optimisation was added in 5.10.0, pro-
totype warnings were not taken into account. A forward declaration
like sub foo() puts a string in the stash element. newATTRSUB was
passing a non-SVt_NULL non-gv stash element to cv_ckproto_len_flags,
which assumed that !SvPOK meant no prototype. That’s not the case
with a reference.
The double colon, which goes back to 5.8.4 (
ebe643b99/
59e7bac08e),
occurs when the sub name is not available:
$ perl5.8.4 -e 'sub foo; sub foo();'
Prototype mismatch:: none vs () at -e line 1.
(Before that the message was worse:
$ perl5.8.3 -e 'sub foo; sub foo();'
Prototype mismatch: vs () at -e line 1.)
In 5.10.0, it started applying to constants as well, which used to
show the sub name:
$ perl5.8.9 -e 'use constant foo=>bar; sub foo(@);'
Prototype mismatch: sub main::foo () vs (@) at -e line 1.
$ perl5.10.0 -e 'use constant foo=>bar; sub foo(@);'
Runaway prototype at -e line 1.
Prototype mismatch:: none vs (@) at -e line 1.
(‘Runaway prototype’ is already gone in blead [
acfcf464b177, in which
I stated wrongly that the warning could only come about with stash
manipulation].)
This commit changes cv_ckproto_len_flags to assume that a reference
is a constant with an empty string for a prototype. It also makes
newATTRSUB pass the sub name sv instead of a gv in those cases where
the stash element isn’t a gv. This doesn’t restore things to exactly
the way they were before (foo instead of main::foo), but I’m not sure
it’s worth the added complexity of constructing the fully-qualified
name, just for a warning.
Father Chrysostomos [Sun, 29 Jul 2012 05:52:57 +0000 (22:52 -0700)]
perldelta for
4499db7385 (vstr =~ s/a/a/)
Father Chrysostomos [Sun, 29 Jul 2012 01:32:02 +0000 (18:32 -0700)]
sv.h: Document SvTHINKFIRST
Father Chrysostomos [Sat, 28 Jul 2012 07:39:41 +0000 (00:39 -0700)]
Dumper.xs: Avoid scan_vstring on 5.17.3
Now that vstring set-magic is gone (
4499db7385), there is no
PL_vtbl_vstring, so we cannot use it for detecting vstring
bugginess.
Father Chrysostomos [Sat, 28 Jul 2012 07:35:18 +0000 (00:35 -0700)]
Increase $Data::Dumper::VERSION to 2.135_07
Father Chrysostomos [Sat, 28 Jul 2012 07:33:33 +0000 (00:33 -0700)]
Oust sv_gmagical_2iv_please
The magic flags patch prevents this from ever being called, since the
OK flags work the same way for magic variables now as they have for
muggle vars, avoid these fiddly games. (It was when writing it that I
realised the value of the magic flags proposal.)
Nicholas Clark [Fri, 27 Jul 2012 17:17:54 +0000 (19:17 +0200)]
Remove code for supporting 80286 based systems.
The 80286 was released two years before Perl 1, but the support code was
added with Perl 3. The chip hasn't been produced for more than 15 years -
even the 80386 hasn't been manufactured since 2007. Most of the other
memory model code was removed by commit
5869b1f143426909 in Sep 2000, so
support for 16 bit systems is long dead.
Nicholas Clark [Fri, 27 Jul 2012 15:53:22 +0000 (17:53 +0200)]
Remove dead code related to the Atari ST port of perl 4.0 patchlevel 19
The subdirectory containing the port specific files was purged when 5.000
was released, but changes made to other files were not removed.
Nicholas Clark [Sat, 28 Jul 2012 08:11:08 +0000 (10:11 +0200)]
Merge the refactoring of the filetest OPs' return code.
Nicholas Clark [Fri, 27 Jul 2012 14:38:01 +0000 (16:38 +0200)]
Comment the code with how filetest operators interact with the Perl stack.
Nicholas Clark [Fri, 27 Jul 2012 13:05:00 +0000 (15:05 +0200)]
Eliminate the macros FT_RETURN_FALSE() and FT_RETURN_TRUE().
As they now simply return the results of S_ft_return_false() and
S_ft_return_true() respectively, use this explicitly in the 7 places where
the macros had been used.
Nicholas Clark [Fri, 27 Jul 2012 12:47:56 +0000 (14:47 +0200)]
Refactor the macro FT_RETURN_TRUE() into the function S_ft_return_true()
This makes the true and false code paths as similar as possible. It also
eliminates a macro that the HP compiler was choking on.
Nicholas Clark [Fri, 27 Jul 2012 12:19:27 +0000 (14:19 +0200)]
Consolidate the code for returning false values from filetest operators.
Move the code that implements the non-stacking return processing from the
macro FT_RETURN_FALSE() into the static function S_ft_stacking_return_false().
Rename the function to S_ft_return_false() as it now handles all false cases.
Nicholas Clark [Fri, 27 Jul 2012 11:32:33 +0000 (13:32 +0200)]
Reorder S_ft_stacking_return_false().
Move the code which deals with setting the return value on perl's stack
ahead of the code which calculates which op to run next (the return value of
the C function).
Nicholas Clark [Fri, 27 Jul 2012 11:16:29 +0000 (13:16 +0200)]
Remove dSP from all filetest ops.
Following commit
d2c4d2d1e22d3125, all filetest ops avoid manipulating the
stack pointer until the point of pushing a return value. As all the filetest
returns now go through either FT_RETURN_FALSE() or FT_RETURN_TRUE(), it's
viable to put the dSP inside those two macros and use *PL_stack_sp in place
of TOPs. This eliminates all uses of sp in the bodies of the functions
(explicit, or implicit via macros), and that makes it clear that the main
bodies of the functions are not manipulating the stack.
Nicholas Clark [Fri, 27 Jul 2012 10:54:49 +0000 (12:54 +0200)]
Replace the macro RETURNX() with its expansion in FT_RETURN_{FALSE,TRUE}
The macros FT_RETURN_FALSE and FT_RETURN_TRUE in pp_ctl.c are already very
complex, sufficient to trigger an internal failure in HP's compiler [and
possibly also some humans :-)]. Replacing RETURNX() with the 3 statements it
expands to makes the intent of macros clearer, and exposes more refactoring
possibilities.
Father Chrysostomos [Sat, 28 Jul 2012 07:17:04 +0000 (00:17 -0700)]
perldelta for
1eb0b7be2ff1 (B::Deparse and loopex prec)
Father Chrysostomos [Sat, 28 Jul 2012 07:15:58 +0000 (00:15 -0700)]
perldelta for
1f039d60d3 (last $foo)
Father Chrysostomos [Sat, 28 Jul 2012 07:12:59 +0000 (00:12 -0700)]
perldelta for
2ba1f20ac3a (loopex prec docs)
Father Chrysostomos [Sat, 28 Jul 2012 07:10:53 +0000 (00:10 -0700)]
Father Chrysostomos [Sat, 28 Jul 2012 07:09:11 +0000 (00:09 -0700)]
perldelta for
42409c4069 (truncate FILENAME)
Father Chrysostomos [Sat, 28 Jul 2012 07:07:17 +0000 (00:07 -0700)]
Father Chrysostomos [Sat, 28 Jul 2012 07:04:25 +0000 (00:04 -0700)]
perldelta for
c9df4fdaad9 (dump LABEL leak)
Father Chrysostomos [Sat, 28 Jul 2012 06:59:19 +0000 (23:59 -0700)]
doop.c: Simplify do_trans’ un-cow logic
Since it calls SvPV_force_nomg a little further on, there is no need
for a separate sv_force_normal call to handle COWs.
Father Chrysostomos [Sat, 28 Jul 2012 06:51:59 +0000 (23:51 -0700)]
Fix C++ build broken by
1f039d60d3
The goto was bypassing initialisation. Avoiding goto altogether actu-
ally simplifies things.
Father Chrysostomos [Sat, 28 Jul 2012 06:46:07 +0000 (23:46 -0700)]
Flatten vstrings modified in place
A substitution forces its target to a string upon successful substitu-
tion, even if the substitution did nothing:
$ ./perl -Ilib -le '$a = *f; $a =~ s/f/f/; print ref \$a'
SCALAR
Notice that $a is no longer a glob after s///.
But vstrings are different:
$ ./perl -Ilib -le '$a = v102; $a =~ s/f/f/; print ref \$a'
VSTRING
I fixed this in 5.16 (
1e6bda93) for those cases where the vstring ends
up with a value that doesn’t correspond to the actual string:
$ ./perl -Ilib -le '$a = v102; $a =~ s/f/o/; print ref \$a'
SCALAR
It works through vstring set-magic, that does the check and removes
the magic if it doesn’t match.
I did it that way because I couldn’t think of any other way to fix
bug #29070, and I didn’t realise at the time that I hadn’t fixed
all the bugs.
By making SvTHINKFIRST true on a vstring, we force it through
sv_force_normal before any in-place string operations. We can also
make sv_force_normal handle vstrings as well. This fixes all the lin-
gering-vstring-magic bugs in just two lines, making the vstring set-
magic (which is also slow) redundant. It also allows the special case
in sv_setsv_flags to be removed.
Or at least that was what I had hoped.
It turns out that pp_subst, twists and turns in tortuous ways, and
needs special treatment for things like this.
And do_trans functions wasn’t checking SvTHINKFIRST when arguably it
should have.
I tweaked sv_2pv{utf8,byte} to avoid copying magic variables that do
not need copying.
Father Chrysostomos [Sat, 28 Jul 2012 01:05:02 +0000 (18:05 -0700)]
pp.c:pp_trans: avoid redundant sv in transr
I think I added the if (OP_TRANSR) block to the wrong spot, because the
mortal scalar created just before it is only used for y/// without /r.
Eric Brine [Fri, 27 Jul 2012 22:54:24 +0000 (18:54 -0400)]
Document return to be exempt from the looks-like-a-function rule, like dump, goto and next.
Father Chrysostomos [Fri, 27 Jul 2012 21:52:21 +0000 (14:52 -0700)]
perlfunc: document last/next EXPR
Also remove some repetitive text from goto, added in
2ba1f20ac3.
Father Chrysostomos [Fri, 27 Jul 2012 21:41:05 +0000 (14:41 -0700)]
B::Deparse: loopexes have assignment prec
See ticket #113684 for detail.
Father Chrysostomos [Fri, 27 Jul 2012 21:37:22 +0000 (14:37 -0700)]
Increase $B::Deparse::VERSION to 1.16
Father Chrysostomos [Fri, 27 Jul 2012 21:26:39 +0000 (14:26 -0700)]
[perl #113684] Make redo/last/next/dump accept expr
These functions have been allowing arbitrary expressions, but would
treat anything that did not resolve to a const op as the empty string.
Not only were arguments swallowed up without warning, but constant
folding could change the behaviour. Computed labels are allowed for
goto, and there is no reason to disallow them for these other ops.
This can also come in handy for certain types of code generators.
In the process of modifying pp functions to accept arbitrary labels,
I noticed that the label and loop-popping code was identical in three
functions, so I moved it out into a separate static function, to make
the changes easier.
I also had to reorder newLOOPEX significantly, because code under the
goto branch needed to a apply to last, and vice versa. Using multiple
gotos to switch between the branches created too much of a mess.
I also eliminated the use of SP from pp_last, to avoid copying the
value back and forth between SP and PL_stack_sp.
Father Chrysostomos [Fri, 27 Jul 2012 20:36:35 +0000 (13:36 -0700)]
pp.h: Make [TP]OPp and [TP]OPpx identical
In the absence of n_a (see
8c074e2a and
95fad918), there is no differ-
ence between [TP]OPp and [TP]OPpx except speed, so there is no reason
for the x-less variant to be deprecated.
Father Chrysostomos [Fri, 27 Jul 2012 20:02:13 +0000 (13:02 -0700)]
op.c: apidoc typo
Father Chrysostomos [Fri, 27 Jul 2012 17:46:26 +0000 (10:46 -0700)]
[perl #113684] Document actual prec of loop exits
These have always* had assignment precedence, such that
$a = goto $b = $c
is equivalent to
$a = (goto ($b = $c))
* I haven’t checked before perl 5.
Father Chrysostomos [Fri, 27 Jul 2012 17:30:58 +0000 (10:30 -0700)]
Fix CvOUTSIDE assert/refcnt bugs with sub redefinition
my $sub = sub { 4 };
*foo = $sub;
*bar = *foo;
undef &$sub;
eval "sub bar { 3 }";
undef *foo;
undef *bar;
As of 5.8.4, this script produces:
Attempt to free unreferenced scalar: SV 0x8002c4.
As of 5.14.0:
panic: del_backref.
Or, undef debugging builds:
Assertion failed: (!CvWEAKOUTSIDE(cv)), function Perl_newATTRSUB_flags, file op.c, line 7045.
Commit
5c41a5fa918 (backported to 5.8.4 in commit
7a565e5d) caused the
first bug:
commit
5c41a5fa918d32924e1ac2f02418d5d7f465ef26
Author: Dave Mitchell <davem@fdisolutions.com>
Date: Sun Jan 25 02:04:23 2004 +0000
Remove small memory leak in newATTRSUB that manifested as a
leaking scalar after the interpeter was cloned
p4raw-id: //depot/perl@22209
diff --git a/op.c b/op.c
index b902fed..5fd21bf 100644
--- a/op.c
+++ b/op.c
@@ -4165,6 +4165,8 @@ Perl_newATTRSUB(pTHX_ I32 floor, OP *o, OP *proto, OP *attrs, OP *block)
/* transfer PL_compcv to cv */
cv_undef(cv);
CvFLAGS(cv) = CvFLAGS(PL_compcv);
+ if (!CvWEAKOUTSIDE(cv))
+ SvREFCNT_dec(CvOUTSIDE(cv));
CvOUTSIDE(cv) = CvOUTSIDE(PL_compcv);
CvOUTSIDE_SEQ(cv) = CvOUTSIDE_SEQ(PL_compcv);
CvOUTSIDE(PL_compcv) = 0;
Checking the flags right after clobbering them can’t be a good idea.
Commit
437388a93 caused the panics and assertion failures. See com-
mit f6894bc for detail.
Commit f6894bc fixed the panics and assertion failures involving CvGV.
One remaining assertion (!CvWEAKOUTSIDE) added by
437388a93 is still
incorrect. It’s not true that CvWEAKOUTSIDE is never set on a re-
used stub.
In both cases (
5c41a5fa’s code and
437388a93’s code), the weakness
of CvOUTSIDE is ignored and the outside sub (the eval) is freed
prematurely.
It could be that this type of redefinition should be disallowed (des-
pite its usefulness), but that is a separate issue. This used to
work. And pure-Perl code should not be triggering assertion failures
or freeing scalars twice.
Father Chrysostomos [Fri, 27 Jul 2012 17:11:25 +0000 (10:11 -0700)]
Fix CvGV assertion bug with sub redefinition
*foo = \&baz;
*bar = *foo;
eval 'sub bar { print +(caller 0)[3], "\n" }';
bar();
Before 5.14, that produces:
main::foo
As of 5.14, it produces:
main::baz
Or, under debugging builds:
Assertion failed: (CvGV(cv) == gv), function Perl_newATTRSUB_flags, file op.c, line 7139.
commit
437388a93114b1acbfb3a173dfa7aa2138fd8283
Author: Nicholas Clark <nick@ccl4.org>
Date: Thu Nov 18 14:54:44 2010 +0000
Refactor newATTRSUB()'s logic for grafting a sub definition to an existing stub
Previously it was using cv_undef() to (partially) free the target CV (the
pre-existing stub), before donating it the padlist and outside pointers from
the source CV (the definition, just compiled), and then freeing up the remains
of the source CV.
Instead, explicitly exchange padlist and outside pointers, explicitly assign
other fields that need changing (file and stash), and assert that various
CvFLAGS are as we expect them.
That commit adds some assertions, including:
+ assert(!CvCVGV_RC(cv));
+ assert(CvGV(cv) == gv);
Those assertions are not always true. CvGV might be refcounted, and
it might not point to the same gv.
437388a93 also changed things such that the CVf_CVGV_RC flag is clob-
bered, so refcounting and backrefs get out of synch (tests for that
specific bug will be in a subsequent commit). It also stopped sub
redefinition from setting CvGV.
Nicholas Clark [Fri, 27 Jul 2012 15:36:40 +0000 (17:36 +0200)]
Restore microperl, which has been unable to build since January.
microperl was broken by commit
82ad65bb0613be64 on 2012-01-16, which used
IN_LOCALE_COMPILETIME for the first time in the C code. Unlike
IN_LOCALE_RUNTIME, it had no fallback definition for microperl.
Commit
f90a9a0230170cc0 on 2012-01-28 added the first use of Strtol(),
which means that microperl now needs to assume that the system has strtol().
(Which is not unreasonable, as it's part of C89).
Chip Salzenberg [Thu, 26 Jul 2012 03:27:30 +0000 (20:27 -0700)]
When setting environment variables via %ENV, force values to be strings only
(turning off other OK flags), make them byte strings; if wide characters can't
be downgraded to bytes, leave the string utf8 and issue a warning.
Chip Salzenberg [Thu, 26 Jul 2012 01:41:50 +0000 (18:41 -0700)]
Make all the SvPV*force* macros always return sv with SvPOK_only, as API
docs always claimed they did. Also update those docs to be clearer.
Karl Williamson [Thu, 26 Jul 2012 15:56:27 +0000 (09:56 -0600)]
mktables: Change \w definition to match new Unicode's
Unicode has changed their definition of what should match \w.
http://www.unicode.org/reports/tr18/. This follows that change.
Chris 'BinGOs' Williams [Thu, 26 Jul 2012 14:58:02 +0000 (15:58 +0100)]
Make Module::CoreList install into 'site' >= 5.012
Also if versiononly is set make sure that corelist is installed
with the appropriate versioned suffix.
Father Chrysostomos [Thu, 26 Jul 2012 07:16:00 +0000 (00:16 -0700)]
[perl #113872] Fix leavewrite’s stack handling
This commit fixes Scope::Escape compatibility by restoring the old
stack pointer stored on the context stack when exiting a write.
I don’t really understand why this fixes Scope::Escape, or rather, how
Scope::Escape ends up leaving some number of items on the stack other
than 1. But I *do* know this is the correct approach, as it mirrors
what pp_leavesub does in scalar context, but pops the stack back
to the old value (SP = newsp), rather than the old value+1 (see
pp_hot.c:pp_leavesub: MARK = newsp + 1; and later SP = MARK;). Then
the code that follows takes care of pushing write’s own return value.
Father Chrysostomos [Thu, 26 Jul 2012 05:19:56 +0000 (22:19 -0700)]
op.c: op_clear is tempting fate
This if() statement can be reached by op types to which the OpTRANS*
flags to not apply. They happen at present not to use any flags that
conflict with these (except when OPf_KIDS is set, in which case this
code is not reached). But we should make sure, via an assertion,
that new flags added to goto or last do not conflict with trans utf8
flags, and that trans utf8 flags (1 and 2), if renumbered, do not con-
flict with goto/last utf8 flags (128).
Father Chrysostomos [Thu, 26 Jul 2012 05:07:12 +0000 (22:07 -0700)]
Don’t let ?: folding affect truncate
truncate(${\1} ? foo : bar, 0) and truncate(1 ? foo : bar, 0) should
behave the same way, but were treated differently, due to the way ?:
is folded in the latter case. Now that foldedness is recorded in the
op tree (
cc2ebcd7902), we can use the OPpCONST_FOLDED flag to distin-
guish truncate(1 ? foo : bar, 0) from truncate(foo, 0).
Father Chrysostomos [Thu, 26 Jul 2012 05:04:02 +0000 (22:04 -0700)]
Stop truncate(word) from falling back to file name
In commit
5e0adc2d66, which was a bug fix, I made the mistake of
checking the truth of the return value of gv_fetchsv, which is called
when truncate’s argument is a bareword.
This meant that truncate FOO, 0; would truncate the file named FOO if
the glob happened to have been deleted.
Father Chrysostomos [Thu, 26 Jul 2012 03:15:36 +0000 (20:15 -0700)]
Don’t let ?: folding affect stat
stat(${\1} ? foo : bar) and stat(1 ? foo : bar) should behave the same
way, but were treated differently, due to the way ?: is folded in
the latter case. Now that foldedness is recorded in the op tree
(
cc2ebcd7902), we can use the OPpCONST_FOLDED flag to distinguish
stat(1 ? foo : bar) from stat(foo).
Father Chrysostomos [Thu, 26 Jul 2012 01:00:34 +0000 (18:00 -0700)]
Merge ck_trunc and ck_chdir
ck_chdir, added in 2006 (
d4ac975e) duplicates ck_trunc, added in
1993 (
79072805), except for a null op check which is harmless when
applied to chdir.
Father Chrysostomos [Wed, 25 Jul 2012 23:40:37 +0000 (16:40 -0700)]
op.c: dump LABEL leaks its label
./perl -Ilib -e 'warn $$; eval "sub { dump a }" while 1'
Watch the memory usage go up.
It didn’t have its own case in op_clear.
Father Chrysostomos [Wed, 25 Jul 2012 23:31:07 +0000 (16:31 -0700)]
op.c:op_free: Rmv dead code; simplify cop_free logic
This reverts
c53f1caa and
cc93af5f.
See the thread starting at
http://www.nntp.perl.org/group/perl.perl5.porters/2008/04/msg135885.html
Basically, change
c53f1caa made a change, but then
cc93af5f undid it,
but differently. This resulted in dead code left by
c53f1caa (type is
unused after the assignment). And in the end the code behaved exactly
the same way, so the original problem was not fixed. I suspect this
was a B::C bug.