platform/upstream/perl.git
11 years agoSwitch dump.c over to using SvREFCNT_dec_NN
Father Chrysostomos [Sat, 8 Dec 2012 14:06:11 +0000 (06:06 -0800)]
Switch dump.c over to using SvREFCNT_dec_NN

No uses of SvREFCNT_dec in dump.c are ever passed null SVs, so
don’t check for that.

11 years agodoio.c: Use SvREFCNT_dec_NN
Father Chrysostomos [Sat, 8 Dec 2012 14:00:28 +0000 (06:00 -0800)]
doio.c: Use SvREFCNT_dec_NN

The sole use of SvREFCNT_dec in doio.c is on a variable than is
never null (setdefout would fail an assertion otherwise), so
no need to check whether it is.

11 years agoConvert some SvREFCNT_dec's to SvREFCNT_dec_NN's for efficiency
Steffen Mueller [Sun, 9 Dec 2012 16:26:13 +0000 (17:26 +0100)]
Convert some SvREFCNT_dec's to SvREFCNT_dec_NN's for efficiency

11 years agoregexec.c: Replace infamous if-else-if sequence by loop
Karl Williamson [Fri, 7 Dec 2012 18:50:25 +0000 (11:50 -0700)]
regexec.c: Replace infamous if-else-if sequence by loop

This saves 1.5 KB in the text section on my machine in regexec.o
(unoptimized) and 820 optimized.  I did not benchmark, as we don't
really care very much about performance under 'use locale'.

11 years agoChange 4 byte bitmap to 32 bit single word
Karl Williamson [Fri, 7 Dec 2012 05:15:52 +0000 (22:15 -0700)]
Change 4 byte bitmap to 32 bit single word

I presume that the reason this bitmap was expressed in bytes was that
the macros for dealing with that were already readily available and
familiar, and because it could easily be grown.

However, it's extremely unlikely that we would ever need more bits.
This bit map is for the Posix character classes, and no one is making
more of them.  There is currently one spare bit available, and if we
don't back out of the \s and [:space:] unification, a second will become
available in 5.20 or 5.22.

Using a single word is more efficient, so this changes to use that.
Should we ever need more bits, we can change back.

11 years agohandy.h: Add an enum typedef
Karl Williamson [Fri, 7 Dec 2012 04:01:29 +0000 (21:01 -0700)]
handy.h: Add an enum typedef

This creates a copy of all the Posix character class numbers and puts
them in an enum.  This enum is for internal Perl core use only, and is
used so hopefully compilers can generate better code from future commits
that will make use of it.

11 years agohandy.h: Reorder char class #defines; add comments
Karl Williamson [Fri, 7 Dec 2012 03:48:29 +0000 (20:48 -0700)]
handy.h: Reorder char class #defines; add comments

This groups the Posix-like classes in two groups, one which contains
those classes whose above-Latin1 lookups are done via swashes; the other
which aren't.  This will prove useful in future commits.

11 years agoregcomp.h: Revise #define setup and checking
Karl Williamson [Fri, 7 Dec 2012 03:35:03 +0000 (20:35 -0700)]
regcomp.h: Revise #define setup and checking

This revises how these #defines are set up so that the order can change
(as will be done in a later commit), and the only dependencies are on
VERTWS and the max one from handy.h.

11 years agohandy.h: Add comment
Karl Williamson [Fri, 7 Dec 2012 02:09:26 +0000 (19:09 -0700)]
handy.h: Add comment

11 years agoregexec.c: White space only; no code changes
Karl Williamson [Thu, 6 Dec 2012 17:14:38 +0000 (10:14 -0700)]
regexec.c: White space only; no code changes

This entire function was indented by 8 instead of the standard 4
columns.  I'm about to make significant changes to it, and would like
the extra 4 columns.

11 years agoMerge branch 'handy' into blead
Karl Williamson [Sun, 9 Dec 2012 17:31:09 +0000 (10:31 -0700)]
Merge branch 'handy' into blead

This branch revises some handy.h macros, implements some that are
missing, more fully documents the set of them, adds missing tests,
hides from the API the functions that these macros may call, and
deprecates the similar functions not used in the Perl core.

11 years agoDeprecate some functions in utf8.c
Karl Williamson [Fri, 7 Dec 2012 04:41:23 +0000 (21:41 -0700)]
Deprecate some functions in utf8.c

These functions are not used by the Perl core.  Code should be using
the equivalent macros in handy.h that may avoid a function call.

11 years agohandy.h: Improve isDIGIT_utf8() and isXDIGIT_utf8() macros
Karl Williamson [Fri, 7 Dec 2012 01:49:14 +0000 (18:49 -0700)]
handy.h: Improve isDIGIT_utf8() and isXDIGIT_utf8() macros

There are no digits in the upper Latin1 range, therefore we can skip
testing for such.

11 years agoutf8.c: Add locale support to functions
Karl Williamson [Thu, 6 Dec 2012 16:10:41 +0000 (09:10 -0700)]
utf8.c: Add locale support to functions

