This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perl5.git
6 years agoRevert "perl.h: Use STMT_START { ... } STMT_END"
Lukas Mai [Thu, 9 Nov 2017 13:34:00 +0000 (14:34 +0100)]
Revert "perl.h: Use STMT_START { ... } STMT_END"

This reverts commit 11b2cef65dac01e8723c9a6f6e640665cb752a2c.

DECLARE_STORE_LC_NUMERIC_SET_TO_NEEDED seems to be unused, but the
previous commit made it a syntax error (unmatched '{').

It also doesn't make sense to wrap what is supposed to be a declaration
in a { } block.

6 years agoFix missing close brace before STMT_END
Dagfinn Ilmari Mannsåker [Thu, 9 Nov 2017 13:22:40 +0000 (13:22 +0000)]
Fix missing close brace before STMT_END

The macro isn't actually used anywhere (in core or on CPAN)

6 years agolocale.c: Avoid potential read beyond buffer end
Karl Williamson [Mon, 11 Sep 2017 23:24:00 +0000 (17:24 -0600)]
locale.c: Avoid potential read beyond buffer end

I noticed this flaw by code reading; I doubt that it's exploitable.
foldEQ assumes that both operands are at least as long as its length
parameter.  In this case, it's possible that the codeset returned by
nl_langinfo is shorter than 5, in which case, it would try to access the
extra characters in the heap.  Real codesets tend to be longer than
this, so an attacker would likely have to install a locale with a
made-up codeset whose name is shorter.

Even the C locale is longer: "ANSI_X3.4-1968"

6 years agolocale.c: Clarify some debug statements
Karl Williamson [Wed, 13 Sep 2017 22:03:53 +0000 (16:03 -0600)]
locale.c: Clarify some debug statements

6 years agolocale.c: Slight refactor
Karl Williamson [Tue, 12 Sep 2017 00:56:49 +0000 (18:56 -0600)]
locale.c: Slight refactor

This makes savepv() part of the expressions instead of a separate
statement.

6 years agolocale.c: Use REPLACEMENT_CHARACTER as a test
Karl Williamson [Mon, 11 Sep 2017 23:41:57 +0000 (17:41 -0600)]
locale.c: Use REPLACEMENT_CHARACTER as a test

This is trying to determine if the locale is UTF-8.  The easiest way to
tell is if the codeset returned by nl_langinfo says UTF-8, but if that
fails or nl_langinfo() is not present on the system, a fallback method
is to use the libc routines to convert a known byte string to code point
and see if that matches the expected Unicode code point.  Prior to this
patch, the byte string representing HYPHEN was used.  That's probably
good enough, but we can do better with no extra work.  This commit
changes to use the REPLACEMENT CHARACTER instead.  That is a Unicode
concept.  The chances of a non-UTF-8 locale taking the UTF-8 byte string
for the REPLACEMENT and evaluating to REPLACEMENT are vanishingly small.

6 years agolocale.c: Avoid extra call to mbtowc()
Karl Williamson [Mon, 11 Sep 2017 23:32:42 +0000 (17:32 -0600)]
locale.c: Avoid extra call to mbtowc()

This is done only when debugging, but in some locales that have shift
states, the extra call could blow up.  Instead save the result of the
mbtowc() call we care about.

6 years agolocale.c: Add macro
Karl Williamson [Mon, 11 Sep 2017 23:19:05 +0000 (17:19 -0600)]
locale.c: Add macro

This adds STRLENs() where the argument must be a literal string
constant.

This may deserve wider applicability, but in case it doesn't, I'm making
it local to just this file.

6 years agolocale.c: Rmv extraneous detail from comment
Karl Williamson [Mon, 11 Sep 2017 22:10:42 +0000 (16:10 -0600)]
locale.c: Rmv extraneous detail from comment

This comment contains a list of code points that are unusual, but it
also included ones that are standard, which made me keep looking to see
why they were unusual, each time realizing in the end that they were
not.

6 years agoembed.fnc: Change fcn from A to X
Karl Williamson [Mon, 28 Aug 2017 23:51:06 +0000 (17:51 -0600)]
embed.fnc: Change fcn from A to X

This function is marked as accessible anywhere, but experimental, and
so is changeable at any time without notice, and its name begins with an
underscore to indicate its private nature.  I didn't know at the time I
wrote it that we have an existing mechanism to deal with functions whose
only use should be a public macro.  This changes to use that mechanism.

