2 days agocustom smoke-me/khw-encode
Karl Williamson [Thu, 8 Sep 2016 04:41:02 +0000]
custom

2 days agosmoke
Karl Williamson [Thu, 8 Sep 2016 04:34:20 +0000]
smoke

2 days agoAPItest/t/utf8.t: Add tests
Karl Williamson [Thu, 8 Sep 2016 04:22:01 +0000]
APItest/t/utf8.t:   Add tests

These fill in gaps in current testing.  In particular all the overlong
UTF-8 possible edge cases are now tested.

2 days agoAPItest/utf8.t: Some clean up
Karl Williamson [Thu, 8 Sep 2016 04:14:38 +0000]
APItest/utf8.t: Some clean up

This adds some information to test names, does some white-space
alignments, changes one test to stress things slightly more, and adds a
'use bytes' because in some cases the desired byte-oriented output was
not showing up.

2 days agoTest isUTF8_CHAR()
Karl Williamson [Mon, 5 Sep 2016 03:32:08 +0000]
Test isUTF8_CHAR()

2 days agoisUTF8_CHAR(): Bring UTF-EBCDIC to parity with ASCII
Karl Williamson [Sat, 3 Sep 2016 20:12:27 +0000]
isUTF8_CHAR(): Bring UTF-EBCDIC to parity with ASCII

This changes the macro isUTF8_CHAR to have the same number of code
points built-in for EBCDIC as ASCII.  This obsoletes the
IS_UTF8_CHAR_FAST macro, which is removed.

Previously, the code generated by regen/regcharclass.pl for ASCII
platforms was hand copied into utf8.h, and LIKELY's manually added, then
the generating code was commented out.  Now this has been done with
EBCDIC platforms as well.  This makes regenerating regcharclass.h
faster.

The copied macro in utf8.h is moved by this commit to within the main
code section for non-EBCDIC compiles, cutting the number of #ifdef's
down, and the comments about it changed somewhat.

2 days agoregen/regcharclass.pl: surrogates are code points
Karl Williamson [Sat, 3 Sep 2016 18:15:29 +0000]
regen/regcharclass.pl: surrogates are code points

They are not "characters"

2 days agoAdd IS_UTF8_INVARIANT and IS_UVCHR_INVARIANT to API
Karl Williamson [Sat, 3 Sep 2016 22:13:15 +0000]
Add IS_UTF8_INVARIANT and IS_UVCHR_INVARIANT to API

2 days agoutfebcdic.h: Fix typo in comment
Karl Williamson [Thu, 8 Sep 2016 04:03:21 +0000]
utfebcdic.h: Fix typo in comment

2 days agoUse core REPLACEMENT CHARACTER definition
Karl Williamson [Thu, 1 Sep 2016 18:20:52 +0000]
Use core REPLACEMENT CHARACTER definition

This allows the code to now work on EBCDIC as well.

2 days agoXXX commit msg: Encode.xs: Rmv unused function
Karl Williamson [Thu, 1 Sep 2016 18:16:00 +0000]
XXX commit msg: Encode.xs: Rmv unused function

2 days agoEncode.xs: white-space only
Karl Williamson [Thu, 1 Sep 2016 18:12:39 +0000]
Encode.xs: white-space only

2 days agoXXX maybe more in commit msg: Speed up Encode UTF-8 validation checking
Karl Williamson [Thu, 1 Sep 2016 18:12:06 +0000]
XXX maybe more in commit msg: Speed up Encode UTF-8 validation checking

This replaces the current scheme for checking UTF-8 validity by one
in which normal processing doesn't require having to decode the UTF-8
into code points.  The copying of characters individually from the input
to the output is changed to be a single operation for each entire span
of valid input at once.

Thus in the normal case, what ends up happening is a tight loop to
check the validity, and then a memmove of the entire input to the
output, then return.

If an error is found, it copies all the valid input before the error,
then handles the character in error, then positions to the next input
position, and repeats the whole process starting from there.

It uses the functionality available from the Perl 5 core to to look at
just the bytes that comprise the UTF-8 to make the determination,
converting to code points only those that are defective some how in
order to display them in warnings and error messages.

Thus, this does not need to know about the intricacies of UTF-8
malformations, relying on the core to handle this.

This cannot be pushed to CPAN until Devel::PPPort has been updated to
implement all the functions now needed.

2 days agoAdd additional tests for DirHandle to improve coverage.
James E Keenan [Fri, 5 Aug 2016 23:13:15 +0000]
Add additional tests for DirHandle to improve coverage.

Add descriptions to all tests. Revise per suggestions by Tony Cook.

For: RT #128856

2 days agorename S_delimcpy() to S_delimcpy_intern()
David Mitchell [Wed, 7 Sep 2016 19:57:01 +0000]
rename S_delimcpy() to S_delimcpy_intern()

Its a bit confusing having both S_delimcpy() and Perl_delimcpy()
functions.