These functions were marked as XXX to add locale support.  It was a
simple matter to do.  We support locales for code points under 256,
so just call the appropriate macro for those, returning the Unicode
interpretation for those over 255.

11 years agohandy.h: Change documentation for perlapi
Karl Williamson [Mon, 3 Dec 2012 23:57:05 +0000 (16:57 -0700)]
handy.h: Change documentation for perlapi

This documents several more of the character classification macros,
including all variants of them.  There are no code changes.

The READ_XDIGIT macro was moved to "Miscellaneous Functions", as it
really isn't character classification.

Several of the macros remain undocumented because I'm not comfortable
yet about their names/and or functionality.

11 years agoperlapi: Remove a bunch of functions from API
Karl Williamson [Mon, 3 Dec 2012 06:09:57 +0000 (23:09 -0700)]
perlapi: Remove a bunch of functions from API

These functions are undocumented.  We add a flag in embed.fnc to stop
them from being listed as undocumented functions suitable for
documenting.  They should not be used explicitly, but exist only to aid
macros in handy.h that need functions to handle portions of their
functionality.  Thus the handy.h macros should be used; not these.

11 years agohandy.h: Sort macros in groups alphabetically
Karl Williamson [Mon, 3 Dec 2012 05:33:49 +0000 (22:33 -0700)]
handy.h: Sort macros in groups alphabetically

This should make it easier to find things.  No code changes, but there
are some comment changes

11 years agohandy.h: Make clear that macro is only true in ASCII range
Karl Williamson [Mon, 3 Dec 2012 05:21:57 +0000 (22:21 -0700)]
handy.h: Make clear that macro is only true in ASCII range

I don't believe there are platforms that this is wrong on, but using the
_A suffix clearly indicates that only ASCII-range characters can match
this, like its cohort macros that surround it.

11 years agohandy.h: Fix isBLANK_LC_uni()
Karl Williamson [Mon, 3 Dec 2012 05:17:27 +0000 (22:17 -0700)]
handy.h: Fix isBLANK_LC_uni()

This macro can be defined in terms of the foo_uvchr() version.  It
should be correct on platforms that have an isblank() function in the C
library.  I don't know why this macro exists.  It doesn't correspond to
any of the other ones (though a recent commit removed one it did
correspond to, but which can't have been in use because it expanded to a
non-existent function).  I'm leaving it in just for back compat.  I did
not add tests for this macro.

11 years agoext/XS-APItest/t/handy.t: White space only
Karl Williamson [Mon, 3 Dec 2012 05:08:33 +0000 (22:08 -0700)]
ext/XS-APItest/t/handy.t: White space only

Indent a newly formed block

11 years agohandy.h: White space only
Karl Williamson [Mon, 3 Dec 2012 05:06:31 +0000 (22:06 -0700)]
handy.h: White space only

This makes things line up in columns and not exceed 80 columns in width.

11 years agoXS-APItest: Add tests for handy.h
Karl Williamson [Mon, 3 Dec 2012 04:34:41 +0000 (21:34 -0700)]
XS-APItest: Add tests for handy.h

This adds missing tests for the locale versions of the macros in
handy.h, plus some to make sure that WORDCHAR and ALNUM are synonyms

11 years agoutf8.c: Change is_uni_idfirst_lc() to use Perl's defn
Karl Williamson [Mon, 3 Dec 2012 04:55:16 +0000 (21:55 -0700)]
utf8.c: Change is_uni_idfirst_lc() to use Perl's defn

The Perl definition is slightly more restrictive of what Unicode's
idfirst is.  We should use our definition consistently.

11 years agohandy.h: Fix up Posix Space macros
Karl Williamson [Mon, 3 Dec 2012 04:46:50 +0000 (21:46 -0700)]
handy.h: Fix up Posix Space macros

Under the default Posix locale, \s and [[:space:]] are the same, so
there is no need to try to make sure that [[:space:]] matches a vertical
tab -- it already does.  Also one of the macros had a typo, trying to
add a form feed instead of a vertical tab

11 years agoAdd functions for getting ctype ALNUMC
Karl Williamson [Mon, 3 Dec 2012 04:01:12 +0000 (21:01 -0700)]
Add functions for getting ctype ALNUMC

We think this is meant to stand for C's alphanumeric, that is what is
matched by POSIX [:alnum:].  There were not functions and a dedicated
swash available for accessing it.  Future commits will want to use
these.

11 years agohandy.h: Add some missing macros
Karl Williamson [Mon, 3 Dec 2012 03:48:20 +0000 (20:48 -0700)]
handy.h: Add some missing macros

Not all character classifications had macros.  This commit adds all but
one of the missing ones.  It will be added in a separate commit.

11 years agohandy.h: Add synonym for some macros
Karl Williamson [Mon, 3 Dec 2012 03:42:06 +0000 (20:42 -0700)]
handy.h: Add synonym for some macros

