platform/upstream/perl.git
12 years agoDon’t create formats after compilation errors
Father Chrysostomos [Tue, 7 Aug 2012 04:59:17 +0000 (21:59 -0700)]
Don’t create formats after compilation errors

Otherwise you can end up with a format that has nonsensical op tree,
but it gets attached and you can call it anyway.

12 years agoAdd freed ops to PL_op_(name|desc)
Father Chrysostomos [Tue, 7 Aug 2012 00:52:10 +0000 (17:52 -0700)]
Add freed ops to PL_op_(name|desc)

This is useful for debugging, especially with -DT.

12 years agotoke.c: Fix confused interp-in-format parsing
Father Chrysostomos [Mon, 6 Aug 2012 21:34:25 +0000 (14:34 -0700)]
toke.c: Fix confused interp-in-format parsing

The lexer keeps track of how many levels of brackets it is currently
in (including the = and . delimiting formats, which count as brackets)
in PL_lex_brackets.

When parsing a format, the lexer sets lex_formbrack to the form’s
bracket number.  Whitespace parsing takes note of this, and avoids
reading beyond the end of the current line inside a format, unless it
is in an inner bracketed construct.  So this:

format =
@
$a
 + $b
.

treats ‘ + $b’ as a literal string, which becomes the second line
of output.

But this:

format =
@
{ $a
   + $b }
.

treats the whole {...} block as the argument for the first format pic-
ture line.

For interpolating (i.e., quoted) constructs, the lexer temporarily
resets the bracket count.  This is so that when it reaches the final
brace in "${...}foo()" it can parse the rest (foo()) as a constant,
rather than a sub call.

When the bracket count was reset, lex_formbrack was left as it was,
resulting in confusion:

# ok
format =
@
${; use
    strict}
.

# also ok
format =
@
"${; {use
      strict} }"
.

# syntax error (or crash)
format =
@
"${; use
     strict }"
.

# crash
format =
@
"${ use
    strict }"
.

When the bracket count is localised and reset at the start of a quoted
construct, we now do the same with lex_formbrack.

12 years agoUpgrade IO-Compress to 2.055
Steve Hay [Wed, 8 Aug 2012 13:15:41 +0000 (14:15 +0100)]
Upgrade IO-Compress to 2.055

12 years agoUpgrade Compress-Raw-Bzip2 and Compress-Raw-Zlib to 2.055
Steve Hay [Wed, 8 Aug 2012 13:09:53 +0000 (14:09 +0100)]
Upgrade Compress-Raw-Bzip2 and Compress-Raw-Zlib to 2.055

12 years agoMAgic for Zlib & Bzip2
Paul [Sat, 4 Aug 2012 15:53:10 +0000 (16:53 +0100)]
MAgic for Zlib & Bzip2

12 years agoignore PERL_XMLDUMP when tainting
Tony Cook [Wed, 8 Aug 2012 11:29:29 +0000 (13:29 +0200)]
ignore PERL_XMLDUMP when tainting

In theory this is a security issue, but from discussion on the
security list that the system perl (or the perl used for anything
critical) is wildly unlikely to have been built with -Dmad.

12 years agoDon't try to set perms in makerel on files which no longer exist
Steve Hay [Wed, 8 Aug 2012 08:22:40 +0000 (09:22 +0100)]
Don't try to set perms in makerel on files which no longer exist

12 years agoAdd /Module/CoreList/TieHashDelta.pm to lib/.gitignore
Steve Hay [Wed, 8 Aug 2012 08:12:00 +0000 (09:12 +0100)]
Add /Module/CoreList/TieHashDelta.pm to lib/.gitignore

12 years agoAllow .tgz as a recognized suffix in core-cpan-diff
Steve Hay [Wed, 8 Aug 2012 07:47:51 +0000 (08:47 +0100)]
Allow .tgz as a recognized suffix in core-cpan-diff
otherwise Memoize-1.03.tgz gets skipped.

12 years agoNote that core-cpan-diff always requires diff(1), even without --diff
Steve Hay [Wed, 8 Aug 2012 07:44:59 +0000 (08:44 +0100)]
Note that core-cpan-diff always requires diff(1), even without --diff

12 years agoUse _strtoi64, _strtoui64 and _atoi64 for WIN64 VC++ builds
Steve Hay [Tue, 7 Aug 2012 07:53:42 +0000 (08:53 +0100)]
Use _strtoi64, _strtoui64 and _atoi64 for WIN64 VC++ builds

VC++ has QUADKIND == QUAD_IS___INT64 so the "secret handshakes" were only
getting used for WIN64 GCC builds (where QUADKIND == QUAD_IS_LONG_LONG).

12 years agoVC++ has QUADKIND == QUAD_IS___INT64 so we might as well make use of it
Steve Hay [Tue, 7 Aug 2012 07:49:09 +0000 (08:49 +0100)]
VC++ has QUADKIND == QUAD_IS___INT64 so we might as well make use of it

- Use I64/UI64 suffixes rather than I64TYPE/U64TYPE casts for
  INT64_C/UINT64_C, not just when _WIN64 is defined
- Use UI64 suffix rather than UL for U64_CONST

12 years agoData::Dumper: Updated changelog
Steffen Mueller [Tue, 7 Aug 2012 06:48:08 +0000 (08:48 +0200)]
Data::Dumper: Updated changelog