6 years agoChange name of internal function
Karl Williamson [Mon, 28 Aug 2017 23:43:29 +0000 (17:43 -0600)]
Change name of internal function

Following on the previous commit, this changes the name of the function
that changes the variable to be in sync with it.

6 years agoChange name of locale per-interpreter variable
Karl Williamson [Mon, 28 Aug 2017 23:21:09 +0000 (17:21 -0600)]
Change name of locale per-interpreter variable

The real purpose of this internal variable is to give the name of the
locale that is the underlying one for the C program.  Various macros
already indicate that.  This furthers the process.

6 years agoPOSIX.xs is PERL_EXT
Karl Williamson [Thu, 9 Nov 2017 03:31:50 +0000 (20:31 -0700)]
POSIX.xs is PERL_EXT

Specifying so automatically gets the reentrant versions of various libc
functions in threaded perls, lowering race condition odds.

6 years agoBump version of B/t/OptreeCheck to 0.16
Karl Williamson [Thu, 9 Nov 2017 03:18:10 +0000 (20:18 -0700)]
Bump version of B/t/OptreeCheck to 0.16

6 years agoBump version of B/O.pm to 1.03
Karl Williamson [Thu, 9 Nov 2017 03:16:34 +0000 (20:16 -0700)]
Bump version of B/O.pm to 1.03

6 years agoperl.h: Use STMT_START { ... } STMT_END
Karl Williamson [Mon, 28 Aug 2017 23:16:27 +0000 (17:16 -0600)]
perl.h: Use STMT_START { ... } STMT_END

This should be used in macros that have statements.

6 years agoperl.h: White-space only
Karl Williamson [Mon, 28 Aug 2017 23:11:29 +0000 (17:11 -0600)]
perl.h: White-space only

Indent some nested #defines, remove an extra empty line

6 years agotoke.c: Add comment
Karl Williamson [Thu, 10 Aug 2017 22:03:16 +0000 (16:03 -0600)]
toke.c: Add comment

6 years agoDest buffer needs to be bigger for utf16_to_utf8()
Karl Williamson [Thu, 10 Aug 2017 21:52:35 +0000 (15:52 -0600)]
Dest buffer needs to be bigger for utf16_to_utf8()

These undocumented functions require the destination buffer to have the
worst case size.  However that size (previously listed as 3/2 * input)
is wrong for EBCDIC.  Correct the comments, and the single use of these
in core.

These functions do not have a way to avoid overflowing, which strikes me
as wrong.

6 years ago_byte_dump_string(): Don't output leading space
Karl Williamson [Thu, 10 Aug 2017 20:33:40 +0000 (14:33 -0600)]
_byte_dump_string(): Don't output leading space

This changes this function to not put an initial space character in the
returned string.

6 years agoPOSIX.xs: Move constant tests out of loop
Karl Williamson [Fri, 11 Aug 2017 03:39:06 +0000 (21:39 -0600)]
POSIX.xs: Move constant tests out of loop

Whether or not a locale is in UTF-8 doesn't change in this loop;
calculate it once, prior to the loop

6 years agonumeric.c: Refactor #if #else in Perl_my_aotf
Karl Williamson [Tue, 1 Aug 2017 18:41:12 +0000 (12:41 -0600)]
numeric.c: Refactor #if #else in Perl_my_aotf

This simplifies things, eliminating nested #if's

6 years agonumeric.c: Rename some variables
Karl Williamson [Tue, 1 Aug 2017 18:38:09 +0000 (12:38 -0600)]
numeric.c: Rename some variables

The new names are clearer.

6 years agoPerl_locale(): Refactor for clarity
Karl Williamson [Mon, 24 Jul 2017 04:08:50 +0000 (22:08 -0600)]
Perl_locale(): Refactor for clarity

This code is full of 'if's interrupted by #ifdefs, which makes it hard
to read.  Changing it to a switch() makes it much easier to understand.

6 years agolocale.c:sync_locale(): Add debugging info
Karl Williamson [Mon, 24 Jul 2017 03:53:28 +0000 (21:53 -0600)]
locale.c:sync_locale(): Add debugging info

