perl.git
8 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.

8 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.

8 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.

8 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

8 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.

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

8 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.

8 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.

8 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.

8 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

8 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.

8 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.

8 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.

8 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.

8 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.

8 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<>.

8 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]

8 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

8 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.

8 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.

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

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

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

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

8 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

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

8 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.

8 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

8 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

8 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

8 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

8 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>
8 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.

8 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*)

8 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.

8 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

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

8 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.

8 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.

8 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

8 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.

8 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

8 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.

8 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().

8 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.

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

8 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.

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

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

8 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.

8 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

8 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

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

8 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

8 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

8 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.

8 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.

8 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

8 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.

8 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.

8 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.

8 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.

8 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.

8 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.

8 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.

8 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()

8 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.

8 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.

8 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().

8 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.

8 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

8 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))

8 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
    }

8 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>
8 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

8 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?

8 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

8 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

8 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

8 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

8 years agoRemove duplicate code from pp_study(), caused by a4f4e9060b702ac8.
Nicholas Clark [Thu, 19 May 2011 10:07:29 +0000 (11:07 +0100)] 
Remove duplicate code from pp_study(), caused by a4f4e9060b702ac8.

The duplicated code could have had no effect - for the case of pos <= 0
pp_study had already returned NO. The second call to SvPV() would have had no
side effects, because scalars with side effects don't have SvPOK() true, so
would also have already returned NO.

8 years agoCreate open_print_header() to avoid duplicate parameters to open_new().
Nicholas Clark [Sat, 14 May 2011 21:28:58 +0000 (22:28 +0100)] 
Create open_print_header() to avoid duplicate parameters to open_new().

8 years agoRename do_not_edit() to open_print_header(), and move open_new() into it.
Nicholas Clark [Sat, 14 May 2011 21:28:08 +0000 (22:28 +0100)] 
Rename do_not_edit() to open_print_header(), and move open_new() into it.

This removes duplication of open_new() calls.

8 years agoAdd a 'quote' argument to read_only_top(), to pass in an optional Tolkien.
Nicholas Clark [Sat, 14 May 2011 21:13:56 +0000 (22:13 +0100)] 
Add a 'quote' argument to read_only_top(), to pass in an optional Tolkien.

Use this in embed.pl for perlapi.c, and reentr.pl for reentr.c.

8 years agoAdd an optional third argument to open_new(), to invoke read_only_top() with.
Nicholas Clark [Sat, 14 May 2011 20:59:38 +0000 (21:59 +0100)] 
Add an optional third argument to open_new(), to invoke read_only_top() with.

Merge together many calls to open_new() and read_only_top().

8 years agoIn regen/uconfig_h.pl use read_only_bottom_close_and_rename().
Nicholas Clark [Sat, 14 May 2011 18:11:27 +0000 (19:11 +0100)] 
In regen/uconfig_h.pl use read_only_bottom_close_and_rename().

This eliminates the only remaining external caller of read_only_bottom(), so
inline read_only_bottom() into read_only_bottom_close_and_rename().

8 years agoMerge safer_close() and rename_if_different() into close_and_rename()
Nicholas Clark [Sat, 14 May 2011 17:16:50 +0000 (18:16 +0100)] 
Merge safer_close() and rename_if_different() into close_and_rename()

Inline safer_rename() into its only caller, close_and_rename().

8 years agoAdd an optional 'mode' argument to open_new(), to open for appending.
Nicholas Clark [Sat, 14 May 2011 16:22:55 +0000 (17:22 +0100)] 
Add an optional 'mode' argument to open_new(), to open for appending.

Use this in regen/uconfig_h.pl

8 years agoRename safer_open() to open_new(), and eliminate the first parameter.
Nicholas Clark [Sat, 14 May 2011 16:08:56 +0000 (17:08 +0100)] 
Rename safer_open() to open_new(), and eliminate the first parameter.

Update the SHA256s where necessary in the generated files.

8 years agoIn makemeta, pass the final file name as the second argument to safer_open()
Nicholas Clark [Sat, 14 May 2011 15:30:01 +0000 (16:30 +0100)] 
In makemeta, pass the final file name as the second argument to safer_open()

With this change, all callers to safer_open() pass 2 arguments.

8 years agostudy uses I32 internally for offsets, so should be skipped for long strings.
Nicholas Clark [Thu, 19 May 2011 09:14:16 +0000 (10:14 +0100)] 
study uses I32 internally for offsets, so should be skipped for long strings.

It already skips for anything that isn't a plain byte string with non-zero
length. Otherwise it risks becoming confused for strings longer than 2**31.

8 years agoRemove empty #ifdef/#else/#endif block.
Nicholas Clark [Thu, 19 May 2011 08:56:20 +0000 (09:56 +0100)] 
Remove empty #ifdef/#else/#endif block.

