This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perl5.git
6 years agoPPPort: silence a recent compiler warning
David Mitchell [Wed, 17 Jan 2018 14:15:11 +0000 (14:15 +0000)]
PPPort: silence a recent compiler warning

RealPPPort.c: In function ‘XS_Devel__PPPort_die_sv’:
RealPPPort.xs:1522:9: warning: variable ‘op’ set but not used [-Wunused-but-set-variable]
     OP *op;

6 years agoperldelta for 57bd660029
Tony Cook [Wed, 17 Jan 2018 01:01:03 +0000 (12:01 +1100)]
perldelta for 57bd660029

6 years ago(perl #131954) don't initialize mark before a possible move of the stack
Tony Cook [Thu, 24 Aug 2017 05:52:33 +0000 (15:52 +1000)]
(perl #131954) don't initialize mark before a possible move of the stack

6 years agoadditional test for lazy array element creation
Zefram [Tue, 16 Jan 2018 18:45:40 +0000 (18:45 +0000)]
additional test for lazy array element creation

6 years agotest for IO handle in localised glob
Zefram [Tue, 16 Jan 2018 18:08:57 +0000 (18:08 +0000)]
test for IO handle in localised glob

Tests the case in [perl #16113] that failed prior to Perl 5.19.10.

6 years agoFix -> inside C<> in perl58[89]delta
Dagfinn Ilmari Mannsåker [Tue, 16 Jan 2018 16:19:13 +0000 (16:19 +0000)]
Fix -> inside C<> in perl58[89]delta

6 years agoFix stray > in L<perlapi/sv_usepvn_flags>
Dagfinn Ilmari Mannsåker [Tue, 16 Jan 2018 16:18:24 +0000 (16:18 +0000)]
Fix stray > in L<perlapi/sv_usepvn_flags>

6 years agoFix broken POD markup in perlapi/Pad Data Structures
Dagfinn Ilmari Mannsåker [Tue, 16 Jan 2018 15:55:38 +0000 (15:55 +0000)]
Fix broken POD markup in perlapi/Pad Data Structures

6 years agofix parsing of braced subscript after parens
Zefram [Tue, 16 Jan 2018 08:04:08 +0000 (08:04 +0000)]
fix parsing of braced subscript after parens

Where an arrow is omitted between subscripts, if a parenthesised
subscript is followed by a braced one, PL_expect was getting set to
XBLOCK due to code intended for "foreach (...) {...}".  This broke
bareword autoquotation, and the parsing of operators following the
braced subscript.  Alter PL_expect from XBLOCK to XOPERATOR following
a parenthesised subscript.  Fixes [perl #8045].

6 years agovivify array elements when putting them on stack
Zefram [Tue, 16 Jan 2018 06:22:17 +0000 (06:22 +0000)]
vivify array elements when putting them on stack

When the elements of an array are put on the stack, by a padav, rv2av,
or padrange op, null pointers in the AvARRAY were being pushed as
&PL_sv_undef, which was OK in rvalue contexts but caused misbehaviour
in lvalue contexts.  Change this to vivify these elements.  There's no
attempt here to limit the vivification to lvalue contexts: the existing
op flags aren't enough to detect \(@a), and attempting to catch all
cases where a new flag needs to be set would be an error-prone process.
Fixes [perl #8910].

6 years agocorrect error returns from fast_abs_path()
Zefram [Tue, 16 Jan 2018 05:16:41 +0000 (05:16 +0000)]
correct error returns from fast_abs_path()

fast_abs_path() is documented as behaving like abs_path(), and is even
used as the main version of abs_path() on Cygwin, so it should indicate
errors in the same manner.  It was croaking; change this to return undef
with $! set.  Leave croaking for the error that breaks the abs_path()
rules, where fast_abs_path() has changed cwd and fails to change back.
Problem noted on [perl #132648].

6 years agoSet more sensible -O optimization on FreeBSD origin/tonyc/132704-freebsd-optimize
Tom Hukins [Wed, 10 Jan 2018 18:53:24 +0000 (18:53 +0000)]
Set more sensible -O optimization on FreeBSD

FreeBSD's /usr/share/mk/sys.mk specifies -O2 for architectures other
than arm and mips.  By default, compile perl with the same optimization
levels.

6 years ago(perl #132533) updates to Devel::PPPort
Tony Cook [Mon, 15 Jan 2018 23:56:37 +0000 (10:56 +1100)]
(perl #132533) updates to Devel::PPPort

6 years ago(perl #132533) bump $Devel::PPPort::VERSION
Tony Cook [Mon, 15 Jan 2018 23:28:53 +0000 (10:28 +1100)]
(perl #132533) bump $Devel::PPPort::VERSION

6 years ago(perl #132533) add missing generated file updates
Tony Cook [Mon, 15 Jan 2018 23:18:51 +0000 (10:18 +1100)]
(perl #132533) add missing generated file updates

6 years agoFix test warning: Use of uninitialized value
Pali [Sun, 3 Dec 2017 16:42:14 +0000 (17:42 +0100)]
Fix test warning: Use of uninitialized value

Function ok() compares values as strings which leads to stringification of
undef and throwing warning.

6 years agoFix security problem: CWE-134: Use of Externally-Controlled Format String
Pali [Sun, 3 Dec 2017 16:02:53 +0000 (17:02 +0100)]
Fix security problem: CWE-134: Use of Externally-Controlled Format String

Function croak() takes printf-like formatted string, so passing arbitrary
char* can leads to buffer overflow. Use croak_sv() which is now available
and avoids converting SV* to char*.

6 years agoUse croak_sv in threads
Pali [Sun, 3 Dec 2017 16:01:10 +0000 (17:01 +0100)]
Use croak_sv in threads

Now when croak_sv is available, there is no need to use croak() with SV* to
char* conversion.

6 years agoImplement mess
Pali [Sun, 3 Dec 2017 15:57:46 +0000 (16:57 +0100)]
Implement mess

This patch provides implementation of the following functions:
croak_sv, die_sv, mess_sv, warn_sv, mess, vmess, warn_nocontext,
croak_nocontext, croak_no_modify, croak_memory_wrap, croak_xs_usage

TonyC: add parts/inc/mess to MANIFEST

6 years agoAvoid some branches
Karl Williamson [Sat, 13 Jan 2018 22:40:34 +0000 (15:40 -0700)]
Avoid some branches

This replaces some looping with branchless code in two places: looking
for the first UTF-8 variant byte in a string (which is used under
several circumstances), and looking for an ASCII or non-ASCII character
during pattern matching.

Recent commits have changed these operations to do word-at-a-time look-
ups, essentially vectorizing the problem into 4 or 8 parallel probes.
But when the word is found which contains the desired byte, until this
commit, that word would be scanned byte-at-a-time in a loop.

I found some bit hacks on the internet, which when stitched togther, can
find the first desired byte in the word without branching, while doing
this while the word is still loaded, without having to load each byte.

6 years agoinline.h: Add comment.
Karl Williamson [Mon, 15 Jan 2018 22:15:14 +0000 (15:15 -0700)]
inline.h: Add comment.

6 years agoperldiag: miscapitalization
Father Chrysostomos [Mon, 15 Jan 2018 20:59:27 +0000 (12:59 -0800)]
perldiag: miscapitalization

6 years agoSort perldiag
Father Chrysostomos [Mon, 15 Jan 2018 20:57:41 +0000 (12:57 -0800)]
Sort perldiag

6 years agoVMS does have fchmod and fchown.
Craig A. Berry [Sun, 14 Jan 2018 19:42:05 +0000 (13:42 -0600)]
VMS does have fchmod and fchown.

The test for fchmod in t/io/fs.t does, however, reveal a wrinkle
that is also true of chmod on VMS: a mode argument of zero does
not mean turn off all permisions but rather set permissions to the
user's default.  This is probably an ancient behavior from
pre-standard days.  For now, just skip the affected test and
document what's different.

6 years agoregexec.c: Complement the correct operand
Karl Williamson [Mon, 15 Jan 2018 03:40:54 +0000 (20:40 -0700)]
regexec.c: Complement the correct operand

This was complementing the & mask which looks like 0x808080...
hence anding 0x7f7f7f... which is TRUE for all operands execpt the
0x808080....  It is being used to scan a string to find an ASCII
character, so it would return TRUE inappropriately, but never wrongly
returning FALSE.  Since the result is then checked for matching, this
didn't actually cause an error; just unnecessary work.

6 years agoperllocale: Wording/formatting nits
Karl Williamson [Mon, 15 Jan 2018 03:14:50 +0000 (20:14 -0700)]
perllocale: Wording/formatting nits

6 years agoperllocale: Fix typo
Karl Williamson [Sun, 14 Jan 2018 18:44:22 +0000 (11:44 -0700)]
perllocale: Fix typo

6 years agoDevel-PPPort: Rmv impediment to compiling under C++11
Karl Williamson [Sat, 19 Nov 2016 12:57:46 +0000 (05:57 -0700)]
Devel-PPPort: Rmv impediment to compiling under C++11

C++11 changed from earlier versions to require space between the end of
a string literal and a macro, so that a feature can unambiguously be
added to the language.  Starting in g++ 6.2, the compiler emits a
deprecation warning when there isn't a space (presumably so that future
versions can support C++11).

Although not required by the C++11 change, this patch also makes sure
there is space after a macro call, before a string literal.

Code and modules included with the Perl core need to be compilable using
C++.  This is so that perl can be embedded in C++ programs. (Actually,
only the hdr files need to be so compilable, but it would be hard to
test that just the hdrs are compilable.)  So we need to accommodate
changes to the C++ language.

6 years agoFix goto-into-string-eval under PERL_UNICODE
Father Chrysostomos [Fri, 12 Jan 2018 16:37:18 +0000 (08:37 -0800)]
Fix goto-into-string-eval under PERL_UNICODE

More precisely, goto-to-jump-into-the-parameter-of-a-string-eval,
which is tested in goto.t as of 6d90e98384, but fails as of that
commit under PERL_UNICODE, because entereval gets a second kid
op (a hintseval op) and ‘looks like’ a list operator, which
6d90e98384 generally forbad.

The easiest way to fix this is simply to add another exception.

6 years agoVMS does have gai_strerror.
Craig A. Berry [Thu, 11 Jan 2018 20:42:43 +0000 (14:42 -0600)]
VMS does have gai_strerror.

And we need to say we have it for the latest version of Socket
to build successfully.

6 years agoUpdate Socket to CPAN version 2.025
Dagfinn Ilmari Mannsåker [Tue, 9 Jan 2018 17:32:51 +0000 (17:32 +0000)]
Update Socket to CPAN version 2.025

2.025   2018-01-09 15:12:51
        [CHANGES]
         * Add IPPROTO_ICMPV6

        [BUGFIXES]
         * Fix for C++11 compilers - require a space either side of
           string-pasting macros (thanks Karl Williamson)
         * Fix for machines lacking HAS_SOCKADDR_IN6 (RT116913) (thanks ilmari)
         * Print to STDERR on test failures (RT123436) (thanks ilmari)

2.024   2016/08/11 13:49:48
        [BUGFIXES]
         * Restore back-compat to pre-2.011 behaviour on undefined port
           numbers to pack_sockaddr_in(6?) - silently accept undef as zero
           (RT116699)
         * Warn if pack_sockaddr_un is truncating an overly long path
           (mitigates but does not resolve RT116819)

2.023   2016/08/02 14:50:50
        [CHANGES]
         * Add more socket(7), ip(7) and ipv6(7) socket options from Linux

        [BUGFIXES]
         * Fix skip count for abstract AF_UNIX path tests when not running on
           Linux

2.022   2016/08/01 16:02:48
        [CHANGES]
         * Throw exceptions if pack/unpack sockaddr functions are passed
           undefined arguments (RT116624)

        [BUGFIXES]
         * Fix coverty complaint (RT111707)

2.021   2015/11/18 17:09:13
        [CHANGES]
         * Add constants for TCP fastopen (RT105155)

        [BUGFIXES]
         * Respect HAS_GETHOSTBYNAME before calling gethostbyname() (RT105947)
         * Fixes for inet_pton() fallback on Win32 (RT107058)
         * Fix for INET_ADDRSTRLEN on AmigaOS (really!) (RT106797)
         * Provide gai_strerror() fallback on platforms that lack one
           (RT76091)

6 years agofix Data-Dumper postentry for quoted glob
Zefram [Wed, 10 Jan 2018 21:09:45 +0000 (21:09 +0000)]
fix Data-Dumper postentry for quoted glob

In Data-Dumper, where a glob with a quoted name required a postentry,
the name part of the postentry was being emitted as just "}".  This was
an old bug affecting upgraded glob names, which the recent commit
abda9fe0fe75ae824723761c1c98af958f17a41c made affect all quoted glob
names.  Fix the postentry name to encompass the entire quoted name.
Fixes [perl #132695].

6 years agoloc_tools.pl: properly load fallback locales
Tomasz Konojacki [Wed, 10 Jan 2018 03:49:08 +0000 (04:49 +0100)]
loc_tools.pl: properly load fallback locales

It turns out that some tests using loc_tools.pl are being executed
from a different working directory than './t', which causes
do("./lib/locale/<locale>") to fail.

This fixes lib/warnings.t on Windows.

Discussion:
https://www.nntp.perl.org/group/perl.perl5.porters/2018/01/msg248652.html

6 years agoUse ck_null for ~.
Father Chrysostomos [Mon, 8 Jan 2018 16:29:26 +0000 (08:29 -0800)]
Use ck_null for ~.

It no longer needs ck_bitop, which it only used before for the
experimental warning that has been removed.

6 years agoDevel;:PPPort: Skip tests invalid on EBCDIC
Karl Williamson [Wed, 10 Jan 2018 02:49:32 +0000 (19:49 -0700)]
Devel;:PPPort: Skip tests invalid on EBCDIC

I don't think it's worth the effort to port these couple of tests.

6 years agot/loc_tools.pl: Remove debug line
Karl Williamson [Tue, 9 Jan 2018 21:20:35 +0000 (14:20 -0700)]
t/loc_tools.pl: Remove debug line

This was inadvertently left in in the previous commit

6 years agot/loc_tools.pl: Display diagnostic on non-found file
Karl Williamson [Tue, 9 Jan 2018 20:19:12 +0000 (13:19 -0700)]
t/loc_tools.pl: Display diagnostic on non-found file

The diagnostic output added in 759b442cd504fd04e125d71b981f7092ec3fbea1
shows that in some platforms that the path to certain files is not
correct at the time  (spotted by Tomasz Konojacki).

This commit tests for the existence of the files, and if not found warns
and doesn't process further.  This warning gives a better clue in the
future as to the cause of the problem.  The other warning remains, in
case there are other causes, now or in the future.

We are still working on the best way to specify these files, as the
hard-coded relative path that specifies them gets disrupted if the
current directory gets changed.

6 years agot/op/exec.t: Add missing /i
Karl Williamson [Tue, 9 Jan 2018 16:48:59 +0000 (09:48 -0700)]
t/op/exec.t: Add missing /i

This was failing on z/OS due to its capitalization of an expected word.
The similar tests in this file use /i; this is the only one missing it.

I'm presuming we don't want to do a qr// in testing this basic
functionality, othewise it would be better to use the same re everywhere
to avoid this kind of typo.

6 years agoUpdate Encode to CPAN version 2.94
Chris 'BinGOs' Williams [Tue, 9 Jan 2018 12:43:33 +0000 (12:43 +0000)]
Update Encode to CPAN version 2.94

  [DELTA]

$Revision: 2.94 $ $Date: 2018/01/09 05:53:00 $
! lib/Encode/Alias.pm
  Fixed: deep recursion in Encode::find_encoding when decoding
  bad MIME header
  https://github.com/dankogai/p5-encode/pull/127
! Encode.pm
  Pulled: Include more information about Encode::is_utf8() that it
  should not be normally used
  https://github.com/dankogai/p5-encode/pull/126
  Pulled: Remove misleading documentation about UTF8 flag
  https://github.com/dankogai/p5-encode/pull/125

6 years agoUpdate Time-HiRes to CPAN version 1.9752
Chris 'BinGOs' Williams [Tue, 9 Jan 2018 12:41:38 +0000 (12:41 +0000)]
Update Time-HiRes to CPAN version 1.9752

  [DELTA]

1.9752 [2018-01-04]
 - fix an error in the error message of utimensat() not available:
   it said futimens() not available
 - add --force alias for Makefile.PL --configure

1.9751 [2018-01-02]
 - in macOS/OSX/Darwin, use __has_builtin() check also for utimensat(),
   can cause errors like
   "HiRes.xs:1474:16: error: unrecognized platform name macOS"
   [rt.cpan.org #123994]
   (oversight from 1.9749)
 - do not define TIME_HIRES_STAT/d_hires_stat if none was found, instead
   of defining it to be zero, which case has no implementation in hrstatns()
   (thanks to Nigel Horne)
 - in t/utime.t try to divine if the filesystem of the tempfiles has been
   mounted with the 'noatime' option, which can prohibit updating the
   access time timestamp.  Also document this in HiRes.pm.
   (thanks to Nigel Horne, original analysis by Slaven Rezic)
 - synchronize the constant lists in HiRes.pm:@EXPORT_OK
   and Makefile.PL:doConstants and regenerate fallback/const-c.inc
   and fallback/const-xs.inc, this fixes Perl 5.6.2 issue with
   d_futimens not allegedly being a valid macro in t/utime.t
   (using Perl 5.26.1 for the regenerating, not 5.6.2)
   (thanks to Nigel Horne)
 - in t/utime.t define a nop sub done_testing for ancient Perls
   (like Perl 5.6.2)
 - in Perl 5.6.2 a bogus warning
   "Use of uninitialized value in subroutine entry"
   is issued from t/alarm.t: add a comment documenting that

6 years agoperldelta for #130936
Father Chrysostomos [Mon, 8 Jan 2018 16:18:21 +0000 (08:18 -0800)]
perldelta for #130936

6 years ago[perl #130936] Forbid some cases of inward goto
Father Chrysostomos [Mon, 8 Jan 2018 06:23:03 +0000 (22:23 -0800)]
[perl #130936] Forbid some cases of inward goto

This commit in general forbids entry into the parameter of a binary or
list operator, to avoid crashes and stack corruption.

In cases like

    goto f;
    push @array, do { f: }

and

    goto f;
    $a + do { f: };

it’s not possible to fix this in general.  Cases like

    goto f;
    do { f: } + $a;

(jumping into the first parameter) have never caused problems, but I
went ahead and forbad that usage too, since it would be too compli-
cated to figure out exactly which parameter is being jumped into.
(It’s not impossible; it would just double the amount of code used to
find labels.)

List operators taking just a simple list, such as die(), have never
worked properly, because goto() bypasses the pushmark.  They could be
made to work, but that would require extra work to distinguish cases
like push and print that have a first operand (sometimes implicit for
print) of a specific type.  I figured it was easier just to forbid
jumping into any list operator.  It’s also much easier to document.

6 years agostate.t: Allow to run under miniperl
Father Chrysostomos [Mon, 8 Jan 2018 05:13:01 +0000 (21:13 -0800)]
state.t: Allow to run under miniperl

Useful for debugging.

6 years agoStop alloc_LOGOP from always setting OPf_KIDS
Father Chrysostomos [Mon, 8 Jan 2018 04:46:54 +0000 (20:46 -0800)]
Stop alloc_LOGOP from always setting OPf_KIDS

Commit v5.21.1-125-g3253bf8, which added the function, caused entertry
to get a kid op.  Before:

$ perl5.20.1 -MO=Concise -eeval{}
5  <@> leave[1 ref] vKP/REFC ->(end)
1     <0> enter ->2
2     <;> nextstate(main 2 -e:1) v:{ ->3
4     <@> leavetry vK ->5
3        <|> entertry(other->4) v ->6
6        <0> stub v ->4
-e syntax OK

Notice entertry has no K.  After:

$ perl5.22.0 -MO=Concise -eeval{}
5  <@> leave[1 ref] vKP/REFC ->(end)
1     <0> enter ->2
2     <;> nextstate(main 1 -e:1) v:{ ->3
4     <@> leavetry vK ->5
3        <|> entertry(other->4) vK ->6
6        <0> stub v ->4
-e syntax OK

This time it has a K, but it has no kid ops.

This causes problems for a patch I am working on, because one
can no longer depend on cUNOPo->op_first being non-null when
o->op_flags & OPf_KIDS.

alloc_LOGOP should only set the KIDS flag if it actually has kids.

6 years agoFacilitate building with quadmath on Cygwin.
Peter John Acklam [Sun, 7 Jan 2018 13:28:58 +0000 (08:28 -0500)]
Facilitate building with quadmath on Cygwin.

For: RT # 128627

6 years agoAlternate backup file rename test for VMS.
Craig A. Berry [Fri, 5 Jan 2018 19:54:35 +0000 (13:54 -0600)]
Alternate backup file rename test for VMS.

The existing test that made a directory called foo.bak and then
made sure the rename of a backup file from in-place edit failed
to overwrite the directory doesn't work on VMS because there is
no conflict between a file named foo.bak and directory named
[foo^.bak] in directory syntax or foo^.bak.DIR in filename syntax.
The .DIR extension is always there, and other dots in the name
are escaped with caret because dot is the directory delimiter.

So just make version 32767 of foo.bak and when the rename tries
to make the next higher version it will fail.  We're testing what
happens when the rename fails not why it fails, so we accomplish
the same goal via a different mechanism.

6 years agoDocument system(1, @args) under VMS in perlport.
Craig A. Berry [Fri, 5 Jan 2018 18:10:25 +0000 (12:10 -0600)]
Document system(1, @args) under VMS in perlport.

It's been there for Win32 for some time, but we've imitated the
Windows behavior since eed5d6a149b02c1699.

6 years agoHide Perl_isSCRIPT_RUN from the re extension.
Craig A. Berry [Thu, 4 Jan 2018 23:32:46 +0000 (17:32 -0600)]
Hide Perl_isSCRIPT_RUN from the re extension.

Otherwise the extension fails to build on VMS because the symbol
is multiply defined and a linker warning about that is escalated
to a run-time error.

6 years agoActually remove stray ';'
Karl Williamson [Thu, 4 Jan 2018 19:50:35 +0000 (12:50 -0700)]
Actually remove stray ';'

The previous commit was supposed to include this

6 years agoregexec.c: Clarify comments; remove stray ';'
Karl Williamson [Thu, 4 Jan 2018 19:24:43 +0000 (12:24 -0700)]
regexec.c: Clarify comments; remove stray ';'

6 years agoScript Run: Scripts couldn't start with Common
Karl Williamson [Thu, 4 Jan 2018 19:22:26 +0000 (12:22 -0700)]
Script Run: Scripts couldn't start with Common

The Common script is supposed to be intermixable with any other script.
But it wasn't properly handling the case where the first character in
the string was Common, and a subsequent character was some real script.

6 years agoScript runs: was swallowing next char in pattern
Karl Williamson [Thu, 4 Jan 2018 19:13:23 +0000 (12:13 -0700)]
Script runs: was swallowing next char in pattern

In /(+script_run:foo)bar/, the 'b' was being swallowed without being
acted upon.  This would affect the '$' to mean match end of string

6 years agoMake script run code a separate function
Karl Williamson [Mon, 1 Jan 2018 20:39:42 +0000 (13:39 -0700)]
Make script run code a separate function

This just does the minimal work (plus white space) to make this code
into a separate function, so that it can be called from elsewhere in the
core.

6 years agoAdd missing newline to the "Unable to flush stdout" diagnostic
Niko Tyni [Sat, 16 Sep 2017 08:24:18 +0000 (11:24 +0300)]
Add missing newline to the "Unable to flush stdout" diagnostic

Originally reported by Jakub Wilk.

Bug-Debian: https://bugs.debian.org/875361

6 years agopp_multiconcat(): fix win32 compiler warning
David Mitchell [Tue, 2 Jan 2018 13:55:29 +0000 (13:55 +0000)]
pp_multiconcat(): fix win32 compiler warning

pp_hot.c(930) : warning C4146: unary minus operator applied to unsigned type,
result still unsigned

Negating an unsigned STRLEN (aka Size_t) string length in this case will
never encounter a situation where the value is too big to be negated,
because at that point we have both the string and a grown buffer of at
least equal size in memory simultaneously, so targ_len < Size_t_MAX/2.

So just cast away the warning.

6 years agoQuote one-liner in exec.t on VMS.
Craig A. Berry [Mon, 1 Jan 2018 21:48:36 +0000 (15:48 -0600)]
Quote one-liner in exec.t on VMS.

On VMS, system() sends a complete command to the CLI rather than
passing arguments via exec.  So arguments need to be quoted if
they have anything the shell doesn't like or contain spaces.

6 years agoReenable numeric first argument of system() on VMS.
Craig A. Berry [Mon, 1 Jan 2018 16:10:33 +0000 (10:10 -0600)]
Reenable numeric first argument of system() on VMS.

This was broken in 64def2aeaeb63f92dadc6dfa334, and fixed for Win32
only in 8fe3452cc6ac7af8c08.  But VMS also uses a numeric first
argument to system() as a flag indicating spawn without waiting for
completion.

6 years agot/loc_tools.pl: Add diagnostic output
Karl Williamson [Mon, 1 Jan 2018 19:33:38 +0000 (12:33 -0700)]
t/loc_tools.pl: Add diagnostic output

We are getting non-fatal output from this on z/OS.  This will help pin
down the problem, and remain in place in case other such situations
arise.

6 years agot/loc_tools.pl: Implement fail() if not available
Karl Williamson [Mon, 1 Jan 2018 19:32:22 +0000 (12:32 -0700)]
t/loc_tools.pl: Implement fail() if not available

Previously, this file require the caller to have implemented ok() (which
they may not have done.  Now, it uses fail() instead if available, and
itsd own hand-rolled version otherwise.

6 years agot/loc_tools.pl: Tidy up
Karl Williamson [Sun, 31 Dec 2017 19:25:25 +0000 (12:25 -0700)]
t/loc_tools.pl: Tidy up

Instead of using $@, use the variable set to $@ just after the eval.
This is cleaner, and avoids an issue should new code be inserted between
them that affects $@

6 years agoregexec.c: Change declaration to U8
Karl Williamson [Sun, 31 Dec 2017 19:03:01 +0000 (12:03 -0700)]
regexec.c: Change declaration to U8

from char in the new script_run code.  This makes it more convenient to
run gdb on.

6 years agolocale.c: Add checks for improper locale
Karl Williamson [Sun, 31 Dec 2017 16:49:46 +0000 (09:49 -0700)]
locale.c: Add checks for improper locale

There has been code to check that the new locale is compatible with
ASCII when switching to one; this commit expands those checks.  A locale
that isn't ASCII-compatible doesn't play well with Perl.

6 years agoregen/mk_invlists.pl: Add table for currency symbols
Karl Williamson [Sun, 31 Dec 2017 16:23:37 +0000 (09:23 -0700)]
regen/mk_invlists.pl: Add table for currency symbols

This will be used in a future commit

6 years agolocale.c: Improve debugging output
Karl Williamson [Sun, 31 Dec 2017 14:53:32 +0000 (07:53 -0700)]
locale.c: Improve debugging output

This extracts some debugging output code into a function (so that it can
be called from more than one place) and add some detail to the output.

6 years agoRemove constness of parameter that no longer is
Karl Williamson [Sun, 31 Dec 2017 14:40:26 +0000 (07:40 -0700)]
Remove constness of parameter that no longer is

This was masked by the fact that this is a macro that calls the real
function

6 years ago[Merge] Make bitwise feature no longer experimental
Father Chrysostomos [Mon, 1 Jan 2018 01:03:36 +0000 (17:03 -0800)]
[Merge] Make bitwise feature no longer experimental

6 years agoperldelta for bitwise ops
Father Chrysostomos [Mon, 1 Jan 2018 01:02:13 +0000 (17:02 -0800)]
perldelta for bitwise ops

6 years agoUpdate docs wrt bitwise ops
Father Chrysostomos [Sun, 31 Dec 2017 20:54:44 +0000 (12:54 -0800)]
Update docs wrt bitwise ops

6 years agoEnable bitwise feature with ‘use v5.28’
Father Chrysostomos [Sun, 31 Dec 2017 20:24:01 +0000 (12:24 -0800)]
Enable bitwise feature with ‘use v5.28’

6 years agoRemove experimental bitwise warning
Father Chrysostomos [Sun, 31 Dec 2017 19:24:57 +0000 (11:24 -0800)]
Remove experimental bitwise warning

6 years agoXSLoader shouldn't use mod2fname when finding .bs files.
Craig A. Berry [Sun, 31 Dec 2017 14:10:23 +0000 (08:10 -0600)]
XSLoader shouldn't use mod2fname when finding .bs files.

This is a belated follow-up to 907196b2ca1c36611c32cb8, where I
did the same for DynaLoader but failed to notice that XSLoader has
its own check for the .bs file before it invokes DynaLoader.

This finally gets the new bootstrap.t test added to XS::APItest
in 2e6f1ae9c4f7857e86f85fde07 passing on VMS.

6 years agoperldelta for /[[:ascii:]]/ changes
Karl Williamson [Sun, 31 Dec 2017 06:24:35 +0000 (23:24 -0700)]
perldelta for /[[:ascii:]]/ changes

6 years agoregexec.c: Replace loop by memchr()
Karl Williamson [Wed, 27 Dec 2017 01:13:36 +0000 (18:13 -0700)]
regexec.c: Replace loop by memchr()

This loop can be potentially very long as it is used to find the next
place there is a potential match in something like /(foo)+abc/.  (It's
trying to find the 'a' in that example.

6 years agoassert nested CV existence when freeing CV
Zefram [Sat, 30 Dec 2017 12:36:54 +0000 (12:36 +0000)]
assert nested CV existence when freeing CV

[perl #131631] has a convoluted test case that messes up parser error
recovery and causes a segv via null pointer dereference.  Turn the segv
into an assertion failure, by asserting non-nullness of the pointer.
This doesn't fix the actual problem with error recovery.

6 years agoclarify doc of "-m" et al
Zefram [Sat, 30 Dec 2017 11:48:00 +0000 (11:48 +0000)]
clarify doc of "-m" et al

Expand perlrun's documentation of module-loading options.  Rather than
describe the options only in terms of C<use> declarations, also describe
their effects in terms of module loading operations.  Fixes [perl #131518].

6 years agoOptimize /[...]/ into ASCII regnode if appropriate
Karl Williamson [Fri, 29 Dec 2017 22:03:47 +0000 (15:03 -0700)]
Optimize /[...]/ into ASCII regnode if appropriate

Previously the optimization of this into a Posix regnode was skipped, as
the regnode for bracketed character classes had about the same
performance as the Posix regnodes did.  But the previous commit has
greatly improved the performance of this functionality by using new
ASCII regnodes, so now the optimization makes sense.

6 years agoUse new regnodes for /[[:ascii:]]/
Karl Williamson [Fri, 29 Dec 2017 20:35:00 +0000 (13:35 -0700)]
Use new regnodes for /[[:ascii:]]/

Prior to this commit, the ASCII Posix class was treated as any other
Posix class under /a.  It turns out that by making separate nodes for it
(and its complement), the performance gains can be astronomical on ASCII
platforms.  This is mainly due to the fact that scanning can be done
word-at-a-time, but also because various conditionals can be skipped.

Below are some measurements from Porting/bench.pl on a 64-bit Linux g++
-O2 system.The numbers are for very long strings, as otherwise, the
delta due solely to this change is masked by the overhead around pattern
matching in general.  These numbers are for finding an ASCII character
at the end of a very long string of non-ASCII ones.

All 1-byte (non-utf8) characters improvement ratio
    Ir      1990.8
    Dr      2995.4
    Dw      17296.7
  COND      786.0

All 2-byte characters improvement ratio
    Ir      242.2
    Dr      232.9
    Dw      17237.8
  COND      100.0

The numbers for three and more bytes per character are essentially the
same as for two bytes.

As an example, the Dw for strings consisting entirely of 2-byte
characters (before the terminal ASCII one) now take 584 instructions,
and previously 100,582

The gain would be less for a 32-bit system.

bench.pl returns other measurements which I omitted above, because they
either have unchanged performance or involve a trivial number of total
instructions.

6 years agoregcomp.sym: Add regnodes for [[:ascii:]]
Karl Williamson [Tue, 26 Dec 2017 17:57:49 +0000 (10:57 -0700)]
regcomp.sym: Add regnodes for [[:ascii:]]

These will be used in a future commit

6 years agoSpeed up /[[:posix:]]/a UTF-8 matching
Karl Williamson [Fri, 29 Dec 2017 05:38:39 +0000 (22:38 -0700)]
Speed up /[[:posix:]]/a UTF-8 matching

Before this commit, when a Posix class (not the negation) was matched
against a UTF-8 string, it ignored the UTF-8ness, because it's irrelevant
to the success or failure of the match.  However, I now realize it is
relevant to the speed of the match, hence this commit.

In particular, when scanning a string for the next occurrence of, say,
an ASCII word character, it tested every continuation byte.  Each one is
relatively efficient, because it is an array lookup, but it's work that
would be avoided if we skipped continuation bytes.

However, to skip continuation bytes, we have to look up how many to
skip.  This is extra work that the previous version avoided.  So, if the
string is entirely ASCII (but with the UTF-8 bit set), this will be a
loser, as you still have to examine every byte anyway.  The more
continuation bytes get skipped, the more of a win this will be.  Below
are some measurements from Porting/bench.pl on a 64-bit Linux g++ -O2
system.  The numbers are for very long strings, as otherwise, the delta
due solely to this change is masked by the overhead around pattern
matching in general.

All 1-byte characters improvement ratio
    Ir      100.0
    Dr      80.0
    Dw      100.0
  COND      100.0

All 2-byte characters improvement ratio
    Ir      200.0
    Dr      114.3
    Dw      200.0
  COND      200.0

All 3-byte characters improvement ratio
    Ir      300.0
    Dr      171.4
    Dw      300.0
  COND      300.0

All 4-byte characters improvement ratio
    Ir      400.0
    Dr      228.6
    Dw      400.0
  COND      400.0

This means that if a string consists entirely of ASCII (1-byte chars),
this patch worsens the number of data read instructions by 20%, while
the other measurements are unchanged.  But if the target string consists
entirely of multi-byte characters, the performance in all other criteria
goes up by much larger amounts.

The most important measurement here is COND.  One can extrapolate that
if the string contains even just a few multi-byte characters, the COND
improves over what the previous behavior did, and hence this patch is
worth doing.

It's unclear what the average number of bytes in a string might be.  If
one is processing text with a large number of bytes per character, why
would one be using /a?  But if everything is just ASCII, why is the
UTF-8 bit set?  So my best guess is that the strings that this patch
will affect are mostly, but not entirely ASCII, and the number of
conditional branches goes down in this case.

bench.pl returns other measurements which I omitted above, because they
either have unchanged performance or involve a trivial number of total
instructions.

6 years agoregcomp.c: Fix an optimization criterium
Karl Williamson [Fri, 29 Dec 2017 21:54:17 +0000 (14:54 -0700)]
regcomp.c: Fix an optimization criterium

/[...]/ patterns get optimized into Posix ones if they match the same
things, as the latter are somewhat speedier.  The code that checks if
they match was off-by-one, so that it didn't check for a match for \v.

6 years agoregcomp.c: Fix comment
Karl Williamson [Fri, 29 Dec 2017 21:52:34 +0000 (14:52 -0700)]
regcomp.c: Fix comment

This comment misspoke, and was unclear.

6 years agoregexec.c: White-space, braces only
Karl Williamson [Wed, 27 Dec 2017 00:53:13 +0000 (17:53 -0700)]
regexec.c: White-space, braces only

This indents code that the previous commit added a block around, and
aligns some conditionals vertically, and adds some braces for clarity,
and removes a couple of extra bank lines.

6 years agoregexec.c: Save a conditional per iteration
Karl Williamson [Wed, 27 Dec 2017 00:32:10 +0000 (17:32 -0700)]
regexec.c: Save a conditional per iteration

This commit changes two places where to use a mask instead of a
condition in loops implementing things like /a+/, which can potentially
iterate many times.

This arises under /i matching where we accept either an 'A' or an 'a'
for example.  In most cases, the case folds differ in only a single bit,
so we can mask that bit out during comparisons, yielding two possible
characters, precisely the ones we are interested in.  This means we
don't have to test for the character being 'A', then test for it being
'a'.  We can accomplish this in one conditional.

6 years agoperlre: Note a way to continue long regexes across lines
Karl Williamson [Wed, 27 Dec 2017 01:00:57 +0000 (18:00 -0700)]
perlre: Note a way to continue long regexes across lines

This documents a usage to include \n chars within (?#\n) to easily
break long patterns into smaller chunks that fit on a line.  I was not
familiar with this technique until I saw it used, in some of our core
code, so am documenting it for others.

6 years agoSkip failing exit(0) tests on VMS.
Craig A. Berry [Fri, 29 Dec 2017 22:30:23 +0000 (16:30 -0600)]
Skip failing exit(0) tests on VMS.

It turns out VMS does not have the [perl #2754] bug.  When a call
to Perl_my_exit(0) is made from one of the blocks processed during
perl_parse, STATUS_ALL_SUCCESS sets PL_statusvalue_vms to 1. This
is the value that becomes the return value of perl_parse via
STATUS_EXIT.  That return value, when non-zero, means perl_run is
skipped.  Which seems to be the desired behavior, i.e., exit(0)
from BEGIN, CHECK, and UNITCHECK does actually exit.

The fix on Unix has been rolled back in 857320cbf85e762add18885ae8
temporarily because Module::Install was depending on the bug.  It
doesn't seem worth trying to write a compatible bug for VMS, so
just skip the tests that are enforcing the buggy behavior.

6 years agoperldelta for smartmatch reversion
Zefram [Fri, 29 Dec 2017 13:51:29 +0000 (13:51 +0000)]
perldelta for smartmatch reversion

6 years agorevert smartmatch to 5.27.6 behaviour
Zefram [Fri, 29 Dec 2017 12:39:31 +0000 (12:39 +0000)]
revert smartmatch to 5.27.6 behaviour

The pumpking has determined that the CPAN breakage caused by changing
smartmatch [perl #132594] is too great for the smartmatch changes to
stay in for 5.28.

This reverts most of the merge in commit
da4e040f42421764ef069371d77c008e6b801f45.  All core behaviour and
documentation is reverted.  The removal of use of smartmatch from a couple
of tests (that aren't testing smartmatch) remains.  Customisation of
a couple of CPAN modules to make them portable across smartmatch types
remains.  A small bugfix in scope.c also remains.

6 years agomake experimental.pm test agnostic about switch
Zefram [Fri, 29 Dec 2017 12:19:49 +0000 (12:19 +0000)]
make experimental.pm test agnostic about switch

Anticipating imminent reversion of smartmatch behaviour, make
experimental.pm able to test against either version of the switch feature,
detecting empirically which version the running perl supports.

6 years agomake autodie more agnostic about smartmatch
Zefram [Fri, 29 Dec 2017 12:16:52 +0000 (12:16 +0000)]
make autodie more agnostic about smartmatch

Instead of saying that smartmatch lhs overloading no longer works, say
that it is likely to not work in the future.  This makes it accurate for
the upcoming reversion of smartmatch behaviour, while remaining usefully
open to this kind of smartmatch change in the future.

6 years agominor grammar and punctuation fixes
Karen Etheridge [Fri, 29 Dec 2017 03:29:15 +0000 (19:29 -0800)]
minor grammar and punctuation fixes

6 years agoRemove unused AUTOGEN_FILES Makefile variable
Dagfinn Ilmari Mannsåker [Thu, 28 Dec 2017 18:12:56 +0000 (18:12 +0000)]
Remove unused AUTOGEN_FILES Makefile variable

Commit 36bb303b6ac55df9c2780b48d374c505374dc378 moved the chmod +w that
the variable was used for into regen.pl, but failed to remove the
variable.  The regenerated files are already listed in the comment
above (including which script generates them), so the variable doesn't
even have any informational value, it's just a maintenance burden.

6 years agoSimplify Unicode::UCD::openunicode() and callers
Dagfinn Ilmari Mannsåker [Thu, 28 Dec 2017 17:24:43 +0000 (17:24 +0000)]
Simplify Unicode::UCD::openunicode() and callers

Get rid of the file-global filehandles and the unused filename return
value, instead return the filehandle and assign it to a lexical
variable.  Also don't bother checking the return value; it croaks on
failure anyway.

In passing, eliminate erroneous assignment of {} to %CASESPEC for
Unicode < 2.1.8.

6 years agoFix typo in POD for new Unicode::UCD::num() variant
Dagfinn Ilmari Mannsåker [Thu, 28 Dec 2017 15:14:48 +0000 (15:14 +0000)]
Fix typo in POD for new Unicode::UCD::num() variant

6 years agoFix Pod::Html for EBCDIC
Karl Williamson [Thu, 28 Dec 2017 04:39:50 +0000 (21:39 -0700)]
Fix Pod::Html for EBCDIC

Commit 38e30ca7507a601c2d84596bc51d88c0f3c516b4 introduced a
non-portable regular expression pattern which breaks the module on
EBCDIC.

Any range whose endpoints aren't both digits, both uppercase or both
lowercase will not work on EBCDIC.  /[^ -~]/ can more legibly and
portably be written as /[[:^print:]]/a, which is what this commit does.

6 years agot/op/exec.t: Use diag for errors, so not swallowed
Karl Williamson [Thu, 28 Dec 2017 04:32:33 +0000 (21:32 -0700)]
t/op/exec.t: Use diag for errors, so not swallowed

This test was just doing a printf to STDOUT.

6 years agoFix t/comp/parser_run.t for EBCDIC
Karl Williamson [Thu, 28 Dec 2017 01:55:13 +0000 (18:55 -0700)]
Fix t/comp/parser_run.t for EBCDIC

Commit 36000cd1c47863d8412b285701db7232dd450239 added a test which isn't
portable to EBCDIC, using \xD5.  The is "N" on EBCDIC platforms, whereas
a non-alphabetic character was intended.

Change to use \xB6 which means paragraph sign on both character sets.

6 years agolib/utf8.pm: Further clarification of UTF-8 flavor
Karl Williamson [Thu, 28 Dec 2017 01:34:35 +0000 (18:34 -0700)]
lib/utf8.pm: Further clarification of UTF-8 flavor

Commit 50a85cfe6c852deb0c2f738cb82006623052dc8e clarified that this
module uses Perl's extended UTF-8, but missed the mention fixed in this
commit.

6 years agoPOD fix for perlop
Scott Lanning [Thu, 23 Nov 2017 18:33:13 +0000 (19:33 +0100)]
POD fix for perlop

Commit 33be4c6111bea619c1662 added a line in pod/perlop.pod
for a new Non-capture mode modifier to qr//.
The 2nd paragraph below that line said:

  The last four modifiers listed above, added in Perl 5.14,
  control the character set rules, but C</a> is the only one
  you are likely to want to specify explicitly; the other three
  are selected automatically by various pragmas.

Since the "n" line was added, that paragraph no longer makes sense.  I
changed it to refer to the modifiers explicitly instead of the last four
lines. (An alternative would be to move the "n" line above the other
four.)

6 years agoUnicode::UCD: Add optional paramter to num()
Karl Williamson [Wed, 27 Dec 2017 20:50:43 +0000 (13:50 -0700)]
Unicode::UCD: Add optional paramter to num()

As discussed in http://nntp.perl.org/group/perl.perl5.porters/244444,
this sets the optional scalar ref paramater to the length of the valid
initial portion of the first parameter passed to num().  This is useful
in teasing apart why the input is invalid.

6 years agopostpone perl_parse() exit(0) bugfix
Zefram [Wed, 27 Dec 2017 21:13:59 +0000 (21:13 +0000)]
postpone perl_parse() exit(0) bugfix

Commit 0301e899536a22752f40481d8a1d141b7a7dda82 fixed a long-standing
bug regarding exit(0) during perl_parse().  This turned out to cause
enough trouble to Module::Install, which accidentally relies on the
bug, that the pumpking wants more time to roll out the fix to affected
CPAN distros.  So make perl_parse() once again return 0 for an exit(0).
Reintroduces [perl #2754]; addresses [perl #132577].