6 years agolocale.c:sync_locale(): Rmv useless call
Karl Williamson [Mon, 24 Jul 2017 03:39:46 +0000 (21:39 -0600)]
locale.c:sync_locale(): Rmv useless call

This was changing to use the locale's radix, but this is unnecessary for
the later things in this function, and those change things to use dot,
so this call is useless.

6 years agolocale.c: Use new nl_langinfo equivalent
Karl Williamson [Thu, 14 Sep 2017 19:32:58 +0000 (13:32 -0600)]
locale.c: Use new nl_langinfo equivalent

This converts the final plain nl_langinfo() function call in locale.c to
use the new equivalent that is more thread safe, and you don't have to
free the returned memory.  There was an unlikely leak before this, if
the return was somehow "".

6 years agolocale.c: Rmv erroneous complement operator
Karl Williamson [Thu, 14 Sep 2017 03:17:28 +0000 (21:17 -0600)]
locale.c: Rmv erroneous complement operator

The extra '!' that snuck in there caused this code to not work properly.
Fortunately, it doesn't get used except as a last resort, and that
apparently hasn't happened so as to have gotten reported from the field.
A test can't be added because it would only occur on a system that had
bad locales.

6 years agolocale.c: Refactor locale macros
Karl Williamson [Thu, 14 Sep 2017 18:44:40 +0000 (12:44 -0600)]
locale.c: Refactor locale macros

This standardizes things to make things easier to understand and prepare
for future commits

6 years agolocale.c: Convert setlocale() calls to macros
Karl Williamson [Fri, 21 Jul 2017 01:16:55 +0000 (19:16 -0600)]
locale.c: Convert setlocale() calls to macros

This will be useful in future commits

6 years agolocale.c: Change static fcn name
Karl Williamson [Wed, 19 Jul 2017 17:34:08 +0000 (11:34 -0600)]
locale.c: Change static fcn name

The new name more closely reflects what it does

6 years agolocale.c: Refactor static fcn to save work
Karl Williamson [Thu, 20 Jul 2017 22:20:01 +0000 (16:20 -0600)]
locale.c: Refactor static fcn to save work

This adds a parameter to the function that sets the radix character for
floating point numbers.  We know that the radix by default is a dot, so
no need to calculate it in that case.

This code was previously using localeconv() to find the locale's decimal
point.  The just added my_nl_langinfo() fcn does the same with an easier
API, and is more thread safe, and automatically switches to use
localeconv() when n nl_langinfo() isn't available, so revise the
conditional compilation directives that previously were necessary, and
collapse directives that were unnecessarily nested.

And adjust indentation

6 years agolocale.c: Create extended internal Perl_langinfo()
Karl Williamson [Tue, 12 Sep 2017 01:12:56 +0000 (19:12 -0600)]
locale.c: Create extended internal Perl_langinfo()

This extended version allows it to be called so that it uses the current
locale for the LC_NUMERIC, instead of toggling to the underlying one.
(This can be useful when in the middle of things.)

This ability won't be used until the next commit

6 years agolocale.c: Rmv redundant fcn call
Karl Williamson [Thu, 20 Jul 2017 22:24:42 +0000 (16:24 -0600)]
locale.c: Rmv redundant fcn call

This function is called as part of the call made in the line before.  No
need to do it twice.

6 years agolocale.c: White-space, comment, rearrange some #else
Karl Williamson [Sun, 16 Jul 2017 00:19:48 +0000 (18:19 -0600)]
locale.c: White-space, comment, rearrange some #else

This file is full of conditional compilation, due to the fact that
locale support has been highly variable in the OSes Perl has operated
on.  This commit properly indents nested compiler directives, and makes
sure there is a blank line between the directives and real code.  I find
that much easier to read.  It also re-orders some

    #ifdef some_feature
        Many lines of code handling feature
    #else
        1 to 3 lines of trivial code to avoid compilation warnings
    #endif

to

    #ifndef some_feature
        1 to 3 lines of trivial code to avoid compilation warnings
    #else
        Many lines of code handling feature
    #endif

Otherwise the trivial code may be hundreds of lines from the original
'#if', which makes it hard to grok.

This commit also clarifies and fixes typos in comments, and removes some
obsolete comments.

6 years agoMerge branch 'BO' into blead
Todd Rinaldo [Wed, 8 Nov 2017 22:39:12 +0000 (16:39 -0600)]
Merge branch 'BO' into blead