12 years agoData::Dumper: Fix tests for pure-Perl implementation
Steffen Mueller [Tue, 7 Aug 2012 06:45:56 +0000 (08:45 +0200)]
Data::Dumper: Fix tests for pure-Perl implementation

Father Chrysostomos fixed vstring handling in both XS and pure-Perl
implementations of Data::Dumper in
de5ef703c7d8db6517e7d56d9c018d3ad03f210e.

He also updated the tests for the default XS implementation, but it seems
that he missed the test changes necessary for the pure-Perl implementation
which now also does the right thing.

12 years agoDelta entry for Data::Dumper optimization
Steffen Mueller [Mon, 6 Aug 2012 18:14:47 +0000 (20:14 +0200)]
Delta entry for Data::Dumper optimization

12 years agoData::Dumper: Fix to use with earlier Perls
Karl Williamson [Mon, 6 Aug 2012 17:27:53 +0000 (11:27 -0600)]
Data::Dumper: Fix to use with earlier Perls

Commit 4b88fb76efce8c436e63b907c9842345d4fa77c7 broke Data::Dumper when
it is used on Perl versions earlier than v5.16.

12 years agocv.h: macro parentheses
Father Chrysostomos [Mon, 6 Aug 2012 21:03:31 +0000 (14:03 -0700)]
cv.h: macro parentheses

I forgot about -- having higher precedence than unary *.  And then
I forgot to test it, convincing myself I had. :-(

12 years agoNested formats
Father Chrysostomos [Mon, 6 Aug 2012 16:48:07 +0000 (09:48 -0700)]
Nested formats

Are nested formats a good idea?  Probably not.  But the only rea-
son they don’t work is that the parser becomes confused and loses
track of where it is.

And it would be nice to have some consistency.  I can put sub defini-
tions inside a format:

format =
@
;sub foo {
    bar
}
.

and:

format =
@
{
    sub foo {
        bar
    }
}
.

so why not these?

format foo =
@
;format bar =
@
.
.

format foo =
@
{
    format bar =
@
.
}
.

In perl 5.17.2 and earlier, you can nest formats, but, due to the
parser being confused, the outer format must be terminated with }
instead of a dot.  That stopped working with commit 7c70caa5333.

format =
@<<<<<<<<<<<<<<<
"Just another"; format STDERR =
@<<<<<<<<<<<<<<<
"Perl hacker"
.
}
write; select STDERR;
write;

12 years agotoke.c: move leftbracket label
Father Chrysostomos [Mon, 6 Aug 2012 15:41:07 +0000 (08:41 -0700)]
toke.c: move leftbracket label

The only code path that goesto leftbracket was precede by s--.
The first thing leftbracket did was s++.

We can simplify the code slighty by moving the label down one
statement and not s--ing before goingto leftbracket.

12 years ago[perl #114040] Parse formats in interpolating constructs
Father Chrysostomos [Mon, 6 Aug 2012 15:38:28 +0000 (08:38 -0700)]
[perl #114040] Parse formats in interpolating constructs

For re-evals, this is something that broke recently, post-5.16 (the
jumbo fix).  For other interpolating constructs, this has never
worked, as far as I can tell.

The lexer was losing track of PL_lex_state (aka PL_parser->lex_state)
when parsing formats.  Usually, the state alternates between
LEX_FORMLINE (a picture line) and LEX_NORMAL (an argument line), but
the LEX_NORMAL should actually be whatever the state was before the
format started.

This commit adds a new parser member to track the ‘normal’ state when
parsing a format.

It also tweaks S_scan_formline to handle multi-line buffers outside of
string eval (such as happens in interpolating constructs).

That bufend assignment that is removed as a result is not necessary as
of a0d0e21ea6ea (perl 5.000).  That very commit added a bufend assign-
ment after the sv_gets (later filter_gets; later lex_next_chunk) fur-
ther down in the loop in scan_formline.

12 years agoUpdate notes on which Cygwin tools are needed to make a release on Windows
Steve Hay [Mon, 6 Aug 2012 17:10:37 +0000 (18:10 +0100)]
Update notes on which Cygwin tools are needed to make a release on Windows

(corelist.pl no longer uses curl, diffstat is no longer required to produce
the list of acknowledgements and 7z should be used to create smaller
tarballs. Also, core-cpan-diff no longer uses wget.)

12 years agoRestore parts of config_H.gc lost by regen_config_h
Steve Hay [Mon, 6 Aug 2012 08:02:50 +0000 (09:02 +0100)]
Restore parts of config_H.gc lost by regen_config_h

12 years agoRun regen_config_h for GCC
Steve Hay [Mon, 6 Aug 2012 07:58:07 +0000 (08:58 +0100)]
Run regen_config_h for GCC

A few new symbols are added but no existing ones are changed.

12 years agoRun regen_config_h for VC++
Steve Hay [Mon, 6 Aug 2012 07:57:44 +0000 (08:57 +0100)]
Run regen_config_h for VC++

A few new symbols are added but no existing ones are changed.

12 years agoData::Dumper: Import more change history
Steffen Mueller [Fri, 3 Aug 2012 05:52:21 +0000 (07:52 +0200)]
Data::Dumper: Import more change history

12 years agoForbid braces as format delimiters
Father Chrysostomos [Mon, 6 Aug 2012 05:24:09 +0000 (22:24 -0700)]
Forbid braces as format delimiters

As long the argument line is not missing, braces can be used
for a format:

# valid
format foo {
@<<<
$a
}

but if the argument line is missing, you get a syntax error:

# invalid
format foo {
@<<<
}

and also if the name is missing:

# invalid
format {
@<<<
$a
}

If you use = then you can use a closing brace to terminate the format,
but only if the argument line is missing:

# valid, but useless
format =
@<<<
}

# invalid
format =
@<<<
$a
}

