Nicholas Clark [Thu, 19 May 2011 19:24:14 +0000 (20:24 +0100)]
Fold Abigail's TAP generation logic back into cmpVERSION.pl
Reduce t/porting/cmp_version.t down to an invocation of cmpVERSION.pl with
--tap.
Nicholas Clark [Thu, 19 May 2011 17:25:36 +0000 (18:25 +0100)]
Change the -x option of cmpVERSION.pl to exclude upstream ne 'blead'
Previously it was excluding if CPAN were true, which meant that anything
with a DISTRIBUTION was excluded, including files where blead is upstream,
and hence something we should fix.
Nicholas Clark [Thu, 19 May 2011 17:00:37 +0000 (18:00 +0100)]
Pass the git tag to cmpVERSION.pl with a --tag argument.
If no tag is specified, default to git describe --abbrev=0.
(This is David Golden's suggestion, added t/porting/cmp_version.t in
3d92e8b1e4996571)
Eliminate the source_dir command line argument - this is now always assumed to
be '.'.
Nicholas Clark [Thu, 19 May 2011 16:22:43 +0000 (17:22 +0100)]
Convert cmpVERSION.pl to Getopt::Long from Getopt::Std.
Nicholas Clark [Thu, 19 May 2011 15:55:06 +0000 (16:55 +0100)]
Trim the import list from File::Spec::Functions and don't use File::Find.
Most of the vestigial entries were caused by the refactoring to use git in
42e700c91cf83f56. Use File::Spec::Functions::devnull() in place of hard coded
values based on $^O.
Nicholas Clark [Thu, 19 May 2011 15:39:50 +0000 (16:39 +0100)]
Only load Maintainers.pm if cmpVERSION.pl is invoked with -x
Skip chdir $source_dir with -x, because -x checks that it's '.'
Nicholas Clark [Mon, 23 May 2011 14:05:42 +0000 (15:05 +0100)]
Refactor podcheck.t to slurp files into scalars, instead of an array of lines.
Multiline matches in the regex engine are faster than looping and processing
in Perl space.
Johan Vromans [Mon, 23 May 2011 13:20:21 +0000 (06:20 -0700)]
Incorrect heading and index entries for (*MARK) in pod/perlre.pod
Nicholas Clark [Mon, 23 May 2011 11:10:15 +0000 (12:10 +0100)]
Correct and update the comments about FBMs in Perl_sv_2[inu]v_flags().
Nicholas Clark [Mon, 23 May 2011 09:21:07 +0000 (10:21 +0100)]
Add find2perl as a dependency for the target 'test_prep'.
If t/porting/podcheck.t can't find x2p/find2perl, then it is unable to find an
external target for a pod link in perlutil.pod, which it flags up as an error.
find2perl was already a dependency of the 'all' target, hence without this
rule podcheck.t would pass for 'make all test', but not 'make test'.
Father Chrysostomos [Mon, 23 May 2011 06:23:29 +0000 (23:23 -0700)]
Add another address for Sisyphus
Sisyphus [Mon, 23 May 2011 06:15:30 +0000 (23:15 -0700)]
[perl #91354] win32/makefile.mk needs patching for gcc-4.x.x
The current win32/makefile.mk wants us to edit it when we are using
the gcc-4.x.x compiler. Firstly, we have to signify that we are using
gcc-4.x.x, then we have to nominate (from a supplied list) the name of
the helper dll that needs to be copied to the t folder (in order that
the taint.t tests can pass).
The supplied list of candidates is deficient - the name of the helper
dll from one of my gcc compilers is not listed there. Also, I'm now
finding that a second dll (libstdc++-6.dll) needs to be copied to the
t folder - otherwise the taint.t test still crashes.
The attached makefile.mk patch addresses these issues in such a way
that we don't have to do any editting (re the using of gcc-4.x.x) of
the makefile.mk at all.
There's a small discussion about this on the p5p mailing list in the
thread "win32/makefile.mk patch" (15 may 2011).
This change to the makefile.mk means that README.win32 needs a
slight modification - and the attached README.win32 patch addresses
that issue.
The README.win32 patch also alters the link to the 64-bit (mingw64)
compiler made available by kmx. This has nothing to do with the
subject of this bug report, but I don't see why that correction to
the link (as suggested to me by kmx, in private correspondence)
can't be made.
Max Maischein [Mon, 23 May 2011 04:36:57 +0000 (21:36 -0700)]
Turn $$ into a magical readonly variable that always fetches getpid() instead of caching it
The intent is that by not caching $$, we eliminate one opportunity for bugs:
If one embeds Perl or uses XS and calls fork(3) from C, Perls notion of $$
may go out of sync with what getpid() returns. By always fetching the
value of $$ via getpid(), this bug opportunity is eliminated. The overhead
of always fetching $$ should be small and is likely only used for tempfile
creation, which should be dwarfed by file system accesses.
Father Chrysostomos [Mon, 23 May 2011 01:23:49 +0000 (18:23 -0700)]
Make hash-rt85026.t less noisy
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.
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.
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
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]
Josh Jore [Sun, 22 May 2011 19:25:26 +0000 (12:25 -0700)]
Downgrade Unicode pod escape to ASCII for readbility
Karl Williamson [Sun, 22 May 2011 16:51:40 +0000 (10:51 -0600)]
regcomp.c: Another leak regression
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.
Father Chrysostomos [Sat, 21 May 2011 17:18:26 +0000 (10:18 -0700)]
Test require override with Deparse [perl #62500]
Tom Christiansen [Sat, 21 May 2011 12:19:09 +0000 (05:19 -0700)]
General perlfunc edit; document ‘default’
Father Chrysostomos [Sat, 21 May 2011 05:08:42 +0000 (22:08 -0700)]
Revert "Revert "Missing bug number in d12b49d""
This reverts commit
d33333ec9850d2a0f2f5466e207dcc612dc4dc31.
Father Chrysostomos [Sat, 21 May 2011 05:07:50 +0000 (22:07 -0700)]
Increase constant’s version
in preparation for the next commit
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.
Father Chrysostomos [Sat, 21 May 2011 03:29:46 +0000 (20:29 -0700)]
What’s wrong with me?
Father Chrysostomos [Fri, 20 May 2011 23:43:11 +0000 (16:43 -0700)]
Remove fixed bug from Deparse’s docs
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.
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.
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.
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.
Father Chrysostomos [Fri, 20 May 2011 16:28:51 +0000 (09:28 -0700)]
[perl #91008] Deparse doesn't like each $ref
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.
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.
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.
Karl Williamson [Fri, 20 May 2011 14:27:02 +0000 (08:27 -0600)]
podcheck.t: Fully qualify carp call from package
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.
Karl Williamson [Fri, 20 May 2011 03:10:15 +0000 (21:10 -0600)]
utf8.c: revise comment
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.
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.
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.
Tony Cook [Tue, 29 Mar 2011 10:32:52 +0000 (21:32 +1100)]
handle a static Cwd when generating the deps for x2p/utils
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.
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.
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.
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.
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.
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<>.
Father Chrysostomos [Fri, 20 May 2011 00:05:48 +0000 (17:05 -0700)]
Tests for iterator deletion [perl #85026]
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
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.
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.
Karl Williamson [Thu, 19 May 2011 22:39:20 +0000 (16:39 -0600)]
perlvar: Fix broken links
Karl Williamson [Thu, 19 May 2011 22:38:27 +0000 (16:38 -0600)]
perluniintro: fix broken link
Karl Williamson [Thu, 19 May 2011 22:35:59 +0000 (16:35 -0600)]
perlrecharclass: Fix broken link
Karl Williamson [Thu, 19 May 2011 22:34:27 +0000 (16:34 -0600)]
perlre: Fix broken links
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
Karl Williamson [Thu, 19 May 2011 22:18:47 +0000 (16:18 -0600)]
perlutil: Fix broken links
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.
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
David Mitchell [Thu, 19 May 2011 14:51:45 +0000 (15:51 +0100)]
sv_clear only test for SvOBJECT on >= MG
micro-optimisation
Robin Barker [Sun, 15 May 2011 13:40:46 +0000 (14:40 +0100)]
use __attribute__unused__ to silence -Wunused-but-set-variable
Robin Barker [Sun, 15 May 2011 18:02:29 +0000 (19:02 +0100)]
unused variables in pp_ctl.c
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>
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.
Zsbán Ambrus [Thu, 19 May 2011 05:03:43 +0000 (22:03 -0700)]
[perl #90592] Porting/epigraphs.pod: add 5.14.0(-RC*)
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.
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
Karl Williamson [Sat, 14 May 2011 17:43:05 +0000 (11:43 -0600)]
perluniprops: Add markup, like C<>
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.
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.
Karl Williamson [Fri, 13 May 2011 16:25:16 +0000 (10:25 -0600)]
regcomp.c: \x{17f} can match /\xdf/i
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.
Karl Williamson [Fri, 13 May 2011 16:02:18 +0000 (10:02 -0600)]
fold_grind.t: No longer any TODOs
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.
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().
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.
Karl Williamson [Sat, 14 May 2011 16:07:37 +0000 (10:07 -0600)]
utf8_heavy: Add comments
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.
Karl Williamson [Thu, 12 May 2011 03:07:37 +0000 (21:07 -0600)]
utf8_heavy.pl: Revise comment
Karl Williamson [Wed, 11 May 2011 17:43:16 +0000 (11:43 -0600)]
utf8.c: Remove unnecessary temporary
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.
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
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
Karl Williamson [Mon, 9 May 2011 15:03:13 +0000 (09:03 -0600)]
regex: Add comments
Karl Williamson [Mon, 9 May 2011 15:01:20 +0000 (09:01 -0600)]
fold_grind.t: Slightly change debug stmt
Karl Williamson [Mon, 9 May 2011 14:59:51 +0000 (08:59 -0600)]
fold_grind.t: Make sure special-cased code points are tested
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.
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.
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
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.
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.
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.
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.
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.
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.
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.
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()
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.