This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perl5.git
11 years agoRemove win32/config*.gc64nox
Steve Hay [Sat, 9 Jun 2012 16:56:40 +0000 (17:56 +0100)]
Remove win32/config*.gc64nox

The ARCHPREFIX setting from makefile.mk is now passed into config_sh.PL
and config_h.PL and used to apply the changes necessary to the
config*.gc64 files to support both the usual gcc suite and the
x86_64-w64-mingw32-gcc suite (used when GCCCROSS=define).

Also remove the redundant INST_VER argument in the config_h.PL calls.

11 years agoRemove __GNUC__ / _MSC_VER games from win32/config_H.*
Steve Hay [Sat, 9 Jun 2012 10:57:58 +0000 (11:57 +0100)]
Remove __GNUC__ / _MSC_VER games from win32/config_H.*

The code was added by 465b7da985, based on changes in ActivePerl 816, but
it's not working correctly because the current build process winds up with
a config.h in lib/CORE which doesn't contain that code anyway.

(The appropriate canned config_H.* file is copied to config.h in order to
build miniperl.exe, but then miniperl.exe is used to run config_h.PL to
generate the real config.h from config_h.SH and config.sh. The real
config.h is then used to build perl.exe and is what gets copied into
lib/CORE for later use when building extensions, but it doesn't contain
the support for other compilers because that isn't in config_h.SH...)

Removing the code won't affect ActivePerl since it has not been getting
installed anyway, and Jan Dubois has confirmed that it is possible to
build a Perl extension using e.g. Off_t with MinGW even with the VC
config.h header file. Furthermore, anyone building perl from source
themselves will presumably be able to use the same compiler to build
extensions as they used to build perl itself anyway, so there is no
obvious need for this in the core perl distro.

Therefore, removing it rather than fixing it is better for simplicity.

11 years agoUpdated perlfaq to CPAN version 5.0150040
Chris 'BinGOs' Williams [Sat, 9 Jun 2012 11:27:09 +0000 (12:27 +0100)]
Updated perlfaq to CPAN version 5.0150040

  [DELTA]

  5.0150040 Sat  9 Jun 2012 12:02:27 +0100
    * perlglossary provided by Tom C. from Camel 4
    * remove prototypes and & for subroutine (mauke)
    * Grammar from patch [RT #113492]
    * utf8 in Email::MIME (wchristian)

11 years agoQuieten B::Deparse warnings (fixes #113464).
Paul Johnson [Sat, 2 Jun 2012 12:44:47 +0000 (14:44 +0200)]
Quieten B::Deparse warnings (fixes #113464).

11 years ago[perl #111610] Trouble with XS-APItest/t/clone-with-stack.t
Michael Schroeder [Sat, 9 Jun 2012 03:29:54 +0000 (20:29 -0700)]
[perl #111610] Trouble with XS-APItest/t/clone-with-stack.t

I ran into a bit of a problem when building perl-5.16.0.
'make test' showed a segfault in ext/XS-APItest/t/clone-with-stack.t.
It seems to be caused by accessing already freed memory, it
segfaults because I have MALLOC_PERTUBE_ set, thus glibc fills
freed memory with some value.

Digging deeper, it seems like perl_clone() does not fix
the cx's blk_oldcop element when doing context cloning, thus
blk_oldcop still points to PL_compiling in the old interp--the
calling scope for the BEGIN block being the compilation of the
code surrounding it--and the POPBLOCK done in leavesub will copy
the data from the old interp to PL_curcop.

After fixing this, it still crashed because interp_dup->Iop was
zero after the runops_standard() call (which is probably
correct as the end of the BEGIN block was reached). So I
also added an if statement that checks the pointer.

11 years agocflags: clang complains a lot about -Wunused-value which are not fixable
Reini Urban [Thu, 31 May 2012 19:58:35 +0000 (14:58 -0500)]
cflags: clang complains a lot about -Wunused-value which are not fixable

11 years agoAdd alloccopstash provisionally to the API
Father Chrysostomos [Sat, 9 Jun 2012 00:58:39 +0000 (17:58 -0700)]
Add alloccopstash provisionally to the API

11 years agoUpgrade initialization code in vms/vms.c.
Craig A. Berry [Fri, 8 Jun 2012 23:33:33 +0000 (18:33 -0500)]
Upgrade initialization code in vms/vms.c.

The LIB$INITIALIZE program section is examined by the image
activator for an array of 32-bit pointers to functions that will
get called early in start-up, before main() is called.  We use
this mechanism to get and set various run-time features.

The implementation we had was a bit cluttered with undocumented
features that weren't being used, and it didn't work under C++.
This new implementation is simpler and follows the documented
usage in the C++ release notes much more closely, and it works
under both C and C++.

We also now explicitly export the LIB$INITIALIZE psect in the
linker options file used to create the PERLSHR shareable image.

11 years agoRemove pragma about pragma messages.
Craig A. Berry [Fri, 8 Jun 2012 23:17:54 +0000 (18:17 -0500)]
Remove pragma about pragma messages.

We currently aren't getting any warnings about pragmas that need
to be suppressed and the C++ compiler doesn't know about the
"pragma" class of warnings, so stop disabling them.

11 years agoConsistent indentation in perlbook
Father Chrysostomos [Fri, 8 Jun 2012 23:19:40 +0000 (16:19 -0700)]
Consistent indentation in perlbook

11 years agoIncrease $B::Deparse::VERSION to 1.15
Father Chrysostomos [Fri, 8 Jun 2012 21:50:35 +0000 (14:50 -0700)]
Increase $B::Deparse::VERSION to 1.15

11 years agoB::Deparse: loopexes have list prec
Father Chrysostomos [Fri, 8 Jun 2012 21:49:57 +0000 (14:49 -0700)]
B::Deparse: loopexes have list prec

11 years agoConstant folding for x
Father Chrysostomos [Fri, 8 Jun 2012 19:58:42 +0000 (12:58 -0700)]
Constant folding for x

11 years agocv.h: Add comments
Father Chrysostomos [Fri, 8 Jun 2012 19:27:16 +0000 (12:27 -0700)]
cv.h: Add comments

11 years agoMake __SUB__ work in special blocks
Father Chrysostomos [Fri, 8 Jun 2012 17:00:38 +0000 (10:00 -0700)]
Make __SUB__ work in special blocks

11 years agosv.h: Comment typo
Father Chrysostomos [Fri, 8 Jun 2012 15:45:11 +0000 (08:45 -0700)]
sv.h: Comment typo

11 years agocop_stashoff is an integer, not a pointer.
Craig A. Berry [Fri, 8 Jun 2012 22:28:00 +0000 (17:28 -0500)]
cop_stashoff is an integer, not a pointer.

Fix for compiler warning introduced by d4d03940c58.

11 years agoUpdate perlbook.pod with recent releases
Herbert Breunung [Fri, 8 Jun 2012 22:16:12 +0000 (23:16 +0100)]
Update perlbook.pod with recent releases

Signed-off-by: Chris 'BinGOs' Williams <chris@bingosnet.co.uk>
11 years agoExperimentally Use Unicode 6.2 beta
Karl Williamson [Fri, 8 Jun 2012 16:10:28 +0000 (10:10 -0600)]
Experimentally Use Unicode 6.2 beta

Unicode 6.2 is proposing some changes that may very well break some
CPAN modules.  The timing of this nicely coincides with Perl's being
early in the release cycle.  This commit takes the current beta 6.2,
adds the proposed changes that aren't yet in it, and subtracts the
changes that would affect \X processing, as those turn out to have
errors, and may have to be rethought.  Unicode has been notified of
these problems.

This commit is to gather data as to whether or not the proposed changes
cause us problems.  These will be presented to Unicode to aid in their
final decision as to whether or not to go forward with the changes.

This commit should be reverted at some point, and the final 6.2 used
instead.

11 years agomktables: Remove unused $scalar
Karl Williamson [Fri, 8 Jun 2012 15:53:57 +0000 (09:53 -0600)]
mktables: Remove unused $scalar

This variable is no longer used, but the expression needs to be
evaluated anyway.  The code is outdented.

11 years agounicore/README.perl: Make text comments
Karl Williamson [Thu, 7 Jun 2012 04:32:53 +0000 (22:32 -0600)]
unicore/README.perl: Make text comments

This is so that it can be run by a Unix shell command to rename the
files that Unicode furnishes to the ones that Perl expects (because of
DOS 8.3 filesystems).

11 years agomktables: Add error check for overloaded &=
Karl Williamson [Fri, 8 Jun 2012 03:38:01 +0000 (21:38 -0600)]
mktables: Add error check for overloaded &=

This operation is not commutative, so should fail if the operands are
swapped.

11 years agomktables: Add &= overload for Range_Lists
Karl Williamson [Fri, 8 Jun 2012 03:35:17 +0000 (21:35 -0600)]
mktables: Add &= overload for Range_Lists

This is useful under the -annotate option

11 years agomktables: Use control names under -annotate
Karl Williamson [Fri, 8 Jun 2012 03:33:10 +0000 (21:33 -0600)]
mktables: Use control names under -annotate

Now that all the control characters have names, use them instead of the
generic, "Control", but retain that as a fall back just in case.

11 years agoSync base in Maintainers.pl with CPAN version
Chris 'BinGOs' Williams [Fri, 8 Jun 2012 12:26:48 +0000 (13:26 +0100)]
Sync base in Maintainers.pl with CPAN version

11 years agoperldelta for $@=3; warn
Father Chrysostomos [Fri, 8 Jun 2012 06:48:14 +0000 (23:48 -0700)]
perldelta for $@=3; warn

11 years agoperldelta for -$utf8
Father Chrysostomos [Fri, 8 Jun 2012 06:46:18 +0000 (23:46 -0700)]
perldelta for -$utf8

11 years agoperldelta for -"-10" with gmagic
Father Chrysostomos [Fri, 8 Jun 2012 06:45:16 +0000 (23:45 -0700)]
perldelta for -"-10" with gmagic

11 years agoperldelta for -$str_with_cached_num
Father Chrysostomos [Fri, 8 Jun 2012 06:44:10 +0000 (23:44 -0700)]
perldelta for -$str_with_cached_num

11 years agoperldelta for numeric opts, gmg, and 64-bit ints
Father Chrysostomos [Fri, 8 Jun 2012 06:40:55 +0000 (23:40 -0700)]
perldelta for numeric opts, gmg, and 64-bit ints

11 years agoperldelta for warn gmagic fixes
Father Chrysostomos [Fri, 8 Jun 2012 06:38:40 +0000 (23:38 -0700)]
perldelta for warn gmagic fixes

11 years agoperldelta for prototype($1)
Father Chrysostomos [Fri, 8 Jun 2012 06:35:16 +0000 (23:35 -0700)]
perldelta for prototype($1)

11 years agoperldelta for open, <&, and $1
Father Chrysostomos [Fri, 8 Jun 2012 06:31:39 +0000 (23:31 -0700)]
perldelta for open, <&, and $1

11 years agoperldelta for UNIVERSAL::can($num,...)
Father Chrysostomos [Fri, 8 Jun 2012 06:28:42 +0000 (23:28 -0700)]
perldelta for UNIVERSAL::can($num,...)

11 years agoperldelta for ‘Not a format ref’
Father Chrysostomos [Fri, 8 Jun 2012 06:25:39 +0000 (23:25 -0700)]
perldelta for ‘Not a format ref’

11 years agoperldelta for B::COP::stashpv and utf8/nulls
Father Chrysostomos [Fri, 8 Jun 2012 06:23:19 +0000 (23:23 -0700)]
perldelta for B::COP::stashpv and utf8/nulls

11 years agoperldelta for B::COP::stashoff
Father Chrysostomos [Fri, 8 Jun 2012 06:22:41 +0000 (23:22 -0700)]
perldelta for B::COP::stashoff

11 years agoperldelta for caller crashing on SvOOK str
Father Chrysostomos [Fri, 8 Jun 2012 06:20:52 +0000 (23:20 -0700)]
perldelta for caller crashing on SvOOK str

11 years agoperldelta for cop_stashoff
Father Chrysostomos [Fri, 8 Jun 2012 06:17:22 +0000 (23:17 -0700)]
perldelta for cop_stashoff

11 years agoperldelta for #78742 — eval "__PACKAGE__"
Father Chrysostomos [Fri, 8 Jun 2012 03:02:19 +0000 (20:02 -0700)]
perldelta for #78742 — eval "__PACKAGE__"

11 years agoperldelta: fix pod syntax
Father Chrysostomos [Fri, 8 Jun 2012 02:54:36 +0000 (19:54 -0700)]
perldelta: fix pod syntax

11 years agoperldelta for rv2cv not cloning closures
Father Chrysostomos [Fri, 8 Jun 2012 01:01:07 +0000 (18:01 -0700)]
perldelta for rv2cv not cloning closures

11 years agoperldelta for ‘Runaway prototype’ removal
Father Chrysostomos [Thu, 7 Jun 2012 23:14:18 +0000 (16:14 -0700)]
perldelta for ‘Runaway prototype’ removal

11 years agoperldelta for study code removal
Father Chrysostomos [Thu, 7 Jun 2012 23:12:49 +0000 (16:12 -0700)]
perldelta for study code removal

11 years agoperldelta for #113060
Father Chrysostomos [Thu, 7 Jun 2012 23:10:36 +0000 (16:10 -0700)]
perldelta for #113060

11 years agoperldelta for #97478
Father Chrysostomos [Thu, 7 Jun 2012 22:59:59 +0000 (15:59 -0700)]
perldelta for #97478

11 years agoperldelta tweaks
Father Chrysostomos [Thu, 7 Jun 2012 21:57:06 +0000 (14:57 -0700)]
perldelta tweaks

11 years agoperldelta for new coresubs
Father Chrysostomos [Thu, 7 Jun 2012 21:56:32 +0000 (14:56 -0700)]
perldelta for new coresubs

11 years agoperldelta for #111782
Father Chrysostomos [Thu, 7 Jun 2012 17:02:29 +0000 (10:02 -0700)]
perldelta for #111782

11 years agoperldelta for #76546
Father Chrysostomos [Thu, 7 Jun 2012 16:57:28 +0000 (09:57 -0700)]
perldelta for #76546

11 years agoperldelta for #9423
Father Chrysostomos [Thu, 7 Jun 2012 16:44:57 +0000 (09:44 -0700)]
perldelta for #9423

11 years agoperldelta for #111510
Father Chrysostomos [Thu, 7 Jun 2012 16:42:24 +0000 (09:42 -0700)]
perldelta for #111510

11 years agocop.h: Clarify comment
Father Chrysostomos [Wed, 6 Jun 2012 22:55:16 +0000 (15:55 -0700)]
cop.h: Clarify comment

11 years agoper the request of the metacpan crew, cc them on release
Ricardo Signes [Fri, 8 Jun 2012 01:58:31 +0000 (21:58 -0400)]
per the request of the metacpan crew, cc them on release

11 years agoUCD.t: Cope with $/ being set.
Karl Williamson [Thu, 7 Jun 2012 18:28:54 +0000 (12:28 -0600)]
UCD.t: Cope with $/ being set.

These tests fail in some earlier Unicode versions because $/ is being
set.  Reset it to $/ around the reads and chomps this .t does.

11 years agoRevert "UCD.t: Don't use BEL for $/"
Karl Williamson [Mon, 4 Jun 2012 15:08:19 +0000 (09:08 -0600)]
Revert "UCD.t: Don't use BEL for $/"

This reverts commit 9a8e4a54f8b3668a7ebd8f229cdfb405a1dce77c.  It turns
out that the reason this was there was to add a stress test.  Outside
setting of $/ should not break Unicode::UCD

11 years agomktables: Use initialize instead of a push
Karl Williamson [Mon, 4 Jun 2012 15:06:07 +0000 (09:06 -0600)]
mktables: Use initialize instead of a push

The code later on used to be done only sometimes; now that it is
executed always, some of it can be done at initialization time.

11 years agoSync the version of Perl-Perldoc in Maintainers.pl with CPAN
Chris 'BinGOs' Williams [Thu, 7 Jun 2012 19:06:26 +0000 (20:06 +0100)]
Sync the version of Perl-Perldoc in Maintainers.pl with CPAN

11 years agoutf8.c: White-space only
Karl Williamson [Wed, 6 Jun 2012 21:56:09 +0000 (15:56 -0600)]
utf8.c: White-space only

11 years agoutf8.c: Refactor a portion of to_utf8_case()
Karl Williamson [Wed, 6 Jun 2012 21:50:53 +0000 (15:50 -0600)]
utf8.c: Refactor a portion of to_utf8_case()

This routine can never return 0, as if there is no case mapping, the
input is used instead.  The code point for that input has already been
derived earlier in the function, so it doesn't have to be recalculated.
And, rearrange the order of things slightly.

11 years agoutf8.c: Avoid some extra work
Karl Williamson [Wed, 6 Jun 2012 21:40:38 +0000 (15:40 -0600)]
utf8.c: Avoid some extra work

In the case changed, the output is the input, so can just Copy it
instead of re-deriving it.

11 years agoutf8.c: Add, revise comments
Karl Williamson [Wed, 6 Jun 2012 21:40:02 +0000 (15:40 -0600)]
utf8.c: Add, revise comments

11 years agodocs patch: 'unicode_strings' doesn't change utf8ness
Karl Williamson [Wed, 6 Jun 2012 17:12:24 +0000 (11:12 -0600)]
docs patch: 'unicode_strings' doesn't change utf8ness

We had a field report of lack of clarity around this, so add some
text.

11 years agoperlfunc: Add comma
Karl Williamson [Wed, 6 Jun 2012 17:11:34 +0000 (11:11 -0600)]
perlfunc: Add comma

11 years agoRemove droppings from t/
Father Chrysostomos [Thu, 7 Jun 2012 15:28:01 +0000 (08:28 -0700)]
Remove droppings from t/

I accidentally added these when resolving merge conflicts.

11 years ago[Merge] SvPOK bug hunt
Father Chrysostomos [Thu, 7 Jun 2012 15:19:32 +0000 (08:19 -0700)]
[Merge] SvPOK bug hunt

Spurred on by a comment in ticket #109542, I went looking for misuse
of SvPOK, where SvPOKp should be used instead (since variables with
get-magic don’t have SvPOK set).

I discovered a few bugs like that, plus many more bugs that were sim-
ilar, but not quite the same.

11 years agoMake warn treat $@=3 and $@="3" the same
Father Chrysostomos [Thu, 7 Jun 2012 06:19:47 +0000 (23:19 -0700)]
Make warn treat $@=3 and $@="3" the same

If we get this:

$ ./perl -Ilib -e '$@ = "3"; warn'
3 ...caught at -e line 1.

then we shouldn’t get this:

$ ./perl -Ilib -e '$@ = 3; warn'
Warning: something's wrong at -e line 1.

as the two scalars hold the same value.

11 years agopp.c:pp_negate: Move looks_like_number where it matters
Father Chrysostomos [Thu, 7 Jun 2012 06:07:18 +0000 (23:07 -0700)]
pp.c:pp_negate: Move looks_like_number where it matters

Since we already have a check further down to see whether a string
begins with an identifier or sign, and since looks_like_number
was added for strings representing negative numbers, move the
looks_like_number down to where we already know the string
begins with '-'.

This is a micro-optimisation, but it also makes the code more
straightforward (to me at least).

This happens to let magical integers-as-strings fall down to code that
they used not to reach, so that has to change to account.

11 years agopp_negate: Support magic big ints as strings
Father Chrysostomos [Thu, 7 Jun 2012 06:05:24 +0000 (23:05 -0700)]
pp_negate: Support magic big ints as strings

-$1 was treating $1 as a float even if the string consisted of an
integer, due to incorrect flag checks.  It was doing the same things
with tied variables returning str+int dualvars.

Simply checking whether the privates flags consist solely of SVp_IOK
(which works for tie variables returning pure integers--so I wasn’t
entirely wrong in adding that logic a few commits ago), isn’t suffi-
cient. For gmagical variables that have already had get-magic called
on them, the private flags are equivalent to public flags for other
variables.

11 years agopp_negate and the Unicode Bug
Father Chrysostomos [Wed, 6 Jun 2012 22:54:08 +0000 (15:54 -0700)]
pp_negate and the Unicode Bug

$ ./perl -Ilib -Mutf8 -CO -le 'print -"3 apples"'
-3
$ ./perl -Ilib -Mutf8 -CO -le 'print -"3 μῆλα"'
-3 μῆλα

This has been this way since 5.10.1.  In 5.10.0, it was consistent:

$ perl5.10.0 -Mutf8 -CO -le 'print -"3 apples"'
-3
$ perl5.10.0 -Mutf8 -CO -le 'print -"3 μῆλα"'
-3

But the worst part is that we get a non-numeric warning now for a
string operation:

$ perl5.10.1 -Mutf8 -CO -lwe 'print -"3 μῆλα"'
Argument "\x{33}\x{20}..." isn't numeric in negation (-) at -e line 1.
-3 μῆλα

This goes back to commit a43d94f2c089, which by itself looks perfectly
correct (I won’t quote the diff here, as it is long; but it doesn’t
touch pp_negate):

commit a43d94f2c089c6f14197795daeebb7835550a747
Author: Nicholas Clark <nick@ccl4.org>
Date:   Mon Jan 7 18:24:39 2008 +0000

    Don't set the public IV or NV flags if the string converted from has
    trailing garbage. This behaviour is consistent with not setting the
    public IV or NV flags if the value is out of range for the type.

    p4raw-id: //depot/perl@32894

It seems that pp_negate was already buggy before that (or ‘validly’
assumed that numeric coercion would set public flags).  And it looks
as though commit 8eb28a70b2e is at fault here.

It changed this:

$ perl5.6.2 -Mutf8 -lwe 'print -"ð"'


to this:

$ perl5.8.1 -Mutf8 -lwe 'print -"ð"'
Argument "\x{f0}" isn't numeric in negation (-) at -e line 1.
0

to comply with what happens when the UTF8 flag is not set.  But it was
relying on bugs in sv_2iv, etc.

So, from 5.8.0 to 5.10.0 inclusive, unary negation prepends "-" if the
string begins with [A-Za-z], but from 5.10.1 onwards it behaves diffe-
rently depending on the internal UTF8 flag (even prepending "-" to
ASCII-only strings like "%apples" if the UTF8 flag is on).

This commit restores the 5.8.0-5.10.0 behaviour, which was at least
self-consistent.

11 years agoFix perl #57706 for magical vars: -"-10"
Father Chrysostomos [Wed, 6 Jun 2012 19:49:05 +0000 (12:49 -0700)]
Fix perl #57706 for magical vars: -"-10"

Commit a5b92898 caused -"-10" to return 10, not "+10".  But it wasn’t
working for magical variables.

SvIV_please_nomg was fixed recently for magical variables, but not
SvIV_please, so change pp_negate to use that.

(Ironically, SvIV_please has never called magic, so the
SvIV_please_nomg variant never needed to exist.  So the two could
be merged.)

11 years agopp_negate: Don’t treat nummified str as num
Father Chrysostomos [Wed, 6 Jun 2012 05:38:12 +0000 (22:38 -0700)]
pp_negate: Don’t treat nummified str as num

I think it’s a bug that this prints 0:

$ ./perl -lIlib -MDevel::Peek -e '$x = "dogs"; 0+$x; Dump $x; print -$x'
SV = PVNV(0x802340) at 0x821b90
  REFCNT = 1
  FLAGS = (POK,pIOK,pNOK,pPOK)
  IV = 0
  NV = 0
  PV = 0x301620 "dogs"\0
  CUR = 4
  LEN = 16
0

This variable is a string, not a number.  The number 0 is just a
cached value.  It lacks the IOK flag precisely because the IV is not
representative of the actual value of the scalar.

This logic here is a little bit odd:

        if( !SvNIOK( sv ) && looks_like_number( sv ) ){
           SvIV_please( sv );
        }

if ((flags & SVf_IOK) || ((flags & (SVp_IOK | SVp_NOK)) == SVp_IOK)) {

SvIV_please sets the flags on sv but then they are ignored when check-
ing for integrality.

To fix the bug mentioned above, I had to change this logic to use sv
directly, rather than the saved flags.

That meant that this bug was also fixed at the same time, since the
integer code is no longer bypassed when it is SvIV_please that sets
the integer flags:

$ ./perl -Ilib -le 'print -97656250000000000'
-97656250000000000
$ ./perl -Ilib -le 'print -"97656250000000000"'
-9.765625e+16

11 years ago[perl #109542] Make num ops treat $1 as "$1"
Father Chrysostomos [Wed, 6 Jun 2012 03:09:32 +0000 (20:09 -0700)]
[perl #109542] Make num ops treat $1 as "$1"

Numeric ops were not taking magical variables into account.  So $1 (a
magical variable) would be treated differently from "$1" (a non-magi-
cal variable0.

In determining whether to use an integer operation, they would call
SvIV_please_nomg, and then check whether the sv was SvIOK as a result.

SvIV_please_nomg would call SvIV_nomg if the sv were SvPOK or SvNOK.

The problem here is that gmagical variables are never SvIOK, but
only SvIOKp.

In fact, the private flags are used differently for gmagical and non-
magical variables.  For non-gmagical variables, the private flag indi-
cates that there is a cached value.  If the public flag is not set,
then the cached value is imprecise.  For gmagical variables, imprecise
values are never cached; only the private flags are used, and they are
equivalent to the public flags on non-gmagical variables.

This commit changes SvIV_please_nomg to take gmagical variables
into account, using the newly-added sv_gmagical_2iv_please (see the
docs for it in the diff).  SvIV_please_nomg now returns true or
false, not void, since a subsequent SvIOK is not reliable.  So
‘SvIV_please_nomg(sv); if(SvIOK)’ becomes ‘if(SvIV_please_nomg(sv))’.

11 years agoMake warn handle magic vars (fixes [perl #97480])
Father Chrysostomos [Sun, 27 May 2012 07:11:31 +0000 (00:11 -0700)]
Make warn handle magic vars (fixes [perl #97480])

pp_warn was checking flags before calling get-magic, resulting in sev-
eral bugs that I fixed all at once::
• warn now calls get-magic exactly once on its argument, when there
  is just one argument (it always worked correctly for multiple)
  [perl #97480].
• warn calls get-magic exactly once on $@ when falling back to it,
  instead of zero times.
• A tied variable returning an object that stringifies as an empty
  string is no longer ignored if the tied variable was not ROK
  before FETCH.
• A tied $@ containing a string, or $@ aliased to $1, is no
  longer ignored.
• A tied $@ that last returned a reference but will return a string on
  the next FETCH now gets "\t...caught" appended.

11 years agoMake prototype call FETCH before checking CORE:: prefix
Father Chrysostomos [Sat, 26 May 2012 13:00:01 +0000 (06:00 -0700)]
Make prototype call FETCH before checking CORE:: prefix

$ perl5.16.0 -e '"CORE::length" =~ /(.*)/; warn prototype $1;'
Warning: something's wrong at -e line 1.
$ perl5.16.0 -e 'warn prototype "CORE::length"'
_ at -e line 1.

Since sv_2cv calls get-magic, the easiest solution is to copy the
argument if it is magical.

11 years agoMake strict refs report $1 the same way as "$1"
Father Chrysostomos [Sat, 26 May 2012 05:44:39 +0000 (22:44 -0700)]
Make strict refs report $1 the same way as "$1"

A magical variable is never SvPOK, but only SvPOKp.  The code that
determined whether to put an ellipsis mark after a truncated symbol
name was only checking SvPOK, resulting in this discrepancy:

$ perl5.15.9 -e 'use strict; *{"a"x40}'
Can't use string ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"...) as a symbol ref while "strict refs" in use at -e line 1.
$ perl5.15.9 -e 'use strict; ("a"x40)=~/(.*)/; *{$1}'
Can't use string ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") as a symbol ref while "strict refs" in use at -e line 1.
$ perl5.15.9 -e 'use strict; ${"a"x40}'
Can't use string ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"...) as a SCALAR ref while "strict refs" in use at -e line 1.
$ perl5.15.9 -e 'use strict; ("a"x40)=~/(.*)/; ${$1}'
Can't use string ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") as a SCALAR ref while "strict refs" in use at -e line 1.

SvPOK variables are also SvPOKp, so checking just the latter suffices.

11 years agoMake open(... "<&", $fileno) respect magic
Father Chrysostomos [Fri, 25 May 2012 06:13:37 +0000 (23:13 -0700)]
Make open(... "<&", $fileno) respect magic

A magical variable is never SvPOK, but only SvPOKp.  The code for
checking whether a duplicatee is a numeric file descriptor was only
checking SvPOK.  So a regular variable containing a fileno-as-a-string
would work, such as the $a below, as would a stringified magical vari-
able ("$1"), but not $1 itself.

$ echo foo | perl -le '$a = "0"; open a, "<&", $a; warn <a>'
foo
$ echo foo | perl -le '"0" =~ /(.)/; open a, "<&", $1; warn <a>'
Can't use an undefined value as filehandle reference at -e line 1.
$ echo foo | perl -le '"0" =~ /(.)/; open a, "<&", "$1"; warn <a>'
foo

SvPOK variables are also SvPOKp, so checking only the latter suffices.

11 years agoutil.c:report_evil_fh: Report name w/initial null
Father Chrysostomos [Fri, 25 May 2012 05:46:56 +0000 (22:46 -0700)]
util.c:report_evil_fh: Report name w/initial null

In the error message, we shouldn’t omit a handle whose name begins
with "\0", but, rather, a handle whose name has no length to it.

11 years agoutil.c:report_evil_fh: Rmv redundant SvPOK
Father Chrysostomos [Fri, 25 May 2012 05:46:16 +0000 (22:46 -0700)]
util.c:report_evil_fh: Rmv redundant SvPOK

newSVhek (used to create this SV) always returns an SvPOK scalar.

11 years agoutil.c:report_wrongway_fh: Report name w/initial null
Father Chrysostomos [Fri, 25 May 2012 05:41:53 +0000 (22:41 -0700)]
util.c:report_wrongway_fh: Report name w/initial null

In the error message, we shouldn’t omit a handle whose name begins
with "\0", but, rather, a handle whose name has no length to it.

11 years agoutil.c:report_evil_fh: Rmv redundant isGV check
Father Chrysostomos [Fri, 25 May 2012 05:19:29 +0000 (22:19 -0700)]
util.c:report_evil_fh: Rmv redundant isGV check

Checking isGV_with_GP makes the isGV check redundant.  The only case
in which isGV could be true when isGV_with_GP is false could be a GV
playing PVBM, but those don’t exist any more.  When they did exist,
this check was probably wrong (and crashable).

11 years agoutil.c:report_wrongway_fh: Don’t create an SV
Father Chrysostomos [Fri, 25 May 2012 05:16:52 +0000 (22:16 -0700)]
util.c:report_wrongway_fh: Don’t create an SV

Now that sv_vcatpvfn supports HEKs directly, we don’t need to create a
temporary SV out of one.

11 years agoutil.c:report_wrongway_fh: Rmv redundant isGV check
Father Chrysostomos [Fri, 25 May 2012 05:10:32 +0000 (22:10 -0700)]
util.c:report_wrongway_fh: Rmv redundant isGV check

Checking isGV_with_GP makes the isGV check redundant.  The only case
in which isGV could be true when isGV_with_GP is false could be a GV
playing PVBM, but those don’t exist any more.  When they did exist,
this check was probably wrong (and crashable).

11 years agoMake UNIVERSAL::can treats str and num the same way
Father Chrysostomos [Fri, 25 May 2012 03:37:01 +0000 (20:37 -0700)]
Make UNIVERSAL::can treats str and num the same way

11 years agoUse the same top format error for ""
Father Chrysostomos [Thu, 24 May 2012 19:45:58 +0000 (12:45 -0700)]
Use the same top format error for ""

See also the previous commit.

2dd78f96 added the ‘Undefined top format called’ message for those
cases where a GV doesn’t have a name.  That was a bug that used to
happen with *{$io}, which can’t happen any more.

The code that 2dd78f96 added ended up changing a zero-length name to
be treated the same way as no name.  It also checked the length by
cheating and checking the first character instead.

Now that we have support for embedded nulls, that logic ends up wrong
for names like "\0foo".  And there is no need to treat "" differently
from "foo" anyway.

So this patch restores things the way they were before 2dd78f96.

It also improves the tests for ‘Undefined format’.

Writing tests for ‘Undefined top format’ was quite painful, as that
error seems to leave the internal state out of synch.  I suspect
PL_formtarget needs to be localised, or the error just needs to come
earlier in pp_leavewrite.  But I’ll save that for later, or for Dave
Mitchell. :-)

11 years agoGet rid of ‘Not a format reference’
Father Chrysostomos [Thu, 24 May 2012 19:17:02 +0000 (12:17 -0700)]
Get rid of ‘Not a format reference’

This commit:

commit 2dd78f96d61cc6382dc72214930c993567209597
Author: Jarkko Hietaniemi <jhi@iki.fi>
Date:   Sun Aug 6 01:33:55 2000 +0000

    Continue fixing the io warnings.  This also
    sort of fixes bug ID 20000802.003: the core dump
    is no more.  Whether the current behaviour is correct
    (giving a warning: "Not a format reference"), is another matter.

    p4raw-id: //depot/perl@6531

added a check to see whether the format GV’s name is null, and, if
so, it dies with ‘Not a format reference’.  Before that, that message
occurred only for lack of a GV.

The bug mentioned is now #3617, involving write(*STDOUT{IO}).  write
puts an implicit *{} around its argument.

*{$io} has historically been very buggy in its stringification, so
this patch seems to have been working around that bugginess, by fall-
ing back to the ‘Not a format reference’ error if the name couldn’t be
determined for ‘Undefined format "foo" called’.

*{$io} was fixed once and for all in 5.16.  It now stringifies as
*foopackage::__ANONIO__.

I don’t think producing a completetly different error based on the
name of the GV (whether it’s "foo" or "") is correct at all.  And the
patch that made it happen was just a fix for a crash that can’t hap-
pen any more.

So the only case that should produce ‘Not a format reference’ is that
in which there is no format GV (fgv).

I can prove that fgv is always set (see below), and has been at least
since 5.000, so that ‘Not a format reference’ actually could never
occur before 2dd78f96d61c.  (Actually, XS code could set PL_defoutgv
to null until the previous commit, but everything would start crashing
as a result, so it has never been done in practice.)

gv_efullname4 always returns a name, so checking SvPOK(tmpsv) is
redundant; checking whether the string buffer begins with a non-null
char is not even correct, as "\0foo" fails that test.

Proof that fgv is always set:

The current (prior to this commit) code in pp_enterwrite is like this:

    if (MAXARG == 0) {
gv = PL_defoutgv;
EXTEND(SP, 1);
    }
    else {
gv = MUTABLE_GV(POPs);
if (!gv)
    gv = PL_defoutgv;
    }

If the stack value is null (which actually can’t happen), PL_defoutgv
is used.  PL_defoutgv can’t be null.

At this point, gv is set to something non-null.

    io = GvIO(gv);
    if (!io) {
RETPUSHNO;
    }

Here we only set fgv to IoFMT_GV(io) if it is non-null.  Otherwise we
use gv, which we know is non-null.

    if (IoFMT_GV(io))
fgv = IoFMT_GV(io);
    else
fgv = gv;

11 years agoMake setdefout accept only NN
Father Chrysostomos [Thu, 24 May 2012 19:07:37 +0000 (12:07 -0700)]
Make setdefout accept only NN

Just search through the source for GvIOp(PL_defoutgv) and you will see
that perl assumes that PL_defoutgv is never null.

I tried setting it to null from XS and got crashes, unsurprisingly.

The only CPAN user of PL_defoutgv sets it to STDOUT.

11 years agoAssertion failure with $/=*foo; warn;
Father Chrysostomos [Thu, 24 May 2012 06:24:35 +0000 (23:24 -0700)]
Assertion failure with $/=*foo; warn;

$ ./perl -Ilib -e '$/=*foo; <>; warn' <./perl
Assertion failed: (!isGV_with_GP(_svcur)), function Perl_mess_sv, file util.c, line 1467.
Abort trap

The assertion happens when ‘<...> line 42’ is being appended to
the message.

The line of code in question is this:

    const bool line_mode = (RsSIMPLE(PL_rs) &&
      SvCUR(PL_rs) == 1 && *SvPVX_const(PL_rs) == '\n');

It uses this macro in perl.h:

#define RsSIMPLE(sv)  (SvOK(sv) && (! SvPOK(sv) || SvCUR(sv)))

which was last modified by commit af7d13df559:

-#define RsSIMPLE(sv)  (SvOK(sv) && SvCUR(sv))
-#define RsPARA(sv)    (SvOK(sv) && ! SvCUR(sv))
+#define RsSIMPLE(sv)  (SvOK(sv) && (! SvPOK(sv) || SvCUR(sv)))
+#define RsPARA(sv)    (SvPOK(sv) && ! SvCUR(sv))

So it looks as though it has always called SvCUR on something that is
not necessarily a PV.  As of commit af7d13df559, it has also called
SvPVX on a potential non-PV.

Fixing this simply involves using SvPV instead of SvPVX.

I don’t know that t/io/open.t is the best place for the test, but all
the other ‘<...> line 42’ tests are there.

11 years agoRemove some commented-out lines from win32/config_h.PL
Steve Hay [Thu, 7 Jun 2012 13:24:42 +0000 (14:24 +0100)]
Remove some commented-out lines from win32/config_h.PL

11 years agoRemove some unnecessary apostrophes from win32/config_sh.PL
Steve Hay [Thu, 7 Jun 2012 12:39:01 +0000 (13:39 +0100)]
Remove some unnecessary apostrophes from win32/config_sh.PL

11 years agoUse strict and warnings in win32/config_(s)h.PL
Steve Hay [Thu, 7 Jun 2012 12:36:37 +0000 (13:36 +0100)]
Use strict and warnings in win32/config_(s)h.PL

11 years agoRemove $patchlevel from win32/config_h.PL since it is never used
Steve Hay [Thu, 7 Jun 2012 07:58:13 +0000 (08:58 +0100)]
Remove $patchlevel from win32/config_h.PL since it is never used

11 years agoSet version directly in Windows config.xxx files
Steve Hay [Thu, 7 Jun 2012 07:48:09 +0000 (08:48 +0100)]
Set version directly in Windows config.xxx files

There is no need for doing it via a ~VERSION~ substitution string since
that is not used anywhere else.

11 years agoUpdate how subversion is set in win32 config.xxx files
Steve Hay [Thu, 7 Jun 2012 07:35:23 +0000 (08:35 +0100)]
Update how subversion is set in win32 config.xxx files

SUBVERSION was the old name from patchlevel.h but we should prefer to use
PERL_SUBVERSION now, just like patchlevel is already set from PERL_VERSION
rather than the old PATCHLEVEL.

11 years agoRemove INST_DRV from Windows makefiles' CFG_VARS
Steve Hay [Thu, 7 Jun 2012 07:20:09 +0000 (08:20 +0100)]
Remove INST_DRV from Windows makefiles' CFG_VARS

It isn't directly used by config_sh.PL, and the only appearance of it
in a config.xxx file was config.ce, where it was surely wrong: prefixexp
should be a ~name expanded version of prefix, so just set it to ~INST_TOP~
like the other config.xxx files all do.

11 years agoSync Maintainers.pl for recent Storable CPAN release
Chris 'BinGOs' Williams [Thu, 7 Jun 2012 07:03:31 +0000 (08:03 +0100)]
Sync Maintainers.pl for recent Storable CPAN release

11 years agooptimise (?:|) and related NOTHING like constructs out of the compiled optree
Yves Orton [Wed, 6 Jun 2012 06:53:05 +0000 (08:53 +0200)]
optimise (?:|) and related NOTHING like constructs out of the compiled optree

A pattern like (?:|) causes the regex engine to do extra work even though
it is equivelent to matching nothing. This optimises such sequences into
more efficient opcodes that do less work, and in some cases optimises
them away entirely.

11 years agoCorrect the dlsrc entry in configure.com.
Craig A. Berry [Thu, 7 Jun 2012 02:53:48 +0000 (21:53 -0500)]
Correct the dlsrc entry in configure.com.

It's not the .c, it's the .xs from which we generate the .c.

Spotted by Nicholas.

11 years agoRemove Win9x hangover from win32/config_sh.PL
Steve Hay [Wed, 6 Jun 2012 18:17:16 +0000 (19:17 +0100)]
Remove Win9x hangover from win32/config_sh.PL

We no longer support Win9x so there is no need to undef d_flock and d_link
in that case.

11 years agoRemove redundant substitution from win32/config_sh.PL
Steve Hay [Wed, 6 Jun 2012 18:15:25 +0000 (19:15 +0100)]
Remove redundant substitution from win32/config_sh.PL

INST_VER doesn't contain a ~VERSION~ placeholder.