Nicholas Clark [Thu, 13 Dec 2012 16:16:52 +0000 (17:16 +0100)]
Note the GDBM_File changes in perldelta.
Nicholas Clark [Thu, 13 Dec 2012 16:06:26 +0000 (17:06 +0100)]
Eliminate the fifth argument from GDBM_File::TIEHASH.
This was intended to provide control of the callback used by gdbm* functions
in case of fatal errors (such as filesystem problems), but did not work (and
could never have worked). No code on CPAN even attempted to use it. The
callback is now always the previous default, croak.
This eliminates the only used of 'FATALFUNC' in the *DBM modules' type
files, so remove it from all of them.
It also eliminates a cast from a data pointer to a function pointer, which
is not legal C, and rightly upsets pedantic ANSI C compilers. The fact that
there was exactly cast, and only in one direction, gives a clue as to how
likely this was ever to work.
Nicholas Clark [Thu, 13 Dec 2012 15:38:17 +0000 (16:38 +0100)]
GDBM_File is meant to croak() if the gdbm library has a fatal error.
gdbm_open() takes a fifth argument, for an optional callback function used
to report a fatal error. Since it was added in 5.000, the tied hash wrapper
implemented in GDBM_File.xs has (intended) to default this to croak().
However, the callback expects a function taking a single const char *
argument, whereas croak(const char *pat, ...) has variable arguments.
The code as-was had two bugs
1) The calling ABI on some platforms differs between a (known) variable-
argument function, and one which takes (known) fixed arguments. As the
call site knows the pointer is to a function with fixed arguments, the
calling convention it uses doesn't match what Perl_croak_nocontext()
expects, which can lead to crashes.
2) A message containing % characters will be interpreted as a printf format.
Both these are fixed by using a small station function as a wrapper, which
takes a single string argument, and passes to croak() a "%s" format string,
followed by the string for the error message.
Add a test for this functionality.
David Mitchell [Thu, 13 Dec 2012 13:24:58 +0000 (13:24 +0000)]
B.xs: silence clang warning
PADOFFSET is unsigned, so checking that it's >= 0 is pointless.
Craig A. Berry [Thu, 13 Dec 2012 13:10:17 +0000 (07:10 -0600)]
chdir's argument is a directory in DosGlob.t.
It probably doesn't matter anywhere but VMS, but on VMS,
disk:[dir.blead]t (the result of catfile) is an invalid argument to
chdir, but disk:[dir.blead.t] (the result of catdir) is correct.
Father Chrysostomos [Thu, 13 Dec 2012 13:26:56 +0000 (05:26 -0800)]
Sigh. Fix lex.t again
PERL_UNICODE can cause things to happen in a different order
internally.
Father Chrysostomos [Thu, 13 Dec 2012 02:09:57 +0000 (18:09 -0800)]
{Dos,}Glob.xs: Skip freeing during global destruction
See ticket #116064.
File::Glob and ::DosGlob free data associated with a calling op when
that op is freed.
During global destruction, there is no need to do that, as it will be
freed anyway.
Also, during sv_clean_all dMY_CXT can cause us to read freed memory.
Father Chrysostomos [Thu, 13 Dec 2012 01:55:06 +0000 (17:55 -0800)]
Fix occasional failures in svleak.t and DosGlob.t
If the random number of ops happens to be 0 the first time, then we
end up with a false positive, as evaluating '$x+<*>' after '<*>' will
vivify the *x glob.
Father Chrysostomos [Tue, 11 Dec 2012 13:51:03 +0000 (05:51 -0800)]
leakfinder.pl: More exceptions
David Mitchell [Wed, 12 Dec 2012 10:34:29 +0000 (10:34 +0000)]
perl.h: fix signedness warning with clang
'len' arg to my_vsnprintf() is supposed to be Size_t; cast it that way
before testing it.
Nicholas Clark [Wed, 12 Dec 2012 09:18:21 +0000 (10:18 +0100)]
In DosGlob.xs, add a block around MY_CXT_INIT, as it contains a declaration.
The macro MY_CXT_INIT contains a variable declaration, and xsubpp doesn't
wrap XS BOOT sections within a block, hence code at the start of the BOOT
section may already be after code. Hence wrap MY_CXT_INIT within a block, to
ensure that its initialisation is before any code.
Steffen Mueller [Wed, 12 Dec 2012 06:35:21 +0000 (07:35 +0100)]
Data::Dumper is at 2.139
Steffen Mueller [Wed, 12 Dec 2012 06:33:33 +0000 (07:33 +0100)]
Bring Data::Dumper version and changelog up to date with CPAN release
The 2.139 CPAN release just went out. It has the same code that is in
blead now, but it has distribution fixes on top of blead that wouldn't
make sense here. This bumps the version and imports the change log.
Karl Williamson [Tue, 11 Dec 2012 23:51:59 +0000 (16:51 -0700)]
perlvar.pod: Slight clarification, typo
Daniel Dragan [Tue, 11 Dec 2012 19:01:54 +0000 (14:01 -0500)]
better POD for mg_get and SvGROW
SvGROW unconditionally derefs SvANY to check SvLEN. A crash occurs if the
sv is SVt_NULL. Also mg_get uses SvMAGIC which also has the same problem.
Rather than having people finding these properties out by trial and error,
document them. There is no sense in adding type checks since these 2 calls
have been had sv type restrictions since probably day 1 and for
performance reason. Anyone who hit the restrictions would have either
fixed their code immediately, or abandoned using XS. I observed someone
abandoning XS in the field over these undocumented restrictions.
Father Chrysostomos [Wed, 12 Dec 2012 00:18:40 +0000 (16:18 -0800)]
Really fix t/op/lex.t
I *thought* I had run the tests after making commit
6d70c68615.
Father Chrysostomos [Tue, 11 Dec 2012 16:59:56 +0000 (08:59 -0800)]
[Merge] hash assignment fixes and speedup
In <CAMOxC8vCaYk3GD0NRH=jxGmNKu+bmKTrYKR2nsrgU6Wei+xmYQ@mail.gmail.com>
Ruslan Zakirov wrote:
> I've finished my work on pp_aassign. I find it ready for review.
> Each commit has plenty of details, but here is short description:
>
> * scalar(%h = (1,1,1,1)) returns 4, not 2
> * warn on ($s,%h) = (1,{}) as on (%h) = ({})
> * (%h = (1)) in list context returns (1, $h{1})
> instead of (1)
> * return of (%h = (1,1,1)) in list context was incorrect
> * in list context returned keys was aliased to RHS scalars
> of aassign
> * returned list from ((%h, @a) = ...), hash on LHS followed by
> array or hash, was incorrect
> * implemented right to left algorithm for not magic hash assignment
> in scalar and void context
> * use less mortals is list context
> * in list context hash assignment return keys aliased to RHS
> when it's ok (it's not LVALUE context)
Hugo van der Sanden [Tue, 11 Dec 2012 14:17:26 +0000 (06:17 -0800)]
pp_hot.c: Comments to clarify pp_aassign
[The committer took these from <
201210240658.q9O6w1u25266@crypt.org>
and turned them into a patch.]
Father Chrysostomos [Tue, 11 Dec 2012 13:59:00 +0000 (05:59 -0800)]
hashassign.t: Suppress oddball warnings
Father Chrysostomos [Tue, 11 Dec 2012 13:57:41 +0000 (05:57 -0800)]
hashassign.t: Test undef explicitly
thereby eliminating uninit warnings
Father Chrysostomos [Thu, 25 Oct 2012 01:04:20 +0000 (18:04 -0700)]
Copy keys for aassign in lvalue sub
Checking LVRET (which pp_aassign does, as of a few commits ago)
has no effect if OPpMAYBE_LVSUB is not set on the op. This com-
mit changes op.c:op_lvalue_flags to set this flag on aassign ops.
This makes sub:lvalue{%h=($x,$x)} behave correctly if the return
values of the sub are assigned to ($x is unmodfied).
Ruslan Zakirov [Sat, 20 Oct 2012 10:40:13 +0000 (14:40 +0400)]
hash argument is not used anymore in do_oddball
rename arguments to make more clear what function takes
Father Chrysostomos [Mon, 10 Dec 2012 13:43:41 +0000 (05:43 -0800)]
pp_hot.c:pp_aassign: mortalise variable only if we have to
This affects the hash-assignment path.
Don’t mortalise the value to protect it from a magical key making the
hv_store_ent call die, as that could unduly extend the mortals stack.
Instead, copy the key if it is magical.
Based on a patch by Ruslan Zakirov.
Ruslan Zakirov [Wed, 17 Oct 2012 16:04:58 +0000 (20:04 +0400)]
don't create a copy of keys if it's not LVALUE context
Making another copy slows things down. We can avoid it
if aassign is not expected to return LVALUEs.
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