This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perl5.git
9 years agoUpdate podcheck db to reflect fixed problem
Karl Williamson [Sat, 31 May 2014 15:58:16 +0000 (09:58 -0600)]
Update podcheck db to reflect fixed problem

9 years agoregen/mk_PL_charclass.pl: Rmv hard-coded char names
Karl Williamson [Sun, 17 Mar 2013 04:48:22 +0000 (22:48 -0600)]
regen/mk_PL_charclass.pl: Rmv hard-coded char names

Since this program was written, the abbreviated names of the control
characters have become available from charnames::viacode().  We change
to use these instead of hard-coding them in.

At the same time, this shortens the names for some of the other
characters in cases where it is easy to read the short ones.

It also changes to use mnemonics instead of hard-coded ordinals, like
using ASCII instead of x < 128.  This allows it to be run on an EBCDIC
platform.

9 years agoPATCH: [perl #121777] User-defined prop and packages
Karl Williamson [Wed, 7 May 2014 23:36:40 +0000 (17:36 -0600)]
PATCH: [perl #121777] User-defined prop and packages

The solution to this is to add the package name to the property name for
run-time lookup.

Thanks for Darin McBride for finding an inefficiency in an earlier
version of this patch.

9 years agoregcomp.c: Rmv temporary variable
Karl Williamson [Wed, 7 May 2014 22:41:51 +0000 (16:41 -0600)]
regcomp.c: Rmv temporary variable

This variable is unused after its first use, so can just be elminated.

9 years agolib/utf8_heavy.pl: Stack '?' and ':' ternaries
Karl Williamson [Wed, 7 May 2014 22:40:48 +0000 (16:40 -0600)]
lib/utf8_heavy.pl: Stack '?' and ':' ternaries

This is to make the code easier to read.

9 years agoUpgrade Encode from version 2.60_01 to 2.62
Steve Hay [Sat, 31 May 2014 12:50:42 +0000 (13:50 +0100)]
Upgrade Encode from version 2.60_01 to 2.62

The new version incorporates previous blead CUSTOMIZATIONS.

9 years agoRemove old Class-ISA remnants
Steve Hay [Sat, 31 May 2014 13:28:00 +0000 (14:28 +0100)]
Remove old Class-ISA remnants

9 years agoRemove Package-Constants remnant
Steve Hay [Sat, 31 May 2014 13:20:10 +0000 (14:20 +0100)]
Remove Package-Constants remnant

9 years agoRemove Module-Build remnants
Steve Hay [Sat, 31 May 2014 13:19:38 +0000 (14:19 +0100)]
Remove Module-Build remnants

9 years agoRemove CGI.pm remnants
Steve Hay [Sat, 31 May 2014 13:17:28 +0000 (14:17 +0100)]
Remove CGI.pm remnants

9 years agoUpgrade libnet from version 1.25 to 1.27
Steve Hay [Sat, 31 May 2014 11:43:56 +0000 (12:43 +0100)]
Upgrade libnet from version 1.25 to 1.27

This eliminates the need to have a CUSTOMIZED Makefile.PL. The other changes
(to modules and test scripts) are whitespace only.

9 years agoBelt and braces, add Module-CoreList version checks in porting too
Chris 'BinGOs' Williams [Sat, 31 May 2014 13:50:40 +0000 (14:50 +0100)]
Belt and braces, add Module-CoreList version checks in porting too

9 years agoAdded core-only version check to Module-CoreList
Chris 'BinGOs' Williams [Sat, 31 May 2014 11:12:47 +0000 (12:12 +0100)]
Added core-only version check to Module-CoreList

This should ensure that the versions of Module-CoreList modules
always match the version of perl.

Have to special-case skip for v5.21.1, because rjbs

9 years agoClarify "require <>"-message.
Norman Koch [Sat, 31 May 2014 01:31:29 +0000 (03:31 +0200)]
Clarify "require <>"-message.

Changed "<> should be quotes" to "<> at require-statement should be
quotes".  This way, when someone writes "require <Module>", it is way
easier to find the specific command that caused this.

9 years agoCorrect illegal use of >> in Exporter POD.
Todd Rinaldo [Mon, 14 Apr 2014 02:37:42 +0000 (21:37 -0500)]
Correct illegal use of >> in Exporter POD.

Discovered during POD unit tests on release of 5.70 to CPAN.
Also correct AUTHORS and checkAUTHORS.PL email to toddr@cpan.org.
Bump Exporter $VERSION to 5.71.

9 years agoregexec.c: Eliminate a malloc/free
Karl Williamson [Mon, 21 Apr 2014 02:06:04 +0000 (20:06 -0600)]
regexec.c: Eliminate a malloc/free

This uses an C automatic variable instead of a malloc and free.

9 years agoutf8.c: Move documentation next to its function
Karl Williamson [Mon, 5 May 2014 15:56:43 +0000 (09:56 -0600)]
utf8.c: Move documentation next to its function

Somehow this pod stuff was orphaned from the function it describes.

9 years agosv.c: Clarify comment
Karl Williamson [Mon, 5 May 2014 01:00:40 +0000 (19:00 -0600)]
sv.c: Clarify comment

I find reordering the text makes it easier to understand

9 years agoperlapi: Clarify some instances where NUL is or isn't permitted
Karl Williamson [Mon, 5 May 2014 00:58:51 +0000 (18:58 -0600)]
perlapi: Clarify some instances where NUL is or isn't permitted

Some functions that take a string/length pair can have embedded NULs and
don't have to be NUL terminated; others are the opposite.  This adds
text to clarify the issue.

9 years agoWrap various pod uses of NUL with C<>
Karl Williamson [Sun, 4 May 2014 23:09:22 +0000 (17:09 -0600)]
Wrap various pod uses of NUL with C<>

This makes the uses of this consistent in our pods.  Also changed one
use of the word 'buffer' into 'string', the latter being more
appropriate.

9 years agoregen/regcharclass.pl: Improve the generated code
Karl Williamson [Sat, 3 May 2014 21:38:27 +0000 (15:38 -0600)]
regen/regcharclass.pl: Improve the generated code

This is a small improvement when a consecutive group of U8 code points
begins at 0 or ends at 255.  These end points are physically impossible
of being exceeded, so there is no need to test for that end of the
range.  In several places this causes a mask operation to not be
generated.

9 years agoregcomp.c: Fix comment
Karl Williamson [Tue, 29 Apr 2014 03:50:52 +0000 (21:50 -0600)]
regcomp.c: Fix comment

9 years agoregcomp.c: Tighten up synthetic start class for Unicode characters
Karl Williamson [Tue, 29 Apr 2014 03:43:39 +0000 (21:43 -0600)]
regcomp.c: Tighten up synthetic start class for Unicode characters

When creating a synthetic start class (SSC) for EXACTFish nodes, in many
instances prior to this patch we punted and assumed any code point could
be matched.  This patch actually goes to the trouble of figuring out
what Unicode code points could possibly match, and uses those.  The only
time it punts now is when the node starts with a string of multiple
characters that together could be the fold of a single one.  It's too
complicated getting all the possibilities for these, as there could be
overlapping sequences that work.

9 years agoregcomp.c: Fix typo in comment
Karl Williamson [Tue, 29 Apr 2014 03:40:47 +0000 (21:40 -0600)]
regcomp.c: Fix typo in comment

9 years agoregcomp.c: Add assertion
Karl Williamson [Tue, 29 Apr 2014 03:10:48 +0000 (21:10 -0600)]
regcomp.c: Add assertion

This is because coverity thinks this could happen, and jhi and khw don't

9 years agoregcomp.c: Change a panic into an assert
Karl Williamson [Tue, 29 Apr 2014 03:08:19 +0000 (21:08 -0600)]
regcomp.c: Change a panic into an assert

This really should never happen, so might as well be an assert.

9 years agoregcomp.c: Move code into a function
Karl Williamson [Tue, 29 Apr 2014 02:55:50 +0000 (20:55 -0600)]
regcomp.c: Move code into a function

This is in preparation for it to be called from another place

9 years agoregcomp.c: Remove obsolete code
Karl Williamson [Tue, 29 Apr 2014 01:53:39 +0000 (19:53 -0600)]
regcomp.c: Remove obsolete code

Commit cd209d9d0a3b8eec779c744b3a98c9101e3f1a21 changed things so that
this code (as its comments suggest) is now obsolete.

9 years agoregcomp.c, regexec.c: Move common code to a function
Karl Williamson [Tue, 29 Apr 2014 01:48:40 +0000 (19:48 -0600)]
regcomp.c, regexec.c: Move common code to a function

There are other cases where this functionality will be needed as well.

9 years agoregen/regcharclass_multi_char_folds.pl: Add some comments
Karl Williamson [Tue, 29 Apr 2014 01:44:28 +0000 (19:44 -0600)]
regen/regcharclass_multi_char_folds.pl: Add some comments

9 years agoregen/regcharclass.pl: Don't generate macro twice
Karl Williamson [Tue, 29 Apr 2014 01:42:32 +0000 (19:42 -0600)]
regen/regcharclass.pl: Don't generate macro twice

Until this patch, this could happen if both 'safe' and 'fast' are
specified with a cp macro.

9 years agoOptimize /[a-z]/ and /[A-Z]/
Karl Williamson [Sun, 27 Apr 2014 16:53:00 +0000 (10:53 -0600)]
Optimize /[a-z]/ and /[A-Z]/

These bracketed character classes can easily be optimized into smaller
probably faster regops that match identically.

9 years ago/x in patterns now includes all \p{PatWS}
Karl Williamson [Sun, 27 Apr 2014 16:26:58 +0000 (10:26 -0600)]
/x in patterns now includes all \p{PatWS}

This brings Perl regular expressions more into conformance with Unicode.
/x now accepts 5 additional characters as white space.  Use of these
characters as literals under /x has been deprecated since 5.18, so now
we are free to change what they mean.

This commit eliminates the static function that processes the old
whitespace definition (and a generated macro that was used only for
this), using the already existing one for the new definition.  It
refactors slightly the static function that skips comments to mesh
better with the needs of its callers, and calls it in one place where
before the code was essentially duplicated.

p5p discussion starting in
http://nntp.perl.org/group/perl.perl5.porters/214726 convinced me that
the (?[ ]) comments should be terminated the same way as regular /x
comments, and this was also done in this commit.  No prior notice is
necessary as this is an experimental feature.

9 years agoDeprecate NBSP in \N{...} names
Karl Williamson [Sat, 26 Apr 2014 17:27:52 +0000 (11:27 -0600)]
Deprecate NBSP in \N{...} names

This is currently allowed, but is non-graphic, and is indistinguishable
from a regular space.  I was the one who initially allowed it, and did
so out of ignorance of the negative consequences of doing so.  There is
no other precedent for including it.

9 years agoFix bug where charnames xlator doesn't return utf8
Karl Williamson [Sat, 26 Apr 2014 17:07:11 +0000 (11:07 -0600)]
Fix bug where charnames xlator doesn't return utf8

A user-supplied charnames translator for \N{} processing doesn't have to
return in UTF-8.  Prior to this patch, the code in toke.c assumed it
did.

9 years agoFatalize deprecated \N{} definitions
Karl Williamson [Thu, 24 Apr 2014 14:35:08 +0000 (08:35 -0600)]
Fatalize deprecated \N{} definitions

Having a sequence of multiple spaces in a charnames alias name
definition or having trailing spaces in it have been deprecated since
5.18, and it is now time to make them fatal.

9 years agocharnames: Eliminate need to sync code in two places
Karl Williamson [Thu, 24 Apr 2014 02:33:12 +0000 (20:33 -0600)]
charnames: Eliminate need to sync code in two places

This refactors the code so that it doesn't have to be kept in sync
with other code.

9 years agoFatalize splitting '(?' and '(*' in regexes
Karl Williamson [Wed, 23 Apr 2014 18:40:30 +0000 (12:40 -0600)]
Fatalize splitting '(?' and '(*' in regexes

Inserting spaces or comments between the '(' and '?' or '*' has been
deprecated since v5.18.0.

9 years agoutfebcdic.h: Comment changes only
Karl Williamson [Tue, 22 Apr 2014 03:02:44 +0000 (21:02 -0600)]
utfebcdic.h: Comment changes only

Clarifications and typo fix.

9 years agohandy.h: Comments, white-space only
Karl Williamson [Tue, 22 Apr 2014 02:05:57 +0000 (20:05 -0600)]
handy.h: Comments, white-space only

9 years agohandy.h: Use some common macros for ASCII/EBCDIC
Karl Williamson [Tue, 22 Apr 2014 02:00:16 +0000 (20:00 -0600)]
handy.h: Use some common macros for ASCII/EBCDIC

It turns out that the EBCDIC definitions can be made the same as the
ASCII ones, so this moves the ASCII definitions to the spot where other
ones common to the 2 platforms reside, and removes the EBCDIC ones.  In
other words it combines separate definitions into common ones.

9 years agoregexec.c: Fix some EBCDIC problems
Karl Williamson [Tue, 25 Jun 2013 03:14:37 +0000 (21:14 -0600)]
regexec.c: Fix some EBCDIC problems

We were testing for UTF-8 invariant, when we should have been testing
for ASCII.  This is a problem only on EBCDIC platforms, where they mean
two different sets of code points.

9 years agoUnicode::UCD.pm: Pod clarifications and nits
Karl Williamson [Sun, 31 Mar 2013 03:13:38 +0000 (21:13 -0600)]
Unicode::UCD.pm: Pod clarifications and nits

9 years agodquote_static.c: Clarify code
Karl Williamson [Mon, 21 Apr 2014 18:11:40 +0000 (12:11 -0600)]
dquote_static.c: Clarify code

We output the message when there is a printable ASCII character, so use
that as the test instead of complementing the test for a control.  This
makes the code somewhat clearer.

9 years ago"\cX" where X is non-printable is now fatal
Karl Williamson [Wed, 9 Apr 2014 01:27:59 +0000 (19:27 -0600)]
"\cX" where X is non-printable is now fatal

It had been deprecated, scheduled to be removed in 5.22.

9 years agoRevert "DEBUG_X_TEST are only for DEBUGGING."
Jarkko Hietaniemi [Fri, 30 May 2014 02:37:11 +0000 (22:37 -0400)]
Revert "DEBUG_X_TEST are only for DEBUGGING."

This reverts commit efbe0e532ca914af071ffbd40bfc8932fab1ecf9.

9 years agoUndo 63b558ddd980cd36bcbd8a7465a3412e886ba75e.
Jarkko Hietaniemi [Fri, 30 May 2014 02:01:06 +0000 (22:01 -0400)]
Undo 63b558ddd980cd36bcbd8a7465a3412e886ba75e.

(For some odd reason assert() cannot be found and Jenkins becomes apoplectic.)

9 years agoDEBUG_X_TEST are only for DEBUGGING.
Jarkko Hietaniemi [Fri, 30 May 2014 01:53:44 +0000 (21:53 -0400)]
DEBUG_X_TEST are only for DEBUGGING.

9 years agoMove #include <assert.h> before ASSUME/NOT_REACHED.
Jarkko Hietaniemi [Fri, 30 May 2014 01:47:57 +0000 (21:47 -0400)]
Move #include <assert.h> before ASSUME/NOT_REACHED.

9 years agoUse NOT_REACHED for the impossible case.
Jarkko Hietaniemi [Fri, 30 May 2014 01:24:47 +0000 (21:24 -0400)]
Use NOT_REACHED for the impossible case.

The default case really is impossible because all the valid
enums values are already covered in the switch.

The NOT_REACHED; is for the compiler (from perl.h),
the /* NOTREACHED */ is for static analyzers.

9 years agoperlre: Clarify /x eol can't be escaped
Karl Williamson [Mon, 19 May 2014 22:36:33 +0000 (16:36 -0600)]
perlre: Clarify /x eol can't be escaped

9 years agot/run/locale.t: Skip some tests for some shells
Karl Williamson [Tue, 13 May 2014 23:31:39 +0000 (17:31 -0600)]
t/run/locale.t: Skip some tests for some shells

Some sh programs don't accept changes of environment variables like
LC_ALL to invalid values.  For these the tests aren't testing what they
think they are, so change them to just return the expected value, so
they will pass.  This effectively skips the tests when run on these
shells.  See http://nntp.perl.org/group/perl.perl5.porters/214503

9 years agot/run/locale.t: Rmv obsolete complicated idiom
Karl Williamson [Tue, 13 May 2014 23:08:24 +0000 (17:08 -0600)]
t/run/locale.t: Rmv obsolete complicated idiom

See http://nntp.perl.org/group/perl.perl5.porters/213369

9 years agot/test.pl: Use existing variable instead of recalculating
Karl Williamson [Tue, 6 May 2014 22:26:05 +0000 (16:26 -0600)]
t/test.pl: Use existing variable instead of recalculating

If the current platform is ascii is available already in a variable.
Use that instead of inventing a different paradigm.

9 years agoXS-APItest/t/handy.t: Change output message
Karl Williamson [Fri, 15 Mar 2013 17:50:35 +0000 (11:50 -0600)]
XS-APItest/t/handy.t: Change output message

On EBCDIC platforms, the output is not in terms of \N{U+}; change text
to \x{ }

9 years agomktables: Add comment
Karl Williamson [Sat, 22 Feb 2014 23:36:28 +0000 (16:36 -0700)]
mktables: Add comment

9 years agoPATCH: [perl #121630]: perlpod clarification
Karl Williamson [Mon, 28 Apr 2014 20:10:37 +0000 (14:10 -0600)]
PATCH: [perl #121630]: perlpod clarification

9 years agot/lib/charnames/alias: Add comment
Karl Williamson [Thu, 24 Apr 2014 15:30:07 +0000 (09:30 -0600)]
t/lib/charnames/alias: Add comment

9 years agot/re/charset.t: Fix comment, test names
Karl Williamson [Tue, 22 Apr 2014 03:27:37 +0000 (21:27 -0600)]
t/re/charset.t: Fix comment, test names

Some of the test names have hard-coded values that are wrong.  This uses
a calculated value.

9 years agoRevert "mktables: Remove obsolete sort constraint"
Karl Williamson [Wed, 30 Apr 2014 02:18:42 +0000 (20:18 -0600)]
Revert "mktables: Remove obsolete sort constraint"

This reverts commit cf13ddc5efb78ce6d588441978947303e5baf1d8,
and adds a comment as to why.

9 years agomktables: Add regenerated header to file
Karl Williamson [Wed, 28 May 2014 03:23:34 +0000 (21:23 -0600)]
mktables: Add regenerated header to file

This file is generated by mktables, so any changes made to it are lost.
Add the standard header for such files to it.

9 years agoRemove deprecated 'PL_sv_objcount'
Karl Williamson [Wed, 9 Apr 2014 00:46:25 +0000 (18:46 -0600)]
Remove deprecated 'PL_sv_objcount'

This was scheduled to be removed in 5.20, but was forgotten.

9 years agoutf8.c: Silence compiler warning
Karl Williamson [Fri, 30 May 2014 00:43:21 +0000 (18:43 -0600)]
utf8.c: Silence compiler warning

This was brought to my attention by Jarkko Hietaniemi.  The compiler was
complaining that a variable could be used uninitialized.  In practice
this doesn't happen, as it would only happen on bad data, and Perl
itself generates the data used.  (I suppose if the data got corrupted,
it could happen.)  This commit initializes the value unconditionally,
which allows a conditional setting of it to be removed.

9 years agoutf8.c: Move static function to embed.fnc
Karl Williamson [Fri, 30 May 2014 00:41:58 +0000 (18:41 -0600)]
utf8.c: Move static function to embed.fnc

This automatically generates assertions for pointer arguments, etc.

9 years agoUnify the "fall-through" lint annotation.
Jarkko Hietaniemi [Fri, 30 May 2014 00:41:22 +0000 (20:41 -0400)]
Unify the "fall-through" lint annotation.

Used by linters (static checkers), and also good for human readers.

Even though "FALL THROUGH" seems to be the most common, e.g BSD lint
manual only knows "FALLTHROUGH" (or "FALLTHRU").

9 years agoOnly prototype should_warn_nl under PERL_CORE.
Craig A. Berry [Thu, 29 May 2014 22:08:37 +0000 (17:08 -0500)]
Only prototype should_warn_nl under PERL_CORE.

Otherwise the prototype is seen in places where the function
itself is not defined, which is illegal for inline functions.

Follow-up to 7cb3f9598b37fc.

9 years agoGive caretx.c an explicit rule in vms/descrip_mms.template.
Craig A. Berry [Thu, 29 May 2014 21:46:19 +0000 (16:46 -0500)]
Give caretx.c an explicit rule in vms/descrip_mms.template.

Without an explicit rule it gets build with CFLAGS rather than
CORECFLAGS, which could make it miss important things, such as
PERL_CORE being defined.

9 years agoActually define SS_NOPRIV.
Craig A. Berry [Thu, 29 May 2014 21:44:11 +0000 (16:44 -0500)]
Actually define SS_NOPRIV.

Because in cd52bc19d9de6bc we made it just like all the others
except for the fact that the others already existed and this
one didn't.

9 years agoFurther simplify the sockatmark().
Jarkko Hietaniemi [Thu, 29 May 2014 21:36:41 +0000 (17:36 -0400)]
Further simplify the sockatmark().

(And do not assign the fd in PREINIT.)

9 years agoBuild fixes for Win32 after the Coverity smoke.
Jarkko Hietaniemi [Thu, 29 May 2014 20:56:28 +0000 (16:56 -0400)]
Build fixes for Win32 after the Coverity smoke.

(for 375ed12a42c6092b1af1d8e395bf3dadd9a66e48)

9 years agoGet rid of "grep empty(sub)expression" noise.
Jarkko Hietaniemi [Thu, 29 May 2014 19:16:47 +0000 (15:16 -0400)]
Get rid of "grep empty(sub)expression" noise.

In OS X (and assumedly *BSD) Configure output starts with:

grep empty(sub)expression

apparently because plain 'grep' understands the 'os\(/\|\)2'
somewhat differently (BRE vs ERE, RTFM re_format(7))

Cure: redirect the stderr of grep to stdout (which is then promptly
redirected to /dev/null).  The grep will still fail, and not take
the OS/2 (or DJGPP) branch.

9 years agoWe cannot assert(sv) since sv can be validly null
Jarkko Hietaniemi [Thu, 29 May 2014 19:14:34 +0000 (15:14 -0400)]
We cannot assert(sv) since sv can be validly null
(see the top of the function), but we can test it.

9 years agoDevel::PPPort 3.24 from CPAN.
Jarkko Hietaniemi [Thu, 29 May 2014 18:17:18 +0000 (14:17 -0400)]
Devel::PPPort 3.24 from CPAN.

9 years agoNo more x2p.
Jarkko Hietaniemi [Thu, 29 May 2014 17:56:35 +0000 (13:56 -0400)]
No more x2p.

9 years agoVersion bumping thanks to the Coverity deluge.
Jarkko Hietaniemi [Thu, 29 May 2014 17:52:25 +0000 (13:52 -0400)]
Version bumping thanks to the Coverity deluge.

9 years agoFollowup to 316ebaf (aka perl #121894).
Jarkko Hietaniemi [Thu, 29 May 2014 17:24:36 +0000 (13:24 -0400)]
Followup to 316ebaf (aka perl #121894).

Adding asserts to more spots.

Fix for Coverity perl5 CIDs 28962,28968,28969:
CID ...: Dereference after null check (FORWARD_NULL)
var_deref_op: Dereferencing null pointer p->q

9 years agoBump version for Devel::Peek
Karl Williamson [Thu, 29 May 2014 17:33:10 +0000 (11:33 -0600)]
Bump version for Devel::Peek

Commit 316ebaf2966c5b6fd47a9d1dc6fb64fcbd262379 changed this module
without changing the version number

9 years agofcntl receiving -1 from fileno, fcntl failing.
Jarkko Hietaniemi [Thu, 29 May 2014 16:36:28 +0000 (12:36 -0400)]
fcntl receiving -1 from fileno, fcntl failing.

(Also very few spots of negative numgroups for getgroups(),
and fgetc() return, but almost all checking is for fcntl.)

(merged fix for perl #121743 and perl #121745: hopefully
picked up all the fixes-to-fixes from the ticket...)

Fix for Coverity perl5 CIDs 28990..29003,29005..29011,29013,
45354,45363,49926:

Argument cannot be negative (NEGATIVE_RETURNS) fd is
passed to a parameter that cannot be negative.

and CIDs 29004, 29012:
Argument cannot be negative (NEGATIVE_RETURNS)
num_groups is passed to a parameter that cannot be negative

and because of CIDs 29005 and 29006 also CID 28924.

In the first set of issues a fd is retrieved from PerlIO_fileno, and
that is then used in places like fstat(), fchown(), dup(), etc.,
without checking whether the fd is valid (>=0).

In the second set of issues a potentially negative
number is potentially passed to getgroups().

The CIDs 29005 and 29006 were a bit messy: fixing them needed also
resolving CID 28924 where the return value of fstat() was ignored,
and for completeness adding two croak calls (with perldiag updates):
a bit of a waste since it's suidperl code.

9 years agoInsert asserts to paths suspected by Coverity.
Jarkko Hietaniemi [Thu, 29 May 2014 15:37:56 +0000 (11:37 -0400)]
Insert asserts to paths suspected by Coverity.

Coverity suspects paths like this:

(1)

  p = foo();
  if (!p) p = bar();
  baz(p->q);

since it cannot prove that p is always non-NULL at the dereference.

(2) Or simply something like:

  mg = mg_find(...);
  foo(mg->blah);

Since mg_find() can fail returning NULL.

Adding assert() calls before the dereferences.  Testing with -DDEBUGGING.
Hopefully there are regular smokes doing the same.

[perl #121894]

Fix for Coverity perl5 CIDs 28950,28952..28955,28964,28967,28970..28795,49921:
CID ...: Dereference after null check (FORWARD_NULL)
var_deref_op: Dereferencing null pointer p->q

(TODO: Coverity perl5 CIDs 28962,28968,28969: the same issue, but would
conflict with already in-flight changes, prepare catch-up patch later.)
---
 dist/Data-Dumper/Dumper.xs | 1 +
 dump.c                     | 1 +
 ext/Devel-Peek/Peek.xs     | 1 +
 ext/XS-APItest/APItest.xs  | 1 +
 mg.c                       | 2 ++
 mro.c                      | 4 +++-
 op.c                       | 4 ++++
 perlio.c                   | 1 +
 pp_hot.c                   | 5 +++--
 regcomp.c                  | 3 +++
 regexec.c                  | 5 ++++-
 universal.c                | 2 +-
 util.c                     | 4 +++-
 13 files changed, 28 insertions(+), 6 deletions(-)

diff --git a/dist/Data-Dumper/Dumper.xs b/dist/Data-Dumper/Dumper.xs
index 12c4ebd..23e0cf4 100644
--- a/dist/Data-Dumper/Dumper.xs
+++ b/dist/Data-Dumper/Dumper.xs
@@ -641,6 +641,7 @@ DD_dump(pTHX_ SV *val, const char *name, STRLEN namelen, SV *retval, HV *seenhv,
      else {
        sv_pattern = val;
      }
+     assert(sv_pattern);
      rval = SvPV(sv_pattern, rlen);
      rend = rval+rlen;
      slash = rval;
diff --git a/dump.c b/dump.c
index 59be3e0..c2d72fd 100644
--- a/dump.c
+++ b/dump.c
@@ -471,6 +471,7 @@ Perl_sv_peek(pTHX_ SV *sv)
   finish:
     while (unref--)
  sv_catpv(t, ")");
+    /* XXX when is sv ever NULL? */
     if (TAINTING_get && SvTAINTED(sv))
  sv_catpv(t, " [tainted]");
     return SvPV_nolen(t);
diff --git a/ext/Devel-Peek/Peek.xs b/ext/Devel-Peek/Peek.xs
index 679efa5..b20fa94 100644
--- a/ext/Devel-Peek/Peek.xs
+++ b/ext/Devel-Peek/Peek.xs
@@ -450,6 +450,7 @@ PPCODE:
 BOOT:
 {
     CV * const cv = get_cvn_flags("Devel::Peek::Dump", 17, 0);
+    assert(cv);
     cv_set_call_checker(cv, S_ck_dump, (SV *)cv);

     XopENTRY_set(&my_xop, xop_name, "Dump");
diff --git a/ext/XS-APItest/APItest.xs b/ext/XS-APItest/APItest.xs
index a51924d..18ba381 100644
--- a/ext/XS-APItest/APItest.xs
+++ b/ext/XS-APItest/APItest.xs
@@ -2096,6 +2096,7 @@ newCONSTSUB(stash, name, flags, sv)
                break;
         }
         EXTEND(SP, 2);
+        assert(mycv);
         PUSHs( CvCONST(mycv) ? &PL_sv_yes : &PL_sv_no );
         PUSHs((SV*)CvGV(mycv));

diff --git a/mg.c b/mg.c
index 76912bd..7f3339a 100644
--- a/mg.c
+++ b/mg.c
@@ -1675,6 +1675,7 @@ Perl_magic_clearisa(pTHX_ SV *sv, MAGIC *mg)
     same function. */
  mg = mg_find(mg->mg_obj, PERL_MAGIC_isa);

+    assert(mg);
     if (SvTYPE(mg->mg_obj) == SVt_PVAV) { /* multiple stashes */
  SV **svp = AvARRAY((AV *)mg->mg_obj);
  I32 items = AvFILLp((AV *)mg->mg_obj) + 1;
@@ -3437,6 +3438,7 @@ Perl_magic_copycallchecker(pTHX_ SV *sv, MAGIC *mg, SV *nsv,

     sv_magic(nsv, &PL_sv_undef, mg->mg_type, NULL, 0);
     nmg = mg_find(nsv, mg->mg_type);
+    assert(nmg);
     if (nmg->mg_flags & MGf_REFCOUNTED) SvREFCNT_dec(nmg->mg_obj);
     nmg->mg_ptr = mg->mg_ptr;
     nmg->mg_obj = SvREFCNT_inc_simple(mg->mg_obj);
diff --git a/mro.c b/mro.c
index 1b37ca7..ccf4bf4 100644
--- a/mro.c
+++ b/mro.c
@@ -638,12 +638,14 @@ Perl_mro_isa_changed_in(pTHX_ HV* stash)
                       hv_storehek(mroisarev, namehek, &PL_sv_yes);
                 }

-                if((SV *)isa != &PL_sv_undef)
+                if ((SV *)isa != &PL_sv_undef) {
+                    assert(namehek);
                     mro_clean_isarev(
                      isa, HEK_KEY(namehek), HEK_LEN(namehek),
                      HvMROMETA(revstash)->isa, HEK_HASH(namehek),
                      HEK_UTF8(namehek)
                     );
+                }
             }
         }
     }
diff --git a/op.c b/op.c
index 796cb03..79621ce 100644
--- a/op.c
+++ b/op.c
@@ -2907,6 +2907,7 @@ S_my_kid(pTHX_ OP *o, OP *attrs, OP **imopsp)
      S_cant_declare(aTHX_ o);
  } else if (attrs) {
      GV * const gv = cGVOPx_gv(cUNOPo->op_first);
+     assert(PL_parser);
      PL_parser->in_my = FALSE;
      PL_parser->in_my_stash = NULL;
      apply_attrs(GvSTASH(gv),
@@ -2929,6 +2930,7 @@ S_my_kid(pTHX_ OP *o, OP *attrs, OP **imopsp)
     else if (attrs && type != OP_PUSHMARK) {
  HV *stash;

+        assert(PL_parser);
  PL_parser->in_my = FALSE;
  PL_parser->in_my_stash = NULL;

@@ -10229,6 +10231,7 @@ Perl_ck_split(pTHX_ OP *o)
  op_append_elem(OP_SPLIT, o, newDEFSVOP());

     kid = kid->op_sibling;
+    assert(kid);
     scalar(kid);

     if (!kid->op_sibling)
@@ -10902,6 +10905,7 @@ Perl_cv_set_call_checker(pTHX_ CV *cv, Perl_call_checker ckfun, SV *ckobj)
  MAGIC *callmg;
  sv_magic((SV*)cv, &PL_sv_undef, PERL_MAGIC_checkcall, NULL, 0);
  callmg = mg_find((SV*)cv, PERL_MAGIC_checkcall);
+ assert(callmg);
  if (callmg->mg_flags & MGf_REFCOUNTED) {
      SvREFCNT_dec(callmg->mg_obj);
      callmg->mg_flags &= ~MGf_REFCOUNTED;
diff --git a/perlio.c b/perlio.c
index d4c43d0..e6ff9e4 100644
--- a/perlio.c
+++ b/perlio.c
@@ -2225,6 +2225,7 @@ PerlIOBase_dup(pTHX_ PerlIO *f, PerlIO *o, CLONE_PARAMS *param, int flags)
  PerlIO_funcs * const self = PerlIOBase(o)->tab;
  SV *arg = NULL;
  char buf[8];
+ assert(self);
  PerlIO_debug("PerlIOBase_dup %s f=%p o=%p param=%p\n",
       self ? self->name : "(Null)",
       (void*)f, (void*)o, (void*)param);
diff --git a/pp_hot.c b/pp_hot.c
index 2cccc48..9c9d1e9 100644
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -3078,6 +3078,7 @@ S_method_common(pTHX_ SV* meth, U32* hashp)
  const HE* const he = hv_fetch_ent(stash, meth, 0, *hashp);
  if (he) {
      gv = MUTABLE_GV(HeVAL(he));
+     assert(stash);
      if (isGV(gv) && GvCV(gv) &&
  (!GvCVGEN(gv) || GvCVGEN(gv)
                   == (PL_sub_generation + HvMROMETA(stash)->cache_gen)))
@@ -3085,9 +3086,9 @@ S_method_common(pTHX_ SV* meth, U32* hashp)
  }
     }

+    assert(stash || packsv);
     gv = gv_fetchmethod_sv_flags(stash ? stash : MUTABLE_HV(packsv),
-              meth, GV_AUTOLOAD | GV_CROAK);
-
+                                 meth, GV_AUTOLOAD | GV_CROAK);
     assert(gv);

     return isGV(gv) ? MUTABLE_SV(GvCV(gv)) : MUTABLE_SV(gv);
diff --git a/regcomp.c b/regcomp.c
index eaee604..3d49827 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -2007,6 +2007,7 @@ S_make_trie(pTHX_ RExC_state_t *pRExC_state, regnode *startbranch,
     });

     re_trie_maxbuff = get_sv(RE_TRIE_MAXBUF_NAME, 1);
+    assert(re_trie_maxbuff);
     if (!SvIOK(re_trie_maxbuff)) {
         sv_setiv(re_trie_maxbuff, RE_TRIE_MAXBUF_INIT);
     }
@@ -14920,6 +14921,7 @@ S_set_ANYOF_arg(pTHX_ RExC_state_t* const pRExC_state,
  av_store(av, 0, (runtime_defns)
  ? SvREFCNT_inc(runtime_defns) : &PL_sv_undef);
  if (swash) {
+     assert(cp_list);
      av_store(av, 1, swash);
      SvREFCNT_dec_NN(cp_list);
  }
@@ -16609,6 +16611,7 @@ S_dumpuntil(pTHX_ const regexp *r, const regnode *start, const regnode *node,
         last= plast;

     while (PL_regkind[op] != END && (!last || node < last)) {
+        assert(node);
  /* While that wasn't END last time... */
  NODE_ALIGN(node);
  op = OP(node);
diff --git a/regexec.c b/regexec.c
index 362390b..ffab4f2 100644
--- a/regexec.c
+++ b/regexec.c
@@ -7010,6 +7010,8 @@ no_silent:
                 sv_commit = &PL_sv_yes;
             sv_yes_mark = &PL_sv_no;
         }
+        assert(sv_err);
+        assert(sv_mrk);
         sv_setsv(sv_err, sv_commit);
         sv_setsv(sv_mrk, sv_yes_mark);
     }
@@ -7620,6 +7622,7 @@ Perl__get_regclass_nonbitmap_data(pTHX_ const regexp *prog,
                     *only_utf8_locale_ptr = ary[2];
                 }
                 else {
+                    assert(only_utf8_locale_ptr);
                     *only_utf8_locale_ptr = NULL;
                 }

@@ -7641,7 +7644,7 @@ Perl__get_regclass_nonbitmap_data(pTHX_ const regexp *prog,
      }
      else if (doinit && ((si && si != &PL_sv_undef)
                                  || (invlist && invlist != &PL_sv_undef))) {
-
+ assert(si);
  sw = _core_swash_init("utf8", /* the utf8 package */
        "", /* nameless */
        si,
diff --git a/universal.c b/universal.c
index a29696d..65e02df 100644
--- a/universal.c
+++ b/universal.c
@@ -67,7 +67,7 @@ S_isa_lookup(pTHX_ HV *stash, const char * const name, STRLEN len, U32 flags)
     if (our_stash) {
  HEK *canon_name = HvENAME_HEK(our_stash);
  if (!canon_name) canon_name = HvNAME_HEK(our_stash);
-
+ assert(canon_name);
  if (hv_common(isa, NULL, HEK_KEY(canon_name), HEK_LEN(canon_name),
        HEK_FLAGS(canon_name),
        HV_FETCH_ISEXISTS, NULL, HEK_HASH(canon_name))) {
diff --git a/util.c b/util.c
index b90abe5..cd0afb6 100644
--- a/util.c
+++ b/util.c
@@ -850,15 +850,17 @@ Perl_fbm_instr(pTHX_ unsigned char *big, unsigned char *bigend, SV *littlestr, U

     {
  const MAGIC *const mg = mg_find(littlestr, PERL_MAGIC_bm);
- const unsigned char * const table = (const unsigned char *) mg->mg_ptr;
  const unsigned char *oldlittle;

+ assert(mg);
+
  --littlelen; /* Last char found by table lookup */

  s = big + littlelen;
  little += littlelen; /* last char */
  oldlittle = little;
  if (s < bigend) {
+     const unsigned char * const table = (const unsigned char *) mg->mg_ptr;
      I32 tmp;

    top2:
--
1.8.5.2 (Apple Git-48)

9 years agobump version on NDBM_File
David Mitchell [Thu, 29 May 2014 15:28:12 +0000 (16:28 +0100)]
bump version on NDBM_File

9 years agoO_BINARY versus O_TEXT.
Jarkko Hietaniemi [Thu, 29 May 2014 15:18:24 +0000 (11:18 -0400)]
O_BINARY versus O_TEXT.

O_BINARY and O_TEXT can be either different (mostly in Windowsy platforms,
and in some hybrids, and then they can be either effective or no-ops);
or equal (in UNIXy platforms, no-ops).  If they are no-ops, and especially
if one or both of them are zeros, one cannot even test for them (bit-and),
without introducing dead/non-sensical code.

[perl #121739]

Fix for Coverity perl5 CID 28948:
Logically dead code (DEADCODE)
dead_error_line: Execution cannot reach this statement mode[ix++] = 'b';

9 years agoStrengthen the ix zero min-clamping to panic.
Jarkko Hietaniemi [Thu, 29 May 2014 15:09:48 +0000 (11:09 -0400)]
Strengthen the ix zero min-clamping to panic.

Currently the ix cannot ever be less than zero (detected by Coverity).
Furthermore, it probably should never get less than zero, so panic if
that ever happens.

[perl #121897]

Fix for Coverity perl5 CID 28946:
at_least: At condition ix < 0, the value of ix must be at least 0.
dead_error_condition: The condition ix < 0 cannot be true.
Logically dead code (DEADCODE)
dead_error_line: Execution cannot reach this statement ix = 0;

9 years agoMakefile.SH: Module::Build is no longer there, stop copying it
Brian Fraser [Thu, 29 May 2014 11:47:31 +0000 (13:47 +0200)]
Makefile.SH: Module::Build is no longer there, stop copying it

This only affected 'make test' for cross-compilation builds; in
those, we try to copy files relevant to 'make test' to the target
system.

Since Module::Build is no longer part of the core, no need to
try to copy it over.

9 years agomake regen for uconfig.h
Brian Fraser [Thu, 29 May 2014 11:28:00 +0000 (13:28 +0200)]
make regen for uconfig.h

9 years agoFix for [perl #121963] 5.20.0-RC1 can't compile on Android
Brian Fraser [Thu, 29 May 2014 10:58:52 +0000 (12:58 +0200)]
Fix for [perl #121963] 5.20.0-RC1 can't compile on Android

On some native android builds, this was causing warnings and
possibly build errors before Config.pm was generated.

9 years agoSH_PATH should be $targetsh, not $sh
Brian Fraser [Thu, 29 May 2014 10:54:59 +0000 (12:54 +0200)]
SH_PATH should be $targetsh, not $sh

Due to a small oversight, this was reverted in the last metaconfig
update, and was preventing backticks/system/exec/two-arg-pipe-open
from working in some Android devices.

9 years agoMax size of the flop operator range.
Jarkko Hietaniemi [Thu, 29 May 2014 15:00:31 +0000 (11:00 -0400)]
Max size of the flop operator range.

Firstly, rename {max,j} -> {j,n} since j as the count is very confusing.

The j > SSize_t_MAX cannot (usually) fire.

(1) If the IV and SSize_t are the same (very likely) the count (an IV)
simply cannot be larger than the max of SSize_t.

(2) If IV is larger than SSize_t (e.g. long longs for IVs but only
32-bit pointers available) the count could conceivably be larger than
the max of SSize_t, but we still need to correctly dance around the
max: the signed maxima are tricky since the behavior of overflow is
undefined.

(3) The IV cannot be smaller than than SSize_t (e.g. I32 for IV but
64-bit pointers available): IV is supposed to be large enough to
contain pointers).

NOTE: this logic only protects against the wraparound, not against
an OOM: we will run out of memory long before we create (even)
SSize_t_MAX SVs. There is nothing magical about SSize_t as such,
except that it is a likely wraparound spot.

Fix for Coverity perl5 CID 28933:
Operands don't affect result (CONSTANT_EXPRESSION_RESULT)
result_independent_of_operands: j > 9223372036854775807L
/* (ssize_t)(~((size_t)0) >> 1) */ is always false regardless of
The values of its operands. This occurs as the logical operand of if.

9 years agoUse system default locale only if there is one.
Jarkko Hietaniemi [Thu, 29 May 2014 14:40:02 +0000 (10:40 -0400)]
Use system default locale only if there is one.

(Currently, only Win32 has one.)

[perl #121865]

Fix for Coverity perl5 CID 28949:
Logically dead code (DEADCODE)
dead_error_line: Execution cannot reach this statement
name = system_default_locale;

9 years agoprintf %s, cast appropriately.
Jarkko Hietaniemi [Thu, 29 May 2014 14:34:28 +0000 (10:34 -0400)]
printf %s, cast appropriately.

[perl #121881]

Fix for Coverity perl5 CID 29050:
Printf arg type mismatch (PW.PRINTF_ARG_MISMATCH)
printf_arg_mismatch: argument is incompatible with corresponding
format string conversion

9 years agoUnused dTHX, even under threads.
Jarkko Hietaniemi [Thu, 29 May 2014 14:26:54 +0000 (10:26 -0400)]
Unused dTHX, even under threads.

[perl #121882].

Fix for Coverity perl5 CID 49935:
Unused pointer value (UNUSED_VALUE)
returned_pointer: Pointer my_perl returned by
pthread_getspecific(PL_thr_key) is never used.

9 years ago __APPLE__ is not Apple, use PERL_DARWIN instead.
Jarkko Hietaniemi [Thu, 29 May 2014 14:21:58 +0000 (10:21 -0400)]
 __APPLE__ is not Apple, use PERL_DARWIN instead.

See hints/darwin.sh for details.

9 years agoReindent the block. Whitespace-only change.
Jarkko Hietaniemi [Thu, 29 May 2014 14:17:51 +0000 (10:17 -0400)]
Reindent the block. Whitespace-only change.

Followup to 99e8c5.

9 years agoFix false nesting.
Jarkko Hietaniemi [Thu, 29 May 2014 14:13:08 +0000 (10:13 -0400)]
Fix false nesting.

[perl #121744]

Fix for Coverity perl5 CID 29014:
Nesting level does not match indentation (NESTING_INDENT_MISMATCH)

(Reindentation of the whole "if (!PL_use_safe_putenv)" block will follow.)

9 years agoUV casting to avoid intermediate sign extension.
Jarkko Hietaniemi [Thu, 29 May 2014 14:01:13 +0000 (10:01 -0400)]
UV casting to avoid intermediate sign extension.

[perl #121746]

Fix for Coverity perl5 CIDs 29069, 29070, 29071:
Unintended sign extension: ... ... if ... U8 (8 bits unsigned) ... 32
bits, signed ...  64 bits, unsigned ... is greater than 0x7FFFFFFF,
the upper bits of the result will all be 1.

9 years agoRemove x2p
Leon Timmermans [Wed, 21 May 2014 11:56:54 +0000 (13:56 +0200)]
Remove x2p

This removes find2perl, s2p and a2p from core. They have all been
released to CPAN as separate distributions.

9 years agoStandardize spelling of program name on American English.
Doug Bell [Thu, 29 May 2014 12:23:42 +0000 (08:23 -0400)]
Standardize spelling of program name on American English.

For: https://rt.perl.org/Ticket/Display.html?id=121978

9 years agotemporary fix for [perl #121975] COW speedup lost after e8c6a474
Yves Orton [Thu, 29 May 2014 09:33:56 +0000 (11:33 +0200)]
temporary fix for [perl #121975] COW speedup lost after e8c6a474

Disable use of Perl_safesysmalloc_size by default. Only use it when PERL_USE_MALLOC_SIZE is defined.

Using Perl_safesysmalloc_size() perl cannot tell a deliberately preallocated buffer
which we probably dont want to COW from a malloc() preallocated buffer where we probably
dont care. Hopefully this fixes the slowdown observed on some platforms.

9 years agoQuad_t and Uquad_t cannot unpack as NVs.
Jarkko Hietaniemi [Tue, 6 May 2014 16:50:55 +0000 (12:50 -0400)]
Quad_t and Uquad_t cannot unpack as NVs.

If IVSIZE >= 8, a Quad_t is always >= IV_MIN, and <= IV_MAX, and an
Uquad_t is always (>= 0 aka UV_MIN and) <= UV_MAX; they cannot escape
their quadness and be NVs.  (This logic may fail if Quad_t is not 8
bytes, but then other things would no doubt fail.)

Also tighten the logic by adding HAS_QUAD, also for the pack case.

Fix for Coverity perl5 CID 28942.

9 years agosi_names access one past the end.
Jarkko Hietaniemi [Fri, 9 May 2014 22:49:25 +0000 (18:49 -0400)]
si_names access one past the end.

Fix for Coverity perl5 CID 45359.

9 years agocleanup on commit "Pseudo-fork dups arg array on argless calls"
Daniel Dragan [Tue, 29 Apr 2014 16:27:42 +0000 (12:27 -0400)]
cleanup on commit "Pseudo-fork dups arg array on argless calls"

less branching, less cpu intructions, easier to read