Make it simpler to divine if modules are there because of loading B/O or
because the actual program used them.

NPD

6 years agoext/B/t/strict.t: Assure B.pm and O.pm pass strict and warnings checks.
Todd Rinaldo [Wed, 13 Sep 2017 19:35:39 +0000 (14:35 -0500)]
ext/B/t/strict.t: Assure B.pm and O.pm pass strict and warnings checks.

We need to test these in unit tests since they do not load these modules to
prevent pollution of the stash in compilers.

6 years agoFix warnings (used once) for O.pm
Todd Rinaldo [Wed, 13 Sep 2017 19:35:35 +0000 (14:35 -0500)]
Fix warnings (used once) for O.pm

6 years agoFix warnings (used once) for B.pm
Todd Rinaldo [Wed, 13 Sep 2017 19:35:30 +0000 (14:35 -0500)]
Fix warnings (used once) for B.pm

6 years agoRemove unnecessary module loads from B and O
Todd Rinaldo [Wed, 13 Sep 2017 19:35:21 +0000 (14:35 -0500)]
Remove unnecessary module loads from B and O

This commit removes multiple unnecessary modules so that
perl -MO= can hand back to compile as cleanly as possible.

This change caused significant jitter in tests for B::Concise. While updating
the test to the new reality, OptreeCheck.pm was corrected to stop stripping
regexes off $got when it started failing so it would be easier to see where
the failure happened.

6 years agoSimplify travis.yml config for Continuous Integration
Nicolas R [Wed, 8 Nov 2017 22:30:37 +0000 (15:30 -0700)]
Simplify travis.yml config for Continuous Integration

The goal is to have a quick smoke on travis smokers
to plug in short future CI for any new commits/PR.

NPD

6 years agorestore error message for unterminated strings
Lukas Mai [Wed, 8 Nov 2017 22:05:35 +0000 (23:05 +0100)]
restore error message for unterminated strings

The previous strchr/memchr changes inadvertently broke the error message
for perl -e '"'. Instead of

    Can't find string terminator '"' anywhere before EOF

it became

    Can't find string terminator """ anywhere before EOF

6 years agodisable t/porting/authors.t for distro packaging
Nicolas R [Mon, 6 Nov 2017 23:44:17 +0000 (16:44 -0700)]
disable t/porting/authors.t for distro packaging

NPD

6 years agodisable t/porting/podcheck.t for distro packaging
Nicolas R [Mon, 6 Nov 2017 23:42:08 +0000 (16:42 -0700)]
disable t/porting/podcheck.t for distro packaging

NPD

6 years agoAllow custom PL_strtab hash in perl_construct.
Nicolas R [Wed, 8 Nov 2017 15:56:20 +0000 (08:56 -0700)]
Allow custom PL_strtab hash in perl_construct.

Such a patch allow PL_strtab optimizations at compile time
to statically malloc PL_strtab to an optimized size at startup.

Custom entries can then be added (after PL_hash_seed initialization)
without risking the hash to be reset by perl_construct.

6 years agoPERL_STRLEN_ROUNDUP: parenthesize macro parameter
Lukas Mai [Wed, 8 Nov 2017 10:45:05 +0000 (11:45 +0100)]
PERL_STRLEN_ROUNDUP: parenthesize macro parameter

Also:
- factor out common expression
- remove redundant double parens
- add spaces to expression

6 years agotoke.c: Fix wrong use of memrchr
Karl Williamson [Tue, 7 Nov 2017 22:56:32 +0000 (15:56 -0700)]
toke.c: Fix wrong use of memrchr

This was a replacement of strchr(), so should not have used the
find-right-most memrchr.

This was spotted by Christian Hansen.  I don't know what the
implications are, but thought I should get a fix in immediately.

6 years agoBlead breaks DBD::SQLite
Karl Williamson [Tue, 7 Nov 2017 19:52:09 +0000 (12:52 -0700)]
Blead breaks DBD::SQLite

This partially reverts 0f12654f40.

The particular spot being reverted is in gv.c, and the change did not
take into account all the nuances involved, so simply revert it.  I
believe what is happening is that a negative number is being generated
and treated as a very large number.  Instead the code should retain the
original test that it was ok to do the subtraction, before actually
doing it.

