This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perl5.git
6 years agodon't lose mark when pp_reverse extends stack
Zefram [Fri, 8 Dec 2017 19:23:29 +0000 (19:23 +0000)]
don't lose mark when pp_reverse extends stack

Nullary reverse needs to extend the stack to push its result scalar.
It was actually extending the stack, but doing so invalidated MARK,
which it relied upon to place the stack pointer afterwards.  Upon stack
reallocation it was therefore leaving the stack pointer pointing to the
freed stack memory.  Reformulate stack manipulation to not rely on MARK
after extending.  Fixes [perl #132544].

6 years agoRevert "re_intuit_start(): rename some local vars"
David Mitchell [Thu, 14 Dec 2017 09:32:46 +0000 (09:32 +0000)]
Revert "re_intuit_start(): rename some local vars"

This reverts commit ea569f0097183cb2c1b98852f31b47264605f0b7.

This was just a cosmetic (if useful) change and clashes with a branch
Yves is working on. So I'll redo it some other time.

6 years agowarn on $a.$b.$c in void context
Zefram [Thu, 14 Dec 2017 04:23:58 +0000 (04:23 +0000)]
warn on $a.$b.$c in void context

$a.$b.$c gets transformed early on to execute as ($a.$b).=$c, which didn't
warn about void context becuase .= looks like a useful side effect.
Happily, the recently-added OPpCONCAT_NESTED flag identifies that this
has happened.  Make scalarvoid() pay attention to this flag when a concat
op is put into void context.  Fixes [perl #6997]

6 years agoCwd: Change strcmp into strEQ
Karl Williamson [Thu, 9 Mar 2017 19:06:34 +0000 (12:06 -0700)]
Cwd: Change strcmp into strEQ

The latter is easier to read

6 years agoFix typo in 183a822da3e11eb0f7dba393f5e6f2bc515cffe6
Karl Williamson [Thu, 14 Dec 2017 03:28:53 +0000 (20:28 -0700)]
Fix typo in 183a822da3e11eb0f7dba393f5e6f2bc515cffe6

Spotted by Tony Cook++

6 years agoData::Dumper: Change a strncmp to memBEGINs
Karl Williamson [Thu, 9 Mar 2017 17:54:20 +0000 (10:54 -0700)]
Data::Dumper: Change a strncmp to memBEGINs

The latter is much clearer as to what's going on

6 years agoData::Dumper: Change strcpy to strlcpy
Karl Williamson [Mon, 27 Mar 2017 20:24:41 +0000 (14:24 -0600)]
Data::Dumper: Change strcpy to strlcpy

strlcpy is safer.  This reverts to using strcpy if no version of strlcpy
is available (but one has been available in Perl since 5.9.4)

6 years agoadd preload to .gitignore
Zefram [Thu, 14 Dec 2017 02:37:03 +0000 (02:37 +0000)]
add preload to .gitignore

6 years agofix links in generated HTML documentation
Zefram [Thu, 14 Dec 2017 02:27:28 +0000 (02:27 +0000)]
fix links in generated HTML documentation

Invoke installhtml in the right way for it to generate relative links.
Fix installhtml's code for creating relative links in the index for
split documents.  Update Pod::Html's section name transformer to
match the actual output seen via Pod::Simple::XHTML.  Incidentally
update split-on-head code for the new style of HTML generated by
Pod::Simple::XHTML.  Fixes [perl #110056].

6 years agoAdd PERL_REENTRANT for XS modules
Karl Williamson [Thu, 14 Dec 2017 02:07:04 +0000 (19:07 -0700)]
Add PERL_REENTRANT for XS modules

This allows them to get the reentrant versions of libc functions
automatically.  Previously if they wanted to do this, they had to
declare themselves (shudder) as PERL_CORE or PERL_EXT.

6 years agoperlfunc: Add note about reentrant functions
Karl Williamson [Thu, 14 Dec 2017 01:36:02 +0000 (18:36 -0700)]
perlfunc: Add note about reentrant functions

perl automatically and silently uses reentrant versions of some
functions in threaded perls when such functions are available.  Note
this.

6 years agoautomatic titling in Pod::Html
Zefram [Wed, 13 Dec 2017 22:59:28 +0000 (22:59 +0000)]
automatic titling in Pod::Html

Automatic extraction of a title from the content was lost with the
switch to using Pod::Simple::XHTML for rendering.  It would be tricky
to add in Pod::Simple::XHTML, or anything else integrated into that
parser, because the stream-oriented approach plays poorly with any kind
of lookahead.  Instead go to a two-stage conversion, parsing the input
to tree form using Pod::Simple::SimpleTree and later feeding the tree
to the stream-oriented Pod::Simple::XHTML for output.  Between the two
stages, extract a default title from the tree, in time to use it when
setting options for Pod::Simple::XHTML.  Fixes [perl #110520].

6 years agopp_multiconcat() Use faster UTF-8 variant counting
Karl Williamson [Thu, 23 Nov 2017 06:10:58 +0000 (23:10 -0700)]
pp_multiconcat() Use faster UTF-8 variant counting

6 years agore_intuit_start()/S_reghop3(): don't go beyond end
David Mitchell [Wed, 13 Dec 2017 15:53:51 +0000 (15:53 +0000)]
re_intuit_start()/S_reghop3(): don't go beyond end

RT #132552

when hopping N characters along a string, if the 'end stop' lim wasn't
on a char boundary, the value returned by S_reghop3() could be up to
(but not including) one char's worth of bytes beyond lim.

This is fairly harmless, but gave valgrind/ASan palpitations.

So fixed by this commit.

6 years agore_intuit_start(): rename some local vars
David Mitchell [Wed, 13 Dec 2017 13:14:59 +0000 (13:14 +0000)]
re_intuit_start(): rename some local vars

(no functional changes)

For local variables which hold a length, rename that var with a _c or _b
suffix to indicate whether it holds a byte or character count.

There is a mixture of the two, and it's easy to get confused.

Also, in places, rename vars to more closely match the field they're
extracted from. For example, start_shift is set from the min_offset field
of the check slot of the substrings array, so it makes more sense to call
it check_min_offset_c.

Also add some code comments about what the vars are for.

6 years agoUpgrade Time::Piece from vesion 1.3202 to 1.3203
Steve Hay [Wed, 13 Dec 2017 08:37:43 +0000 (08:37 +0000)]
Upgrade Time::Piece from vesion 1.3202 to 1.3203

6 years agoinline.h: Fix wrong order of shift and mask
Karl Williamson [Wed, 13 Dec 2017 06:01:02 +0000 (23:01 -0700)]
inline.h: Fix wrong order of shift and mask

I realized that one should mask before the shift in this macro that is
used in is_utf8_invariant_string_loc() and variant_under_utf8_count().
This would only show up on a 32-bit platform that doesn't have 64-bit
ability at all.

6 years agorevise advice about DESTROY
Zefram [Wed, 13 Dec 2017 03:50:01 +0000 (03:50 +0000)]
revise advice about DESTROY

perlobj advised that a DESTROY method dying could clobber $@ for an
exception being thrown, which is no longer true since 5.14.  Remove that
caveat, and fix the description of what happens when a DESTROY method
dies.  Revise the related advice about localising global status variables,
including a list of all affected variables.  Fixes [perl #121761] and
[perl #122753].

6 years agoUpdate Filter::Util::Call to CPAN version 1.58
Chris 'BinGOs' Williams [Tue, 12 Dec 2017 11:39:20 +0000 (11:39 +0000)]
Update Filter::Util::Call to CPAN version 1.58

  [DELTA]

1.58 2017-11-15 rurban
----
  * Drop 5.005 support
  * Switch from DynaLoader to XSLoader [atoomic #5]
  * Replace use vars by our. [atoomic #5]
  * Lazy load Carp only when required. [atoomic #5]
  * Minor test improvements
  * Fix v5.8 cast warnings

6 years agoUpdate B-Debug to CPAN version 1.26
Chris 'BinGOs' Williams [Tue, 12 Dec 2017 11:32:35 +0000 (11:32 +0000)]
Update B-Debug to CPAN version 1.26

  [DELTA]

1.26 2017-12-03 rurban
  * Avoid too many -I when calling subprocess (sprout, RT#123816)

6 years agoUpdate experimental to CPAN version 0.019
Chris 'BinGOs' Williams [Tue, 12 Dec 2017 11:29:29 +0000 (11:29 +0000)]
Update experimental to CPAN version 0.019

  [DELTA]

0.019     2017-12-03 18:40:19+01:00 Europe/Amsterdam
          - Rerelease without NYTProf files

6 years agorevise doc about returning values from threads
Zefram [Tue, 12 Dec 2017 11:54:04 +0000 (11:54 +0000)]
revise doc about returning values from threads

Returning subs is now generally fine, as is creating threads in BEGIN
blocks et al.  Describe the problems that come from losing the identity
of returned objects.  Fixes [perl #96538].

6 years agobetter document version check aspect of "use"
Zefram [Tue, 12 Dec 2017 10:16:46 +0000 (10:16 +0000)]
better document version check aspect of "use"

6 years agofix GvSV refcounting in sort
Zefram [Tue, 12 Dec 2017 09:47:41 +0000 (09:47 +0000)]
fix GvSV refcounting in sort

Where a sort operation passes the comparands to a comparison block in $a
and $b, it wasn't taking account of the fact that the GvSV slots in *a
and *b are refcounted.  It would write the comparands into those slots
without altering any reference counts, and end by restoring the values
those slots had to start with.  This was all fine so long as nothing
else touched those slots during the process.  But code running during
the comparison is free to write to them by "*a = \1", which does frob
the reference counts.

Fix it by switching sort to manipulate GvSV in a refcount-preserving
manner, compatible with all other operations on those slots.  Fixes
[perl #92264].

6 years agoUpgrade CPAN from version 2.18-TRIAL to 2.20-TRIAL
Steve Hay [Tue, 12 Dec 2017 08:21:04 +0000 (08:21 +0000)]
Upgrade CPAN from version 2.18-TRIAL to 2.20-TRIAL

6 years agoproperly check readpipe()'s argument list
Zefram [Tue, 12 Dec 2017 06:24:01 +0000 (06:24 +0000)]
properly check readpipe()'s argument list

readpipe() wasn't applying context to its argument list, resulting in
readpipe()'s context leaking in, and broken stack discipline when a list
expression was used.  Fixes [perl #4574].

6 years agofix doc about filter subroutines' $_[0]
Zefram [Tue, 12 Dec 2017 03:53:33 +0000 (03:53 +0000)]
fix doc about filter subroutines' $_[0]

Filter subroutines established by an @INC callback have always received
a numeric zero as their first argument, not a referencet to the sub
as documented.  Fixes [perl #115754].

6 years agocorrect detection of arg absence in Data::Dumper
Zefram [Tue, 12 Dec 2017 03:19:26 +0000 (03:19 +0000)]
correct detection of arg absence in Data::Dumper

The combined getter/setter methods were mistaking a supplied undef
argument value (of a setter call) for absence of an argument (making it
a getter call).  Fixes [perl #113090].

6 years agosv.c: White-space only
Karl Williamson [Fri, 8 Dec 2017 01:47:34 +0000 (18:47 -0700)]
sv.c: White-space only

This outdents some lines that the previous commit removed an enclosing
block of.

6 years agoutf8_upgrade_flags_grow(): Use faster variant count
Karl Williamson [Fri, 8 Dec 2017 01:42:53 +0000 (18:42 -0700)]
utf8_upgrade_flags_grow(): Use faster variant count

Now that we have a much faster way of counting the characters that would
expand to two bytes when a string is translated into UTF-8, use that,
instead of trying to choose one of two methods.  This simplifies the
code.  Note that the faster method doesn't happen on EBCDIC platforms,
but the simplification is worth the potential loss of being able to
choose methods.

6 years agoinline.h: Change extensive comment to a link
Karl Williamson [Tue, 12 Dec 2017 02:13:45 +0000 (19:13 -0700)]
inline.h: Change extensive comment to a link

I'm thinking the explanation of how the algorithm works  doesn't belong
in the code, so replace it by the commit number so it can be found
quickly.

6 years agoAdd variant_under_utf8_count() core function
Karl Williamson [Thu, 23 Nov 2017 05:30:16 +0000 (22:30 -0700)]
Add variant_under_utf8_count() core function

This function takes a string that isn't encoded in UTF-8 (hence is
assumed to be in Latin1), and counts how many of the bytes therein
would change if it were to be translated into UTF-8.  Each such byte
would occupy two UTF-8 bytes.

This function is useful for calculating the expansion factor precisely
when converting to UTF-8, so as to know how much to malloc.

This function uses a non-obvious method to do the calculations
word-at-a-time, as opposed to the byte-at-a-time method used now, and
hence should be much faster than the current methods.

The performance change in short string lengths is equivocal.  Here is
the result for a single character and a 64-bit word.

          bytes    words Ratio %
        -------- -------- -------
     Ir    932.0    947.0    98.4
     Dr    325.0    325.0   100.0
     Dw    104.0    104.0   100.0
   COND    136.0    137.0    99.3
    IND     28.0     28.0   100.0

 COND_m      1.0      0.0   Inf
  IND_m      6.0      6.0   100.0

There are some extra instructions executed and an extra branch to check
for and handle the case where we can go word-by-word vs. not.  But the
one cache miss is removed.

The results are essentially the same until we get to being able to
handle a full word.  Some of the extra instructions are to ensure that
if the input is not aligned on a word boundary, that performance doesn't
suffer.

Here's the results for 8-bytes on a 64-bit system.

           bytes    words Ratio %
        -------- -------- -------
     Ir    974.0    955.0   102.0
     Dr    332.0    325.0   102.2
     Dw    104.0    104.0   100.0
   COND    143.0    138.0   103.6
    IND     28.0     28.0   100.0

 COND_m      1.0      0.0     Inf
  IND_m      6.0      6.0   100.0

Things keep improving as the strings get longer.  Here's for 24 bytes.

           bytes    words Ratio %
        -------- -------- -------
     Ir   1070.0    975.0   109.7
     Dr    348.0    327.0   106.4
     Dw    104.0    104.0   100.0
   COND    159.0    140.0   113.6
    IND     28.0     28.0   100.0

 COND_m      2.0      0.0     Inf
  IND_m      6.0      6.0   100.0

And 96:

           bytes    words Ratio %
        -------- -------- -------
     Ir   1502.0   1065.0   141.0
     Dr    420.0    336.0   125.0
     Dw    104.0    104.0   100.0
   COND    231.0    149.0   155.0
    IND     28.0     28.0   100.0

 COND_m      2.0      1.0   200.0
  IND_m      6.0      6.0   100.0

And 10,000

           bytes    words Ratio %
        -------- -------- -------
     Ir  60926.0  13445.0   453.1
     Dr  10324.0   1574.0   655.9
     Dw    104.0    104.0   100.0
   COND  10135.0   1387.0   730.7
    IND     28.0     28.0   100.0

 COND_m      2.0      1.0   200.0
  IND_m      6.0      6.0   100.0

I found this trick on the internet many years ago, but I can't seem to
find it again to give them credit.

6 years agois_utf8_invariant_string(): small speed optimization
Karl Williamson [Tue, 12 Dec 2017 01:17:29 +0000 (18:17 -0700)]
is_utf8_invariant_string(): small speed optimization

This adds a few shifing, masking, and integer arithmetic operations to a
conditional which in return makes sure that one branch is taken only
when it is going to do some good, avoiding a conditional in it.

6 years agoAPItest/t/handy_base.pl: Avoid uninitialized warning
Karl Williamson [Tue, 12 Dec 2017 01:26:52 +0000 (18:26 -0700)]
APItest/t/handy_base.pl: Avoid uninitialized warning

This .pl in /t is generally called from a test file in that directory,
but if run by hand, this commit makes sure things are properly
initialized

6 years agodocument rules for identifying smoke-me branches
Zefram [Mon, 11 Dec 2017 21:25:38 +0000 (21:25 +0000)]
document rules for identifying smoke-me branches

6 years agofakesdio.h: Typo
Father Chrysostomos [Mon, 11 Dec 2017 18:01:35 +0000 (10:01 -0800)]
fakesdio.h: Typo

6 years agoAPItest.xs: shenanigans to avoid warnings
Father Chrysostomos [Mon, 11 Dec 2017 17:59:47 +0000 (09:59 -0800)]
APItest.xs: shenanigans to avoid warnings

We have an unresolved issue that #include "fakesdio.h" causes one
of the typemaps to make assignments between different pointer types,
something we can’t fix straightforwardly with casts, since adding
casts to the default typemap (which we are trying to test) may
suppress real problems in production.  This is a temporary plaster
till we figure out what to do.

6 years agosvleak.t: Disable crashing test
Father Chrysostomos [Mon, 11 Dec 2017 17:56:29 +0000 (09:56 -0800)]
svleak.t: Disable crashing test

till we get to the bottom of it

6 years agoNote schedule for $[ removal in perlvar
Dagfinn Ilmari Mannsåker [Mon, 11 Dec 2017 12:31:30 +0000 (12:31 +0000)]
Note schedule for $[ removal in perlvar

6 years agoS_maybe_multiconcat(): use OPpCONCAT_NESTED flag
David Mitchell [Mon, 11 Dec 2017 12:02:57 +0000 (12:02 +0000)]
S_maybe_multiconcat(): use OPpCONCAT_NESTED flag

RT # 132554

I recently added the OPpCONCAT_NESTED flag to distinguish between

    $a .= ...

and
    $a . $b . $c

where the latter has been optimised into

    ($a . $b) .= $c

Update S_maybe_multiconcat() to recognise this new flag.
It was failing an assert on this code:

    ./perl -e 'H.-w.w.=0'

6 years agoDeclaration after statement in typemap
Father Chrysostomos [Mon, 11 Dec 2017 04:25:59 +0000 (20:25 -0800)]
Declaration after statement in typemap

A follow-up to 6da090e6cb and 732d3893ab.

6 years agoperldelta for #115814
Father Chrysostomos [Mon, 11 Dec 2017 01:13:17 +0000 (17:13 -0800)]
perldelta for #115814

db9848c8d3fb and 6da090e6cb.

6 years agoIncrease $ExtUtils::Typemaps::VERSION to 3.37
Father Chrysostomos [Mon, 11 Dec 2017 00:54:44 +0000 (16:54 -0800)]
Increase $ExtUtils::Typemaps::VERSION to 3.37

6 years agoAvoid newGVgen in blead-upstream modules
Father Chrysostomos [Mon, 11 Dec 2017 00:53:45 +0000 (16:53 -0800)]
Avoid newGVgen in blead-upstream modules

ExtUtils::ParseXS::Typemaps:
Just in documentation, but it’s good to change it, in case peo-
ple copy it.

Time::HiRes:
It doesn’t even use these typemap entries, but I changed it in case
they get used in the future.  (The changes are not identical to the
default typemap, because Time::HiRes is 5.6-compatible, at least
nominally.)

os2/os2.c:
No, this is not a module, but I changed it, too.

Some other instances of newGVgen are already handled properly, or are
just in tests, so I left them alone.

6 years agoAvoid newGVgen in default typemap
Father Chrysostomos [Mon, 11 Dec 2017 00:37:11 +0000 (16:37 -0800)]
Avoid newGVgen in default typemap

newGVgen leaks memory, because it puts it vivifies a typeglob in the
symbol table, without arranging for it to be deleted.  A typemap is not
an appropriate place to use it, since callers of newGVgen are responsible
for seeing that the GV is freed, if they care.

This came up in #115814.

6 years agoperlapio: wrong param type
Father Chrysostomos [Mon, 11 Dec 2017 00:33:22 +0000 (16:33 -0800)]
perlapio: wrong param type

6 years agorevise documentation about set-id
Zefram [Mon, 11 Dec 2017 00:28:43 +0000 (00:28 +0000)]
revise documentation about set-id

perlsec's section on set-id scripts was written confusingly, with several
half-formed references to the long-ago-deleted suidperl, and with temporal
references that are well out of date.  Revise that section, and slightly
expand the perldiag entry for the message about detecting a set-id script.
Add another section to perlsec about sudo.  Fixes [perl #74142].

6 years agoassert well-formedness of argv in perl_parse()
Zefram [Sun, 10 Dec 2017 23:20:18 +0000 (23:20 +0000)]
assert well-formedness of argv in perl_parse()

6 years agoremove incorrect doc para about exit from BEGIN
Zefram [Sun, 10 Dec 2017 22:23:31 +0000 (22:23 +0000)]
remove incorrect doc para about exit from BEGIN

I misinterpreted the behaviour of exit from BEGIN when writing that
paragraph.  exit from BEGIN actually does cause perl_parse() to return
normally, but perl_run() wouldn't subsequently do anything.

6 years agoproperly define perl_parse() return value
Zefram [Sun, 10 Dec 2017 21:37:16 +0000 (21:37 +0000)]
properly define perl_parse() return value

perl_parse()'s return value has historically had conflicting purposes.
perlmain.c uses it as a truth value, but perlembed.pod has shown it being
used as an exit code.  perl_parse() has not had its own documentation.
What the function has actually done is to return zero for normal
completion and an exit code for early termination.  For this to be
a usable convention depended on early termination never using exit
code 0, and that's specifically *native* exit code 0, which could have
any significance.  In fact exit code 0 could arise for a compile-time
termination even on Unix through "CHECK { exit 0 }", and the mishandling
of that situation was bug [perl #2754].

Since perl_destruct() provides a native exit code unencumbered by any
attempt to simultaneously be a truth value, perl_parse() doesn't really
need to provide an exit code.  So define that perl_parse()'s return
value is principally a truth value.  Change the perlembed tutorial to
show it being so used, with an exit code coming from perl_destruct().
However, most of the historical usage of perl_parse()'s return value
as an exit code can be preserved.  Make it return 0x100 for exit(0),
which both serves as the essential truth value and on Unix also serves
as the proper exit code, because that set bit will be masked off when
actually exiting.  This works on Unix but will have variable effect on
other OSes; at least it will reliably indicate an actual exit.

perl_run() has a similar problem in the interpretation of its return
value, but not affecting the main perl executable, because perlmain.c
ignores its return value.  Similarly define that it is principally a
truth value, with preserved usage of non-zero return values as exit
codes, with exit code 0 transformed into 0x100.  This requires some
extra logic to distinguish between local completion and exit(0), which
were not previously distinguished.

Fully document perl_parse(), perl_run(), and perl_destruct() as API
functions.  Make the perlembed tutorial always show a proper exit
from main(), using "exit(EXIT_SUCCESS)" for portability when errors
are not being checked.  Make perlembed always show a null argv[argc]
being supplied to perl_parse(), where an argv is constructed.  (Commit
54c85bb058e15520a2fc0ba34007743aae56be34 added a note to perlembed saying
that that's required, but didn't fix the examples to show it being done.)

6 years agosort perldiag
Father Chrysostomos [Sun, 10 Dec 2017 20:11:13 +0000 (12:11 -0800)]
sort perldiag

6 years ago[perl #74764] Forbid ‘goto’ jumping into ‘given’
Father Chrysostomos [Sun, 10 Dec 2017 15:07:07 +0000 (07:07 -0800)]
[perl #74764] Forbid ‘goto’ jumping into ‘given’

It does not make sense to jump into a ‘given’ any more than it makes
sense to jump into ‘foreach’, which has long been forbidden, since
there is no value to turn into a topic.  Up till now this construct
has always crashed.

6 years agoExplicitly test goto-into-foreach
Father Chrysostomos [Wed, 6 Dec 2017 21:55:26 +0000 (13:55 -0800)]
Explicitly test goto-into-foreach

It is already tested in t/op/goto.t, but only as part of an existing
test to see which of multiple identical labels gets chosen.

6 years agopp_ctl.c: Move goto-into-foreach error
Father Chrysostomos [Wed, 6 Dec 2017 21:44:32 +0000 (13:44 -0800)]
pp_ctl.c: Move goto-into-foreach error

Put it in a static function, instead of repeating the code.  This way I
can add more conditions to that code in subsequent commits.

6 years agoClarify different cases of assignment to list of scalars.
James E Keenan [Thu, 7 Dec 2017 21:09:54 +0000 (16:09 -0500)]
Clarify different cases of assignment to list of scalars.

Prepared in response to RT #132538, with feedback from Father Chrysostomos.

6 years agostop gensyming when vivifying IO handles
Zefram [Sun, 10 Dec 2017 01:34:04 +0000 (01:34 +0000)]
stop gensyming when vivifying IO handles

When open() is given as a handle a scalar with undef value, the rv2gv
op creates a new glob for the I/O handle, and mutates the scalar to
contain an RV referencing the glob.  This is documented behaviour.
The question arises of what GvNAME the glob should have.  There's some
compile-time logic that spots that this might happen, and if the handle
expression is simple enough it stores in the pad a name representing
that expression, and rv2gv uses that for the GvNAME.  But if no name
was supplied by that route then rv2gv was using newGVgen() to generate
the glob.  That succeeds in giving it some kind of name, but has the
unwanted side effect of interning the glob in the stash under that name.
From the user's point of view, that creates a phantom reference to the
glob, which means that killing the RV doesn't remove the last reference
to the glob and so doesn't close the handle.

Instead of gensyming, just create an uninterned glob and give it a
fixed GvNAME.  Fixes [perl #115814].

6 years agoBetter selection of homegrown ino_t in vmsish.h.
Craig A. Berry [Sat, 9 Dec 2017 14:54:39 +0000 (08:54 -0600)]
Better selection of homegrown ino_t in vmsish.h.

We had been using a 64-bit definition of myino_t only when
_LARGEFILE is defined, but we actually get large file support via
either _LARGEFILE or _USE_STD_STAT because both give us 64-bit
off_t, so look at both definitions.

The size of off_t is not any great indicator for the size of
ino_t, but this preserves the intent of the existing code.

TODO: figure out when _USE_STD_STAT became available; it's
possible we no longer need this hackish layer on top of the
stat struct.

6 years agoAPItest/t/utf8.t: Simplify some tests
Karl Williamson [Tue, 5 Dec 2017 00:40:58 +0000 (17:40 -0700)]
APItest/t/utf8.t: Simplify some tests

The complicated nested loops of tests this commit replaces don't need to
be such.  To test utf8_is_invariant_string, we just need to put a single
variant in each position of a string that spans more than a full word
(since we have full-word lookup now) and includes partial words on either
side.  We set those partial words up to be one byte each less than a
full word.  The code needs to work on strings that don't start on a full
word, and don't end on one, and this commit continues to do that.

6 years agoinline.h: Use new C99 emulation
Karl Williamson [Tue, 5 Dec 2017 20:51:48 +0000 (13:51 -0700)]
inline.h: Use new C99 emulation

We don't have to know explicitly if the platform is 64 or 32 bits, and
can derive the constants that were formerly hard-coded in.

6 years agoAllow %j on non-C99 platforms
Karl Williamson [Tue, 5 Dec 2017 20:39:27 +0000 (13:39 -0700)]
Allow %j on non-C99 platforms

Now that intmax_t is emulated, the %j format is usable on platforms that
aren't C99.

6 years agoEmulate some C99 macros and typedefs
Karl Williamson [Tue, 5 Dec 2017 20:12:48 +0000 (13:12 -0700)]
Emulate some C99 macros and typedefs

On systems that don't have them, this emulates

U?INT(16|32)_C
U?INTMAX_C

and the typedefs

u?intmax_t

Since, these are typedefs that can't be tested for if they exist, this
creates PERL_U?INTMAX_T typedefs instead, setting them to the standard
values in stdint.h if it is available.

In addition, it moves the pre-existing emulation of U?INT64_C from
handy.h to perl.h.  This is because there was duplicate-ish logic in the
two files, and the handy.h version appears to be better thought out.

It converts the couple of places in core that were using the other
deleted logic to instead use the C99 names.

6 years agoinline.h: White space only
Karl Williamson [Fri, 8 Dec 2017 17:38:24 +0000 (10:38 -0700)]
inline.h: White space only

Add indentation to account for block added in the previous commit around
this code.

6 years agois_utf8_invariant_string(): small speed optimization
Karl Williamson [Fri, 8 Dec 2017 17:20:24 +0000 (10:20 -0700)]
is_utf8_invariant_string(): small speed optimization

By pulling a test out of a while loop condition and doing it before the
while starts, we don't increase the number of conditionals; instead we
avoid doing the conditional each time through, and also skip
some conditionals for strings shorter than a word.

6 years agoFix WIDEST_UTYPE in Devel::PPPort.
Craig A. Berry [Fri, 8 Dec 2017 20:48:59 +0000 (14:48 -0600)]
Fix WIDEST_UTYPE in Devel::PPPort.

It was redefining this even when it had already been defined, and
because it was using HAS_QUAD to determine whether 64-bit ints were
available, and HAS_QUAD is undef'd in perl.h when PERL_CORE is not
defined, it was as likely as not redefining it to a 32-bit value
even when 64-bit integers are available.

So only define it if it doesn't exist and when we do define it,
make it depend on QUADKIND rather than HAS_QUAD.

Follow-up to de9e2639368.

6 years agoPATCH: [perl #132548] regcomp.c Fix memory leak
Karl Williamson [Fri, 8 Dec 2017 14:27:13 +0000 (07:27 -0700)]
PATCH: [perl #132548] regcomp.c Fix memory leak

6 years agoRT#132545: memory leak in S_init_main_stash()
Aaron Crane [Fri, 8 Dec 2017 10:17:30 +0000 (10:17 +0000)]
RT#132545: memory leak in S_init_main_stash()

6 years agoadd comment (to test pushing)
Yves Orton [Fri, 8 Dec 2017 10:00:57 +0000 (11:00 +0100)]
add comment (to test pushing)

6 years agoswitch from _qq to _q in t/re/reg_mesg.t
Yves Orton [Fri, 8 Dec 2017 09:56:05 +0000 (10:56 +0100)]
switch from _qq to _q in t/re/reg_mesg.t

we want the string as unescaped as is reasonable, as we want to paste
them into perldiag directly.

6 years agohandy.h: Fix definition of WIDEST_UTYPE for non-core
Karl Williamson [Fri, 8 Dec 2017 01:09:15 +0000 (18:09 -0700)]
handy.h: Fix definition of WIDEST_UTYPE for non-core

Because HAS_QUAD is not defined outside the perl core, this macro was
not getting defined properly for 64-bit systems.  This means, for
example, that someone using this to cast could end up with the wrong
answer.  For example isASCII(2**32) would yield true, because the high
bit would get dropped by the cast, making the value appear to be zero.

This unfortunately creates a warning message in the compile that
WIDEST_UTYPE is redefined, as the definition of that is defective in
PPPort.  It should only define it if it wasn't previously defined, and
it is wrongly using the 32 bit version.  This is added impetus to get
PPPort fixed

6 years agohandy.h: Make U64, I64 available outside core
Karl Williamson [Fri, 8 Dec 2017 00:52:52 +0000 (17:52 -0700)]
handy.h: Make U64, I64 available outside core

The ones corresponding to shorter sizes, like I32, are available
everywhere.  There is no reason to restrict just the 64 variety.

This fixes the bug in the definition for INT64_C and UINT64_C which
caused these to not be defined outside core on some platforms, such as
Windows.

See commit 3edba68397e487b39cca6e7fc0b75ab4a2f6a341 for more
explanation

6 years agoutf8_length() is not a pure function
Karl Williamson [Thu, 7 Dec 2017 04:55:21 +0000 (21:55 -0700)]
utf8_length() is not a pure function

Because it can output warnings.

6 years agoAPItest/t/utf8.t: Clarify a couple of test names
Karl Williamson [Fri, 8 Dec 2017 00:45:23 +0000 (17:45 -0700)]
APItest/t/utf8.t: Clarify a couple of test names

6 years agoAvoid integer overflow with 32-bit ints in hexfp.t.
Craig A. Berry [Fri, 8 Dec 2017 01:08:22 +0000 (19:08 -0600)]
Avoid integer overflow with 32-bit ints in hexfp.t.

6 years agodelete duplicate _qq from test
Zefram [Fri, 8 Dec 2017 00:11:59 +0000 (00:11 +0000)]
delete duplicate _qq from test

Commit af05e4c0b428a803fcdb60c956b1da7ff8a95926 added a _qq() sub
to t/re/reg_mesg.t that duplicates both the intent and the name of
t/test.pl's _qq(), causing a redefinition warning.  Remove the new _qq(),
because t/test.pl's version is better.

6 years agoassert min identifier length in S_pending_ident()
Zefram [Fri, 8 Dec 2017 00:03:16 +0000 (00:03 +0000)]
assert min identifier length in S_pending_ident()

6 years agofix #131649 - extended charclass can trigger assert
Yves Orton [Mon, 26 Jun 2017 11:19:55 +0000 (13:19 +0200)]
fix #131649 - extended charclass can trigger assert

The extended charclass parser makes some assumptions during the
first pass which are only true on well structured input, and it
does not properly catch various errors. later on the code assumes
that things the first pass will let through are valid, when in
fact they should trigger errors.

6 years agoAvoid like in t/re/reg_mesg.t
Yves Orton [Sun, 3 Dec 2017 11:51:50 +0000 (12:51 +0100)]
Avoid like in t/re/reg_mesg.t

Rolling our a own a bit allows us to produce more helpful diagnostics.

6 years agoin capture_warnings() we need to properly localize Level
Yves Orton [Sun, 3 Dec 2017 11:52:27 +0000 (12:52 +0100)]
in capture_warnings() we need to properly localize Level

otherwise we dont get the right line number back from calls to
like or ok() called from within the callback.

6 years agoregcomp.c: handle_regex_sets() - add DEBUG_PARSE and fixup 'depth' logic
Yves Orton [Sun, 25 Jun 2017 20:31:10 +0000 (22:31 +0200)]
regcomp.c: handle_regex_sets() - add DEBUG_PARSE and fixup 'depth' logic

'depth' is used to track the recursion depth during compilation,
and is used by things like DEBUG_PARSE() to show the compilation
process.

handle_regex_sets() was using its own 'depth' for two different purposes,
which is quite confusing.

At the same time, when we call handle_regex_sets() from reg() it is
important to increment 'depth'.

6 years agoprevent integer overflow when compiling a regexp
Tony Cook [Mon, 14 Aug 2017 05:10:22 +0000 (15:10 +1000)]
prevent integer overflow when compiling a regexp

Fixes [perl #131893].

6 years agohandle null op_next in stacked filetests
Zefram [Wed, 6 Dec 2017 18:53:16 +0000 (18:53 +0000)]
handle null op_next in stacked filetests

When a filetest op returns false, it skips past following ops that
are stacked filetests.  The code to do this was assuming that op_next
would always be non-null, which is not always the case, for example in
a sort comparator.  Allow for it to be null.  Fixes [perl #129347].

6 years agofix oct/bin fp fractions in non-HEXFP_UQUAD builds
Zefram [Wed, 6 Dec 2017 17:41:59 +0000 (17:41 +0000)]
fix oct/bin fp fractions in non-HEXFP_UQUAD builds

The code for binaryish floating point literals, on builds where
we're not confident of being able to fit a significand into an
integer type, had built-in knowledge that the radix is 16, after
the radix point.  This gave erroneous values for octal and binary
literals on those builds.  This was shown up by the tests added in
commit 58be57636a42d6c6fd404c48c4e1cb87870182df.  Correct it to use the
actual radix.

6 years agoclarify "bless" doc
Zefram [Wed, 6 Dec 2017 17:15:29 +0000 (17:15 +0000)]
clarify "bless" doc

A couple of points came out of discussion on [perl #124428] that are
worthy of explication.

6 years agoLet 'skip' do the skipping in op/hexfp.t
Dagfinn Ilmari Mannsåker [Wed, 6 Dec 2017 17:17:44 +0000 (17:17 +0000)]
Let 'skip' do the skipping in op/hexfp.t

No need for an if/else when skip already bails out of the block.

6 years agoFix skip count for 64-bit NV-specific tests
Dagfinn Ilmari Mannsåker [Wed, 6 Dec 2017 17:15:26 +0000 (17:15 +0000)]
Fix skip count for 64-bit NV-specific tests

6 years agodocument hostname(@args) deprecation
Zefram [Wed, 6 Dec 2017 16:28:18 +0000 (16:28 +0000)]
document hostname(@args) deprecation

Passing arguments to Sys::Hostname::hostname() is already deprecated.
Note the deprecation's agreed removal version of Perl 5.32.  Also document
it in perldeprecation.pod.  [perl #124349]

6 years agofix a =head level in perldeprecation.pod
Zefram [Wed, 6 Dec 2017 16:17:27 +0000 (16:17 +0000)]
fix a =head level in perldeprecation.pod

6 years agopod: start referring to 5.6 and pre-5.6 as "ancient" instead of just "old"
Ævar Arnfjörð Bjarmason [Wed, 6 Dec 2017 13:21:01 +0000 (13:21 +0000)]
pod: start referring to 5.6 and pre-5.6 as "ancient" instead of just "old"

5.10 and 5.8 are old, 5.6 is ancient archaeology you're very unlikely
to run into, but the casual reader may not know that, add the extra
emphasis in case someone's mistaken about needing to worry about this
for anything more than historical trivia.

6 years agoperlfunc: re-flow docs amended in an earlier commit
Ævar Arnfjörð Bjarmason [Wed, 6 Dec 2017 13:53:45 +0000 (13:53 +0000)]
perlfunc: re-flow docs amended in an earlier commit

There's no wording changes here, just re-flowing this so "An" isn't
left like that on a short line of its own.

6 years agopod/perlfunc: stop recommending older syntax supported by 5.6.*
Ævar Arnfjörð Bjarmason [Wed, 6 Dec 2017 12:41:58 +0000 (12:41 +0000)]
pod/perlfunc: stop recommending older syntax supported by 5.6.*

Stop recommending the more verbose version syntax supported by 5.6.*,
as noted in the docs 5.8.0 is now old enough to drink in some parts of
the world, so we can switch this around to recommending the version
literals first, and then explaining in passing why someone might run
into the older syntax.

Furthermore, since most perl versions people encounter these days are
>=5.10, switch to 5.24.1 as an example for these versions.

While I'm at it, stop calling "use VERSION" the "peculiar" form, it
adds nothing, and just confuses the reader.

6 years agoremove stray NULLOK/NN from apidoc directives
Zefram [Wed, 6 Dec 2017 06:08:22 +0000 (06:08 +0000)]
remove stray NULLOK/NN from apidoc directives

6 years agoput shadowing warnings in their own category
Zefram [Wed, 6 Dec 2017 04:00:04 +0000 (04:00 +0000)]
put shadowing warnings in their own category

As proposed in [perl #125330].

6 years agolimit digits based on radix for oct/bin fp
Tony Cook [Tue, 5 Sep 2017 05:26:41 +0000 (15:26 +1000)]
limit digits based on radix for oct/bin fp

All hexadecimal digits were being permitted in octal and binary floating
point literals.  (That octal and binary literals are permitted at all
might be an accidental result of permitting hexadecimal?)  Restrict which
digits are permitted, in accordance with the radix.

6 years agoavoid negative shift in scan_num()
Zefram [Wed, 6 Dec 2017 01:40:43 +0000 (01:40 +0000)]
avoid negative shift in scan_num()

Lengthy binaryish floating point literals used to perform illegal bit
shifts.  Ignore digits that are past the end of the significand at an
earlier stage to avoid this.  Code fix by Tony C.  Fixes [perl #131894].

6 years agoassert legality of bitshifts in scan_num()
Zefram [Wed, 6 Dec 2017 01:10:31 +0000 (01:10 +0000)]
assert legality of bitshifts in scan_num()

[perl #131894] found some negative-exponent shifting going on here.
Make the illegality more accessible by asserting.

6 years agodon't mistake tr/// for assignable reference
Zefram [Wed, 6 Dec 2017 00:50:05 +0000 (00:50 +0000)]
don't mistake tr/// for assignable reference

For the lhs of an assignment to be an assignable srefgen, the
srefgen must be its top-level op.  ck_refassign() asserted that, but
S_assignment_type() was delving inside a null op looking for the srefgen,
the same way it looks for things that distinguish between scalar and
list assignment.  This showed up in a weird situation where a no-op
transliteration could be applied to an srefgen, getting an srefgen inside
a null op.  Fixes [perl #130578].

6 years agodocument hash/block disambig in perlsyn
Zefram [Tue, 5 Dec 2017 20:51:19 +0000 (20:51 +0000)]
document hash/block disambig in perlsyn

Fixes [perl #130958].

6 years agocorrect and clarify doc of operator precedence
Zefram [Tue, 5 Dec 2017 19:18:19 +0000 (19:18 +0000)]
correct and clarify doc of operator precedence

Fixes [perl #127391].

6 years agoclarify conditions for calling DB::sub
Zefram [Tue, 5 Dec 2017 18:08:51 +0000 (18:08 +0000)]
clarify conditions for calling DB::sub

The wording was ambiguous about which subroutine's compilation matters.
Fixes [perl #131672].

6 years agoremove doc hedge about autovivification
Zefram [Tue, 5 Dec 2017 18:03:12 +0000 (18:03 +0000)]
remove doc hedge about autovivification

We're clear by now that we're not going to change the default
autovivification behaviour, so the documentation should no longer say
that it "may be fixed in a future release".  Fixes [perl #127712].