For some time, WORDCHAR has been preferred to ALNUM because of the
nearly identical ALNUMC which means something else (the C language
definition of alnum).  This adds macros for WORDCHAR, while retaining
ALNUM for backwards compatibility.

Also, another macro is redefined using WORDCHAR in preference to ALNUM

11 years agohandy.h: Make some macros more time efficient
Karl Williamson [Mon, 3 Dec 2012 03:09:46 +0000 (20:09 -0700)]
handy.h: Make some macros more time efficient

These macros check if a UTF-8 encoded character is of particular types
for use with locales.  Prior to this patch, they called a function to
convert the character to a code point value.  This was used as input to
another macro that handles code points.  For values above the Latin1
range, that macro calls a function, which converts back to UTF-8 and
calls another function.

This commit changes that to call the UTF-8 function directly for
above-Latin1 code points.  No conversion need be done.  For Latin1 code
points, it converts, if necessary, to the code point and calls a macro
that handles these directly.

Some of these macros now use a macro instead of a function call for
above-Latin1 code points, as is done in various other places in this
file.

11 years agohandy.h: Avoid function calls in 2 macros
Karl Williamson [Mon, 3 Dec 2012 03:02:03 +0000 (20:02 -0700)]
handy.h: Avoid function calls in 2 macros

There is a macro that returns the same as the function call previously
used in the SPACE macro; and nothing above Latin1 can possibly match the
CNTRL macro

11 years agohandy.h: Define some macros using a base macro
Karl Williamson [Mon, 3 Dec 2012 02:57:12 +0000 (19:57 -0700)]
handy.h: Define some macros using a base macro

This allows the common parts of the definitions of these to all use the
same logic

11 years agohandy.h: Define some locale macros for all inputs
Karl Williamson [Mon, 3 Dec 2012 02:41:11 +0000 (19:41 -0700)]
handy.h: Define some locale macros for all inputs

Prior to this commit, if you called these macros with something outside
the Latin1 range, the return value was not defined, subject to the whims
of your particular C compiler and library.  This commit causes all the
boolean macros to return FALSE for non-Latin1 inputs; and all the map
macros to return their inputs

11 years agohandy.h: Remove unused macro
Karl Williamson [Sun, 2 Dec 2012 19:17:16 +0000 (12:17 -0700)]
handy.h: Remove unused macro

This macro expands to a function or macro call that does not exist, so
this macro itself can't be being used by anyone.  It also doesn't fit
the paradigm of the other macros above it, being defined in terms of
uni instead of uvchr; nor does it really gain anything, since \s is a
posix space under locale.  The \f also appears to be a typo, based on
the commit message, it should have been \v.

11 years agohandy.h: Change EBCDIC isSPACE() to include \v
Karl Williamson [Sun, 2 Dec 2012 19:13:36 +0000 (12:13 -0700)]
handy.h: Change EBCDIC isSPACE() to include \v

This was missed in commit 075b9d7d9a6d4473b240a047655e507c8baa6db3

11 years agoembed.fnc: Note that 'A' functions not necessarily public API
Karl Williamson [Mon, 3 Dec 2012 05:14:07 +0000 (22:14 -0700)]
embed.fnc: Note that 'A' functions not necessarily public API

An 'M' in a function entry means that undocumented functions are
suppressed from perlapi.pod.  Change the comments in embed.fnc to
indicate that, and the text in perlapi to warn against using unlisted
functions.

11 years agolocale.t: Add test
Karl Williamson [Fri, 7 Dec 2012 02:20:22 +0000 (19:20 -0700)]
locale.t: Add test

This makes sure that taint isn't being added unnecessarily

11 years agolocale.t: Add optional test name supplement
Karl Williamson [Fri, 7 Dec 2012 02:19:13 +0000 (19:19 -0700)]
locale.t: Add optional test name supplement

This allows tests to have extra stuff passed in that will be printed as
part of the test results

11 years agoregcomp.c: Typo in comment; white space
Karl Williamson [Fri, 7 Dec 2012 02:07:41 +0000 (19:07 -0700)]
regcomp.c: Typo in comment; white space

11 years agopp.c pp_pack.c: Use macro instead of function
Karl Williamson [Thu, 6 Dec 2012 18:31:19 +0000 (11:31 -0700)]
pp.c pp_pack.c: Use macro instead of function

This converts to use is_SPACE_utf8() instead of the (soon to be
deprecated) is_utf8_space().  The macro is faster, avoiding the function
call completely, so the performance need to make a special case for a SPACE
character is gone.

11 years agoregcomp.c:regprop: [bracketize] \w..., add \v
Karl Williamson [Thu, 6 Dec 2012 16:20:51 +0000 (09:20 -0700)]
regcomp.c:regprop: [bracketize] \w..., add \v

This function returns the name of a character class given its number.
This changes the name of \w, \s, \d to be [\w] ....  And it adds an
entry for \v and \V.  These makes a complete set, and will make things
easier to read, as a result of changes coming in future commits