In commit 79072805 (perl 5.0 alpha 20), the lexer was changed to lie
to the parser about formats’ = and . delimiters, pretending they are
actually { and }, because the bracket-handling code takes care of all
the scoping issues (well, most of them).

Unfortunately, this implementation detail can leak through, but it is
far from consistent, as shown above.

Fixing this makes it easier to fix other bugs.

We do this by recording the fact that we are dealing with a format
token before jumping to the bracket code.  And we feed format-specific
tokens to the parser in that case, so it can’t get fake brackets and
real brackets mixed up.

12 years agoassert_(...)
Father Chrysostomos [Mon, 6 Aug 2012 00:22:29 +0000 (17:22 -0700)]
assert_(...)

This new macro expands to ‘assert(...),’ (with a trailing comma) under
debugging builds; the empty string otherwise.

It allows for the removal of some #ifdef DEBUGGINGs, which could not be
avoided otherwise.

12 years agoFix a typo in perlootut
Dave Rolsky [Mon, 6 Aug 2012 02:00:49 +0000 (21:00 -0500)]
Fix a typo in perlootut

12 years agoDon’t crash when undefining handle of active format
Father Chrysostomos [Sun, 5 Aug 2012 20:13:12 +0000 (13:13 -0700)]
Don’t crash when undefining handle of active format

format FOO =
@
undef *STDOUT
.
$~ = FOO;
write

Commit 7ef822cddfe9 began the work by putting in a null check and a
goto (to bypass the top format), but the goto wentto some code that
lacked the null check.  (It did actually fix the case of a IO with no
ofp, but not the case of a GV with no IO.)  Interestingly, it added a
bad_ofp label, but did not add the code to goto it (an oversight?).

The unused bad_ofp label was commented out in commit 9cbac4c72b52.

There was already a check before 7ef822cddfe9 to see whether there was
an ofp, but only after the format scope has been popped.

This commit extends that check by making sure there is an io first.

It removes the commented-out bad_ofp label.

12 years agoMake glob.t more resilient
Father Chrysostomos [Sun, 5 Aug 2012 19:41:48 +0000 (12:41 -0700)]
Make glob.t more resilient