6 years agoTwo fix-ups following b59bf0b288.
Craig A. Berry [Tue, 7 Nov 2017 03:13:24 +0000 (21:13 -0600)]
Two fix-ups following b59bf0b288.

In one case, memEQs was missing a length parameter, and in the
other, two opening braces had been removed but only one closing
brace.

6 years agotoke.c: use my_memrchr helper for portability [round 2]
Nicolas R [Mon, 6 Nov 2017 23:10:21 +0000 (16:10 -0700)]
toke.c: use my_memrchr helper for portability [round 2]

compilation broken on darwin using clang

6 years agoUse my_memrchr helper for portability
Nicolas R [Mon, 6 Nov 2017 23:03:03 +0000 (16:03 -0700)]
Use my_memrchr helper for portability

Recent commit '8725053bce' breaks darwin compilation.

We should use my_memrchr helper to avoid
portability issues, instead of calling
directly memrchr.

6 years agoMerge branch 'convert strchr to memchr' into blead
Karl Williamson [Mon, 6 Nov 2017 21:32:14 +0000 (14:32 -0700)]
Merge branch 'convert strchr to memchr' into blead

Using C string functions on Perl strings doesn't work properly if they
contain embedded NULs.  This can happen with Perl program text, for
example, and even if the NUL is illegal, the generated diagnostics are
likely to be misleading as the parsing would have terminated
prematurely.

I have done an audit on core for cases where C string functions are used
in contexts where a Perl string is being processed.  This came down to
uses of strchr() and strrchr().  This branch changes many of them to
memchr() and memrchr() respectively.  Not all uses of these functions
need change, as there are places where C strings are what is being
processed, such as dealing with OS strings that are NUL terminated.
File paths and environ are two examples.

Also, memchr and memrchr tend to be faster than their str equivalents,
as they only need to look for one termination condition, and there may
be hardware assistance on some platforms.  Further, memrchr knows
exactly where to start looking, instead of having to find the NUL ending
the string (strrchr is likely to be implemented as iterating over the
string using strchr from the left, over and over until it fails).

I may have converted some str functions to mem ones unnecessarily, as I
didn't check in full detail if some were operating only on C strings, but
given that the mem ones are faster, this is OK

6 years agotoke.c: Convert some strchr to memchr
Karl Williamson [Sat, 25 Mar 2017 21:06:58 +0000 (15:06 -0600)]
toke.c: Convert some strchr to memchr

This allows things to work properly in the face of embedded NULs.
See the branch merge message for more information.

6 years agotoke.c use memBEGINs with prev commit
Karl Williamson [Thu, 2 Nov 2017 20:01:54 +0000 (14:01 -0600)]
toke.c use memBEGINs with prev commit

6 years agotoke.c: Add limit parameter to 3 static functions
Karl Williamson [Mon, 6 Nov 2017 21:12:41 +0000 (14:12 -0700)]
toke.c: Add limit parameter to 3 static functions

This will make it possible to fix to handle embedded NULs in the next
commits.

6 years agoregcomp.c: Convert some strchr to memchr
Karl Williamson [Sat, 25 Mar 2017 21:00:22 +0000 (15:00 -0600)]
regcomp.c: Convert some strchr to memchr

This allows things to work properly in the face of embedded NULs.
See the branch merge message for more information.

6 years agoperl.c: Use memchr instead of strchr
Karl Williamson [Sat, 25 Mar 2017 20:55:08 +0000 (14:55 -0600)]
perl.c: Use memchr instead of strchr

This allows things to work properly in the face of embedded NULs.
See the branch merge message for more information.

6 years agoop.c: Use memchr,memrchr instead of strchr,strrchr
Karl Williamson [Sat, 25 Mar 2017 20:54:13 +0000 (14:54 -0600)]
op.c: Use memchr,memrchr instead of strchr,strrchr

This allows things to work properly in the face of embedded NULs.
See the branch merge message for more information.

6 years agomg.c: Use memchr instead of strchr
Karl Williamson [Sat, 25 Mar 2017 20:53:07 +0000 (14:53 -0600)]
mg.c: Use memchr instead of strchr

This allows things to work properly in the face of embedded NULs.
See the branch merge message for more information.

