platform/upstream/perl.git
10 years agoupdate perldiag for the change in conversion specifiers
Tony Cook [Wed, 20 Nov 2013 04:09:44 +0000 (15:09 +1100)]
update perldiag for the change in conversion specifiers

10 years agofix a few warnings (format strings, unused variable)
Lukas Mai [Sat, 28 Sep 2013 22:12:44 +0000 (00:12 +0200)]
fix a few warnings (format strings, unused variable)

During compilation gcc complains about the following:

perl.c:4970: warning: format '%u' expects argument of type 'unsigned int', but argument 2 has type 'U32' [-Wformat=]
perl.c:5075: warning: format '%u' expects argument of type 'unsigned int', but argument 2 has type 'I32' [-Wformat=]
mg.c:1972: warning: format '%ld' expects argument of type 'long int', but argument 2 has type 'ssize_t' [-Wformat=]
pp_ctl.c:2610: warning: unused variable 'mark' [-Wunused-variable]
regexec.c:2275: warning: format '%ld' expects argument of type 'long int', but argument 3 has type 'int' [-Wformat=]

This patch fixes all of them.

Tony: warning: unused variable 'mark' was fixed in 481c819b

10 years agoremove PL_patchlevel from S_minus_v
Daniel Dragan [Wed, 13 Nov 2013 04:07:16 +0000 (23:07 -0500)]
remove PL_patchlevel from S_minus_v

|SvPVX(vstringify(PL_patchlevel))| is the same string as
|"v" PERL_VERSION_STRING|. No need to go through the overhead of using a
version object. Instead of creating a SV, then further manipulating it.
Create and manipulate it at the same time with Perl_newSVpvf_nocontext or
newSVpvn. "num_len >= level_len " will be folded away by the compiler,
previously, since both lengths came from SVs, they were not const
technically. A very smart compiler might see strncmp/strnEQ takes all
const arguments, and will optimize that away also. VC 2003 didnt do that.
Change SvREFCNT_dec to SvREFCNT_dec_NN for obvious reasons.

There should not be any user visible changes to -v with this patch.
switches.t contains a regexp for -v already so no further tests were added.

This patch is part of #116296.

10 years agoregcomp.c extern -> EXTERN_C
Daniel Dragan [Tue, 19 Nov 2013 01:10:04 +0000 (20:10 -0500)]
regcomp.c extern -> EXTERN_C

Otherwise re wont build on Win32 VC6 C++ mode.

10 years agoioctl on perlhost platforms take a char*, not void*
Daniel Dragan [Tue, 19 Nov 2013 04:26:05 +0000 (23:26 -0500)]
ioctl on perlhost platforms take a char*, not void*

As of commit 0cb9638729 IOCtl from perlhost is prototyped to take a char *.
In the later commit 2986a63f7e5 the netware commit is introduced that adds
a void* cast without explination, but today PerlLIOIOCtl is prototyped as
char* in nwperlhost.h (nwperlhost.h didnt exist at 2986a63f7e5 ). In
commit 6e22d04617 Win32 starts to use the void * cast from netware.

Using a void * cast breaks a VC 2003 C++ mode build of IO.xs because of
different types. Switch to a char * cast that matches the vtable prototype.

10 years agobetter perldelta description for #120091/#118059
Daniel Dragan [Tue, 19 Nov 2013 20:37:58 +0000 (15:37 -0500)]
better perldelta description for #120091/#118059

10 years agoMove <-- HERE arrow for ‘Switch condition not recognized’
Father Chrysostomos [Tue, 19 Nov 2013 05:53:43 +0000 (21:53 -0800)]
Move <-- HERE arrow for ‘Switch condition not recognized’