It was not tolerating editor temp files with spaces in their
names.  It was testing the output of <op/*> by comparing it with
split /\s/, `echo op/*` on non-Windows non-VMS systems (Unix).
`ls op/* | cat` produces more machine-friendly output, so use that.

12 years agoparser.t: Move tests above ‘Add tests here’
Father Chrysostomos [Sun, 5 Aug 2012 19:28:51 +0000 (12:28 -0700)]
parser.t: Move tests above ‘Add tests here’

12 years agoDon’t let active formats be freed
Father Chrysostomos [Sun, 5 Aug 2012 19:15:18 +0000 (12:15 -0700)]
Don’t let active formats be freed

This crashes:

format FOO =
@<
undef *FOO
.
$~ = FOO;
write

The context stack needs to hold a reference count for formats, just as
it does for subs.

12 years agoFix Devel::Peek’s tests for format changes
Father Chrysostomos [Sun, 5 Aug 2012 18:24:26 +0000 (11:24 -0700)]
Fix Devel::Peek’s tests for format changes

12 years agoRecursive formats and closures in formats.
Father Chrysostomos [Sun, 5 Aug 2012 08:05:45 +0000 (01:05 -0700)]
Recursive formats and closures in formats.

Formats called recursively were using the same set of lexicals, so the
inner call would stomp on the outer calls vars, usually clearing them
when exiting.

Previous commits prepared a CvDEPTH field for formats.  This commit
sets it in P(USH|OP)FORMAT and pushes a new pad in enterwrite.

This also allows closures to work properly in formats.  Formerly they
caused assertion failures in cv_clone.  Now cv_clone’s assumptions
about CvDEPTH on CvOUTSIDE and find_runcv are met when subs are embed-
ded in formats.

12 years agoAdd a depth field to formats
Father Chrysostomos [Sun, 5 Aug 2012 07:48:00 +0000 (00:48 -0700)]
Add a depth field to formats

Instead of lengthening the struct, we can reuse SvCUR, which is cur-
rently unused.

12 years agoDisallow setting SvPV on formats
Father Chrysostomos [Sun, 5 Aug 2012 07:34:11 +0000 (00:34 -0700)]
Disallow setting SvPV on formats

Setting a the PV on a format is meaningless, as of the previ-
ous commit.

This frees up SvCUR for other uses.

12 years agoMake PL_(top|body|form)target PVIVs
Father Chrysostomos [Sun, 5 Aug 2012 07:15:52 +0000 (00:15 -0700)]
Make PL_(top|body|form)target PVIVs

These are only used for storing a string and an IV.

Making them into full-blown SVt_PVFMs is overkill.

FmLINES was only being used on these three scalars.  So make it use
the SvIVX field.  struct xpvfm no longer needs an xfm_lines member,
because SVt_PVFMs no longer use it.

This also causes a TODO test in taint.t to start passing, but I do
not fully understand why.  But at least that’s progress. :-)

12 years ago[perl #78550] Fix bad assertion in toke.c:start_subparse
Father Chrysostomos [Sun, 5 Aug 2012 01:01:01 +0000 (18:01 -0700)]
[perl #78550] Fix bad assertion in toke.c:start_subparse

The outer ‘sub’ might actually be a format

12 years agopad.c:cv_clone: Rmv irrelevent part of comment
Father Chrysostomos [Sun, 5 Aug 2012 00:57:21 +0000 (17:57 -0700)]
pad.c:cv_clone: Rmv irrelevent part of comment

12 years agopad.c:cv_clone: add assertions
Father Chrysostomos [Sun, 5 Aug 2012 00:54:32 +0000 (17:54 -0700)]
pad.c:cv_clone: add assertions

The outer sub should always be active and have a pad if it is
a sub that is being cloned.  Only formats can have an inactive or
padless outside.  Add assertions to that effect.

12 years agoClose over stale vars in active subs
Father Chrysostomos [Sat, 4 Aug 2012 21:42:47 +0000 (14:42 -0700)]
Close over stale vars in active subs

\$x and sub { $x }->() should never produce different values.  But
this used to be possible because sub cloning (which happens with
sub{...}) was written to avoid closing over variables that are not
active.  Not closing over inactive variables makes sense in cases like
this (because the variable doesn’t really exist yet):

sub {
    my $x;
    sub foo {
        $x
    }
}
foo;

but the logic breaks down in cases like this (which was printing 3
only on the first print):

sub foo {
    my $x;
    sub bar {
        $x = 3;
        print $x, "\n";
        sub { print $x, "\n" }->()
    }
}
bar();

If bar can see a scalar named $x (even if it is questionable),
sub { $x }->() should jolly well see the same scalar as the immedi-
ately enclosing sub.

The only case where a run-time cloning of a CV should refuse to close
over the same scalar that the outer sub sees is when the outer sub is
not running.  That only happens with formats:

sub f {
    my $x;
    format =
@
$x
.
}
write STDOUT;

As of this commit, it does only happen with formats.

The actual cases of subs refusing to close over stale variables in
active parents have changed twice since 5.10.0.  See the comments in
the tests.

12 years agosv.c:varname: Fix bad assertion added by c6fb3f6e
Father Chrysostomos [Sat, 4 Aug 2012 17:16:01 +0000 (10:16 -0700)]
sv.c:varname: Fix bad assertion added by c6fb3f6e

#!perl -w
my $x;
format =
@
"$x";
.
write;
__END__
Assertion failed: (!cv || SvTYPE(cv) == SVt_PVCV), function Perl_varname, file sv.c, line 13924.
Abort trap

12 years agoRemove CR characters from raw input in op/magic.t on Windows
Steve Hay [Sat, 4 Aug 2012 13:01:27 +0000 (14:01 +0100)]
Remove CR characters from raw input in op/magic.t on Windows

The :raw input added by e2e1d5ce8b broke tests on Windows by introducing
unexpeted CR characters.

Two tests (154 and 157) currently still fail on Windows if the (DOS)
command prompt is using a different code page to perl's native (Windows)
character set.

12 years agoModule::CoreList: Automatically add aliases for releases
David Leadbeater [Sun, 29 Jul 2012 12:12:03 +0000 (13:12 +0100)]
Module::CoreList: Automatically add aliases for releases

When the release in numeric and conventional written form differ add an
alias for the formatted variant automatically.

12 years agoStore version information as a delta in Module::CoreList
David Leadbeater [Sun, 29 Jul 2012 00:39:05 +0000 (01:39 +0100)]
Store version information as a delta in Module::CoreList

This reduces the size of the CoreList.pm file by storing the difference
between the versions of perl rather than a full list for each version.

In order to achieve this without changing the interface each key in the
%version hash is tied to a special tied hash that inflates the stored
difference data to the full list of modules and versions.

As part of the upgrade I ran a comparison with the
%version hash in the current Module::CoreList -- there are no
differences.

12 years agoavoid decoding on input in the new tests added in 613c63b4
Tony Cook [Sat, 4 Aug 2012 03:53:38 +0000 (13:53 +1000)]
avoid decoding on input in the new tests added in 613c63b4

This fixes these tests when run in a unicode environment, eg:

  PERL_UNICODE= LC_ALL=en_AU.utf8 ./perl op/magic.t

This does fix tha code page related issue on Win32.

12 years ago[perl #114222] Make ‘use’ parse arguments in term context
Father Chrysostomos [Sat, 4 Aug 2012 01:35:26 +0000 (18:35 -0700)]
[perl #114222] Make ‘use’ parse arguments in term context

(lexing context, that is)

use constant { () }

was a syntax error, because the lexer was guessing when { should be
a statement or hash.

It should not be doing that where a term is expected.

It was actually getting itself confused, and trying to parse the
argument list as a statement.

Setting PL_expect after force_next is ineffectual, as force_next
records the current value of PL_expect, arranging to have it
restored.

OPERATOR(USE) was setting PL_expect, but too late.  So no we set
PL_expect explicitly in S_tokenize_use, before any forced tokens,
and use TOKEN(USE), which does not set PL_expect (as setting it
there has no effect).

12 years agoperlexperiment.pod clarifications
Reini Urban [Sun, 15 Jul 2012 17:15:45 +0000 (12:15 -0500)]
perlexperiment.pod clarifications

Removed in Perl is misleading. Those modules just moved to CPAN and are not deprecated.
threads are now ithreads since multiplicity.

12 years agoPod-Functions requires that Pod-Escapes be built to build
Tony Cook [Fri, 3 Aug 2012 13:33:10 +0000 (23:33 +1000)]
Pod-Functions requires that Pod-Escapes be built to build

Discovered doing a parallel build on OpenBSD, reproducible elsewhere
with:

  ./Configure ... && make ext/Pod-Functions/pm_to_blib

While Pod-Escapes is a dependency of Pod-Simple, the Pod-Simple build
process doesn't require that Pod-Escapes already be built, while the
Pod-Functions build process does.

12 years agoFix RT [perl #72156] Re: Perl 5.12.0 RC 0 - Pager detection
Andy Dougherty [Thu, 2 Aug 2012 18:59:55 +0000 (14:59 -0400)]
Fix RT [perl #72156] Re: Perl 5.12.0 RC 0 - Pager detection

Instruct ./getfile to trust the default pager value.  It might not begin
with a slash, or it might include some options, such as
"/usr/bin/less -R".
This is based on commit 53ddb3ba3e23ab80444c30b4deefa64114408438 in
the metaconfig repository.

12 years agoData::Dumper: Comment on previous optimization
Steffen Mueller [Thu, 2 Aug 2012 18:24:40 +0000 (20:24 +0200)]
Data::Dumper: Comment on previous optimization

The optimization in the previous commit to Data::Dumper (sparse seen
hash) is not complete: It is so far only applied to non-RV SVs. This
also means that it's safe not to check for weak-refs. Applying the
optimization to RVs should be possible, but is not as easy (I think).

12 years agoData::Dumper: Option to avoid building much of the seen hash
Steffen Mueller [Thu, 2 Aug 2012 16:51:19 +0000 (18:51 +0200)]
Data::Dumper: Option to avoid building much of the seen hash

If the "$Sparseseen" option is set by the user, Data::Dumper eschews
building the seen-this-scalar hash for ALL SCALARS but instead just adds
those that have a refcount > 1. Since the seen hash is exposed
to the user in the OO interface (rats!), this needs to be opt-in in if
OO is used.

If the DD constructor is called from Dumpxs (because the user used the
functional interface as customary), then this option could be
implicitly enabled in those cases as the seen hash is never visible to
the user.

In my real-world-data benchmark, setting this option speeds up
serialization by about 50%!

This is really Yves Orton's idea. I'm just the code monkey on this one.

12 years agoperldelta for unterminated here-docs
Father Chrysostomos [Thu, 2 Aug 2012 17:01:43 +0000 (10:01 -0700)]
perldelta for unterminated here-docs

12 years ago[perl #114104] Better error for unterminated heredoc delim
Father Chrysostomos [Thu, 2 Aug 2012 16:52:27 +0000 (09:52 -0700)]
[perl #114104] Better error for unterminated heredoc delim

12 years agoperldelta for #114340
Father Chrysostomos [Thu, 2 Aug 2012 05:36:48 +0000 (22:36 -0700)]
perldelta for #114340

12 years agoperldelta for Storable and vstrings
Father Chrysostomos [Thu, 2 Aug 2012 05:31:15 +0000 (22:31 -0700)]
perldelta for Storable and vstrings

12 years agoperldelta for given aliasing $_
Father Chrysostomos [Thu, 2 Aug 2012 05:03:34 +0000 (22:03 -0700)]
perldelta for given aliasing $_

12 years agoregcomp.c: Remove unnecessary variable
Karl Williamson [Thu, 2 Aug 2012 00:28:59 +0000 (18:28 -0600)]
regcomp.c: Remove unnecessary variable

This variable was used because another was declared 'register'.  But
that declaration was removed by commit
e1d1eefb8c88e0dcaf2bb9e6c04d7f6192be966f in 2007, making the temporary
variable redundant.

12 years agoregcomp.c: inline trivial static function
Karl Williamson [Wed, 1 Aug 2012 23:04:13 +0000 (17:04 -0600)]
regcomp.c: inline trivial static function

12 years agoregcomp.c: Fix \N{} multi-char fold buffer boundary bug
Karl Williamson [Wed, 1 Aug 2012 21:12:23 +0000 (15:12 -0600)]
regcomp.c: Fix \N{} multi-char fold buffer boundary bug

An earlier commit in this topic branch fixed the bug (for non-\N{})
cases where a multi-character fold could try to span two EXACTFish
nodes, where they are split because the first one would otherwise
contain too long a string.

This commit extends that fix to include characters entered via \N{...}.
It does this by causing \N handling to be split, so that if the \N
resolves to a single code point, it goes through the normal processing,
so that it no longer bypasses the code that was added in the earlier
commit.

12 years agoregcomp.c: Revise API for static function
Karl Williamson [Wed, 1 Aug 2012 20:49:39 +0000 (14:49 -0600)]
regcomp.c: Revise API for static function

This is to allow future changes.   The function now returns success or
failure, and the created regnode (if any) is set via a parameter
pointer.

I removed the 'register' declaration to get this to work, because
such declarations are considered bad form these days, e.g.,
http://stackoverflow.com/questions/314994/whats-a-good-example-of-register-variable-usage-in-c

12 years agoregcomp.c: Fix multi-char fold bug
Karl Williamson [Mon, 18 Jun 2012 19:09:38 +0000 (13:09 -0600)]
regcomp.c: Fix multi-char fold bug

Input text to be matched under /i is placed in EXACTFish nodes.  The
current limit on such text is 255 bytes per node.  Even if we raised
that limit, it will always be finite.  If the input text is longer than
this, it is split across 2 or more nodes.  A problem occurs when that
split occurs within a potential multi-character fold.  For example, if
the final character that fits in a node is 'f', and the next character
is 'i', it should be matchable by LATIN SMALL LIGATURE FI, but because
Perl isn't structured to find multi-char folds that cross node
boundaries, we will miss this it.

The solution presented here isn't optimum.  What we do is try to prevent
all EXACTFish nodes from ending in a character that could be at the
beginning or middle of a multi-char fold.  That prevents the problem.
But in actuality, the problem only occurs if the input text is actually
a multi-char fold, which happens much less frequently.  For example,
we try to not end a full node with an 'f', but the problem doesn't
actually occur unless the adjacent following node begins with an 'i' (or
one of the other characters that 'f' participates in).  That is, this
patch splits when it doesn't need to.

At the point of execution for this patch, we only know that the final
character that fits in the node is that 'f'.  The next character remains
unparsed, and could be in any number of forms, a literal 'i', or a hex,
octal, or named character constant, or it may need to be decoded (from
'use encoding').  So look-ahead is not really viable.

So finding if a real multi-character fold is involved would have to be
done later in the process, when we have full knowledge of the nodes, at
the places where join_exact() is now called, and would require inserting
a new node(s) in the middle of existing ones.

This solution seems reasonable instead.

It does not yet address named character constants (\N{}) which currently
bypass the code added here.

12 years agomktables: Generate tables for chars that aren't in final fold pos
Karl Williamson [Mon, 18 Jun 2012 18:55:42 +0000 (12:55 -0600)]
mktables: Generate tables for chars that aren't in final fold pos

This starts with the existing table that mktables generates that lists
all the characters in Unicode that occur in multi-character folds, and
aren't in the final positions of any such fold.

It generates data structures with this information to make it quickly
available to code that wants to use it.  Future commits will use these
tables.

12 years agoregen/mk_invlists: Add mode to generate above-Latin1 only
Karl Williamson [Mon, 18 Jun 2012 18:44:55 +0000 (12:44 -0600)]
regen/mk_invlists: Add mode to generate above-Latin1 only

This change adds the ability to specify that an output inversion list is
to contain only those code points that are above Latin-1.  Typically,
the Latin-1 ones will be accessed from some other means.

12 years agoUnicode::UCD::prop_invlist() Allow to return internal property
Karl Williamson [Mon, 18 Jun 2012 18:38:41 +0000 (12:38 -0600)]
Unicode::UCD::prop_invlist() Allow to return internal property

This creates an optional undocumented parameter to this function to
allow it to return the inversion list of an internal-only Perl property.
This will be used by other functions in Perl, but should not be
documented, as we don't want to encourage the use of internal-only
properties, which are subject to change or removal without notice.

12 years agomktables: Add comment to gen'd data file
Karl Williamson [Mon, 18 Jun 2012 18:37:52 +0000 (12:37 -0600)]
mktables: Add comment to gen'd data file

12 years agomktables: grammar in comments
Karl Williamson [Mon, 18 Jun 2012 18:22:41 +0000 (12:22 -0600)]
mktables: grammar in comments

12 years agoregen/mk_PL_charclass.pl: Remove obsolete code
Karl Williamson [Mon, 18 Jun 2012 18:20:42 +0000 (12:20 -0600)]
regen/mk_PL_charclass.pl: Remove obsolete code

Octals are no longer checked via this mechanism.

12 years agoregcomp.c: Make invlist_search() usable from re_comp.c
Karl Williamson [Mon, 18 Jun 2012 17:51:43 +0000 (11:51 -0600)]
regcomp.c: Make invlist_search() usable from re_comp.c

This was a static function which I couldn't get to be callable from the
debugging version of regcomp.c.  This makes it public, but known only
in the regcomp.c source file.  It changes the name to begin with an
underscore so that if someone cheats by adding preprocessor #defines,
they still have to call it with the name that convention indicates is a
private function.

12 years agoperlop:clarify wording
Karl Williamson [Mon, 18 Jun 2012 17:41:18 +0000 (11:41 -0600)]
perlop:clarify wording

12 years agoregcomp.c: Rename static fcn to better reflect its purpose
Karl Williamson [Sun, 17 Jun 2012 02:02:07 +0000 (20:02 -0600)]
regcomp.c: Rename static fcn to better reflect its purpose

This function handles \N of any ilk, not just named sequences.

12 years agoregcomp.c: Make comment more accurate
Karl Williamson [Sun, 17 Jun 2012 01:55:15 +0000 (19:55 -0600)]
regcomp.c: Make comment more accurate

12 years agoregcomp.c: Can now do /u instead of forcing to utf8
Karl Williamson [Sun, 17 Jun 2012 01:52:12 +0000 (19:52 -0600)]
regcomp.c: Can now do /u instead of forcing to utf8

Now that there is a /u modifier, a regex doesn't have to be in UTF-8 in
order to force Unicode semantics.  Change this relict from the past.

12 years agoregcomp.c: Comments update
Karl Williamson [Wed, 6 Jun 2012 21:02:43 +0000 (15:02 -0600)]
regcomp.c: Comments update

This adds some comments and white-space lines, and updates other
comments to account for the fact that trie handling has changed since
they were written.

12 years agoregcomp.c: Remove variable whose value needed just once
Karl Williamson [Mon, 28 May 2012 16:49:37 +0000 (10:49 -0600)]
regcomp.c: Remove variable whose value needed just once

Previous commits have removed all but one instance of using this
variable, so just use the expression it equates to.

12 years agoregcomp.c: White-space only
Karl Williamson [Mon, 28 May 2012 16:42:03 +0000 (10:42 -0600)]
regcomp.c: White-space only

This indents and outdents to compensate for newly formed and orphan
blocks, respectively; and reflows comments to fit in 80 columns

12 years agoregcomp.c: Trade stack space for time
Karl Williamson [Sun, 27 May 2012 07:08:46 +0000 (01:08 -0600)]
regcomp.c: Trade stack space for time

Pass 1 of regular expression compilation merely calculates the size it
will need. (Note that Yves and I both think this is very suboptimal
behavior.)  Nothing is written out during this pass, but sizes are
just incremented.  The code in regcomp.c all knows this, and skips
writing things in pass 1.  However, when folding, code in other files is
called which doesn't have this size-only mode, and always writes its
results out.  Currently, regcomp handles this by passing to that code a
temporary buffer allocated for the purpose.  In pass1, the result is
simply ignored; in pass2, the results are copied to the correct final
destination.

We can avoid that copy by making the temporary buffer large enough to
hold the whole node, and in pass1, use it instead of the node.  The
non-regcomp code writes to the same relative spot in the buffer that it
will use for the real node.  In pass2 the real destination is used, and
the fold gets written directly to the correct spot.

Note that this increases the size pushed onto the stack, but code is
ripped out as well.

However, the main reason I'm doing this is not this speed-up; it is
because it is needed by future commits to fix a bug.

12 years agoregcomp.c: Use mnemonic not numeric constant
Karl Williamson [Sun, 27 May 2012 07:04:39 +0000 (01:04 -0600)]
regcomp.c: Use mnemonic not numeric constant

Future commits will add other uses of this number.

12 years agoregcomp.c: Resolve EBCDIC inconsistency towards simpler
Karl Williamson [Sun, 27 May 2012 04:19:22 +0000 (22:19 -0600)]
regcomp.c: Resolve EBCDIC inconsistency towards simpler

This code has assumed that to_uni_fold() returns its folds in Unicode
(i.e.  Latin1) rather than native EBCDIC.  Other code in the core
assumes the opposite.  One has to change.  I'm changing this one, as the
issues should be dealt with at the lowest level possible, which is in
to_uni_fold().  Since we don't currently have an EBCDIC platform to test
on, making sure that it all hangs together will have to be deferred
until such time as we do.

By doing this we make this code simpler and faster.  The fold has
already been calculated, we just need to copy it to the final place
(done in pass2).

12 years agoregcomp.c: Use function instead of repeating its code
Karl Williamson [Sun, 27 May 2012 03:39:32 +0000 (21:39 -0600)]
regcomp.c: Use function instead of repeating its code

A new flag to to_uni_fold() causes it to do the same work that this code
does, so just call it.

12 years agoregcomp.c: Remove (almost) duplicate code
Karl Williamson [Sat, 26 May 2012 20:19:18 +0000 (14:19 -0600)]
regcomp.c: Remove (almost) duplicate code

A previous commit opened the way to refactor this so that the two
fairly lengthy code blocks that are identical (except for changing the
variable <len>) can have one of them removed.

12 years agoregcomp.c: Refactor so can remove duplicate code
Karl Williamson [Fri, 25 May 2012 04:14:04 +0000 (22:14 -0600)]
regcomp.c: Refactor so can remove duplicate code

This commit prepares the way for a later commit to remove a chunk of
essentially duplicate code.  It does this at the cost of an extra
test of a boolean each time through the loop.  But, it saves calculating
the fold unless necessary, a potentially expensive operation.  When the
next input is a quantifier that calculated fold is discarded, unused.
This commit avoids doing that calculation when the next input is a
quantifier.

12 years agoFix a perl5140delta typo in F<> markup.
K.Shirakata [Fri, 6 May 2011 13:12:57 +0000 (22:12 +0900)]
Fix a perl5140delta typo in F<> markup.

(Patch predates the 5.14.0 release, but was missed at the time.)

12 years ago[perl #114020] perlvar: warn against my $_
Father Chrysostomos [Thu, 2 Aug 2012 03:45:29 +0000 (20:45 -0700)]
[perl #114020] perlvar: warn against my $_

12 years agoUpdate perlsyn for given aliasing $_
Father Chrysostomos [Thu, 2 Aug 2012 03:36:10 +0000 (20:36 -0700)]
Update perlsyn for given aliasing $_

plus one typo fix

12 years agoperlfunc/printf: corrections, clarifications
Father Chrysostomos [Thu, 2 Aug 2012 03:12:47 +0000 (20:12 -0700)]
perlfunc/printf: corrections, clarifications

12 years agoperlfunc: clarification
Father Chrysostomos [Thu, 2 Aug 2012 01:08:35 +0000 (18:08 -0700)]
perlfunc: clarification

12 years agoperlvar: Document all uses of implicit $_
Father Chrysostomos [Thu, 2 Aug 2012 01:07:05 +0000 (18:07 -0700)]
perlvar: Document all uses of implicit $_

12 years agoperlfunc: Document implicit $_ in while(each)
Father Chrysostomos [Wed, 1 Aug 2012 21:17:20 +0000 (14:17 -0700)]
perlfunc: Document implicit $_ in while(each)

12 years ago[perl #114020, #90018, #53186] Make given alias $_
Father Chrysostomos [Wed, 1 Aug 2012 21:16:21 +0000 (14:16 -0700)]
[perl #114020, #90018, #53186] Make given alias $_

This commit makes given() alias $_ to the argument, using a slot in
the lexical pad if a lexical $_ is in scope, or $'_ otherwise.

This makes it work very similarly to foreach, and eliminates the
problem of List::Util functions not working inside given().

12 years ago[perl #114368] perl -DA -e '' segfaults
Father Chrysostomos [Wed, 1 Aug 2012 20:04:14 +0000 (13:04 -0700)]
[perl #114368] perl -DA -e '' segfaults

Iterative freeing of hashes uses the SvMAGIC field for a different
purpose.  So clear it before calling hv_undef_flags, which calls
hv_assert, which expects any non-null value fo SvMAGIC to me magic.

12 years agofix icmp ping tests on cygwin
Tony Cook [Thu, 2 Aug 2012 00:28:02 +0000 (10:28 +1000)]
fix icmp ping tests on cygwin

12 years agoNet-Ping: creating an icmp socket requires admin access on recent cygwin
Tony Cook [Fri, 27 Jul 2012 13:47:05 +0000 (23:47 +1000)]
Net-Ping: creating an icmp socket requires admin access on recent cygwin

on recent Windows.

cygwin on XP can create an icmp socket as a normal user but can't do
anything with it.  On Vista or Win7 the process must be running as
an admin to create the socket.

If someone sees value in running the test on cygwin on XP, they can
provide a patch.

12 years agoNet-Ping: add a sensible test note for the icmp ping test
Tony Cook [Fri, 27 Jul 2012 13:39:39 +0000 (23:39 +1000)]
Net-Ping: add a sensible test note for the icmp ping test

12 years agofix the cygwin breakage introduced in 2f794ae1
Tony Cook [Fri, 27 Jul 2012 13:38:59 +0000 (23:38 +1000)]
fix the cygwin breakage introduced in 2f794ae1

All modern Win32 systems* require admin access to use ICMP sockets from
cygwin, the refactor in 2f794ae1 changed the condition for the skip,
producing a failure here when the test is run unprivileged under
cygwin.

* assuming XP can be called modern

12 years agoTest that when directories in @INC are skipped, coderefs are still called.
Nicholas Clark [Thu, 28 Jun 2012 16:21:01 +0000 (18:21 +0200)]
Test that when directories in @INC are skipped, coderefs are still called.

For filenames that are absolute, or start with ./ or ../ only coderefs in
@INC are called - directories are skipped. Test this behaviour.

12 years agoAvoid reading before the buffer start when generating errors from require.
Nicholas Clark [Wed, 27 Jun 2012 16:25:50 +0000 (18:25 +0200)]
Avoid reading before the buffer start when generating errors from require.

In pp_require, the error reporting code treats file names ending /\.p?h\z/
specially. The detection code for this, as refactored in 2010 by commit
686c4ca09cf9d6ae, could read one or two bytes before the start of the
filename for filenames less than 3 bytes long. (Note this cannot happen with
module names given to use or require, as appending ".pm" will always make the
filename at least 3 bytes long.)

12 years agoAdd a USE_64_BIT_INT build option to the Windows makefiles.
Steve Hay [Wed, 1 Aug 2012 17:16:53 +0000 (18:16 +0100)]
Add a USE_64_BIT_INT build option to the Windows makefiles.

Rather than adding more canned configurations, we dynamically set values
which differ from the standard 32-bit build options, and actually remove
the canned configurations for 64-bit builds too and do likewise for them.

The ~ARCHPREFIX~ games used by the outgoing .gc64 configuration needed
bringing into the remaining .gc configuration to maintain support for the
GCCCROSS build option.

Two tweaks to sv.c were required for the USE_64_BIT_INT option to work
with a VC++ build, allowing the I64 printf size specification. The GCC
build worked anyway since it uses ll rather than I64.

The motivation for this change came from a patch submitted by Sisyphus
<sisyphus1@optusnet.com.au>:
Message-ID: <6AC52DD00C96415A9E919A02F12DD05F@desktop2>

12 years agoMakefile.SH needs to delete the perldelta symlink before creating it.
Nicholas Clark [Mon, 30 Jul 2012 15:31:12 +0000 (17:31 +0200)]
Makefile.SH needs to delete the perldelta symlink before creating it.

This seemingly redundant action seems to be necessary for maximum
portability on repeat makes - certainly HP-UX make will happily assume that
the target (the symlink) is out of date, attempt to re-run the rule, and
then fail because the `ln -s` command fails due to the target already
existing.