This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perl5.git
10 years agoMake hash-rt85026.t less noisy
Father Chrysostomos [Mon, 23 May 2011 01:23:49 +0000 (18:23 -0700)]
Make hash-rt85026.t less noisy

10 years agopodcheck.t: Extract line numbers from strings properly
Karl Williamson [Mon, 23 May 2011 03:21:31 +0000 (21:21 -0600)]
podcheck.t: Extract line numbers from strings properly

There was a typo in this regex.  I added a \b for good measure.
This bug was currently showing up on VMS-only, where a string
was getting returned instead of a hash.  And the regex that
deals with strings had a typo, so wasn't matching.

It remains to be seen if there is an underlying issue on VMS that
was causing this error, and other OSs don't have it.

10 years agopodcheck.t: Skip perltoc
Karl Williamson [Mon, 23 May 2011 02:26:47 +0000 (20:26 -0600)]
podcheck.t: Skip perltoc

This pod is extracted from other pods, and the possible errors in those
extractions just keep propagating to this pod.  I tried to fix this
by having -1 entries in perltoc for the common errors which means
to not output them.  But new ones keep cropping up.  So, reluctantly,
I think it's best to just not process this file.

10 years agoPerl_refcounted_he_inc() needs a dVAR to compile with -DPERL_GLOBAL_STRUCT
Nicholas Clark [Thu, 28 Apr 2011 14:14:03 +0000 (15:14 +0100)]
Perl_refcounted_he_inc() needs a dVAR to compile with -DPERL_GLOBAL_STRUCT

10 years agoRestore building with -DPERL_GLOBAL_STRUCT, broken since 4dc941f7cb795735.
Nicholas Clark [Thu, 28 Apr 2011 13:36:15 +0000 (14:36 +0100)]
Restore building with -DPERL_GLOBAL_STRUCT, broken since 4dc941f7cb795735.

As PL_charclass is a constant, it doesn't need to be accessed via the global
struct. It should be exported via globvar.sym, not PERLVARA() in perlvars.h

[With a PERVARA() it all compiles perfectly, once C<dVAR>s are added where
now needed, but the build loops forever because the (real) charclass array is
never initialised]

10 years agoDowngrade Unicode pod escape to ASCII for readbility
Josh Jore [Sun, 22 May 2011 19:25:26 +0000 (12:25 -0700)]
Downgrade Unicode pod escape to ASCII for readbility

10 years agoregcomp.c: Another leak regression
Karl Williamson [Sun, 22 May 2011 16:51:40 +0000 (10:51 -0600)]
regcomp.c: Another leak regression

10 years agoFix deparsing of subs named :::: and ::::::
Father Chrysostomos [Sun, 22 May 2011 01:38:46 +0000 (18:38 -0700)]
Fix deparsing of subs named :::: and ::::::

Since a name like :::: is now divided up as ::/:: (since commit
088225f), there can be a package called ‘::’. But %:: returns %main::,
not %main::::. The result is that the main package is searched again
and again recursively and stash_subs hangs.

The easiest fix is to put main:: at the beginning of a substash’s name
when fetching the stash.