6 years agodoio.c: Change strchr to memchr
Karl Williamson [Sat, 25 Mar 2017 20:51:19 +0000 (14:51 -0600)]
doio.c: Change strchr to memchr

This allows things to work properly in the face of embedded NULs.
See the branch merge message for more information.

6 years agopp_sys.c; Use memchr instead of strchr
Karl Williamson [Sat, 25 Mar 2017 20:50:48 +0000 (14:50 -0600)]
pp_sys.c; Use memchr instead of strchr

This allows things to work properly in the face of embedded NULs.
See the branch merge message for more information.

6 years agoutf8.c: Use memchr instead of strchr
Karl Williamson [Sat, 25 Mar 2017 20:46:50 +0000 (14:46 -0600)]
utf8.c: Use memchr instead of strchr

This allows things to work properly in the face of embedded NULs.
See the branch merge message for more information.

6 years agodquote.c: Use memchr() instead of strchr()
Karl Williamson [Sat, 25 Mar 2017 17:39:05 +0000 (11:39 -0600)]
dquote.c: Use memchr() instead of strchr()

This allows \x and \o to work properly in the face of embedded NULs.
A limit parameter is added to each function, and that is passed to
memchr (which replaces strchr).  See the branch merge message for more
information.

6 years agolocale.c: Tighten what is considered a LC variable
Karl Williamson [Sat, 25 Mar 2017 01:01:39 +0000 (19:01 -0600)]
locale.c: Tighten what is considered a LC variable

Things like LC_CTYPE are locale variables, but not LC_ctype nor
LC__CTYPE.  Prior to this commit all were treated as locale variables.
Many platforms have more locale variables than Perl knows about, e.g.,
LC_PAPER, and the code tries to catch all possibilities.

6 years agolocale.c: White space, extra braces only
Karl Williamson [Thu, 9 Mar 2017 18:53:48 +0000 (11:53 -0700)]
locale.c: White space, extra braces only

Align vertically, and indent blocks to standard.  It adds braces for
clarity.

6 years agoMerge branch for new string comparison macros into blead
Karl Williamson [Mon, 6 Nov 2017 19:50:52 +0000 (12:50 -0700)]
Merge branch for new string comparison macros into blead

See thread beginning with
     http://nntp.perl.org/group/perl.perl5.porters/244335

This branch creates various new macros that are easier to read and use
than the underlying code, and uses them in blead

6 years agohandy.h: Add comments
Karl Williamson [Fri, 3 Nov 2017 04:16:11 +0000 (22:16 -0600)]
handy.h: Add comments

This adds a description of the naming conventions to be used for any new
string comparison macros.

6 years agoMake new macros private
Karl Williamson [Fri, 3 Nov 2017 03:12:08 +0000 (21:12 -0600)]
Make new macros private

Until we decide these weren't a bad idea

6 years agoext/attributes/attributes.xs is PERL_EXT
Karl Williamson [Fri, 3 Nov 2017 14:16:41 +0000 (08:16 -0600)]
ext/attributes/attributes.xs is PERL_EXT

6 years agohandy.h: Make uniform the defns of strFOO, memFOO
Karl Williamson [Fri, 24 Mar 2017 01:38:04 +0000 (19:38 -0600)]
handy.h: Make uniform the defns of strFOO, memFOO

For consistency

6 years agoRemove _memEQs, _memNEs
Karl Williamson [Fri, 3 Nov 2017 03:02:25 +0000 (21:02 -0600)]
Remove _memEQs, _memNEs

All uses of these private macros have been replaced by other calls.

6 years agoAdd memENDPs and use it in core
Karl Williamson [Tue, 25 Apr 2017 02:39:02 +0000 (20:39 -0600)]
Add memENDPs and use it in core

This corresponds to memBEGINPs

6 years agoAdd memBEGINPs() to core and use it
Karl Williamson [Tue, 25 Apr 2017 02:27:24 +0000 (20:27 -0600)]
Add memBEGINPs() to core and use it

This macro is like memBEGINs(), but the 'P' signifies we want a proper
substring, meaning that the 2nd string parameter must not be the entire
first parameter.

6 years agoUse memENDs() in core
Karl Williamson [Tue, 25 Apr 2017 02:11:40 +0000 (20:11 -0600)]
Use memENDs() in core