This was added (with contents) in b162af07ec759e1b. The contents were moved
elsewhere in the refactoring of ac09da3b9065d6e7, but that change failed to
remove the block it had now emptied.

8 years agoAvoid make distclean failing if t/tmp* matches a directory.
Nicholas Clark [Mon, 16 May 2011 11:17:21 +0000 (12:17 +0100)] 
Avoid make distclean failing if t/tmp* matches a directory.

Some of the tests in t/ make directories with names generated by the test.pl
tempfile(), and if they exit abnormally without deleting them, this would cause
distclean to fail. So change `rm -f t/tmp*` to `rm -rf t/tmp*`

Remove other cruft from the same line in the Makefile.
t/misctmp* hasn't been generated since 7a7e49369367a634.
t/forktmp* hasn't been generated since 1c25d394345c1b97.
t/io/fs.t has deleted t/c itself since 44a8e56aa037ed0f.
(Whilst it might abort and fail to delete it, there's no special treatment
in the Makefile for the other file that it creates, "t/TEST$$")

8 years agobdec6fb9 changed utils/Makefile.SH - this needs replicating in utils/Makefile
Nicholas Clark [Thu, 19 May 2011 08:21:56 +0000 (09:21 +0100)] 
bdec6fb9 changed utils/Makefile.SH - this needs replicating in utils/Makefile

(There's a less than idea situation with a somewhat complex history of trying
to resolve it, where utils/Makefile is in the repository for the use of
platforms unable to run utils/Makefile.SH)

8 years agoIn t/op/reset.t, don't eval "" in void context - die if something goes wrong.
Nicholas Clark [Mon, 11 Apr 2011 19:51:06 +0000 (20:51 +0100)] 
In t/op/reset.t, don't eval "" in void context - die if something goes wrong.

Because sometimes the "it can never happen" does. For example, "panic: free
from wrong pool". And it's awfully confusing if the error message is eaten.
There's not even a "I barfed you an error but then I eated it" caption to give
a clue about what happened.

8 years agoIn Perl_op_clear(), uncomment the call to mad_free()
Nicholas Clark [Mon, 11 Apr 2011 19:31:29 +0000 (20:31 +0100)] 
In Perl_op_clear(), uncomment the call to mad_free()

Free the MADPROPs when freeing their parent OP, now that all the other bugs are
fixed.

8 years agoIn S_fold_constants() under MAD, need to copy the SV representing the result.
Nicholas Clark [Mon, 11 Apr 2011 19:25:04 +0000 (20:25 +0100)] 
In S_fold_constants() under MAD, need to copy the SV representing the result.

For the non-MAD case (the historical default), it was fine to use pad_swipe()
(which doesn't adjust any part of the OS), because the OS was freed soon after.
However, the MAD code doesn't free the OS, hence as-was, without this change,
the OS still thought that it owned the pad slot, and much jollity resulted as
two different parts of the code fought over whichever SV had the bad luck to
next be billeted there.

8 years agoUnder ithreads, convert SVOPs stored in MADPROPs to PADOPs.
Nicholas Clark [Mon, 11 Apr 2011 19:18:49 +0000 (20:18 +0100)] 
Under ithreads, convert SVOPs stored in MADPROPs to PADOPs.

Else if a child thread attempts to free an optree with MADPROPs containing OPs
pointing directly to SVs, it will by trying to free SVs to the wrong
interpreter, at which point bad things(tm) happen.

(There still seems to be some fixing needed for the MADPROPs direct pointers,
but as no tests are failing because of them, I'm postponing them until the
failures are addressed)

8 years agoAllocate MADPROPs using PerlMemShared_malloc()
Nicholas Clark [Mon, 11 Apr 2011 19:14:34 +0000 (20:14 +0100)] 
Allocate MADPROPs using PerlMemShared_malloc()

As the MADPROPs are referenced from the optree, which is itself shared,
MADPROPs can't use the default malloc(), which is per i-thread, lest a
child thread frees the optree, and bad things(tm) happen. (a "free to wrong
pool" panic if you're on Win32, or elsewhere if you've got DEBUGGING)

8 years agoscan_heredoc could reallocate PL_parser->linestr's PV
David Leadbeater [Sat, 14 May 2011 12:57:21 +0000 (13:57 +0100)] 
scan_heredoc could reallocate PL_parser->linestr's PV

Since f0e67a1 it was possible the freed buffer may be read from when
parsing a heredoc. This adds a call to lex_grow_linestr to grow the
buffer and ensure the pointers in PL_parser are updated.

The bug is pretty hard to reproduce, hence no test. I'm able to
reproduce it with the following:

  perl -Meverywhere=re,debug -MParams::Util -e1