11 years agoregexec.c: Nits coding standards-type changing
Karl Williamson [Thu, 6 Dec 2012 04:53:06 +0000 (21:53 -0700)]
regexec.c: Nits coding standards-type changing

11 years agoperl.h: Add comments
Karl Williamson [Thu, 6 Dec 2012 04:39:21 +0000 (21:39 -0700)]
perl.h: Add comments

11 years agoperlrecharclass: Fix defn of [:word:]
Karl Williamson [Thu, 6 Dec 2012 04:37:26 +0000 (21:37 -0700)]
perlrecharclass: Fix defn of [:word:]

11 years agointrpvar.h: Add comment
Karl Williamson [Mon, 3 Dec 2012 02:18:34 +0000 (19:18 -0700)]
intrpvar.h: Add comment

11 years agoAdd Todo test for Perl #114272
Karl Williamson [Mon, 3 Dec 2012 01:50:44 +0000 (18:50 -0700)]
Add Todo test for Perl #114272

11 years agoutf8.c: Combine 2 function calls into one
Karl Williamson [Mon, 3 Dec 2012 01:48:33 +0000 (18:48 -0700)]
utf8.c: Combine 2 function calls into one

There is a function that does both these together, more efficiently

11 years agoutf8.c: Move ARGS_ASSERT to earlier in function
Karl Williamson [Mon, 3 Dec 2012 01:47:23 +0000 (18:47 -0700)]
utf8.c: Move ARGS_ASSERT to earlier in function

to a place where people more expect to see it.

11 years agoembed.fnc: Add missing entry
Karl Williamson [Mon, 3 Dec 2012 04:20:36 +0000 (21:20 -0700)]
embed.fnc: Add missing entry

This function is defined in utf8.c, but isn't called by the core, and
there was no entry for it in embed.fnc

11 years agoSilence some g++ compiler warnings
Karl Williamson [Fri, 7 Dec 2012 05:42:18 +0000 (22:42 -0700)]
Silence some g++ compiler warnings

Changing these slightly got rid of the warnings like:
toke.c:9168: warning: format not a string literal and no format arguments

11 years agointrpvar.h: Use #define instead of hard-coded number
Karl Williamson [Sun, 9 Dec 2012 04:42:23 +0000 (21:42 -0700)]
intrpvar.h: Use #define instead of hard-coded number

The number 12 is mysterious as to why we are using it otherwise.

11 years agoSuppress deprec. warning from Devel::PPPort’s tests
Father Chrysostomos [Sun, 9 Dec 2012 02:38:46 +0000 (18:38 -0800)]
Suppress deprec. warning from Devel::PPPort’s tests

This has already been submitted to
<https://rt.cpan.org/Ticket/Display.html?id=81796>.