6 years agoUse memBEGINs() in core
Karl Williamson [Tue, 25 Apr 2017 02:02:57 +0000 (20:02 -0600)]
Use memBEGINs() in core

6 years agoChange some strBEGINs() to memBEGINs()
Karl Williamson [Thu, 2 Nov 2017 20:03:40 +0000 (14:03 -0600)]
Change some strBEGINs() to memBEGINs()

The latter is generally faster when the length is already known.

This commit also changes a few hard-coded numbers to use sizeof().

6 years agoAdd memBEGINs(), memENDs() and use them in APItest
Karl Williamson [Tue, 31 Oct 2017 18:11:12 +0000 (12:11 -0600)]
Add memBEGINs(), memENDs() and use them in APItest

memBEGINs() is like strBEGINs(), but can be used for buffers without
trailing NULs.  It can also be used when there is a trailing NUL, and
the length is known, as it should be somewhat faster, only having to
check for one ending condition.

Same for memENDs vs strENDs

6 years agoChange some strncmp(), etc. to strBEGINs()
Karl Williamson [Thu, 9 Mar 2017 17:55:38 +0000 (10:55 -0700)]
Change some strncmp(), etc. to strBEGINs()

The latter is much clearer as to what's going on, and the programmer and
program reader don't have to count characters.

6 years agoUse memEQs, memNEs in core files
Karl Williamson [Tue, 31 Oct 2017 14:30:38 +0000 (08:30 -0600)]
Use memEQs, memNEs in core files

Where the length is known, we can use these functions which relieve
the programmer and the program reader from having to count characters.
The memFOO functions should also be slightly faster than the strFOO
equivalents.

In some instances in this commit, hard coded numbers are used.  These
come from the 'case' statement values that apply to them.

6 years agoRename strEQs to strBEGINs; remove strNEs
Karl Williamson [Thu, 9 Mar 2017 03:31:25 +0000 (20:31 -0700)]
Rename strEQs to strBEGINs; remove strNEs

The original names are confusing.

See thread beginning with
http://nntp.perl.org/group/perl.perl5.porters/244335

The two macros are mapped into just that one, complementing the result
for the few cases where strNEs was used.

6 years agog++ 4.0 supports __attribute__((unused))
Lukas Mai [Mon, 6 Nov 2017 18:57:08 +0000 (19:57 +0100)]
g++ 4.0 supports __attribute__((unused))

6 years agoFix deparsing of transliterations with unprintable characters.
John Lightsey [Tue, 31 Oct 2017 23:12:26 +0000 (18:12 -0500)]
Fix deparsing of transliterations with unprintable characters.

RT #132405

Signed-off-by: Nicolas R <atoomic@cpan.org>
6 years agosupport -nre in t/harness, exclude files by regex
Yves Orton [Mon, 6 Nov 2017 13:43:32 +0000 (14:43 +0100)]
support -nre in t/harness, exclude files by regex

6 years agoadd assertions about format lexing
Zefram [Sun, 5 Nov 2017 04:45:04 +0000 (04:45 +0000)]
add assertions about format lexing