$ ./perl -Ilib -e '/(?(1(?#...)))/'
Switch condition not recognized in regex; marked by <-- HERE in m/(?(1( <-- HERE ?#...)))/ at -e line 1.
$ ./perl -Ilib -e '/(?(1x(?#...)))/'
Switch condition not recognized in regex; marked by <-- HERE in m/(?(1x(?#...) <-- HERE ))/ at -e line 1.

With the first one-liner, the arrow in the error message is pointing
to the first offending character.

With the second one-liner, the arrow points to the comment following
the offending character.

The logic for positioning the character is a little odd.  The idea is
supposed to be something like:

    if current_character++ is not ')'
        croak with the arrow right before current_character

But nextchar() is used instead of ++, and nextchar() skips trailing
whitespace and comments after incrementing the current parse position.

We already have code right here to revert back to the previous parse
position and then increment it by one character, for the sake of UTF8.
Indeed, it behaves differently if you add a non-ASCII character under
‘use utf8’:

$  ./perl -Ilib -e 'use utf8; /é(?(1x(?#...)))/'
Switch condition not recognized in regex; marked by <-- HERE in m/?(?(1x <-- HERE (?#...)))/ at -e line 1.

So what this commit does is extend that backtrack logic to happen all
the time, not just with UTF8.

10 years agoperldiag: Update descr for ‘Switch condition not recognized’
Father Chrysostomos [Tue, 19 Nov 2013 05:30:45 +0000 (21:30 -0800)]
perldiag: Update descr for ‘Switch condition not recognized’

Originally, the message ‘Switch (?(number%c not recognized’ only
applied to /(?(1junk))/.  perl-5.6.0-657-gb45f050 changed it to read
‘Switch condition not recognized’.

perl-5.8.0-8771-g0a4db38 added (?(<...>)), (?('...')), (?(DEFINE)) and
(?(R...)).  All of these can trigger that messages if there is junk
before the first closing parenthesis (e.g., /(?(<name>junk))/, causing
a mismatch between the cases where the error occurs and the descrip-
tion in perldiag:

    (F) If the argument to the (?(...)if-clause|else-clause) con-
    struct is a number, it can be only a number.  The <-- HERE shows
    whereabouts in the regular expression the problem was discovered.
    See perlre.

(which itself was already confusingly worded).

Whether these should be changed to use the more standard ‘Unknown
switch condition’ message I don’t want to deal with right now.

In any case, the description is only sometimes relevant, so this com-
mit just copies the description from ‘Unknown switch condition’.

10 years agoperldelta for 7583957163
Father Chrysostomos [Tue, 19 Nov 2013 14:26:19 +0000 (14:26 +0000)]
perldelta for 7583957163

Signed-off-by: Chris 'BinGOs' Williams <chris@bingosnet.co.uk>
10 years agoUpdate Module-Build to CPAN version 0.4202
Chris 'BinGOs' Williams [Tue, 19 Nov 2013 13:29:25 +0000 (13:29 +0000)]
Update Module-Build to CPAN version 0.4202

  [DELTA]

0.4202 - Tue Nov 19 12:48:19 CET 2013

  [BUG FIXES]

  - Don't merge prereqs from meta to mymeta [Leon Timmermans]

10 years agoperldelta for b47a847f62
Steve Hay [Tue, 19 Nov 2013 12:21:56 +0000 (12:21 +0000)]
perldelta for b47a847f62

10 years agoS_already_defined no longer uses its gv parameter, remove it
Tony Cook [Tue, 19 Nov 2013 05:45:13 +0000 (16:45 +1100)]
S_already_defined no longer uses its gv parameter, remove it

10 years agoperldelta for e45d8982ae
Tony Cook [Tue, 19 Nov 2013 05:01:29 +0000 (16:01 +1100)]
perldelta for e45d8982ae

10 years agoOptimise 'if ($a || $b)' and 'unless ($a && $b)' early exit
Matthew Horsfall (alh) [Tue, 8 Oct 2013 16:56:08 +0000 (12:56 -0400)]
Optimise 'if ($a || $b)' and 'unless ($a && $b)' early exit

An OP_AND/OP_OR in void context provides a short circuit
through ->op_other that can be used if AND/OR ops contained
within it jump out early. Use that short circuit.

Previously:

  $ ./perl -Ilib -MO=Concise -e 'if ($aa || $bb) {}'
  8  <@> leave[1 ref] vKP/REFC ->(end)
  1     <0> enter ->2
  2     <;> nextstate(main 3 -e:1) v:{ ->3
  -     <1> null vK/1 ->8
  6        <|> and(other->7) vK/1 ->8
  -           <1> null sK/1 ->6
  4              <|> or(other->5) sK/1 ->6              <-- Not optimised
  -                 <1> ex-rv2sv sK/1 ->4
  3                    <$> gvsv(*aa) s ->4
  -                 <1> ex-rv2sv sK/1 ->-
  5                    <$> gvsv(*bb) s ->6
  -           <@> scope vK ->-
  7              <0> stub v ->8

Now:

  $ ./perl -Ilib -MO=Concise -e 'if ($aa || $bb) {}'
  8  <@> leave[1 ref] vKP/REFC ->(end)
  1     <0> enter ->2
  2     <;> nextstate(main 3 -e:1) v:{ ->3
  -     <1> null vK/1 ->8
  6        <|> and(other->7) vK/1 ->8
  -           <1> null sK/1 ->6
  4              <|> or(other->5) sK/1 ->7               <-- Short circuited
  -                 <1> ex-rv2sv sK/1 ->4
  3                    <$> gvsv(*aa) s ->4
  -                 <1> ex-rv2sv sK/1 ->-
  5                    <$> gvsv(*bb) s ->6
  -           <@> scope vK ->-
  7              <0> stub v ->8

10 years agoUpdate Module-Build to CPAN version 0.4201
Chris 'BinGOs' Williams [Tue, 19 Nov 2013 00:13:41 +0000 (00:13 +0000)]
Update Module-Build to CPAN version 0.4201

  [DELTA]

0.4201 - Mon Nov 18 23:23:25 CET 2013

  [BUG FIXES]

  - Prefer META.json over META.yml [Leon Timmermans]

10 years agoCheck symlink status before setting File::Find::fullname to undef.
Victor Efimov [Tue, 19 Nov 2013 00:18:26 +0000 (01:18 +0100)]
Check symlink status before setting File::Find::fullname to undef.

Problem reported by James Avera in RT #120388.  Patches supplied by Victor
Efimov, then adapted to new testing functions in ext/File-Find/t/find.t.

10 years ago[perl #120543] work around a C++ library bug in VC 2003
Tony Cook [Mon, 18 Nov 2013 22:50:25 +0000 (09:50 +1100)]
[perl #120543] work around a C++ library bug in VC 2003

VC 2003 makes overloaded versions of ldexp() available when including
<math.h> which should only be visible when including <cmath>.

The cast ensures the ldexp(double, int) signature is used.

10 years agoUpdate HTTP-Tiny to CPAN version 0.038
Chris 'BinGOs' Williams [Mon, 18 Nov 2013 19:16:26 +0000 (19:16 +0000)]
Update HTTP-Tiny to CPAN version 0.038

  [DELTA]

0.038     2013-11-18 12:56:26 America/New_York

    [FIXED]

    - Fixed a bug where authentication parameters in the URL would override
      an existing Authorization header

10 years agoXS::Typemap: silence compiler warning.
David Mitchell [Mon, 18 Nov 2013 16:48:48 +0000 (16:48 +0000)]
XS::Typemap: silence compiler warning.

xsubpp will give us a RETVAL var whether we use it not.

10 years agothreads: silence some compiler warnings.
David Mitchell [Mon, 18 Nov 2013 15:41:45 +0000 (15:41 +0000)]
threads: silence some compiler warnings.

From 5.8.9, the MGVTBL struct has a 'svt_local' member

Declare some vars volatile within a function that uses jongjmp

Mark the unused return value from PerlLIO_write() as void(), even
though it won't shut up gcc.

10 years agoPOSIX: silence some compiler warnings
David Mitchell [Mon, 18 Nov 2013 15:24:04 +0000 (15:24 +0000)]
POSIX: silence some compiler warnings

10 years agoSDBM_File: fix 'set but not used' warning
David Mitchell [Mon, 18 Nov 2013 15:07:23 +0000 (15:07 +0000)]
SDBM_File: fix 'set but not used' warning

the NEXTKEY() method has a key arg, but sdbm_nextkey() doesn't.
So don't bother mapping the key SV arg to a datum_key type.

10 years agoPerlIO::via: fix compiler warning
David Mitchell [Mon, 18 Nov 2013 14:52:57 +0000 (14:52 +0000)]
PerlIO::via: fix compiler warning

In
    GV *gv = newGVgen(HvNAME_get(s->stash))

HvNAME_get() can return a null value (don't know whether it ever will in
these circumstances), while newGVgen() expects a non-null arg.

So calculate HvNAME_get() first, and bail if it's null.

10 years agoPerlIO::scalar: silence some compiler warnings
David Mitchell [Mon, 18 Nov 2013 14:37:22 +0000 (14:37 +0000)]
PerlIO::scalar: silence some compiler warnings

10 years agoperlhacktips: Two spaces after dots
Father Chrysostomos [Mon, 18 Nov 2013 14:19:33 +0000 (06:19 -0800)]
perlhacktips: Two spaces after dots

It was not consistent throughout.

10 years agoperlhacktips: Fix pod formatting
Father Chrysostomos [Mon, 18 Nov 2013 14:12:03 +0000 (06:12 -0800)]
perlhacktips: Fix pod formatting

10 years agoAdd more examples of perl/gdb usage.
Matthew Horsfall (alh) [Mon, 30 Sep 2013 17:23:22 +0000 (13:23 -0400)]
Add more examples of perl/gdb usage.

Also add doc about gdb's ptype, and make examples more clear.

10 years agoFix ‘panic: memory wrap’ in reg_scan_name
Father Chrysostomos [Mon, 18 Nov 2013 14:01:56 +0000 (06:01 -0800)]
Fix ‘panic: memory wrap’ in reg_scan_name

reg_scan_name was not checking for end-of-string.  If the character it
read were not a word character, it would then increment the current
position (RExC_parse), so that the <-- HERE marker in the error mes-
sage would point to the bad character.

If we try to split a regexp like /(?</ into two pieces when the cur-
rent position is off the end like this:

 ( ? < \0
          ^

then the first ‘half’ of the regexp, before the <-- HERE marker is
"(?<\0" (including the trailing null), and the second ‘half’ is of
negative length.  Negative string lengths are what cause ‘panic: mem-
ory wrap’.

$ ./perl -Ilib -e '/(?</'
panic: memory wrap at -e line 1.

This commit takes advantage of the fact that, ever since 1f4f6bf1,
RExC_parse == name_start has never been true after a call to
reg_scan_name.  This is how reg_scan_name now signals EOS.

10 years agoperldiag: Clarify memory wrap
Father Chrysostomos [Mon, 18 Nov 2013 13:57:50 +0000 (05:57 -0800)]
perldiag: Clarify memory wrap

10 years agoRequire closing paren for (?&...
Father Chrysostomos [Mon, 18 Nov 2013 13:45:19 +0000 (05:45 -0800)]
Require closing paren for (?&...

$ ./perl -Ilib -le 'print "aaz" =~ /(?<a>a)(?&a-z/'
a

(?&name) was actually allowing any non-word character to terminate it.

10 years agoUpdate IPC-Cmd to CPAN version 0.90
Chris 'BinGOs' Williams [Mon, 18 Nov 2013 15:13:01 +0000 (15:13 +0000)]
Update IPC-Cmd to CPAN version 0.90

  [DELTA]

0.90 Mon Nov 18 15:08:15 GMT 2013

  Misc:
  * skip some problematic tests when PERL_CORE

10 years agoperldelta for ff4a442c79
Tony Cook [Mon, 18 Nov 2013 06:01:07 +0000 (17:01 +1100)]
perldelta for ff4a442c79

10 years agoperldelta for fa0789a790
Tony Cook [Mon, 18 Nov 2013 05:53:46 +0000 (16:53 +1100)]
perldelta for fa0789a790

10 years ago[perl #120535] Add UTF8 flag to B::HV->ARRAY keys
Tony Cook [Mon, 18 Nov 2013 05:44:40 +0000 (16:44 +1100)]
[perl #120535] Add UTF8 flag to B::HV->ARRAY keys

10 years agoun-TODO the test for 120535, Reini's patch fixes it
Tony Cook [Mon, 18 Nov 2013 04:20:16 +0000 (15:20 +1100)]
un-TODO the test for 120535, Reini's patch fixes it

10 years agoAdd UTF8 flag to keys returned by B::HV->ARRAY
Reini Urban [Wed, 13 Nov 2013 19:18:09 +0000 (13:18 -0600)]
Add UTF8 flag to keys returned by B::HV->ARRAY

hv_iternextsv() ignores the HEK flags, but we do care about the UTF8 flag
at least when returning hash keys from B::HV->ARRAY

10 years agoTODO test for 120535
Tony Cook [Mon, 18 Nov 2013 04:16:31 +0000 (15:16 +1100)]
TODO test for 120535

10 years agofix expected failure text for new croak.t test
Tony Cook [Mon, 18 Nov 2013 00:00:17 +0000 (11:00 +1100)]
fix expected failure text for new croak.t test

10 years ago[Merge] perldiag stuff
Father Chrysostomos [Sun, 17 Nov 2013 21:09:26 +0000 (13:09 -0800)]
[Merge] perldiag stuff

I noticed that some entries in perldiag had (F ...) with warnings
categories.  Those categories apply only to warnings, not to
fatal errors.

So I looked to see why diag.t was not already catching it, since I
thought I had programmed it to.

It turned out that it was skipping any function calls that lacked
aTHX_, which included yyerror and anything with _nocontext.

So I fixed that and got pages and pages of failures, unsurprisingly.

I went through, fixing them, and inevitably tweaking other things.

In one case, I even changed the message output, removing an extraneous
dot before ‘at file line 24’.

10 years agoperldiag: Don’t let <-- HERE be wrapped
Father Chrysostomos [Sun, 17 Nov 2013 19:45:33 +0000 (11:45 -0800)]
perldiag: Don’t let <-- HERE be wrapped

The meaning is much clearer if the <--
HERE marker doesn’t wrap like that.

10 years agoperldiag: Remove categories from fatal errors
Father Chrysostomos [Sun, 17 Nov 2013 14:44:05 +0000 (06:44 -0800)]
perldiag: Remove categories from fatal errors

These are *warnings* categories, so they don’t apply here.

10 years agodiag.t: Fix copy-and-paste error in os2 exception
Father Chrysostomos [Sun, 17 Nov 2013 14:42:45 +0000 (06:42 -0800)]
diag.t: Fix copy-and-paste error in os2 exception

10 years agodiag.t: Don’t check ‘calls’ in column 0
Father Chrysostomos [Sun, 17 Nov 2013 14:40:14 +0000 (06:40 -0800)]
diag.t: Don’t check ‘calls’ in column 0

because they may be function declarations instead.  It was getting
confused by win32_croak_not_implemented, which does not have ");"
in it before the first string.

10 years agodiag.t: More win32 exceptions
Father Chrysostomos [Sun, 17 Nov 2013 14:39:36 +0000 (06:39 -0800)]
diag.t: More win32 exceptions

10 years agodiag.t: Support multiline perldiag entries better
Father Chrysostomos [Sun, 17 Nov 2013 14:32:02 +0000 (06:32 -0800)]
diag.t: Support multiline perldiag entries better

I.e., don’t require a space before the newline.

10 years agodiag.t: Let diag.t be run on specific source files
Father Chrysostomos [Sun, 17 Nov 2013 14:29:37 +0000 (06:29 -0800)]
diag.t: Let diag.t be run on specific source files

./perl -Ilib t/porting/diag.t regcomp.c

will now run it just on regcomp.c.

10 years agodiag.t: Another exception
Father Chrysostomos [Sun, 17 Nov 2013 14:23:07 +0000 (06:23 -0800)]
diag.t: Another exception

10 years agodiag.t: Skip x2p
Father Chrysostomos [Sun, 17 Nov 2013 14:22:24 +0000 (06:22 -0800)]
diag.t: Skip x2p

10 years agodiag.t: win32 exceptions
Father Chrysostomos [Sun, 17 Nov 2013 14:22:07 +0000 (06:22 -0800)]
diag.t: win32 exceptions

10 years agodiag.t: Support win32_croak_not_implemented
Father Chrysostomos [Sun, 17 Nov 2013 14:18:12 +0000 (06:18 -0800)]
diag.t: Support win32_croak_not_implemented

10 years agodiag.t: Another exception
Father Chrysostomos [Sun, 17 Nov 2013 14:17:58 +0000 (06:17 -0800)]
diag.t: Another exception

10 years agoSprinkle diag_listed_as
Father Chrysostomos [Sun, 17 Nov 2013 14:15:08 +0000 (06:15 -0800)]
Sprinkle diag_listed_as

10 years agoRemove extraneous dot from ‘Missing right brace...’
Father Chrysostomos [Sun, 17 Nov 2013 14:10:40 +0000 (06:10 -0800)]
Remove extraneous dot from ‘Missing right brace...’

$ ./perl -Ilib -e '/\N{/'
Missing right brace on \N{} or unescaped left brace after \N. at -e line 1, within pattern
Execution of -e aborted due to compilation errors.

That dot before ‘at -e’ is confusing.

10 years agoperldiag: Clarify an entry
Father Chrysostomos [Sun, 17 Nov 2013 14:03:57 +0000 (06:03 -0800)]
perldiag: Clarify an entry

‘5.12’ is meaningful to insiders, but it may not be understood by
readers in general.

10 years agoperldiag: Document ‘\N{} in character class restricted...’
Father Chrysostomos [Sun, 17 Nov 2013 13:58:08 +0000 (05:58 -0800)]
perldiag: Document ‘\N{} in character class restricted...’

10 years agoperldiag: Document ‘Zero length \N{}’
Father Chrysostomos [Sun, 17 Nov 2013 13:46:15 +0000 (05:46 -0800)]
perldiag: Document ‘Zero length \N{}’

10 years agoperldiag: Miscapitalisation; clarity
Father Chrysostomos [Sun, 17 Nov 2013 13:38:07 +0000 (05:38 -0800)]
perldiag: Miscapitalisation; clarity

10 years agoperldiag: Clean up ‘Sequence (...’ messages
Father Chrysostomos [Sun, 17 Nov 2013 13:32:45 +0000 (05:32 -0800)]
perldiag: Clean up ‘Sequence (...’ messages

Make sure they are all documented.  Sprinkle diag_listed_as where
appropriate.

10 years agoperldiag: Reword an entry slightly
Father Chrysostomos [Sun, 17 Nov 2013 06:25:32 +0000 (22:25 -0800)]
perldiag: Reword an entry slightly

to make it easier to understand

10 years agoperldiag: Add some ‘in regex’ variants
Father Chrysostomos [Sun, 17 Nov 2013 06:09:48 +0000 (22:09 -0800)]
perldiag: Add some ‘in regex’ variants

10 years agodiag.t: Fix FAIL and vFAIL support
Father Chrysostomos [Sun, 17 Nov 2013 06:02:16 +0000 (22:02 -0800)]
diag.t: Fix FAIL and vFAIL support

Until recently, it was treating them like Perl_croak et al., expecting
there to be an aTHX_.

Now that I fixed that, it turns out that FAIL and vFAIL (which were
being ignored, since all the calls lacked aTHX_) never worked anyway.

If they are matched by $source_msg_call_re, they end up in the wrong
if/else branch; namely, the one for handling packWARN, and they skip
over the one for tacking ‘in regex’ on to the end of the message.

10 years agodiag.t: Exceptions from plan9.c
Father Chrysostomos [Sun, 17 Nov 2013 05:49:06 +0000 (21:49 -0800)]
diag.t: Exceptions from plan9.c

10 years agoperldiag: Document ‘Don't know how to get file name’
Father Chrysostomos [Sun, 17 Nov 2013 05:45:30 +0000 (21:45 -0800)]
perldiag: Document ‘Don't know how to get file name’

10 years agoperldiag: Update Assertion to match reality
Father Chrysostomos [Sun, 17 Nov 2013 05:35:19 +0000 (21:35 -0800)]
perldiag: Update Assertion to match reality

10 years agodiag.t: Exceptions, mostly from os2.c
Father Chrysostomos [Sun, 17 Nov 2013 02:15:59 +0000 (18:15 -0800)]
diag.t: Exceptions, mostly from os2.c

10 years agodiag.t: gv_override is not a croak function
Father Chrysostomos [Sat, 16 Nov 2013 23:59:23 +0000 (15:59 -0800)]
diag.t: gv_override is not a croak function

10 years agoop.c: diag_listed_as for Using !~ with %s
Father Chrysostomos [Sat, 16 Nov 2013 23:58:20 +0000 (15:58 -0800)]
op.c: diag_listed_as for Using !~ with %s

10 years agoStop diag.t from skipping yyerror messages
Father Chrysostomos [Sat, 16 Nov 2013 23:55:30 +0000 (15:55 -0800)]
Stop diag.t from skipping yyerror messages

yyerror does not take aTHX_, but diag.t was expecting aTHX_ on all
warn/croak calls.

Yes, this causes massive failures.

10 years agoperldiag: \%d better written as $%d
Father Chrysostomos [Sat, 16 Nov 2013 23:12:58 +0000 (15:12 -0800)]
perldiag: \%d better written as $%d

splain can’t necessarily find it if we hard-code the number:

$ ./perl -Ilib -Mdiagnostics -we '()="" =~ s/()()/\1/r'
\1 better written as $1 at -e line 1 (#1)
    (W syntax) Outside of patterns, backreferences live on as variables.
    The use of backslashes is grandfathered on the right-hand side of a
    substitution, but stylistically it's better to use the variable form
    because other Perl programmers will expect it, and it works better if
    there are more than 9 backreferences.

$ ./perl -Ilib -Mdiagnostics -we '()="" =~ s/()()/\2/r'
\2 better written as $2 at -e line 1.
$

%d is more intuitive than %c here, so I used %d in the pod instead of
copying the C code that generates it.

10 years agoperldiag: rewrap an entry for better splain output
Father Chrysostomos [Sat, 16 Nov 2013 23:07:51 +0000 (15:07 -0800)]
perldiag: rewrap an entry for better splain output

10 years agoFix POD formatting error.
James E Keenan [Sun, 17 Nov 2013 15:58:07 +0000 (16:58 +0100)]
Fix POD formatting error.

10 years agoperldelta addition for the previous commit.
James E Keenan [Sun, 17 Nov 2013 14:27:14 +0000 (15:27 +0100)]
perldelta addition for the previous commit.

10 years agoConvert to using Test::More. Provide each test with a description.
James E Keenan [Mon, 11 Nov 2013 20:11:14 +0000 (21:11 +0100)]
Convert to using Test::More. Provide each test with a description.

For: RT #120503.  This entailed:

Replacing each instance of Check() and CheckDie() with appropriate
Test::More functions.

Replacing MkDir() and touch() with mkdir_ok() and create_file_ok() to
create a more Test::More-ish interface; create symlink_ok() to handle
similar circumstances.

Providing those three wrapper subroutines with default descriptions,
but allowing a custom description to be passed as an argument.

Highlighting more important unit tests found at the end of subsections
and blocks by prepending 'COMPLETE:' to their descriptions.

More inline comments to guide future maintainers.

Some repositioning of code in order to narrow the scope of variables.
Replacement of hard tabs with spaces; some regularization of indents
and other code tidying.

No tests were added or removed, so the planned number of tests on a
given platform will be unchanged.

TODO:

Some descriptions still need improvement.

There are quite a few File-Find features mentioned in the POD which
are not referenced at all in this test file.  They need to have new
tests written for them.

Coverage analysis.

10 years agoperldelta for the previous commit
Father Chrysostomos [Sat, 16 Nov 2013 14:52:26 +0000 (06:52 -0800)]
perldelta for the previous commit

10 years agoFix memory leak with recursive sub redefinition
Father Chrysostomos [Sat, 16 Nov 2013 14:50:49 +0000 (06:50 -0800)]
Fix memory leak with recursive sub redefinition

See the thread starting at
<20131115042923.7514.qmail@lists-nntp.develooper.com>.

Commits 7004ee4937 and a61818571 changed subroutine redefinition to
null the GvCV slot before freeing the CV, so that destructors won’t
see GvCV without a reference count.  That turns a double free into a
memory leak.

Kent Fredric explains it nice and clearly:

> sub foo{}   # A
> bless \&foo;
> DESTROY { *foo = sub {}  # C }
> eval "sub foo{} "; # B
>
> Previous behaviour was:
>
> B replaces A, triggers DESTROY, which triggers C replacing A, and this
> invoked a double free, because C , triggering the removal of A,
> happened while A still existed ( ?? )
>
> So the change fixes this, so that A is removed from the symbol table
> before DESTROY triggers , so that C is creating a "new" symbol,
> effectively, and the problem is that C is then clobbered by the B
> replacing the slot, after the DESTROY.

So C leaks.

This commit fixes it by changing the SvREFCNT_dec into SAVEFREESV,
essentially delaying the DESTROY until after the subroutine redefini-
tion is complete.

This does mean that C is what ends up in the glob afterwards; but as
long as perl’s own bookkeeping is thrown off, we can leave it to the
user (the Perl programmer) to handle the consequences of naughty
destructors.

10 years agogv.c: Remove redundant mro_method_changed_in()
Father Chrysostomos [Sat, 16 Nov 2013 13:18:59 +0000 (05:18 -0800)]
gv.c: Remove redundant mro_method_changed_in()

Core subs are already accounted for by method lookup, so vivifying
them does not change what gets inherited.  Hence, there is no need
to flush caches here.

10 years agoUnwrap a perldiag entry for better splain output
Father Chrysostomos [Sat, 16 Nov 2013 05:40:45 +0000 (21:40 -0800)]
Unwrap a perldiag entry for better splain output

Before:

$ ./perl -Ilib -Mdiagnostics -e 'warn "Missing '\'']'\'' in prototype for %s : %s"'
Missing ']' in prototype for %s : %s at -e line 1 (#1)
    (W illegalproto) A grouping was started with [ but never closed with
    ].

After:

$ ./perl -Ilib -Mdiagnostics -e 'warn "Missing '\'']'\'' in prototype for %s : %s"'
Missing ']' in prototype for %s : %s at -e line 1 (#1)
    (W illegalproto) A grouping was started with [ but never closed with ].

10 years agoperldiag: ‘my sub’ is no longer ‘reserved’ syntax
Father Chrysostomos [Sat, 16 Nov 2013 05:38:43 +0000 (21:38 -0800)]
perldiag: ‘my sub’ is no longer ‘reserved’ syntax

10 years agoAlphabetise perldiag
Father Chrysostomos [Sat, 16 Nov 2013 05:35:04 +0000 (21:35 -0800)]
Alphabetise perldiag

10 years agoperldiag: remove space from otherwise blank line
Father Chrysostomos [Sat, 16 Nov 2013 05:35:46 +0000 (21:35 -0800)]
perldiag: remove space from otherwise blank line

This enables splain to find the following entry.

10 years agoRevert "make perl core quiet under -Wfloat-equal"
David Mitchell [Sat, 16 Nov 2013 00:01:32 +0000 (00:01 +0000)]
Revert "make perl core quiet under -Wfloat-equal"

A suggested way of avoiding the the warning on nv1 != nv2
by replacing it with (nv1 < nv2 || nv1 > nv2), has too many issues
with NaN.  [perl #120538].

I haven't found any other way of selectively disabling the warning,
so for now I'm just reverting the whole commit.

This reverts commit c279c4550ce59702722d0921739b1a1b92701b0d.

10 years agoUpdate DB_File to CPAN version 1.831
Chris 'BinGOs' Williams [Fri, 15 Nov 2013 23:03:14 +0000 (23:03 +0000)]
Update DB_File to CPAN version 1.831

  [DELTA]

1.831 15 November 2013

   * C99 comment is a nogo
     RT #90383

10 years agoUpdate IPC-Cmd to CPAN version 0.88
Chris 'BinGOs' Williams [Fri, 15 Nov 2013 14:56:16 +0000 (14:56 +0000)]
Update IPC-Cmd to CPAN version 0.88

  [DELTA]

  0.88 Fri Nov 15 14:44:03 GMT 2013

    Misc:
    * skip some problematic tests on Cygwin

10 years ago[perl #120544] fix "goto" around var init error in av_extend_guts
Daniel Dragan [Fri, 15 Nov 2013 08:21:53 +0000 (03:21 -0500)]
[perl #120544] fix "goto" around var init error in av_extend_guts

This fixes a Win32 Visual C 6 in C++ mode syntax error. See #120544 for
the details.

10 years agoperldelta for e68dd03a55
Father Chrysostomos [Fri, 15 Nov 2013 13:31:22 +0000 (05:31 -0800)]
perldelta for e68dd03a55

10 years agoperldelta for c5f75dbad5e3
Father Chrysostomos [Fri, 15 Nov 2013 13:28:24 +0000 (05:28 -0800)]
perldelta for c5f75dbad5e3

10 years agoIncrease $fields::VERSION to 2.17
Father Chrysostomos [Fri, 15 Nov 2013 13:04:39 +0000 (05:04 -0800)]
Increase $fields::VERSION to 2.17

10 years agoRevamp fields documentation
Father Chrysostomos [Fri, 15 Nov 2013 06:13:45 +0000 (22:13 -0800)]
Revamp fields documentation

• Actually give an example of a typed lexical.
• Also show the syntax parenthetically in the pod, since the phrase
 ‘typed lexical’ is not exactly well known.
• Don’t use dev version numbers.
• Don’t talk about pseudo-hashes so pervasively, as the fact that they
  are used is more an implementation detail now than a feature (except
  for phash).
• If we talk about restricted hashes, we should link to Hash::Util.
• -w is not the only way to turn warnings on.

Also mention in perlfunc that ‘my __PACKAGE__’ and ‘my CONSTANT’ work,
so that the only mentions are not in perl561delta and Lexical::Types.

10 years agoperldelta for 7004ee4937 and a618185710
Father Chrysostomos [Fri, 15 Nov 2013 04:30:30 +0000 (20:30 -0800)]
perldelta for 7004ee4937 and a618185710

10 years agoperldelta for 4571f4a728 and, of course, bc81b34d0e
Father Chrysostomos [Fri, 15 Nov 2013 01:53:02 +0000 (17:53 -0800)]
perldelta for 4571f4a728 and, of course, bc81b34d0e

4571f4a728 alone made things worse, causing a double free. :-)

10 years agoAnother perldelta to-do
Father Chrysostomos [Fri, 15 Nov 2013 01:51:04 +0000 (17:51 -0800)]
Another perldelta to-do

I’m sure Dave Mitchell can explain this better than I.

10 years ago[perl #120463] s/// and tr/// with wide delimiters
Father Chrysostomos [Thu, 14 Nov 2013 22:29:51 +0000 (14:29 -0800)]
[perl #120463] s/// and tr/// with wide delimiters

$ perl -Mutf8 -e 's αaαα'
Substitution replacement not terminated at -e line 1.

What is happening is that the first scan goes past the delimiter at
the end of the pattern.  Then a single byte is compared (the previous
character against the first byte of the opening delimiter) to see
whether the parser needs to step back one byte before scanning the
second part.

That means you can do the equivalent of s/foo/|bar|g if / is replaced
with a wide character:

$ perl -l -Mutf8 -e '$_ = "a";  s αaα|b|; print'
b

This commit fixes it by giving toke.c:S_scan_str an extra parameter,
so it can tell the callers that need this (scan_subst and scan_trans)
where to start scanning the replacement.

10 years agoAdd Synology instructions
H.Merijn Brand [Thu, 14 Nov 2013 17:38:38 +0000 (18:38 +0100)]
Add Synology instructions

10 years agomove DEBUGGING section after includes in regexec.c.
Craig A. Berry [Thu, 14 Nov 2013 14:08:34 +0000 (08:08 -0600)]
move DEBUGGING section after includes in regexec.c.

7b75fc16a59 added #ifdef DEBUGGING around a declaration, but that
section of code was before any includes, and (on VMS anyway),
DEBUGGING is defined in config.h, not on the command line.

So just move that declaration after the includes, which is a more
normal way to do things anyway.

10 years agoDon’t skip t/re/reg_eval_scope.t under miniperl
Father Chrysostomos [Thu, 14 Nov 2013 13:26:26 +0000 (05:26 -0800)]
Don’t skip t/re/reg_eval_scope.t under miniperl

re.pm doesn’t load its C code under miniperl, and it’s not needed anyway
here, since we are just setting hints.

10 years agosv.c apidocs: SV_NOSTEAL, not NOSTEAL
Father Chrysostomos [Wed, 13 Nov 2013 14:05:21 +0000 (06:05 -0800)]
sv.c apidocs: SV_NOSTEAL, not NOSTEAL

NOSTEAL is nonexistent.  While abbreviating constants may be fine for
comments, using such forms in API documentation may be less than
helpful.

10 years agoconstant.pm: Consistent spaces after dots in pod
Father Chrysostomos [Wed, 13 Nov 2013 13:54:01 +0000 (05:54 -0800)]
constant.pm: Consistent spaces after dots in pod

It was inconsistent throughout.

10 years agoIncrease $constant::VERSION to 1.29
Father Chrysostomos [Wed, 13 Nov 2013 13:33:00 +0000 (05:33 -0800)]
Increase $constant::VERSION to 1.29

10 years agoCompile-time checking for %$obj{"key"} under ‘use fields’
Father Chrysostomos [Tue, 12 Nov 2013 14:13:44 +0000 (06:13 -0800)]
Compile-time checking for %$obj{"key"} under ‘use fields’

This single line of code also gives us shared hash key optimisa-
tions for free.

10 years agoFix bad read in gp_free introduced by 4571f4a72
Father Chrysostomos [Thu, 14 Nov 2013 13:18:00 +0000 (05:18 -0800)]
Fix bad read in gp_free introduced by 4571f4a72

4571f4a72 attempted to fix this:

$ ./perl -Ilib -e 'sub foo{} bless \&foo; DESTROY { undef *foo } undef *foo'
Attempt to free unreferenced glob pointers, Perl interpreter: 0x7fd6a3803200 at -e line 1.

by lowering the refcount of the gp only after freeing the contents.

But what was missing was a check at the end to make sure the refcount
was not already 0.

In fact, that can’t work either, as, if the refcount has gone down
to 0 while freeing the contents of the gp, we will be reading
freed memory.

In an attempt to implement what my half-baked idea was meant to do,
I thought of incrementing the reference count before freeing the
entries, and then checking it afterwards, but that would cause an
‘undef *foo’ during that to null the gp slot of the gv and replace it
with a new one.  In the mean time, gp_free is only freeing the old gp
and the new gp will leak when it sets GvGP to 0.

I thought of detaching the gp from the gv completely before freeing
its entries, but most code doesn’t expect to see typeglobs with no gp.
GvSV will crash.

I nearly concluded that the only approach I could use was to revert
4571f4a72 and simply extirpate that warning.  As far as I can tell, it
only comes up with recursive gp_free calls.  However, in those cases,
simply returning will cause a memory leak, as pp_undef will give the
gv a new gp, and the outer gp_free call, when it finishes, will set
the gv’s gp slot to null, overwriting what pp_undef put there (a vari-
ation of the leak above).

So, the final solution is for gp_free to re-read the GvGP value each
time it loops, freeing entries.  The reference count will continue to
be decremented at the end of the function, as in 4571f4a72.  That will
prevent any bad reads.  If pp_undef has reallocated the gp in the mean
time, we will simply start using the new one.  We need an extra refer-
ence count check at the end, in case a destructor does glob assignment
and causes the gp to be shared.

Ideally this should fix the recent build errors.  (See
<20131113045538.GA18816@mars.tony.develop-help.com>.)  I tried it
under valgrind on dromedary both before and after the patch, and the
bad reads went away.