Ruslan Zakirov [Sun, 14 Oct 2012 00:41:35 +0000 (04:41 +0400)]
refactor aassign
move populating stack with return values. Place it
into main loop right after we stored values.
This allow us to delete special if blocks for
hash/array on LHS followed by other hash/array.
Also, clearing HV out of ENTER/LEAVE block is bad -
segfaults in corner cases.
Don't use goto for odd elements case.
store undef on stack for odd case. we can avoid NULL
checks in the loop and use assert like array assignment
does.
use SvSETMAGIC rather than repeate what it means.
for array and hash assignment "while (relem <= SP)" loop
at the end was always empty. Put it into else branch.
Ruslan Zakirov [Sat, 13 Oct 2012 17:28:10 +0000 (21:28 +0400)]
ary/hash/firsthashelem should be set only once
Only once for first hash or array, otherwise
(%h,@a) = ... assignment returns wrong results
for duplicates and/or number of elements on RHS.
Ruslan Zakirov [Sat, 13 Oct 2012 17:27:12 +0000 (21:27 +0400)]
we need duplicates counter only in list context
Ruslan Zakirov [Tue, 9 Oct 2012 22:43:40 +0000 (02:43 +0400)]
test return values of aassign with various elements on LHS
* hash on LHS followed by array, other hash or scalar,
for example (%h, @a) = (...);
* above with normal RHS, with duplicates, odd elements
and combination.
* inspect elements returned by aassign for lvaluedness
* assign doesn't return elements that were just cleared
Ruslan Zakirov [Mon, 8 Oct 2012 18:50:50 +0000 (22:50 +0400)]
hash assign in list context should copy key as well
if we don't then returned keys are aliases for RHS
values and can result in unexpected changes
Ruslan Zakirov [Mon, 8 Oct 2012 18:48:52 +0000 (22:48 +0400)]
make sure hash assignment is proper lvalue
Ruslan Zakirov [Mon, 8 Oct 2012 13:32:24 +0000 (17:32 +0400)]
fix issues in hash assignment with odd elements
1) unify code path of processing odd case with regular
loop that process pairs. fixes memory leak when key
is magic and dies on fetch.
2) in list context put undef that we added to compensate
odd elements into returned values, so (%h = (1))
returns (1, $h{1}) rather than (1). This is documented
in perldoc perlop:
a list assignment in list context produces the list
of lvalues assigned to.
Here can be a dispute, but:
* that key without value on RHS is still assigned with
undef
* consider (%h = (1,2,3,4,5,6,3)). Returning (1,2,3,undef,5,6)
is much easier than (1,2,5,6,3).
* order of returned elements follows cases with even number
of elements on RHS and duplicates
3) hash assignment with duplicates and odd elements on
RHS was returning wrong results in list context.
Now (%h = (1,1,1)) returns (1,$h{1}).
Ruslan Zakirov [Mon, 8 Oct 2012 13:26:43 +0000 (17:26 +0400)]
test hash assignment with odd elements for leaks
if key scalar is tied and dies on fetch then hash assignment
is leaking a key value
Ruslan Zakirov [Sun, 7 Oct 2012 22:41:06 +0000 (02:41 +0400)]
warn on ($s,%h) = (1,{}) as on %h = {}
Latter results in "Reference found where even-sized list expected"
message while former produces "Reference found where even-sized list
expected". Quite inconsistent.
Ruslan Zakirov [Sun, 7 Oct 2012 22:35:22 +0000 (02:35 +0400)]
test "Odd number of elements in hash assignment"
Ruslan Zakirov [Sun, 7 Oct 2012 22:30:54 +0000 (02:30 +0400)]
scalar(%h = (1,1,1,1)) should return 4, not 2
perldoc perlop says:
a list assignment in scalar context returns the number of elements
produced by the expression on the right hand side of the assignment
Behaviour was changed as side effect of
ca65944e8ff8fff6e36ea7476ba807be16cfe2a9 where goal was to fix
return value in list context.
Father Chrysostomos [Sun, 9 Dec 2012 13:03:50 +0000 (05:03 -0800)]
t/op/lex.t: Fix test
It was a copied-and-pasted repeat of another test, both of which I
added in commit
67a057d6d. I know it used to crash and the commit
fixed it, as I tested it at the time with one-liners.
David Mitchell [Tue, 11 Dec 2012 13:44:36 +0000 (13:44 +0000)]
regexec.c: silence compiler warning
The code was mixing signed and unsigned types
Father Chrysostomos [Tue, 11 Dec 2012 13:33:36 +0000 (05:33 -0800)]
Glob.xs: PL_opfreehook is an interpreter variable
Hence, there is no need to lock a mutex; also storing the old value
in a C static is bad. It needs to be in a spot local to the current
interpreter, which MY_CXT provides.
Father Chrysostomos [Tue, 11 Dec 2012 00:43:12 +0000 (16:43 -0800)]
DosGlob: Don’t leak when caller’s op tree is freed
File::DosGlob keeps its own hash of arrays of file names. Each array
corresponds to one call site. When iteration finishes, it deletes
the array. But if iteration never finishes, and the op at the call
site is freed, the array remains. So eval "scalar<*>" will cause a
memory leak under the scope of ‘use File::DosGlob "glob"’.
We already have a mechanism for hooking the freeing of ops. So
File::DosGlob can use that.
This is similar to
11ddfebc6e which fixed up File::Glob, but that com-
mit mistakenly used a C static for storing the old hook, even though
PL_opfreehook is an interpreter variable, not a global. (The next
commit will fix that.)
Chris 'BinGOs' Williams [Tue, 11 Dec 2012 11:49:36 +0000 (11:49 +0000)]
Update Digest-SHA to CPAN version 5.80
[DELTA]
5.80 Mon Dec 10 14:15:26 MST 2012
- obtained noticeable speedup on Intel/gcc
-- by setting -O1 and -fomit-frame-pointer
-- SHA-1 about 63% faster, SHA-2 improves 11-20%
Tony Cook [Mon, 10 Dec 2012 23:22:35 +0000 (10:22 +1100)]
perldelta for
34213185
I considered more detail here, but the discussion in the ticket
covers it.
David Mitchell [Mon, 10 Dec 2012 16:28:19 +0000 (16:28 +0000)]
fix warning in PmopSTASH_set()
In the threaded version of PmopSTASH_set(), the assigned value is a
PADOFFSET, not a pointer; so use 0 rather than NULL for the default value.
This keeps clang happy.
Father Chrysostomos [Mon, 10 Dec 2012 14:19:14 +0000 (06:19 -0800)]
Stop DynaLoader.t from unload File::Glob
File::Glob now sets PL_opfreehook. That means that if we unload it we
will leave PL_opfreehook pointing to an invalid address, resulting in
a crash when ops are freed.
I didn’t catch this because the tests are skipped on darwin. They
don’t actually need to be, at least under recent versions, so I modi-
fied the skip code.
Father Chrysostomos [Sun, 9 Dec 2012 14:15:20 +0000 (06:15 -0800)]
Fix problems with -Dr during global destruction
$ cat foo
my $x = '(?{1})';
BEGIN { $^H |= 0x00200000 } # lightweight "use re 'eval'"
"a" =~ /a$_/ for $x;
If I run this under PERL_DESTRUCT_LEVEL=2 with the -Dr flag on a non-
threaded build, the output ends with this:
during global destruction.
during global destruction.
during global destruction.
during global destruction.
during global destruction.
Attempt to free temp prematurely: SV 0x822610 during global destruction.
Attempt to free temp prematurely: SV 0x802340 during global destruction.
Attempt to free temp prematurely: SV 0x8222d0 during global destruction.
Attempt to free temp prematurely: SV 0x822490 during global destruction.
Attempt to free temp prematurely: SV 0x8224f0 during global destruction.
Scalars leaked: 5
And sometimes I even get assertion failures. (I suspect hash random-
isation gives me the inconsistent results.)
t/re/recompile.t happened to trigger this bug, producing noisy output.
Since the assertion failures were in sub-processes, the tests passed
anyway. In this commit I have changed the test to check the status of
the sub-processes, too, before reporting a pass.
This bug appears to have started happening in v5.17.0-424-gd24ca0c,
but I don’t know why. I suspect it was a latent bug waiting
to happen.
During global destruction, all objects are freed, the main stash is
freed, and then various SVs in interpreter variables are also freed.
Finally, if PERL_DESTRUCT_LEVEL is set, there is one last sweep of all
remaining SVs. It is during that sweep that this bug occurs.
When the -Dr flag is present, freeing a regular expression causes the
${^RE_DEBUG_FLAGS} flags variable to be looked up.
Symbol lookup can trigger the ‘Global symbol requires package name’
error (which becomes a warning here, due to the way pp_ctl.c:qerror
works). The code that produces that error assumes that if there is
no stash then the preceding code has detected an attempted stricture
violation.
The preceding code actually tries to provide PL_defstash (aka %main::)
as the stash to look in, since this is a punctuation variable. But
PL_defstash has been set to null.
The logic that no stash equals a stricture violation is there-
fore faulty.
The attempt to output that error message uses a temporary scalar which
is placed on the mortals stack. Freeing of the items on the mortals
stack happens before this SV sweep, and not during or afterwards, so
the SV sweep ends up trying to free those mortals itself. There is a
check in sv_free2, enabled under debugging builds, to see whether the
SV is on the mortals stacking. If it is, a warning is emitted and the
SV is not freed.
My initial attempt at fixing this was to try to avoid putting a mortal
on the stack in this case. The code in question doesn’t actually need
to use the mortals stack, since Perl_mess isn’t going to croak, so it
can free the SV itself. That takes care of the ‘Attempt to free temp
prematurely’ warnings and the final ‘Scalars leaked’. It doesn’t
solve the ‘during global destruction’ message, but I decided to leave
it in place anyway, since creating an SV and freeing it is a little
more efficient that creating it, pushing it on to the mortals stack,
and having FREETMPS free it later.
That ‘during global destruction’ message is supposed to say ‘Global
symbol...’, but diagnostic messages during global destruction use the
same SV, so it’s not suprising that it gets stomped on before it makes
its way to qerror. I’m not sure where it gets stomped on, but it’s
not relevant; we need to get rid of the message altogether.
The final solution is to skip the ‘Global symbol...’ error altogether
while sv_clean_all (the final SV sweep) is being called, which we can
detect based on whether PL_in_clean_all is set.
Father Chrysostomos [Sun, 9 Dec 2012 14:05:22 +0000 (06:05 -0800)]
Don’t leak when partly iterated glob op is freed
File::Glob keeps its own hash of arrays of file names. Each array corresponds to one call site. When iteration finishes, it deletes
the array. But if iteration never finishes, and the op at the call
site is freed, the array remains. So eval "scalar<*>" will cause a
memory leak.
We already have a mechanism for hooking the freeing of ops. So
File::Glob can use that.
Father Chrysostomos [Sun, 9 Dec 2012 02:24:12 +0000 (18:24 -0800)]
Increase $File::Glob::VERSION to 1.19
Father Chrysostomos [Sun, 9 Dec 2012 00:52:37 +0000 (16:52 -0800)]
Remove the second param to tryAMAGICunTARGETlist
This parameter is no longer used. Its value is always 0.
Father Chrysostomos [Sun, 9 Dec 2012 00:48:32 +0000 (16:48 -0800)]
pp.h: Remove tryAMAGICunTARGET
This macro is unused on CPAN and completely undocumented, so this
change should be safe.
Father Chrysostomos [Sun, 9 Dec 2012 00:43:00 +0000 (16:43 -0800)]
Zap PL_glob_index
As of the previous commit, nothing is using it.
Father Chrysostomos [Sat, 28 Apr 2012 07:18:30 +0000 (00:18 -0700)]
Stop using PL_glob_index for PL_globhook
If Glob.xs just uses the address of PL_op as its iterator key all the
time (when called via PL_globhook too, not just via a glob override),
the code is simpler.
Father Chrysostomos [Sun, 9 Dec 2012 00:38:59 +0000 (16:38 -0800)]
Don’t pass PL_glob_index to glob overrides
This magic second argument is undocumented and unused on CPAN and in
the core (as of the last few commits).
It could also get in the way of making glob truly overridable in the
future (e.g., allowing File::Glob to take a list).
Father Chrysostomos [Sat, 28 Apr 2012 00:08:15 +0000 (17:08 -0700)]
File::Glob: Don’t use the magic 2nd arg to glob
See the previous commit. The same applies to File::Glob as well.
In short, the easiest way to fix a memory leak involves using the
address of the glob op rather than a special glob index.
Father Chrysostomos [Fri, 27 Apr 2012 23:48:36 +0000 (16:48 -0700)]
DosGlob: Don’t use the magic 2nd arg to glob
Use the address of the glob op instead.
This argument is going away, because it is undocumented, unused on
CPAN outside of the core, and may get in the way of allowing glob() to
be overridden properly.
Another reason is that File::DosGlob leaks memory, because a glob op
freed before iteration has finished will leave File::DosGlob still
holding on to the remainder of the list of files. The easiest way to
fix that will involve using an op address instead of a special index,
so there will be no reason to keep it.
Father Chrysostomos [Sat, 8 Dec 2012 18:29:55 +0000 (10:29 -0800)]
Increase $File::DosGlob::VERSION to 1.09
Father Chrysostomos [Fri, 27 Apr 2012 21:05:39 +0000 (14:05 -0700)]
Move File::DosGlob from lib to ext
Father Chrysostomos [Sat, 8 Dec 2012 17:58:31 +0000 (09:58 -0800)]
hv.c: hv_undef: Don’t set mro fields to null before freeing
There is no point in modifying a struct just before freeing it.
This was my mistake, in commit
47f1cf7702, when I moved the code from
S_hfreeentries to hv_undef.
Father Chrysostomos [Sat, 8 Dec 2012 14:14:42 +0000 (06:14 -0800)]
Use SvREFCNT_dec_NN in gv.c
Various SvREFCNT_dec calls in gv.c are never given null pointers,
so there is no need to check for them.
I added one const mostly for code documentation purposes
(so one can see at a glance that the variable won’t change).
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.
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.
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
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'.
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.
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.
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.
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.
Karl Williamson [Fri, 7 Dec 2012 02:09:26 +0000 (19:09 -0700)]
handy.h: Add comment
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.
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.
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.
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.
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.
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.
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.
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
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.
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.
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
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.
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
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.
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
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.
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.
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
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.
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
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
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
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.
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
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.
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
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
Karl Williamson [Fri, 7 Dec 2012 02:07:41 +0000 (19:07 -0700)]
regcomp.c: Typo in comment; white space
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.
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
Karl Williamson [Thu, 6 Dec 2012 04:53:06 +0000 (21:53 -0700)]
regexec.c: Nits coding standards-type changing
Karl Williamson [Thu, 6 Dec 2012 04:39:21 +0000 (21:39 -0700)]
perl.h: Add comments
Karl Williamson [Thu, 6 Dec 2012 04:37:26 +0000 (21:37 -0700)]
perlrecharclass: Fix defn of [:word:]
Karl Williamson [Mon, 3 Dec 2012 02:18:34 +0000 (19:18 -0700)]
intrpvar.h: Add comment
Karl Williamson [Mon, 3 Dec 2012 01:50:44 +0000 (18:50 -0700)]
Add Todo test for Perl #114272
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
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.
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
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
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.
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>.
Father Chrysostomos [Sat, 8 Dec 2012 14:45:18 +0000 (06:45 -0800)]
leakfinder.pl: Skip push/unshift after { or (
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.
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.
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.
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.
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{}.
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.
Father Chrysostomos [Fri, 7 Dec 2012 14:09:45 +0000 (06:09 -0800)]
Test error when constant overload handler returns undef
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).
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.
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.
Father Chrysostomos [Thu, 6 Dec 2012 05:49:02 +0000 (21:49 -0800)]
MANIFEST typo
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.)
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.
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
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.
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().