[perl #132158] describes a situation in which a weird kind of unterminated
format caused the parser to crash.  Add some assertions that catch the
messed up parser state before it actually crashes.

6 years agodeparse implicit ~~ as explicit with -x2
Zefram [Sun, 5 Nov 2017 00:09:32 +0000 (00:09 +0000)]
deparse implicit ~~ as explicit with -x2

Fixes [perl #91362].

6 years agoRevert "Speed up Carp.pm when backtrace arguments are references"
Zefram [Sat, 4 Nov 2017 22:04:20 +0000 (22:04 +0000)]
Revert "Speed up Carp.pm when backtrace arguments are references"

This reverts commit 7a831b721c469aeccfe1110a2d177dd115d5998d.  It was
buggy and mostly pointless, and following criticism on p5p it should
never have been committed.

6 years agoinitialisation of simple aggregate state variables
Zefram [Sat, 4 Nov 2017 21:43:59 +0000 (21:43 +0000)]
initialisation of simple aggregate state variables

We now recognise the basic cases of aggregate state variables, to
permit initialisations of the form "state @a =" or "state @a :shared =".
Initialisation of state variable lists remains forbidden, because the
op flags don't let us distinguish "state(...)" from "(state(...))" in
most cases.

6 years agoAdd comment to explain why we want to probe for statfs() et al
Aaron Crane [Wed, 1 Nov 2017 17:52:24 +0000 (17:52 +0000)]
Add comment to explain why we want to probe for statfs() et al

6 years agopp_multiconcat: don't stringify LHS overload arg
David Mitchell [Sat, 4 Nov 2017 10:30:00 +0000 (10:30 +0000)]
pp_multiconcat: don't stringify LHS overload arg

RT #132385

In something like

    $a1 . $a2

where $a2 is overloaded, the concat overload method was being called
like

    concat($a2, "$a1", 1);

(The 1 indicated that the args are reversed).

This commit changes it so that it's called as

    concat($a2, $a1, 1);

i.e. that the original arg is passed in rather than a stringified copy
of it. This is important if for example $a1 is a ref.

6 years agoperldelta for b3937e202aaf1 (Carp & ISA constant)
Father Chrysostomos [Sat, 4 Nov 2017 04:36:20 +0000 (21:36 -0700)]
perldelta for b3937e202aaf1 (Carp & ISA constant)

6 years agoAvoid unique REGCOMP in dynaloader
J. Nick Koston [Wed, 6 Sep 2017 17:18:51 +0000 (12:18 -0500)]
Avoid unique REGCOMP in dynaloader

Dynaloader has 4 unique regex's that cannot be de-duplicated
by perlcc.  Switch them to index/substr

References: CPANEL-15683

Signed-off-by: Nicolas R <atoomic@cpan.org>
6 years agoSpeed up Carp.pm when backtrace arguments are references
Nicolas R [Tue, 22 Aug 2017 18:26:15 +0000 (13:26 -0500)]
Speed up Carp.pm when backtrace arguments are references

Avoid downgrading the string when not required.

Author: J. Nick Koston <nick@cpanel.net>
References: CPANEL-15140

6 years agoAvoid a segfault when untying an object
Nicolas R [Mon, 31 Oct 2016 17:53:17 +0000 (11:53 -0600)]
Avoid a segfault when untying an object

Check if the tied object has a stash set
before calling UNTIE method.

6 years ago(perl #131895) fail stat on names with \0 embedded
Tony Cook [Thu, 2 Nov 2017 20:18:56 +0000 (20:18 +0000)]
(perl #131895) fail stat on names with \0 embedded

Also lstat() and the file test ops.

6 years agoyada-yada is a term, not an operator
Lukas Mai [Thu, 2 Nov 2017 19:48:38 +0000 (19:48 +0000)]
yada-yada is a term, not an operator

6 years agodocument qw's whitespace rules
Zefram [Thu, 2 Nov 2017 19:29:33 +0000 (19:29 +0000)]
document qw's whitespace rules

qw only splits on ASCII whitespace, like primary tokenisation, but
nowadays unlike the split() formulation with which it's documented.
Document this additional difference from split().  Fixes [perl #132272].

6 years agotoke.c: Rmv useless code
Karl Williamson [Sat, 25 Mar 2017 23:38:40 +0000 (17:38 -0600)]
toke.c: Rmv useless code

This code is unreachable because the code above makes sure that the
variable can't be larger than PL_bufend, and the code is only executed
if it is larger.

6 years agotoke.c: White space only
Karl Williamson [Sat, 25 Mar 2017 21:18:27 +0000 (15:18 -0600)]
toke.c: White space only

Fix up some white space, including outdenting a block that was doubly
indented

6 years agomulticoncat: use append_utf8_from_native_byte()
David Mitchell [Wed, 1 Nov 2017 18:45:36 +0000 (18:45 +0000)]
multiconcat: use append_utf8_from_native_byte()

This small inline function does what my code was doing manually in a
couple of places. Should be no functional difference, just makes the code
tidier.

Suggested by Karl.

6 years agosprintf-as-multiconcat: fix \x80 issue
David Mitchell [Wed, 1 Nov 2017 17:14:58 +0000 (17:14 +0000)]
sprintf-as-multiconcat: fix \x80 issue

My recent OP_MULTICONCAT merge which (amongst other things) converts
sprintfs with a constant format that only containing %s's into a
multiconcat op, miscounted variant chars (i.e. chars like \x80, which if
upgraded to utf8, expand the number of bytes they require).
This could cause buffer overruns.

Spotted by Karl Williamson++

NPD