11 years agoleakfinder.pl: Skip push/unshift after { or (
Father Chrysostomos [Sat, 8 Dec 2012 14:45:18 +0000 (06:45 -0800)]
leakfinder.pl: Skip push/unshift after { or (

11 years agoleakfinder.pl: Fix select skip
Father Chrysostomos [Sat, 8 Dec 2012 14:40:52 +0000 (06:40 -0800)]
leakfinder.pl: Fix select skip

It wasn’t skipping select without parentheses, which was the purpose
of that (?:...) group.

11 years agoStop invalid charnames from leaking
Father Chrysostomos [Sat, 8 Dec 2012 14:36:59 +0000 (06:36 -0800)]
Stop invalid charnames from leaking

The tests I added earlier were failing for a different reason than the
test names suggested.

Invalid charnames are not leaking because of the ‘too many errors’
that yyerror croakingly utters, but are leaking even when yyerror
doesn’t croak.

S_get_and_check_backslash_N_name just needs to free the returned SV
before returning if it is undefined.

11 years agotoke.c:S_new_constant: Use NN SvREFCNT_inc in 2 places
Father Chrysostomos [Sat, 8 Dec 2012 13:49:13 +0000 (05:49 -0800)]
toke.c:S_new_constant: Use NN SvREFCNT_inc in 2 places

The sv argument passed to new_constant is never null.  If the function
it calls is naughty enough to push a null on the stack, new_constant’s
callers will crash anyway.  So we can assume res is not null.

This eliminates needless null checks.

11 years agoStop Constant(%s) errors from leaking
Father Chrysostomos [Sat, 8 Dec 2012 13:44:44 +0000 (05:44 -0800)]
Stop Constant(%s) errors from leaking

This error message uses yyerror, so it doesn’t abort immediately, but
adds it to the queue of error messages.

If there are ten accumulated errors, however, yyerror croaks with a
‘too many errors’ message.

In that circumstance these messages were leaking scalars.

Instead of creating an SV especially to hold the message to pass to
yyerror and then freeing it afterwards, we can instead use Perl_form,
which reuses the same SV every time (PL_mess_sv), eliminating that
leak.  In doing so, we can also combine this with another yyerror/
return in the vicinity, avoiding duplicate code.

The sv passed to S_new_constant was also leaking.  When there is no
error, it is currently mortalised.  When there is an error, it also
needs to be mortalised, in case it is a fatal error.  So this commit
changes it to mortalise it unconditionally.  This means we have to
SvREFCNT_inc the return value on error.

11 years agoChange Constant(undef) error to something meaningful
Father Chrysostomos [Fri, 7 Dec 2012 17:25:49 +0000 (09:25 -0800)]
Change Constant(undef) error to something meaningful

Look at these errors:

$ perl5.16.0 -e 'use overload; BEGIN{overload::constant q => sub{}; } "aaa"'
Constant(q): Call to &{$^H{q}} did not return a defined value at -e line 1, near "} "aaa""
Execution of -e aborted due to compilation errors.

$ perl5.16.0 -e 'BEGIN{++$_ for @INC{<charnames.pm _charnames.pm>}} "\N{a}"'
Constant(\N{a}) unknown at -e line 1, within string
Execution of -e aborted due to compilation errors.

$ perl5.16.0 -e 'use overload; BEGIN{overload::constant q => sub{}; } tr"aaa""'
Constant(tr): Call to &{$^H{q}} did not return a defined value at -e line 1, within string
Execution of -e aborted due to compilation errors.

The (q) and (tr) might seem a bit odd, but are not completely meaning-
less.  They match the third argument passed to the overload handler.
Now look at this:

$ perl5.16.0 -e 'use overload; BEGIN{overload::constant integer => sub{}; } 123'
Constant(undef): Call to &{$^H{integer}} did not return a defined value at -e line 1, at end of line
Execution of -e aborted due to compilation errors.

$ perl5.16.0 -e 'use overload; BEGIN{overload::constant float => sub{}; } 1.23'
Constant(undef): Call to &{$^H{float}} did not return a defined value at -e line 1, at end of line
Execution of -e aborted due to compilation errors.

$ perl5.16.0 -e 'use overload; BEGIN{overload::constant binary => sub{}; } 0x123'
Constant(undef): Call to &{$^H{binary}} did not return a defined value at -e line 1, at end of line
Execution of -e aborted due to compilation errors.

That Constant(undef) is not helpful.  This commit changes it to show
the number itself, making these cases similar to \N{}.

11 years agoTest ‘Constant(%s) unknown’ error
Father Chrysostomos [Fri, 7 Dec 2012 14:25:24 +0000 (06:25 -0800)]
Test ‘Constant(%s) unknown’ error

This only happens if someone accidentally (or intentionally :-) unde-
fines %^H or *^H or stops charnames from loading.

11 years agoTest error when constant overload handler returns undef
Father Chrysostomos [Fri, 7 Dec 2012 14:09:45 +0000 (06:09 -0800)]
Test error when constant overload handler returns undef

11 years agoperldiag: Make Constant(%s) messages match reality
Father Chrysostomos [Fri, 7 Dec 2012 04:24:34 +0000 (20:24 -0800)]
perldiag: Make Constant(%s) messages match reality

We no longer have an ‘in regex’ variant (if we ever did).

The Constant(%s)%s: %s represents three specific warnings, one of
which doesn’t have the colon any more.  It’s clearer if we list all
three, especially since the one about returning undef can acciden-
tally happen with ‘normal’ code (as opposed to code that fiddles with
%^H entries it shouldn’t be touching).

11 years agoperldiag: s/about where/whereabouts/
Father Chrysostomos [Thu, 6 Dec 2012 21:26:01 +0000 (13:26 -0800)]
perldiag: s/about where/whereabouts/

Every time I see that ‘about where’ I wonder why it sounds so funny.
It just dawned on me that we should just use the word ‘whereabouts’,
which fits perfectly in this context, and doesn’t sound as though it
needs a rewrite.

11 years agotoke.c: Make _charnames check more robust
Father Chrysostomos [Thu, 6 Dec 2012 07:10:25 +0000 (23:10 -0800)]
toke.c: Make _charnames check more robust

Assuming that $^H{charnames} exists and contains a code ref can result
in crashes.  See the tests in the diff.

It’s not a good idea to do $INC{"_charnames.pm"}++, but perl still
shouldn’t crash.

11 years agoMANIFEST typo
Father Chrysostomos [Thu, 6 Dec 2012 05:49:02 +0000 (21:49 -0800)]
MANIFEST typo

11 years agoFewer strEQ calls in toke.c:S_new_constant
Father Chrysostomos [Thu, 6 Dec 2012 02:27:18 +0000 (18:27 -0800)]
Fewer strEQ calls in toke.c:S_new_constant

There is a small fixed number of keys that can be passed to this
static function:

charnames
binary
float
integer
q
qr

In a few places, we check whether the key is "charnames".  It would
be quicker just to check the first character, since, if it is 'c', the
key must be "charnames".  (Under debugging builds, assert that that
assumption is true.)

11 years agogetline $/ = \N now reads N characters not bytes
Tony Cook [Sun, 9 Dec 2012 02:29:25 +0000 (13:29 +1100)]
getline $/ = \N now reads N characters not bytes

This was discussed for 5.16 but was not included as it was too late
for inclusion.

11 years agoremove the warning added for 5.16 and indicate the count is chars not bytes
Tony Cook [Sun, 9 Dec 2012 02:27:12 +0000 (13:27 +1100)]
remove the warning added for 5.16 and indicate the count is chars not bytes

11 years agoOnly handle PL_rs differently on VMS for record-oriented files.
Craig A. Berry [Fri, 16 Mar 2012 19:20:29 +0000 (14:20 -0500)]
Only handle PL_rs differently on VMS for record-oriented files.

For stream-oriented files, the effects of buffering and other
layers should be exactly as they are on other platforms. For true,
record-oriented files, though, setting $/ = \number must provide
exactly one low-level read per record.  If a read were ever to
return less than a full record (due to, for example, filling up
the perlio buffer), a subsequent read would get the *next* record,
losing whatever data remained in the partially-read record.

11 years agono need to FIXME, it behaves like read() which is the intent
Tony Cook [Sat, 17 Mar 2012 02:10:29 +0000 (13:10 +1100)]
no need to FIXME, it behaves like read() which is the intent

except read() doesn't complain about the invalid characters like
sv_gets().

11 years agofix another boundary case and hopefully improve performance
Tony Cook [Sat, 17 Mar 2012 01:54:17 +0000 (12:54 +1100)]
fix another boundary case and hopefully improve performance

The fix: the if we found ourselves at a charstart with only one
character to read, readsize would be zero, handle that correctly.

Performance: originally I read just the first byte of the next
character, which meant as many extra read calls as there are
characters left to read after the initial read.  So O(Nleft) reads
where Nleft is the number of characters left to read after the initial
read.

Now read as many bytes as there are characters left to read, which
should mean the number of reads comes down to O(log(Nleft**2)) I think
(but don't ask me to justify that.)

11 years agofix a fencepost error I found trying to fall asleep
Tony Cook [Fri, 16 Mar 2012 14:10:36 +0000 (01:10 +1100)]
fix a fencepost error I found trying to fall asleep

11 years agoIncomplete implementation of $/ = \number acting like read()
Tony Cook [Fri, 7 Dec 2012 23:23:20 +0000 (10:23 +1100)]
Incomplete implementation of $/ = \number acting like read()

It's under tested, and incomplete

- readline appears to ignore IN_BYTES, so this code continues to do so.

- currently :utf8 will return invalid utf8, which means this can too,
  if we can be sure of :utf8 returning only valud utf-8 the FIXME can
  be ignored

- VMS is the elephant in the room - the conditional means that the new
  code is completely ignored for reading from files.  If we can detect
  record-oriented files in some way this could change.

11 years agodie, evil [IU]32
Tony Cook [Fri, 7 Dec 2012 23:19:42 +0000 (10:19 +1100)]
die, evil [IU]32

It's still not as dead as I'd like.

11 years agoMerge branch 'blead' of jkeenan@perl5.git.perl.org:/perl into blead
James E Keenan [Sat, 8 Dec 2012 14:28:21 +0000 (09:28 -0500)]
Merge branch 'blead' of jkeenan@perl5.git.perl.org:/perl into blead

11 years agoAdd t/opbasic to list of test directories in one location.
James E Keenan [Sat, 8 Dec 2012 14:24:31 +0000 (09:24 -0500)]
Add t/opbasic to list of test directories in one location.

For RT #115838; bulk88++.

11 years agoUpdate Unicode-Collate to CPAN version 0.95
Chris 'BinGOs' Williams [Sat, 8 Dec 2012 10:05:12 +0000 (10:05 +0000)]
Update Unicode-Collate to CPAN version 0.95

  [DELTA]

  0.95  Sat Dec  8 15:11:09 2012
    - U::C::Locale newly supports locales: bs_Cyrl, ee.
    - updated to CLDR 21: uk.
    - updated to CLDR 22: th, to.
    - added loc_bscy.t, loc_ee.t in t.
    - modified tests: loc_th.t, loc_to.t, loc_uk.t in t.

11 years agoHave each test print out its description.
James E Keenan [Sun, 2 Dec 2012 14:07:40 +0000 (09:07 -0500)]
Have each test print out its description.

Accomplished by modifying the hard-coded 'print ok'-type statements.  (These
tests were written in too idiosyncratic a manner to make conversion to
t/test.pl simple.

Correct order of files in MANIFEST.

See: RT #115838

11 years agoAdd or amplify inline comments as to placement of file in t/opbasic.
James E Keenan [Sun, 2 Dec 2012 13:45:43 +0000 (08:45 -0500)]
Add or amplify inline comments as to placement of file in t/opbasic.

For RT #115838

11 years agoAdjust MANIFEST, Makefiles, test harnesses, documentation, etc., aware of new
James E Keenan [Sun, 2 Dec 2012 13:25:42 +0000 (08:25 -0500)]
Adjust MANIFEST, Makefiles, test harnesses, documentation, etc., aware of new
directory t/opbasic.

For RT #115838

11 years agoCreate subdirectory t/opbasic. Move 5 test files there.
James E Keenan [Sun, 2 Dec 2012 13:11:13 +0000 (08:11 -0500)]
Create subdirectory t/opbasic.  Move 5 test files there.

t/opbasic will hold files formerly held in t/op but which, unlike the vast
majority of tests in the latter directory, are ineligible to use t/test.pl as
a source of test functions.  Affected files:

arith.t
cmp.t
concat.t
magic_phase.t
qq.t

This commit does nothing more than create the new subdirectory and move the
files into it.

For: RT #115838

11 years agofix dtrace (as emulated with systemtap) builds on linux
Tony Cook [Fri, 7 Dec 2012 23:40:26 +0000 (10:40 +1100)]
fix dtrace (as emulated with systemtap) builds on linux

the stap branch of the #if was passing four arguments to
OP_ENTRY_PROBE, much hilarity ensued.

Since literal strings are never passed as the name parameter we can move
OP_ENTRY_PROBE out of the conditional and avoid duplication.

11 years agoscope.c: silence some compiler warnings
David Mitchell [Thu, 6 Dec 2012 16:42:20 +0000 (16:42 +0000)]
scope.c: silence some compiler warnings

clang didn't like %ld on I32's.

11 years agomake regcharclass generate submacros if necessary to keep them short
Yves Orton [Thu, 6 Dec 2012 10:11:47 +0000 (11:11 +0100)]
make regcharclass generate submacros if necessary to keep them short

Some compilers can't handle unexpanded macros longer than something
like 8000 characters. So we split up long ones into sub macros to work
around the problem

11 years agoadd PERL_NO_GET_CONTEXT to xs template in h2xs.PL
Daniel Dragan [Thu, 6 Dec 2012 04:39:44 +0000 (23:39 -0500)]
add PERL_NO_GET_CONTEXT to xs template in h2xs.PL

An XS module not using PERL_NO_GET_CONTEXT is extremely inefficient under
threaded Perls. Prevent PERL_NO_GET_CONTEXT-less modules in the future
by making it a default. Many XS modules are created with h2xs.
Also see this anonymous complaint http://perlmonks.org/?node_id=990732 .

11 years agoStop renamed packages from making reset() crash
Father Chrysostomos [Wed, 5 Dec 2012 20:53:30 +0000 (12:53 -0800)]
Stop renamed packages from making reset() crash

This only affected threaded builds.  I think the comments in the added
test explain well enough what was happening.

The solution is to store a stashpad offset in the pmop, instead of the
name of the stash.  This is similar to what was done with cop stashes
in d4d03940c58a.

Not only does this fix the crash, but it also makes compilation faster
and saves memory (no separate malloc for every m?pat?).

I had to move Safefree(PL_stashpad) later on in perl_destruct, because
freeing a pmop causes the PL_stashpad to be accessed, and pmops can be
freed during sv_clean_all.  Its previous location was not a problem
for cops, as PL_stashpad[cop->cop_stashoff] is only accessed when
PL_curcop==that_cop and Perl code is running, not when cops are freed.

11 years agoDon’t use PMf_ONCE flag for split-to-array
Father Chrysostomos [Tue, 4 Dec 2012 22:52:45 +0000 (14:52 -0800)]
Don’t use PMf_ONCE flag for split-to-array

Currently the PMf_ONCE flag has two purposes.  It is used to indicate
that m?? must match only once.  That’s what distinguishes m?? and m//
internally.  The other use indicates that @x = split... modifies the
array in place.

Whenever the split op is modified to point straight to the array, the
PMf_ONCE flag is set.  pp_split checks both whether there is an array
attached to the op (via a GV in the pad under threads, or a pointer
from the op to the GV under non-threaded builds) and whether the
flag is set.

This makes the flag redundant in the split case.

Removing its use here not only simplifies the code and removes redun-
dant bit-fiddling, but also makes this comment in toke.c, added by
ad639bfb6, come true:

/* This is the only point in the code that sets PMf_ONCE:  */

(That was actually harmless, as it doesn’t hurt to have a stash refer-
ring to pmops that don’t use the PMf_USED flag, and the PMf_ONCE flag
is set for split way after that code is run.  It is also unnecessary
for split, as that bookkeeping code in toke.c only applies to the m??
use of PMf_ONCE.)

This commit also removes a gimme != G_ARRAY check that thas been
redundant since a6d8037e26a.

11 years agoperldiag: -D message is a warning
Father Chrysostomos [Fri, 30 Nov 2012 17:54:08 +0000 (09:54 -0800)]
perldiag: -D message is a warning

Under non-debugging builds, I get this:

$ perl -D -e 'print "ok\n"'
Recompile perl with -DDEBUGGING to use -D switch (did you mean -d ?)
ok

It is a default warning (S), not a fatal error (F).

11 years agoperldiag: Remove category from ‘POSIX syntax [. .]...’
Father Chrysostomos [Fri, 30 Nov 2012 17:50:01 +0000 (09:50 -0800)]
perldiag: Remove category from ‘POSIX syntax [. .]...’

Warnings categories apply only to warnings.

11 years agopp_goto: Call get-magic before choosing goto type
Father Chrysostomos [Thu, 29 Nov 2012 06:42:57 +0000 (22:42 -0800)]
pp_goto: Call get-magic before choosing goto type

Deciding whether this is goto-label or goto-sub can only correctly
happen after get-magic has been invoked, as get-magic can cause the
argument to begin or cease to be a subroutine reference.

11 years agodist/constant/t/utf8.t: Skip tests for early Perls
Sébastien Aperghis-Tramoni [Thu, 6 Dec 2012 00:04:25 +0000 (17:04 -0700)]
dist/constant/t/utf8.t: Skip tests for early Perls

11 years agoAUTHORS: Change email for Sébastien Aperghis-Tramoni
Karl Williamson [Thu, 6 Dec 2012 00:02:23 +0000 (17:02 -0700)]
AUTHORS: Change email for Sébastien Aperghis-Tramoni

11 years agoregen pod issue
Father Chrysostomos [Wed, 5 Dec 2012 17:35:36 +0000 (09:35 -0800)]
regen pod issue

I don’t see how I could have made the number of potential errors
go down, but that’s what podcheck.t insists on saying, even after
I re-ren autodoc.pl to make sure.

11 years agosv.c: Correct newSVpvn_share docs
Father Chrysostomos [Wed, 5 Dec 2012 14:09:42 +0000 (06:09 -0800)]
sv.c: Correct newSVpvn_share docs

something I overlooked

11 years agosv.h: Warning about cows in SvPV_set apidocs
Father Chrysostomos [Wed, 5 Dec 2012 14:07:51 +0000 (06:07 -0800)]
sv.h: Warning about cows in SvPV_set apidocs

11 years agoStop "\N{...}" from leaking after errors
Father Chrysostomos [Wed, 5 Dec 2012 07:13:56 +0000 (23:13 -0800)]
Stop "\N{...}" from leaking after errors

After a syntax error, S_new_constant in toke.c was not mortalising as
promised.

In this case, it doesn’t need to mortalise the variable.  It can sim-
ply free it.

11 years agoUse SvREFCNT_dec_NN in various cop.h macros
Father Chrysostomos [Wed, 5 Dec 2012 06:09:29 +0000 (22:09 -0800)]
Use SvREFCNT_dec_NN in various cop.h macros

Many of these SVs are never null, and therefore need no null checks.

11 years agoStop v111111111111111 from leaking under fatal warnings
Father Chrysostomos [Wed, 5 Dec 2012 06:05:09 +0000 (22:05 -0800)]
Stop v111111111111111 from leaking under fatal warnings

Actually, you need more digits than that to get a leak.

This commit arranges for the SV passed to scan_vstring to be freed
in case scan_vstring triggers an integer overflow warning when fatal
warnings are enabled.

11 years agotoke.c apidocs: Note that scan_vstring might croak
Father Chrysostomos [Wed, 5 Dec 2012 05:59:07 +0000 (21:59 -0800)]
toke.c apidocs: Note that scan_vstring might croak

11 years agoSynchronise CPAN Locale-Maketest and core version
Chris 'BinGOs' Williams [Wed, 5 Dec 2012 16:27:15 +0000 (16:27 +0000)]
Synchronise CPAN Locale-Maketest and core version

11 years agoUpdate CPANPLUS-Dist-Build to CPAN version 0.68
Chris 'BinGOs' Williams [Wed, 5 Dec 2012 16:25:26 +0000 (16:25 +0000)]
Update CPANPLUS-Dist-Build to CPAN version 0.68

  [DELTA]

  0.68 Wed Dec  5 00:17:04 GMT 2012
    - Revert change to wrapper command-line

  0.66 Tue Dec  4 23:05:53 GMT 2012
    - Resolve an issue where Build.PL doesn't generate a
      Build script

11 years agomore dTHX optimizations in /win32/*
Daniel Dragan [Sat, 10 Nov 2012 02:58:22 +0000 (21:58 -0500)]
more dTHX optimizations in /win32/*

In some places, where there is a higher risk of a NULL my_perl happening
at an unknown point in the future IMO new scopes were created. In other
places dTHXa(NULL) and aTHXa were used to avoid large whitespace changes.
win32_rename and win32_getenv I determined would have no benefit from
changing them. More context passing was added to static funcs called by
win32_kill and win32_waitpid removing the need to move the dTHXs in the
2 funcs.

11 years agoSwitch default hash to SIPHASH on 64 bit builds and ONE_AT_A_TIME on 32 bit builds
Yves Orton [Tue, 4 Dec 2012 14:22:28 +0000 (15:22 +0100)]
Switch default hash to SIPHASH on 64 bit builds and ONE_AT_A_TIME on 32 bit builds

Murmurhash has certain disadvantages that neither ONE_AT_A_TIME nor SIPHASH posses