2 days agoadd some code comments for the users of delimcpy()
David Mitchell [Fri, 26 Aug 2016 11:10:58 +0000]
add some code comments for the users of delimcpy()

While fixing delimcpy(), I found that it wasn't always clear what its
callers did, so I've added some extra code comments.

also add a balancing '}' in a comment block to help editors that
jump between matching brackets.

2 days agoPerl_delimcpy(): handle backslash as last char
David Mitchell [Thu, 25 Aug 2016 16:48:34 +0000]
Perl_delimcpy(): handle backslash as last char

[perl #129064] heap-buffer-overflow S_scan_heredoc
[perl #129176] Conditional jump depends on uninitialized values in
               S_scan_heredoc

Perl_delimcpy() is supposed to copy a delimited string to another buffer;
it handles \-<delimiter> escapes, but if the backslash is the last
character in the src buffer, it could overrun the end of the buffer
slightly.

Also document a bit better what this function is supposed to do.

2 days agoperlobj: s/Deferencing/Dereferencing/
Lukas Mai [Wed, 7 Sep 2016 17:30:37 +0000]
perlobj: s/Deferencing/Dereferencing/

3 days agofix errror handling for ':attr(foo' with no ')'
David Mitchell [Wed, 7 Sep 2016 08:30:26 +0000]
fix errror handling for ':attr(foo' with no ')'

When the parameter of an attribute has no matching closing ')', there
are several issues with the way the error is handled.

First, the code currently tries to set PL_bufptr back to the position
of the opening '(' for a better error message. However, since the error
will have been discovered only at EOF after all the remaining lines have
been read and discarded, the buffer no longer contains ':attr(...'.
So the error message includes a spurious \0 followed by possibly some
random chunk of characters from the last line read in.

Worse, if the input buffer gets realloced while perl searches for the ')',
then PL_bufptr is reset to point into the freed buffer. [perl #129086].

It does yyerror() rather than croak(), so further error messages appear,
even though we're at EOF and no further parsing can occur. Similar cases
such as no matching closing string delimiter all croak instead.

It resets cop_line to zero *before* printing the error, so the line number
of the error is erroneously reported as zero.

This commit fixes all these issues by handling the error more similarly
to the way unterminated strings are handled. In particular, it no longer
tries to print out the section of src where it thinks the error is.

For comparison, running perl on this code file:

    # this is line 1
    my $x :foo(bar;
    the
    quick
    brown
    fox jumps over the lazy dog

used to output:

    Unterminated attribute parameter in attribute list at /tmp/p1 line 0, near "\0\0x jumps "
    syntax error at /tmp/p1 line 0, at EOF
    Execution of /tmp/p1 aborted due to compilation errors.

but now outputs:

    Unterminated attribute parameter in attribute list at /tmp/p1 line 2.

Note how previously: the error message included two literal null chars
(represented by \0 above), followed by a random chunk of the last line;
it claimed to be on line 0; it output two further error messages.

For comparison, change the ':foo' to 'q' so that its an unterminated
string, and you get (and always got):

    Can't find string terminator ")" anywhere before EOF at /tmp/p1 line 2.

3 days agoBump Locale-Codes from 3.39 to 3.40
Sullivan Beck [Thu, 1 Sep 2016 15:08:40 +0000]
Bump Locale-Codes from 3.39 to 3.40

3 days agoUpgrade XSLoader from version 0.22 to 0.24
Steve Hay [Wed, 7 Sep 2016 07:49:54 +0000]
Upgrade XSLoader from version 0.22 to 0.24

3 days agoUpgrade Sys::Syslog from version 0.34 to 0.35
Steve Hay [Wed, 7 Sep 2016 07:43:53 +0000]
Upgrade Sys::Syslog from version 0.34 to 0.35

This includes changes that supersede the blead customization.

3 days ago[perl #129106] Check for null PL_curcop in IN_LC()
Father Chrysostomos [Wed, 7 Sep 2016 05:11:05 +0000]
[perl #129106] Check for null PL_curcop in IN_LC()

or, rather, in macros that it calls.

When exiting a string eval, the current cop may be freed, so PL_curcop
gets set to null.  With the -DC option, we may end up printfing NVs
during scope exit, so the locale macros used to make sure that the
locale is sane before converting the numbers to strings need to make
sure not to read PL_curcop->cop_hints when PL_curcop is null.

This used to crash with: ./miniperl -DC -e'eval "l/A"'

I’m not sure how to write a test for this, or even whether it’s worth
writing a test for -D, which often changes behaviour depending on
porters’ whims.

3 days agofix a stupid type error
Tony Cook [Wed, 7 Sep 2016 01:16:49 +0000]
fix a stupid type error

3 days ago(perl #128988) preserve PL_oldoldbufptr is preserved in scan_heredoc()
Tony Cook [Mon, 22 Aug 2016 03:56:26 +0000]
(perl #128988) preserve PL_oldoldbufptr is preserved in scan_heredoc()

In some cases this is used in building error messages.

4 days ago(perl #128095) check pack_sockaddr_un()'s return value
Tony Cook [Mon, 15 Aug 2016 00:39:22 +0000]
(perl #128095) check pack_sockaddr_un()'s return value

pack_sockaddr_un() silently truncates the supplied path if it won't
fit into the sun_path member of sockaddr_un.

This may change in the future, but for now check the path in the
sockaddr matches the desired path, and skip if it doesn't.

4 days agoFix up B::Concise tests following op flag change
Father Chrysostomos [Mon, 5 Sep 2016 17:14:29 +0000]
Fix up B::Concise tests following op flag change

4 days ago[perl #47047] Fix erroneous AUTOLOAD warning
Father Chrysostomos [Mon, 5 Sep 2016 16:31:31 +0000]
[perl #47047] Fix erroneous AUTOLOAD warning

If there was a stub present in the package into which the invocant had
been blessed, then AUTOLOADing via a *method* call would warn with ‘Use
of inherited AUTOLOAD for non-method’ even if it is a method.

A recent commit stopped OPf_REF from being set on OP_ENTERSUB, so this
commit uses that flag to indicate a method call, to allow a fast run-
time check to see whether to pass the method flag to gv_autoload.

4 days agoTest for perl #47047
Rick Delaney [Mon, 5 Sep 2016 16:25:59 +0000]
Test for perl #47047

4 days agoNo need to skip t/op/dump.t on darwin
Father Chrysostomos [Mon, 5 Sep 2016 06:27:42 +0000]
No need to skip t/op/dump.t on darwin

4 days agoStop setting OPf_REF on OP_ENTERSUB
Father Chrysostomos [Mon, 5 Sep 2016 06:14:21 +0000]
Stop setting OPf_REF on OP_ENTERSUB

It isn’t doing anything really here, and I need it for
another purpose.

5 days agotoke.c: fix mswin32 builds
David Mitchell [Mon, 5 Sep 2016 14:49:28 +0000]
toke.c: fix mswin32 builds

9bde56224 added this as part of macro:

- PL_last_lop_op = f; \
+ PL_last_lop_op = f < 0 ? -f : f; \

which broke win32 builds due to this

    UNIBRACK(-OP_ENTEREVAL)

expanding to

    PL_last_lop_op = -345 < 0 ? --345 : -345

and the -- being seen as a pre-dec op.

Diagnosed by Dagfinn Ilmari Mannsåker.

5 days agoMake the "where install" directories Unix-format on VMS.
Craig A. Berry [Mon, 5 Sep 2016 02:13:28 +0000]
Make the "where install" directories Unix-format on VMS.

These paths will get converted to Unix format for loading into
@INC anyway, but since 483efd0abe3 they really need to start out
that way.  Otherwise, when running under a Unix shell, the path
delimiter will be ':' and the absolute VMS specs will get split
in half in S_incpush_use_sep(), which kicks in before the
conversion to Unix format.

5 days agoTainted dirs on VMS when not under DCL.
Craig A. Berry [Mon, 5 Sep 2016 02:10:06 +0000]
Tainted dirs on VMS when not under DCL.

Since 483efd0abe3 the path delimiter is a ':' instead of '|' on
VMS when running under a Unix shell.  So use that as a guide
to whether we should use a colon or a slash to detect relative
directories that should be tainted.

5 days agonewATTRSUB_x(): document what the cv var is for
David Mitchell [Mon, 5 Sep 2016 11:50:37 +0000]
newATTRSUB_x(): document what the cv var is for

5 days agomake S_already_defined() in op.c return void
David Mitchell [Mon, 5 Sep 2016 11:46:02 +0000]
make S_already_defined() in op.c return void

Currently it returns a boolean value, but after the removal of the MAD
code, this value is just equivalent to its 'block' arg; so instead just
make its callers test 'block' instead. This makes the calling code in
newATTRSUB_x and newMYSUB easier to follow.

Also, put the block condition on a single line (whitespace change)

5 days agoreindent and reformat newMYSUB and newATTRSUB_x
David Mitchell [Mon, 5 Sep 2016 11:37:55 +0000]
reindent and reformat newMYSUB and newATTRSUB_x

This commit only contains whitespace changes.

As a follow-on from the previous commit, reindent a  couple of block of
code; but also do a general re-indenting and partial refomatting of these
two similar functions, which were a bit of mess and hard to follow:

    * replace weird mixtures of indents with standard 4-indents;
    * split if (X) Y  into two lines;
    * separate out blocks with a blank line;
    * outdent labels by exactly 2 spaces

5 days agonewMYSUB/Perl_newATTRSUB_x remove a goto
David Mitchell [Mon, 5 Sep 2016 11:08:56 +0000]
newMYSUB/Perl_newATTRSUB_x remove a goto

In both these functions there is code like:

    if (!block)
       goto attrs;
    ...
  attrs:

Change them to

    if (block) {
        ...
    }
  attrs:

Lets not use gotos if there's a better way.

Will re-indent in next commit.

5 days agoavoid using freed ops on BEGIN :attr {}
David Mitchell [Mon, 5 Sep 2016 10:52:23 +0000]
avoid using freed ops on BEGIN :attr {}

If a BEGIN sub has a code attribute applied (no idea why you would want to
do such a thing, but it's not illegal) then part of applying the attribute
is to do 'use attributes', which compiles

    BEGIN { require "attributes"; attributes->import(AAA) }

so we end up compiling a BEGIN while in the middle of compiling a BEGIN.
The part of Perl_newATTRSUB_x() that under some circumstances copies
the body of the newly-compiled CV to the old CV which occupies the name
slot, kicks in here.

Since the ops that make up the AAA above were allocated from the old
BEGIN's op slabs, they get prematurely freed when the old BEGIN's
ops are discarded by the SvREFCNT_dec(PL_compcv).

The simplest fix is to just avoid the copy if we're compiling a BEGIN.

5 days agodo_sv_dump(): handle CvSTART() as slab address
David Mitchell [Mon, 5 Sep 2016 10:15:49 +0000]
do_sv_dump(): handle CvSTART() as slab address

If a CV is CvSLABBED(), then CvSTART() points to the op slab rather than a
start op. Make Perl_do_sv_dump() display this more informatively.

5 days agoassert op not freed in finalize_op() and rpeep()
David Mitchell [Sat, 27 Aug 2016 13:28:24 +0000]
assert op not freed in finalize_op() and rpeep()

This should never happen.

5 days agoparser.t: Suppress warning
Father Chrysostomos [Mon, 5 Sep 2016 05:11:00 +0000]
parser.t: Suppress warning

5 days agoRegression test for RT #129196
Dan Collins [Sun, 4 Sep 2016 18:43:41 +0000]
Regression test for RT #129196

5 days ago[perl #129196] Crash/bad read with ‘evalbytes S’
Father Chrysostomos [Mon, 5 Sep 2016 03:24:19 +0000]
[perl #129196] Crash/bad read with ‘evalbytes S’

5dc13276 added some code to toke.c that did not take into account
that the opnum (‘f’) argument to UNI* could be a negated op number.
PL_last_lop_op must never be negative, since it is used as an offset
into a struct.

Tests for the crash will come in the next commit.

5 days agoinline.h: Declare functions to be inline
Karl Williamson [Sat, 3 Sep 2016 18:17:17 +0000]
inline.h: Declare functions to be inline

The branch merged with commit 8d19ebbca9eecf219cc453cffe88722722860dd9
forgot to give this hint to the compiler.

5 days agorelease_schedule.pod: Tick off last month
Father Chrysostomos [Sun, 4 Sep 2016 23:02:02 +0000]
release_schedule.pod: Tick off last month

5 days ago[perl #129073] Assert failure: ${p{};sub p}()
Father Chrysostomos [Sun, 4 Sep 2016 21:22:37 +0000]
[perl #129073] Assert failure: ${p{};sub p}()

When parsing the special ${var{subscript}} syntax, the lexer notes
that the } matching the ${ will be a fake bracket, and should
be ignored.

In the case of ${p{};sub p}() the first syntax error causes tokens to
be popped, such that the } following the sub declaration ends up being
the one treated as a fake bracket and ignored.

The part of the lexer that deals with sub declarations treats a ( fol-
lowing the sub name as a prototype (which is a single term) if signa-
tures are disabled, but ignores it and allows the rest of the lexer to
treat it as a parenthesis if signatures are enabled.

Hence, the part of the parser (perly.y) that parses signatures knows
that a parenthesis token can only come after a sub if signatures are
enabled, and asserts as much.

In the case of an error and tokens being discarded, a parenthesis may
come after a sub name as far as the parser is concerned, even though
there was a } in between that got discarded.  The sub part of the
lexer, of course did not see the parenthesis because of the interven-
ing brace, and did not treat it as a prototype.  So we get an asser-
tion failure.

The simplest fix is to loosen up the assertion and allow for anomalies
after errors.  It does not hurt to go ahead and parse a signature at
this point, even though the feature is disabled, because there has
been a syntax error already, so the parsed code will never run, and
the parsed sub will not be installed.

6 days agoFix checks for tainted dir in $ENV{PATH}
Father Chrysostomos [Sat, 3 Sep 2016 20:30:22 +0000]
Fix checks for tainted dir in $ENV{PATH}

$ cat > foo
#!/usr/bin/perl
print "What?!\n"
^D
$ chmod +x foo
$ ./perl -Ilib -Te '$ENV{PATH}="."; exec "foo"'
Insecure directory in $ENV{PATH} while running with -T switch at -e line 1.

That is what I expect to see.  But:

$ ./perl -Ilib -Te '$ENV{PATH}="/\\:."; exec "foo"'
What?!

Perl is allowing the \ to escape the :, but the \ is not treated as an
escape by the system, allowing a relative path in PATH to be consid-
ered safe.

6 days agotaint.t: Set up @INC before using it
Father Chrysostomos [Sat, 3 Sep 2016 17:15:22 +0000]
taint.t: Set up @INC before using it

The ‘chdir t’ line is useless if we require ./loc_tools.pl before
setting up @INC properly, as loc_tools.pl uses warnings.pm.

7 days agoTry harder to clean up %ENV in 140_proxy.t.
Craig A. Berry [Sat, 3 Sep 2016 15:59:55 +0000]
Try harder to clean up %ENV in 140_proxy.t.

While the localization earlier in the test *should* leave the
relevent %ENV entries in a good state for the final test, for
some reason this is not happening on VMS.  It may have something
to do with the fact that %ENV has all upper case keys but the
test has previously localized both upper and lower case versions.

In any case, even though it isn't this test's fault, the easiest
and safest way to get it passing is to just do another clean-up.

Awaiting upstream application at:

https://github.com/chansen/p5-http-tiny/pull/95

7 days agoDon't pollute $ENV{LC_ALL} in pod/perlmodlib.PL.
Craig A. Berry [Fri, 2 Sep 2016 20:43:52 +0000]
Don't pollute $ENV{LC_ALL} in pod/perlmodlib.PL.

Because on VMS, DYNAMIC_ENV_FETCH makes environment settings
persist after program exit, and running a program (e.g. Perl)
does not normally start a separate process.  This was confusing
the inadequate attempt in t/run/locale.t to clear the locale-related
environment variables.

7 days agoDelete localized %ENV entries in t/run/locale.t.
Craig A. Berry [Fri, 2 Sep 2016 19:59:25 +0000]
Delete localized %ENV entries in t/run/locale.t.

Localizing %ENV entries actually instantiates them with an undef
value, which, at least on VMS, gets propagated to the various
runperl subprocesses where it can trigger locale warnings at start-up
time.  Deleting the localized entries, though, actually removes
them from the localized %ENV:

$ perl -E '{ local $ENV{FOO}; say exists $ENV{FOO} ? 'Y' : 'N'; }'
Y
$ perl -E '{ delete local $ENV{FOO}; say exists $ENV{FOO} ? 'Y' : 'N'; }'
N

but any pre-existing values in outer scope are safely restored when
the local scope exits.

This gets this test passing on VMS again for the first time in a
very long time.  It turns out pod/perlmodlib.PL has been polluting
LC_ALL and this test has not been adequately defending itself.

7 days agoMore stderr suppression in t/run/locale.t.
Craig A. Berry [Fri, 2 Sep 2016 19:17:45 +0000]
More stderr suppression in t/run/locale.t.

Closing stderr in the parent process doesn't have any effect on
Perl in the subprocess on VMS, so use the facility in the test
infrastructure to suppress stderr there as well.

8 days agoRemove obsolete Test prereq from PathTools
Dagfinn Ilmari Mannsåker [Fri, 2 Sep 2016 15:47:45 +0000]
Remove obsolete Test prereq from PathTools

It was ported to Test::More in cba09117 in 2011, but the upstream
Makefile.PL that was added in 8e6d3e2b in 2013 took the Makefile.PL from
the last CPAN release which was from 2008.

8 days agoMake PERLLIB_SEP dynamic on VMS.
Craig A. Berry [Thu, 1 Sep 2016 18:30:28 +0000]
Make PERLLIB_SEP dynamic on VMS.

Because if we're running under a Unix shell, the path separator is
likely to meet the expectations of Unix shell scripts better if it's
the Unix ':' rather than the VMS '|'.  There is no change when
running under DCL.

8 days agoCorrect 'map' documentation to reflect operation on a list.
Dave Cross [Thu, 1 Sep 2016 22:29:58 +0000]
Correct 'map' documentation to reflect operation on a list.

Rather than on an array.

For: RT #126169.

Dave Cross is now a Perl Author.

8 days agoProvide missing link for one instance of 'eval'.
James E Keenan [Thu, 1 Sep 2016 18:39:16 +0000]
Provide missing link for one instance of 'eval'.

As originally reported by KES.  See RT #129168.

8 days agoFix is_utf8_valid_partial_char()
Karl Williamson [Thu, 1 Sep 2016 18:07:33 +0000]
Fix is_utf8_valid_partial_char()

This should have been part of 4dab108fb5e7e21a547733bb00ddb5d8bffd936d,
but when I was rebasing, these changes got moved to an unrelated commit
that hasn't been pushed yet, and I didn't notice immediately.  I will
add som API tests for this in the next few days.

9 days agoAdd C macros for UTF-8 for BOM and REPLACEMENT CHARACTER
Karl Williamson [Sun, 28 Aug 2016 03:17:49 +0000]
Add C macros for UTF-8 for BOM and REPLACEMENT CHARACTER

This makes it easy for module authors to write XS code that can use
these characters, and be automatically portable to EBCDIC systems.

9 days agoMerge branch for improving API UTF-8 handling into blead
Karl Williamson [Thu, 1 Sep 2016 02:33:21 +0000]
Merge branch for improving API UTF-8 handling into blead

This set of commits came about to allow XS code to more easily and
quickly check for valid UTF-8 without rolling their own, which could be
lacking in security considerations.

Most of the small UTF-8 handling functions have now been inlined, and
the validity-only checking function has been rewritten to never need to
actually calculate the code point the UTF-8 represents.

The original impetus for this was because of changes in Encode that made
it vulnerable to malformed UTF-8.  These changes were to speed up its
UTF-8 processing.  By changing Encode to use this new stuff, it is
sped up on valid input by over a factor of 5 from the original
implementation, at the expense of slowing down entirely invalid input by
a factor of 4.  Since we are expecting mostly valid input, this is an
overall big win.  The original handrolled Encode changes sped up valid
input handling by about 1.5, without slowing handling of invalid down
appreciably.

9 days agoUse new is_utf8_valid_partial_char()
Karl Williamson [Mon, 29 Aug 2016 04:04:16 +0000]
Use new is_utf8_valid_partial_char()

This new function can be used in the implementation of the file test
operators, -B and -T, to see if the whole fixed length buffer is valid
UTF-8.  Previously if all bytes were UTF-8 except the bytes at the end
that could have been a partial character, it assumed the whole thing was
UTF-8.  This improves the prediction slightly

9 days agoAdd is_utf8_valid_partial_char()
Karl Williamson [Sun, 28 Aug 2016 16:54:13 +0000]
Add is_utf8_valid_partial_char()

This new function can test some purported UTF-8 to see if it is
well-formed as far as it goes.  That is there aren't enough bytes for
the character they start, but what is there is legal so far.  This can
be useful in a fixed width buffer, where the final character is split in
the middle, and we want to test without waiting for the next read that
the entire buffer is valid.

9 days agoMake 3 UTF-8 macros API
Karl Williamson [Sun, 28 Aug 2016 02:08:52 +0000]
Make 3 UTF-8 macros API

These may be useful to various module writers.  They certainly are
useful for Encode.  This makes public API macros to determine if the
input UTF-8 represents (one macro for each category)
    a) a surrogate code point
    b) a non-character code point
    c) a code point that is above Unicode's legal maximum.

The macros are machine generated.  In making them public, I am now using
the string end location parameter to guard against running off the end
of the input.  Previously this parameter was ignored, as their use in
the core could be tightly controlled so that we already knew that the
string was long enough when calling these macros.  But this can't be
guaranteed in the public API.  An optimizing compiler should be able to
remove redundant length checks.

9 days agoutf8.c: Add comments
Karl Williamson [Fri, 26 Aug 2016 22:47:32 +0000]
utf8.c: Add comments

9 days agois_utf8_string() is now a pure function
Karl Williamson [Fri, 26 Aug 2016 22:53:00 +0000]
is_utf8_string() is now a pure function

as of the previous commit

9 days agoMove isUTF8_CHAR helper function, and reimplement it
Karl Williamson [Fri, 26 Aug 2016 22:29:54 +0000]
Move isUTF8_CHAR helper function, and reimplement it

The macro isUTF8_CHAR calls a helper function for code points higher
than it can handle.  That function had been an inlined wrapper around
utf8n_to_uvchr().

The function has been rewritten to not call utf8n_to_uvchr(), so it is
now too big to be effectively inlined.  Instead, it implements a faster
method of checking the validity of the UTF-8 without having to decode
it.  It just checks for valid syntax and now knows where the
few discontinuities are in UTF-8 where overlongs can occur, and uses a
string compare to verify that overflow won't occur.

As a result this is now a pure function.

This also causes a previously generated deprecation warning to not be,
because in printing UTF-8, no longer does it have to be converted to
internal form.  I could add a check for that, but I think it's best not
to.  If you manipulated what is getting printed in any way, the
deprecation message will already have been raised.

This commit also fleshes out the documentation of isUTF8_CHAR.

9 days agoAdd #defines for UTF-8 of highest representable code point
Karl Williamson [Fri, 26 Aug 2016 22:23:24 +0000]
Add #defines for UTF-8 of highest representable code point

This will allow the next commit to not have to actually try to decode
the UTF-8 string in order to see if it overflows the platform.

9 days agoutf8.h: Add some LIKELY() to help branch prediction
Karl Williamson [Fri, 26 Aug 2016 22:21:25 +0000]
utf8.h: Add some LIKELY() to help branch prediction

This macro gives the legal UTF-8 byte sequences.  Almost always, the
input will be legal, so help compiler branch prediction for that.

9 days agoutf8.h, utfebcdic.h: Add comments, align white space
Karl Williamson [Fri, 26 Aug 2016 22:07:22 +0000]
utf8.h, utfebcdic.h: Add comments, align white space

9 days agoInline is_utf8_string() and is_utf8_stringloclen()
Karl Williamson [Fri, 26 Aug 2016 21:53:36 +0000]
Inline is_utf8_string() and is_utf8_stringloclen()

9 days agoInline utf8_distance(), utf8_hop()
Karl Williamson [Fri, 26 Aug 2016 21:03:52 +0000]
Inline utf8_distance(), utf8_hop()

9 days agoSlightly simplify utf8_to_uvuni_buf()
Karl Williamson [Fri, 26 Aug 2016 20:47:17 +0000]
Slightly simplify utf8_to_uvuni_buf()

Use a function that does the same thing.  This also clarifies a related
comment

9 days agoInline is_utf8_invariant_string()
Karl Williamson [Fri, 26 Aug 2016 20:07:50 +0000]
Inline is_utf8_invariant_string()

9 days agois_utf8_invariant_string is pure
Karl Williamson [Fri, 26 Aug 2016 19:54:51 +0000]
is_utf8_invariant_string is pure

As are its synonyms.  This also declares the formal parameters 'const'

9 days agoSimplify slightly is_utf8_invariant_string
Karl Williamson [Fri, 26 Aug 2016 19:52:52 +0000]
Simplify slightly is_utf8_invariant_string

This eliminates an unnecessary branch test in unoptimized code.

9 days agoUse new name 'is_utf8_invariant_string' in core
Karl Williamson [Fri, 26 Aug 2016 19:42:53 +0000]
Use new name 'is_utf8_invariant_string' in core

This changes the places in the core to use the clearer synonym added by
the previous commit.  It also changes one place that hand-rolled its own
code to use this function instead.

9 days agoAdd new synonym 'is_utf8_invariant_string'
Karl Williamson [Fri, 26 Aug 2016 19:35:28 +0000]
Add new synonym 'is_utf8_invariant_string'

This is clearer as to its meaning than the existing 'is_ascii_string'
and 'is_invariant_string', which are retained for back compat.  The
thread context variable is removed as it is not used.

9 days agoembed.fnc: Replace blanks by tabs
Karl Williamson [Tue, 23 Aug 2016 19:37:10 +0000]
embed.fnc: Replace blanks by tabs

In this file, tabs are the more accepted field delimiter, and having
them makes it easier to search for particular patterns in it.

9 days agoutf8.c: Use 'break' instead of 'goto'
Karl Williamson [Mon, 22 Aug 2016 18:28:21 +0000]
utf8.c: Use 'break' instead of 'goto'

The goto is a relic of a previous implementation; 'break' is preferred
if there isn't a reason to use goto.

9 days agois_utf8_string_loc() param should not be NULL
Karl Williamson [Mon, 22 Aug 2016 18:25:00 +0000]
is_utf8_string_loc() param should not be NULL

It makes no sense to call this function with a NULL parameter, as the
whole point of using this function is to set what that param points to.
If you don't want this, you should be using the similar function that
doesn't have this parameter.

9 days agoDocument valid_utf8_to_uvchr() and inline it
Karl Williamson [Mon, 22 Aug 2016 18:21:06 +0000]
Document valid_utf8_to_uvchr() and inline it

This function has been in several releases without problem, and is short
enough that some compilers can inline it.  This commit also notes that
the result should not be ignored, and removes the unused pTHX.  The
function has explicitly been marked as being changeable, and has not
been part of the API until now.

9 days agoutf8.c: Clarify comments for valid_utf8_to_uvchr()
Karl Williamson [Mon, 22 Aug 2016 16:48:55 +0000]
utf8.c: Clarify comments for valid_utf8_to_uvchr()

9 days agoutf8.c: Join EBCDIC/non-EBCDIC code
Karl Williamson [Mon, 22 Aug 2016 16:59:48 +0000]
utf8.c: Join EBCDIC/non-EBCDIC code

This was missed in 534752c1d25d7c52c702337927c37e40c4df103d

9 days agoregen/embed.pl: Allow inline funcs to be named Perl_foo
Karl Williamson [Fri, 26 Aug 2016 21:25:20 +0000]
regen/embed.pl: Allow inline funcs to be named Perl_foo

When inlining an existing public function whose name begins with Perl_,
it's best to keep that name, in case someone is calling it that way.
Prior to this commit, the name had to be changed to S_foo.

9 days agoUpdate outdated man links for strlcpy and strlcat.
Theo Buehler [Sat, 27 Aug 2016 01:36:28 +0000]
Update outdated man links for strlcpy and strlcat.

9 days agoAdd Theo Buehler to AUTHORS
Karl Williamson [Thu, 1 Sep 2016 00:07:55 +0000]
Add Theo Buehler to AUTHORS

9 days agoPATCH: [perl #129122] regex sets syntax error
Karl Williamson [Wed, 31 Aug 2016 23:05:45 +0000]
PATCH: [perl #129122] regex sets syntax error

This was caused by two statements being in the wrong order.  One should
save something on the stack before changing it, not after.

However fixing this led to the discovery of another bug in which an
error case was failed to be detected.

9 days agoregcomp.c: Typo, spacing in comment
Karl Williamson [Wed, 31 Aug 2016 22:57:20 +0000]
regcomp.c: Typo, spacing in comment

11 days agoPorting/bisect.pl: /usr/sbin/sysctl exists
Karl Williamson [Sun, 24 Jul 2016 00:28:52 +0000]
Porting/bisect.pl: /usr/sbin/sysctl exists

11 days agoRevert "perlinterp: Use 'e.g' not 'i.e.' for 'for example'"
Karl Williamson [Mon, 29 Aug 2016 23:06:50 +0000]
Revert "perlinterp: Use 'e.g' not 'i.e.' for 'for example'"

This reverts commit ce66b506fa280c2ede0b0d4a3e81b53d0e31cb48.

I misread the text.  This is an exhaustive list, so "i.e." is proper.

11 days agoPATCH: [perl #129038] Crash with s///l
Karl Williamson [Sun, 28 Aug 2016 01:16:17 +0000]
PATCH: [perl #129038] Crash with s///l

The cause of this was bad logic.  It thought it was dealing with UTF-8
when it wasn't.

11 days agoperlinterp: Use 'e.g' not 'i.e.' for 'for example'
Karl Williamson [Sun, 28 Aug 2016 15:39:38 +0000]
perlinterp: Use 'e.g' not 'i.e.' for 'for example'

12 days ago[RT #129069] Perl_yylex: Fix two use-after-free bugs
Dan Collins [Wed, 24 Aug 2016 18:19:09 +0000]
[RT #129069] Perl_yylex: Fix two use-after-free bugs

Perl_yylex maintains up to two pointers, `s` and `d`, into the parser
buffer at PL_bufptr. It can call skipspace(), which can potentially
grow (and realloc) its argument. This can leave the second pointer
pointing at the old buffer. Under most cases it isn't visible, because
the old buffer isn't reused or zeroed. However, under Valgrind or
libdislocator, this memory management error becomes visible.

This patch saves the location of the second pointer in two locations,
and restores it after the call to skipspace.

13 days ago[perl #125679] Don’t make lvref ops on error
Father Chrysostomos [Sun, 28 Aug 2016 14:21:19 +0000]
[perl #125679] Don’t make lvref ops on error

When converting an op into an lvref op (the rv2av in \(@_)=... gets
converted while the refgen gets nulled), if we reject the op as a
valid one for refaliasing we should not go ahead and convert it.  It
we do convert it (as we were doing), then we may convert an op that
uses op_targ for auxiliary information into one that uses it as a pad
offset.  When freeing the op, we will then be reading a ‘random’ off-
set in the pad and trying to free the SV.  That pad entry may not even
be within the pad.

In the specific case of entereval, op_targ holds the hints, and the
larger the value of $^H, the more likely it is to crash.  So
BEGIN{$^H=-1}\eval=... will crash.

2 weeks agoUpgrade to Thread::Semaphore 2.13
jdhedden [Sat, 27 Aug 2016 13:01:40 +0000]
Upgrade to Thread::Semaphore 2.13

2 weeks agoIncrease $Filter::Simple::VERSION to 0.93
Father Chrysostomos [Fri, 26 Aug 2016 13:37:05 +0000]
Increase $Filter::Simple::VERSION to 0.93

2 weeks ago[perl #107726] Filter::Simple: ‘use’ and then ‘no’
Ricardo SIGNES [Fri, 26 Aug 2016 13:36:09 +0000]
[perl #107726] Filter::Simple: ‘use’ and then ‘no’

Filter::Simple was erroneously signalling eof if it encountered a
‘no MyFilter’ right after ‘use’:

use MyFilter;
no MyFilter;

In this case it should simply not filter anything.

The reason for the bug was that the ‘while ($status = filter_read())’
loop in Filter::Simple::gen_filter_import was not incrementing $count
(a variable used basically as a boolean to remember whether we are
still getting input from the file) when finding the terminator (no
MyFilter).  So it would conclude after the loop that the file had come
to an end and simply return 0.

[Commit message written by the committer.]

2 weeks ago[perl #107726] Test for Filter::Simple and ‘no’
Father Chrysostomos [Fri, 26 Aug 2016 13:20:05 +0000]
[perl #107726] Test for Filter::Simple and ‘no’

use MyFilter;
no MyFilter;

does not work.  A fix is forthcoming.

2 weeks agoperlinterp.pod: Expand the op tree section
Father Chrysostomos [Thu, 11 Aug 2016 06:43:34 +0000]
perlinterp.pod: Expand the op tree section

based on things that came up in the thread starting at
<20160808225325.79944d95@shy.leonerd.org.uk>.

2 weeks agoRemove VMS-specific hacks from showlex.t.
Craig A. Berry [Fri, 26 Aug 2016 02:09:01 +0000]
Remove VMS-specific hacks from showlex.t.

I added this 15 years ago in d0c1fe9a9931bc27, but it isn't
necessary for any VMS version now supported and it has recently
caused the test to start failing under the test suite but not
when run individually.  So just get rid of it.