10 years agoTest require override with Deparse [perl #62500]
Father Chrysostomos [Sat, 21 May 2011 17:18:26 +0000 (10:18 -0700)]
Test require override with Deparse [perl #62500]

10 years agoGeneral perlfunc edit; document ‘default’
Tom Christiansen [Sat, 21 May 2011 12:19:09 +0000 (05:19 -0700)]
General perlfunc edit; document ‘default’

10 years agoRevert "Revert "Missing bug number in d12b49d""
Father Chrysostomos [Sat, 21 May 2011 05:08:42 +0000 (22:08 -0700)]
Revert "Revert "Missing bug number in d12b49d""

This reverts commit d33333ec9850d2a0f2f5466e207dcc612dc4dc31.

10 years agoIncrease constant’s version
Father Chrysostomos [Sat, 21 May 2011 05:07:50 +0000 (22:07 -0700)]
Increase constant’s version
in preparation for the next commit

10 years agoMove an assert
Father Chrysostomos [Sat, 21 May 2011 05:06:35 +0000 (22:06 -0700)]
Move an assert

Due to my own sloppy editing, this assert ending up doing nothing,
as perl would already have crashed before reaching it.

10 years agoWhat’s wrong with me?
Father Chrysostomos [Sat, 21 May 2011 03:29:46 +0000 (20:29 -0700)]
What’s wrong with me?

10 years agoRemove fixed bug from Deparse’s docs
Father Chrysostomos [Fri, 20 May 2011 23:43:11 +0000 (16:43 -0700)]
Remove fixed bug from Deparse’s docs

10 years agoMake Deparse use CORE:: when necessary
Father Chrysostomos [Fri, 20 May 2011 23:40:01 +0000 (16:40 -0700)]
Make Deparse use CORE:: when necessary

Till now, Deparse has not added CORE:: to built-in keywords, even when
they are overridden by subs.  Now it does.

It was simply a matter of adding a ‘keyword’ sub that looks in the
current stash to determine whether there is a possible override.  And
it only does so for overridable non-infix functions.  It returns the
keyword with CORE:: added to the beginning if necessary.  Various
parts of the code have been modified to call this routine.

10 years agopodcheck.t: Improve VMS abilities
Karl Williamson [Fri, 20 May 2011 22:10:29 +0000 (16:10 -0600)]
podcheck.t: Improve VMS abilities

This should solve many of the problems encountered on VMS.  It does
it by lower-casing file names before comparison.

10 years agoDeparse: readpipe with complex expression
Father Chrysostomos [Fri, 20 May 2011 21:03:41 +0000 (14:03 -0700)]
Deparse: readpipe with complex expression

readpipe was always being deparse as `...` or qx.

This commit changes it to use the already-existing pure_string routine
to determine whether it can fit in `` first.

10 years agoregcomp.c: Another memory leak regression
Karl Williamson [Fri, 20 May 2011 16:54:22 +0000 (10:54 -0600)]
regcomp.c: Another memory leak regression

The reference count should be decremented upon freeing.

10 years ago[perl #91008] Deparse doesn't like each $ref
Father Chrysostomos [Fri, 20 May 2011 16:28:51 +0000 (09:28 -0700)]
[perl #91008] Deparse doesn't like each $ref

10 years agoBump Attribute::Handlers version to 0.91
Steffen Mueller [Fri, 20 May 2011 15:57:50 +0000 (17:57 +0200)]
Bump Attribute::Handlers version to 0.91

... to match the CPAN version.

No functional changes.

10 years agoBump/upgrade Filter::Simple version to 0.87
Steffen Mueller [Fri, 20 May 2011 15:54:48 +0000 (17:54 +0200)]
Bump/upgrade Filter::Simple version to 0.87

... to match CPAN release.

No functional changes.

10 years agoFix skip() usage in tests
Steffen Mueller [Fri, 20 May 2011 14:03:07 +0000 (16:03 +0200)]
Fix skip() usage in tests

It needs to know how many tests to skip. This never failed in
blead since it's perl version dependent.

10 years agopodcheck.t: Fully qualify carp call from package
Karl Williamson [Fri, 20 May 2011 14:27:02 +0000 (08:27 -0600)]
podcheck.t: Fully qualify carp call from package

10 years agopodcheck.t: Deal properly with -1 counts
Karl Williamson [Fri, 20 May 2011 03:31:35 +0000 (21:31 -0600)]
podcheck.t: Deal properly with -1 counts

These counts are for things like perltoc which are compendiums of other
pods, and so contain any errors in those other pods, which should be
output with the offending pod and not perltoc.  By setting the counts of
errors to a negative in the db, the message for perltoc is suppressed.
But a message was getting improperly output with perltoc when the
original pod got fixed.

10 years agoutf8.c: revise comment
Karl Williamson [Fri, 20 May 2011 03:10:15 +0000 (21:10 -0600)]
utf8.c: revise comment

10 years agoFilename portability for hash-rt85026.t
Craig A. Berry [Fri, 20 May 2011 12:36:53 +0000 (07:36 -0500)]
Filename portability for hash-rt85026.t

File::Temp::tempdir returns a directory in native syntax.  You
can't just paste a file onto that in Unix syntax and expect it
to work.

10 years agoif List-Util is built statically, depend on $(PERL_EXE) instead of the shared library
Tony Cook [Tue, 29 Mar 2011 11:15:23 +0000 (22:15 +1100)]
if List-Util is built statically, depend on $(PERL_EXE) instead of the shared library

of course, it could be that these dependencies are as redundant as the
rest.

10 years agoremove unused dependency rule generation for Text/ParseWords
Tony Cook [Tue, 29 Mar 2011 10:42:48 +0000 (21:42 +1100)]
remove unused dependency rule generation for Text/ParseWords

1) Text/ParseWords isn't XS, so never appears in dynamic_ext

2) there's no lib/auto/Scalar/Util.$dlext target, the file would be
lib/auto/Scalar/Util/Util.$dlext , but it's built as part of
List-Util, so there's no dependency lib/auto/Scalar/Util/Util.$dlext
anyway.

10 years agohandle a static Cwd when generating the deps for x2p/utils
Tony Cook [Tue, 29 Mar 2011 10:32:52 +0000 (21:32 +1100)]
handle a static Cwd when generating the deps for x2p/utils

10 years agoremove unneeded dependencies against Cwd
Tony Cook [Tue, 29 Mar 2011 10:04:25 +0000 (21:04 +1100)]
remove unneeded dependencies against Cwd

these were added because the build process for Encode and SDBM_File
changes directory, invalidating the original "../lib:../../lib"
PERL5LIB.  With buildcustomize.pl they can change directory safely.

10 years agoAdd USE_LOCALE{,_COLLATE,_CTYPE,_NUMERIC} to the output of perl -V
Nicholas Clark [Fri, 20 May 2011 11:16:57 +0000 (12:16 +0100)]
Add USE_LOCALE{,_COLLATE,_CTYPE,_NUMERIC} to the output of perl -V

These 4 compile-time options should be reported, as they have affect the
behaviour of the interpreter binary (albeit only in a small area). They don't
affect binary compatibility.

10 years agoCorrect comments about B::PV::PVBM.
Nicholas Clark [Tue, 17 May 2011 15:07:17 +0000 (16:07 +0100)]
Correct comments about B::PV::PVBM.

Original comments, partially incorrect, added in 5a44e503dc748f53 and
f4c3658468ba5234.

10 years agoBump the version of PerlIO::encoding following 1c2e8ccaafb0b2b1.
Nicholas Clark [Fri, 20 May 2011 09:19:33 +0000 (10:19 +0100)]
Bump the version of PerlIO::encoding following 1c2e8ccaafb0b2b1.

1c2e8ccaafb0b2b1 fixed a typo in a comment in the XS code.

10 years agoBump the versions of B and Storable following 1b95d04f713d9c56.
Nicholas Clark [Fri, 20 May 2011 08:49:24 +0000 (09:49 +0100)]
Bump the versions of B and Storable following 1b95d04f713d9c56.

1b95d04f713d9c56 changed HvKEYS() to HvUSEDKEYS() in the XS code.

10 years agoUse L<> rather than C<> in the Updated Modules section of perldelta.
Nicholas Clark [Fri, 20 May 2011 08:39:11 +0000 (09:39 +0100)]
Use L<> rather than C<> in the Updated Modules section of perldelta.

Previous perldeltas have been inconsistent with each other as to whether to
use L<> to C<> (but internally consistent). perldelta5140.pod uses L<>, which
is more useful, as it provides a direct link to fuller documentation at the
point where the reader is likely to want to follow it.

Switch the two existing entries from C<> to L<>, and update the perldelta
template to suggest L<>.

10 years agoTests for iterator deletion [perl #85026]
Father Chrysostomos [Fri, 20 May 2011 00:05:48 +0000 (17:05 -0700)]
Tests for iterator deletion [perl #85026]

10 years ago[perl #85026] Deleting the current iterator in void context
Ton Hospel [Fri, 20 May 2011 00:05:16 +0000 (17:05 -0700)]
[perl #85026] Deleting the current iterator in void context

Looking at the delete code I see another strange thing. If the delete
of the current iterator is done with the G_DISCARD flag, the corres-
ponding value is not freed and survives until the lazy deleted entry
gets removed on the next hash iteration. This is easily demonstrated
like this:

perl -wle '
sub DESTROY { print "DESTROY" }
%a=(a=>bless[]);
each %a;
delete $a{a};
print "END"
'

This prints:

END
DESTROY

notice the difference with:

perl -wle '
sub DESTROY { print "DESTROY" }
%hash = (a => bless[]);
each %hash;
$dummy = delete $hash{a}; $dummy = 0;
print "END"
'

This prints:

DESTROY
END

This is easily solved by always replacing the deleted entry value with
&PL_sv_placeholder. It actually simplifies the code a bit except for the
fact that the mro_method_changed from free_hash_ent now has to be done
in hv_delete

10 years agoTests for #85026
Father Chrysostomos [Thu, 19 May 2011 23:54:01 +0000 (16:54 -0700)]
Tests for #85026

Almost all of this is taken verbatim from Ton Hospel’s sample script
for demonstrating the bug.

10 years ago[perl #85026] deleting elements in a HASH iterator
Ton Hospel [Mon, 16 May 2011 15:33:07 +0000 (08:33 -0700)]
[perl #85026] deleting elements in a HASH iterator

Internally a perl HASH is an array of single linked chains of entries.
Deleting an element means removing the correct chain entry by replacing
the pointer to the removed entry with a pointer to the next entry and
then freeing the deleted entry

However, if the deleted element is the current entry the deleted entry
is kept after removing it from the chain and the LAZYDEL flag is set.
Only on the next iteration is the element actually removed and the
iterator is set to the next entry.

However, if you delete the current iterator and then delete the next
element in the same chain the "next" pointer of the iterator is not
updated because the iterator is not on the chain anymore. That means
that when the next iteration looks up the iterator next pointer it
will point to the freed memory of the second element.

This patch fixes the places where the delete is done. Drawback is that
you may never forget to do the lazydel fixup in at any place where the
entry chain gets shortened.

10 years agoperlvar: Fix broken links
Karl Williamson [Thu, 19 May 2011 22:39:20 +0000 (16:39 -0600)]
perlvar: Fix broken links

10 years agoperluniintro: fix broken link
Karl Williamson [Thu, 19 May 2011 22:38:27 +0000 (16:38 -0600)]
perluniintro: fix broken link

10 years agoperlrecharclass: Fix broken link
Karl Williamson [Thu, 19 May 2011 22:35:59 +0000 (16:35 -0600)]
perlrecharclass: Fix broken link

10 years agoperlre: Fix broken links
Karl Williamson [Thu, 19 May 2011 22:34:27 +0000 (16:34 -0600)]
perlre: Fix broken links

10 years agopodcheck.t: Missing diagnostics
Karl Williamson [Thu, 19 May 2011 22:29:11 +0000 (16:29 -0600)]
podcheck.t: Missing diagnostics

podcheck.t was not outputting a message when all occurrences of
an issue were removed, and hence the database wasn't getting
regenerated

10 years agoperlutil: Fix broken links
Karl Williamson [Thu, 19 May 2011 22:18:47 +0000 (16:18 -0600)]
perlutil: Fix broken links

10 years agoMaintainers.pl: fix podlators entry
David Mitchell [Thu, 19 May 2011 21:00:15 +0000 (22:00 +0100)]
Maintainers.pl: fix podlators entry

The mapping didn't include the basic '' => cpan/podlators entry,
so core-cpan-diff was reporting lots of errors.
Also, there was much strangeness with *.PL files.

10 years agosv_clear: destructor may change SV type
David Mitchell [Thu, 19 May 2011 15:21:07 +0000 (16:21 +0100)]
sv_clear: destructor may change SV type

so re-initialise the 'type' var afterwards

10 years agosv_clear only test for SvOBJECT on >= MG
David Mitchell [Thu, 19 May 2011 14:51:45 +0000 (15:51 +0100)]
sv_clear only test for SvOBJECT on >= MG

micro-optimisation

10 years agouse __attribute__unused__ to silence -Wunused-but-set-variable
Robin Barker [Sun, 15 May 2011 13:40:46 +0000 (14:40 +0100)]
use __attribute__unused__ to silence -Wunused-but-set-variable

10 years agounused variables in pp_ctl.c
Robin Barker [Sun, 15 May 2011 18:02:29 +0000 (19:02 +0100)]
unused variables in pp_ctl.c

10 years agoDocs: perlhack: Use correct shell code and better git/shell constructs
Michael Witten [Mon, 16 May 2011 01:57:37 +0000 (01:57 +0000)]
Docs: perlhack: Use correct shell code and better git/shell constructs

The example commands for using `git format-patch' and `perlbug' have
been streamlined, and (most importantly) single quotes have been
replaced with double quotes for constructing the argument to `-s'.

Signed-off-by: Michael Witten <mfwitten@gmail.com>
10 years agoRegenerate known_pod_issues.dat
Father Chrysostomos [Thu, 19 May 2011 17:48:37 +0000 (10:48 -0700)]
Regenerate known_pod_issues.dat

podcheck.t is producing spurious failures for two files.

10 years ago[perl #90592] Porting/epigraphs.pod: add 5.14.0(-RC*)
Zsbán Ambrus [Thu, 19 May 2011 05:03:43 +0000 (22:03 -0700)]
[perl #90592] Porting/epigraphs.pod: add 5.14.0(-RC*)

10 years agoregcomp.c: Fix bug in inversion list intersection
Karl Williamson [Tue, 17 May 2011 23:28:51 +0000 (17:28 -0600)]
regcomp.c: Fix bug in inversion list intersection

This code was derived from published code, which says use at your
own risk.   And in fact had bugs.  I don't believe these show up in
5.14, as I think you have to have a list that has been inverted for this
to happen.

The comments describe what should have been done.

10 years agoregcomp.c: Add new macro for readability
Karl Williamson [Tue, 17 May 2011 23:25:22 +0000 (17:25 -0600)]
regcomp.c: Add new macro for readability

Adding this macro which is the complement of an existing macro helps
understanding what is happening at its point of use

10 years agoperluniprops: Add markup, like C<>
Karl Williamson [Sat, 14 May 2011 17:43:05 +0000 (11:43 -0600)]
perluniprops: Add markup, like C<>

10 years agofold_grind.t: Revamp test case coverage analysis
Karl Williamson [Fri, 13 May 2011 16:44:06 +0000 (10:44 -0600)]
fold_grind.t: Revamp test case coverage analysis

The kludgy analysis of what tests to do is hereby simplified and
improved, finding a few extra bugs.

10 years agoregcomp.c: Greek multi-char folds fix
Karl Williamson [Fri, 13 May 2011 16:30:39 +0000 (10:30 -0600)]
regcomp.c: Greek multi-char folds fix

GREEK PROSGEGRAMMENI and COMBINING GREEK YPOGEGRAMMENI fold to the
the first character of one of the tricky folds, and hence need
to be treated as potentially tricky themselves.

10 years agoregcomp.c: \x{17f} can match /\xdf/i
Karl Williamson [Fri, 13 May 2011 16:25:16 +0000 (10:25 -0600)]
regcomp.c: \x{17f} can match /\xdf/i

10 years agofold_grind.t: remove unnecessary tests
Karl Williamson [Fri, 13 May 2011 16:22:16 +0000 (10:22 -0600)]
fold_grind.t: remove unnecessary tests

This is supposed to test weird combinations of things.  Tests like
    'ss' =~ /SS/i
aren't weird, and so can be skipped.

10 years agofold_grind.t: No longer any TODOs
Karl Williamson [Fri, 13 May 2011 16:02:18 +0000 (10:02 -0600)]
fold_grind.t: No longer any TODOs

10 years agoFix some multi-char /i fold bugs
Karl Williamson [Thu, 12 May 2011 03:39:19 +0000 (21:39 -0600)]
Fix some multi-char /i fold bugs

Consider U+FB05 and U+FB06.  These both fold to 'st', and hence should
match each other under /i.  However, Unicode doesn't furnish a rule for
this, and Perl hasn't been smart enought to figure it out.  The bug that
shows up is in constructs like

    "\x{fb06}" =~ /[^\x{fb05}]/i

succeeding.  Most of these instances also have a 'S' entry in Unicode's
CaseFolding.txt, which avoids the problem (as mktables was earlier
changed to include those in the generated table).  But there were
several code points that didn't.

This patch changes utf8.c to look for these when constructing it's
inverted list of case fold equivalents.  An alternative would have been
to change mktables instead to look for them and create synthetic rules.
But, this is more general in case the function ends up being used for
other things.

I will change fold_grind.t to test for these in a separate commit.

10 years agoutf8.c: Remove soon-to-be-obsoleted comment
Karl Williamson [Thu, 12 May 2011 03:13:30 +0000 (21:13 -0600)]
utf8.c: Remove soon-to-be-obsoleted comment

This comment will no longer apply, as the code it talked about is
moving into swash_init().

10 years agoutf8_heavy: Return pointer to special treatment hash.
Karl Williamson [Sat, 14 May 2011 16:10:21 +0000 (10:10 -0600)]
utf8_heavy: Return pointer to special treatment hash.

Many of the mapping tables that utf8_heavy.pl deals with have maps that
don't fit into the general scheme of things, and a hash is generated for
those.  This patch causes utf8_heavy to add an entry to the object it
generates containing a reference to this hash.  Prior to this, the name
of the hash had to be known to the users of the table.

10 years agoutf8_heavy: Add comments
Karl Williamson [Sat, 14 May 2011 16:07:37 +0000 (10:07 -0600)]
utf8_heavy: Add comments

10 years agomktables: Add info giving specials hash name
Karl Williamson [Thu, 12 May 2011 03:08:36 +0000 (21:08 -0600)]
mktables: Add info giving specials hash name

mktables creates %utf8::SwashInfo in each table it generates, giving
some info about the table.  Add an entry to this for tables that have
a hash of special mappings, giving the name of that hash.

10 years agoutf8_heavy.pl: Revise comment
Karl Williamson [Thu, 12 May 2011 03:07:37 +0000 (21:07 -0600)]
utf8_heavy.pl: Revise comment

10 years agoutf8.c: Remove unnecessary temporary
Karl Williamson [Wed, 11 May 2011 17:43:16 +0000 (11:43 -0600)]
utf8.c: Remove unnecessary temporary

10 years agoutf8.c: "<" should be "<="
Karl Williamson [Wed, 11 May 2011 17:38:15 +0000 (11:38 -0600)]
utf8.c: "<" should be "<="

av_len() is misnamed, and hence led me earlier to stop the loop
one shy of what it should have been.  No actual bugs were caused by
this, but it could cause a duplicate entry in an array, which is
searched linearly, hence a slight slowdown.

10 years agofold_grind.t: Refactor subtests
Karl Williamson [Tue, 10 May 2011 00:57:02 +0000 (18:57 -0600)]
fold_grind.t: Refactor subtests

This causes run_test() to be part of the subtests, and makes a subtest
for each pair of code points tested plus the character set.  This
results in fewer tests output, plus more information about what's
happening

10 years agoPATCH: [perl #88822] Re: Test failure t/re_fold_grind.t with bleadperl
Karl Williamson [Mon, 18 Apr 2011 18:16:29 +0000 (12:16 -0600)]
PATCH: [perl #88822] Re: Test failure t/re_fold_grind.t with bleadperl

10 years agoregex: Add comments
Karl Williamson [Mon, 9 May 2011 15:03:13 +0000 (09:03 -0600)]
regex: Add comments

10 years agofold_grind.t: Slightly change debug stmt
Karl Williamson [Mon, 9 May 2011 15:01:20 +0000 (09:01 -0600)]
fold_grind.t: Slightly change debug stmt

10 years agofold_grind.t: Make sure special-cased code points are tested
Karl Williamson [Mon, 9 May 2011 14:59:51 +0000 (08:59 -0600)]
fold_grind.t: Make sure special-cased code points are tested

10 years agofold_grind.t: Add testing of multi-char folds in pattern
Karl Williamson [Mon, 9 May 2011 14:57:29 +0000 (08:57 -0600)]
fold_grind.t: Add testing of multi-char folds in pattern

Previously these were skipped.  Now skip just the ones that don't make
sense or aren't implemented.

10 years agoregcomp.c: Add two tricky fold cases
Karl Williamson [Mon, 9 May 2011 14:43:29 +0000 (08:43 -0600)]
regcomp.c: Add two tricky fold cases

These two characters fold to lower-case characters that are involved
in tricky folds, and hence these can be too.

10 years agoRevamp podcheck.t
Karl Williamson [Wed, 18 May 2011 22:23:17 +0000 (16:23 -0600)]
Revamp podcheck.t

This new podcheck.t catches more problems, and tests more pods than
the current one, while suppressing some existing warnings that really
aren't problems.

It takes longer to execute.  I have profiled it, and most of the increased
time appears to be because of testing more pods.

A complete pod for its usage is included

10 years agoimprove api entries for hv_clear() and hv_undef()
David Mitchell [Wed, 11 May 2011 15:50:45 +0000 (16:50 +0100)]
improve api entries for hv_clear() and hv_undef()

The =apidoc entries for hv_clear() and hv_undef() were a bit spartan.
Make it clearer what the two functions actually do, and the relationship
between them.

10 years agoensure hash iterator gets deleted
David Mitchell [Wed, 11 May 2011 15:17:08 +0000 (16:17 +0100)]
ensure hash iterator gets deleted

The recent commits to make sv_clear() iterative when freeing a hash,
introduced a bug. If the hash only has one key, and that becomes the
iterator, and is then deleted; then when the hash is freed, the LAZYDEL
feature is skipped, and the iterated hash value fails to get deleted.

The fix is simple: check for LAZYDEL before return is keys == 0.

10 years agoassume cleared hv can't be re-blessed
David Mitchell [Wed, 11 May 2011 14:31:40 +0000 (15:31 +0100)]
assume cleared hv can't be re-blessed

followup to previous commit. I'm fairly confident now that a HV being
freed in sv_clear() can never get re-blessed, and thus its SvSTASH field is
*always* safe to use.

The logic behind this is that once you get to sv_clear(), the HV has a
refcnt of zero, which means either:

* nothing references this, so there's no way to bless it;
* we're in SVf_BREAK territory, in which case something may still
  hold a reference to it, but all destructors will have already been
  called, so nothing can call bless.

10 years agomake hv freeing iterative rather than recursive
David Mitchell [Wed, 11 May 2011 11:07:14 +0000 (12:07 +0100)]
make hv freeing iterative rather than recursive

make sv_clear() iteratively free the elements of a hash, rather than
recursing. This stops freeing deeply nested hash of hash structures from
blowing the stack.

This commit is relatively straightfoward, now that
a) the infrastruure is already in place in sv_clear to iteratively
   free AVs;
b) the long sequence of commits leading up to this has provided us with
    the hfree_next_entry() function, which returns just the next sv in the
    hash that needs freeing.

When starting to free a new hash, we have to save the old value of iter_sv
somewhere; we do this by sticking it in the unused SvSTASH slot of the HV.
This slot shouldn't get messed with, since, but this time we've already
called the destructor on this object, and we should have a refcount of
zero, so no destructor should be able to see us to rebless us.

Ideally we'd like to be able to save the old index into HvARRAY when
freeing a new HV, but I couldn't think of anywhere to hide it.
So we get sub-optimal scanning of the parent's HvARRAY when freeing hashes
of hashes.

10 years agoadd hfree_next_entry(), hv_free_ent_ret()
David Mitchell [Tue, 10 May 2011 18:06:45 +0000 (19:06 +0100)]
add hfree_next_entry(), hv_free_ent_ret()

Move body of hfreeentries()' central loop into a new function,
hfree_next_entry(); leaving hfreeentries() as a simple loop that calls
hfree_next_entry() until there are no entries left.

This will in future allow sv_clear() to free a hash iteratively rather
than recursively.

Similarly, turn hv_free_ent() into a thin wrapper around a new function,
hv_free_ent_ret(), which doesn't free HeVAL(), but rather just returns the
SV instead.

10 years agoremove 'hfreeentries failed to free hash' panic
David Mitchell [Tue, 10 May 2011 16:24:29 +0000 (17:24 +0100)]
remove 'hfreeentries failed to free hash' panic

Currently perl attempts to clear a hash 100 times before panicking.
So for example, if a naughty destructor keeps adding things back into the
hash, this will eventually panic.

Note that this can usually only occur with %h=() or undef(%h), since
when freeing a hash, there's usually no reference to the hash that a
destructor can use to mess with the hash.

Remove this limit (so it may potentially loop forever).

My reasoning is that (a) if the user wants to keep adding things back into
the hash, who are we to stop her? (b) as part of of the process of making
sv_clear() non-recursive when freeing hashes, I'm trying to reduce the
amount of state that must be maintained between each iteration.

Note that arrays currently don't have a limit.

10 years agohv_free_ent: free SV as last action
David Mitchell [Tue, 10 May 2011 12:52:48 +0000 (13:52 +0100)]
hv_free_ent: free SV as last action

Move the freeing of the SV from near the beginning to the end of
hv_free_ent(); i.e. free the HE before the SV. Ideally, this should cause
no change in behaviour, but will make using an iterative HV freeing
scheme easier.

10 years agoHV backrefs: another simplification
David Mitchell [Tue, 3 May 2011 16:16:29 +0000 (17:16 +0100)]
HV backrefs: another simplification

Now that HV backrefs are only stored in HvAUX, don't go looking for them
in magic too in sv_clear()

10 years agoassert that HvARRAY is NULL when freeing an HV
David Mitchell [Tue, 3 May 2011 16:10:46 +0000 (17:10 +0100)]
assert that HvARRAY is NULL when freeing an HV

The code path that leads to HvAUX being empty and thus HvARRAY being
freed, is non-obvious: so put in an assert against any future failure.

10 years agoS_hfreeentries: collapse two loops
David Mitchell [Tue, 3 May 2011 15:41:06 +0000 (16:41 +0100)]
S_hfreeentries: collapse two loops

S_hfreeentries() has two nested infinite loops: the inner one
does one sweep through all buckets, freeing all entries in each bucket;
the outer loop repeats the process if new keys have been added in the
meantime.
Collapse these two into a single 'while (keys) {}' loop.
Should be functionally the same, but simpler.

10 years agohfreeentries zeros HvARRAY now, so skip manual
David Mitchell [Tue, 3 May 2011 15:07:51 +0000 (16:07 +0100)]
hfreeentries zeros HvARRAY now, so skip manual

Formerly, hv_clear() and hv_undef() zeroed the contents of
HvARRAY after calling hfreeentries(), but that sub now zeroes
each elements as a by-product of its deleting algorithm.
So we can skip the Zero().

10 years agosimplify HV backref code
David Mitchell [Tue, 3 May 2011 10:41:27 +0000 (11:41 +0100)]
simplify HV backref code

Now that HV backref data is always stored in HvAUX and never in magic,
update the various backref handling functions to account for that.

10 years agomake hash emptying non-atomic
David Mitchell [Tue, 3 May 2011 09:51:17 +0000 (10:51 +0100)]
make hash emptying non-atomic

Currently, when empting a hash of its elements (e.g. via
undef(%h), or %h=()), HvARRAY field is temporarily zeroed, so that
any destructors called on the freed elements see an empty hash.

Change this so that they see any remaining elements. Thus,
%h=() becomes more like C<delete $h{$_} for keys %h>.

The atomic behaviour was introduced (by me) in 2003 with commit
2f86008e34264, to fix RT #3096. This concerned element destructors
that messed with the hash being undeffed, causing unrefed var errors
and the like.

At the time, simply setting HvARRAY to null for the duration seemed like a
simple fix. However, it didn't take account of destructors adding new
elements to the list, thus re-creating HvARRAY. This was subsequently
fixed. Then, the HvAUX structure was invented, which meant that optional
hash fields were hidden away at the end of HvARRAY. This meant that
hfreeentries() acquired a whole bunch of extra code to copy these fields
around between the original HvARRAY and the new HvARRAY and then back
again, and temporarily squirrelling the backref array in backref magic
rather than in HvAUX.

In short, hfreeentries() became a 200 line sprawling mess.
This commit reduces it back to 70, and makes everything conceptually
simpler.

It does however change user-level visible behaviour (back to pre-2003),
but note that the new behaviour now matches the behaviour that arrays have
always had (i.e. destructors see a partially-emptied array).

Note that backref magic for HVs is now always stored in HvAUX

10 years agounify PERL_HASH and PERL_HASH_INTERNAL
David Mitchell [Thu, 28 Apr 2011 15:33:35 +0000 (16:33 +0100)]
unify PERL_HASH and PERL_HASH_INTERNAL

Those two macros expand into two large, almost identical chunks of code.
The only difference between the two is the source of the hash seed.
So parameterize this into a new PERL_HASH_INTERNAL_() macro.

Also, there are a couple of places in hv.c that do the rough equivalent of

    if (HvREHASH(hv))
key = PERL_HASH_INTERNAL(...)
    else
key = PERL_HASH(...)

which incorporates two complete macro expansions into the code.
Reorganise them to be

    key = PERL_HASH_INTERNAL_(..., HvREHASH(hv))

10 years agosimplify hv_clear
David Mitchell [Tue, 26 Apr 2011 15:07:50 +0000 (16:07 +0100)]
simplify hv_clear

Don't use a goto when an else will do

i.e. replace

    if (..) {
        A
        goto reset
    }
    B
    reset:

with

    if (..) {
        A
    }
    else {
        B
    }

10 years agoPerl_ck_split: Avoid unnecessary assignment
Michael Witten [Fri, 8 Apr 2011 00:20:48 +0000 (00:20 +0000)]
Perl_ck_split: Avoid unnecessary assignment

Signed-off-by: Michael Witten <mfwitten@gmail.com>
10 years ago[perl #90594] PATCH for 5.14.1 perlop.pod
Tom Christiansen [Thu, 19 May 2011 05:06:54 +0000 (22:06 -0700)]
[perl #90594] PATCH for 5.14.1 perlop.pod

10 years agoIncrease t::OptreeCheck’s version
Father Chrysostomos [Thu, 19 May 2011 13:13:40 +0000 (06:13 -0700)]
Increase t::OptreeCheck’s version

cmp_version.t was complaining.

Why does this even *have* a version?

10 years ago[perl #90306] Fix simple typos
Marcel Grünauer [Thu, 19 May 2011 04:56:51 +0000 (21:56 -0700)]
[perl #90306] Fix simple typos

10 years agoIncrease B::Concise’s version
Father Chrysostomos [Thu, 19 May 2011 04:53:23 +0000 (21:53 -0700)]
Increase B::Concise’s version

because of the upcoming patch

10 years ago[perl #90122] Make h2ph correctly search gcc include directories
Niko Tyni [Thu, 19 May 2011 04:44:06 +0000 (21:44 -0700)]
[perl #90122] Make h2ph correctly search gcc include directories

System header conversion with "h2ph -a" is currently broken on Ubuntu
Natty and Oneiric (unless the gcc-multilib package is installed for
backward compatibility), resulting in things like

 # perl -e 'require "syscall.ph"'
 Can't locate asm/unistd.ph in @INC [...]

This happens because Ubuntu has switched to a 'multiarch' setup, see
<https://wiki.ubuntu.com/MultiarchSpec> for details.

The asm subdirectory isn't in $Config{usrinc} anymore: /usr/include/asm
is now /usr/include/x86_64-linux-gnu/asm. (The third component of the
new path varies with the actual architecture.)

gcc --print-search-dirs doesn't really tell anything about where gcc
looks for the include directories, it was just used to find the gcc
internal directory prefix.

Parse the output of "gcc -v -E" instead, and append $Config{usrinc}
for safety. Duplicates shouldn't matter.

The h2ph "-a" switch isn't currently tested automatically, and that
seems nontrivial to do portably. Manual testing was done with

 # mkdir ttt
 # ./perl -Ilib ./utils/h2ph -a -d $(pwd)/ttt syscall.h

The gcc invocation has been tested to work with gcc 4.6, 4.1, and 3.3.

http://bugs.debian.org/625808
https://bugs.launchpad.net/bugs/777903

10 years agoRemove PERL_UNUSED_ARG() from Perl_magic_clearsig(), missed by 179c85a2d774d3be
Nicholas Clark [Fri, 13 May 2011 09:48:07 +0000 (10:48 +0100)]
Remove PERL_UNUSED_ARG() from Perl_magic_clearsig(), missed by 179c85a2d774d3be