| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
| |
ae5a807c7dcf moved a check against $@ away from the eval it was
checking and inserted another eval in between, the effect of which
was to make the tests that can only run on VMS get skipped there
too. Ouch.
There are other problems with ae5a807c7dcf, but this is a start.
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This was mentioned in ticket #77388. It turns out to be
related to #4253.
If the file cannot be opened, -T and -B on filenames set the last han-
dle to null and set the last stat type to stat, but leave the actual
stat buffer and success status as they were.
That means that stat(_) will continue to return the previous buffer,
but lstat(_) will no longer work.
This is another of those inconsistent cases where the internal stat
info is only partially set.
Originally, this code would set PL_laststatval (the success status) to
-1. Commit 25988e07 (the patch in ticket #4253) intentionally changed
this to make -T _ less suprising on read-only files.
But the patch ended up affecting -T with an explicit file name, too.
It also only partially fixed things for -T _, because the last stat
type *was* still being set.
This commit changes it to set all the stat info, for explicit file
names, or no stat info, for _ (if the previous stat was with a
file name).
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
-r or -T on a GV with no IO or on an IO with no fp (or dirp for -r)
will produce an ‘unopened’ warning. stat() on a filehandle will warn
about an unopened filehandle not only if there is no fp, but also if
the fstat call fails (with errno containing EBADP, EFAULT or EIO, at
least on Darwin).
I don’t know if there is a way to test this.
(But pp_stat and my_stat_flags are getting closer, so this must be
correct. :-)
|
|
|
|
|
|
|
|
|
|
|
| |
Due to the order of the statements, SETERRNO would never be reached
with fatal warnings.
I’ve added another SETERRNO out of paranoia. If there is a nicely-
behaved __WARN__ handler, we should still be setting errno just before
-T returns, in case the handler changed it. We can’t do much in
the case of fatal handlers that do system calls. (Is $! localised
for those?)
|
|
|
|
|
|
|
| |
Fatal warnings were preventing it from being set, because the warning
came first.
(PL_laststatval records the success status of the previous stat.)
|
|
|
|
|
|
|
|
| |
-T and -B on handles always set PL_laststatval (which indicates the
success of the previous stat). But they don’t set the last stat type
(PL_laststype) for closed filehandles. Those two should always go
together. stat and -r, -w etc., always set PL_laststype for a closed
or missing filehandle.
|
|
|
|
|
|
| |
This is a waste of CPU cycles.
PL_statname is always a PV.
|
|
|
|
|
|
|
|
|
|
|
|
| |
-T _ and -B _ always do another stat() on the previous file handle or
filename, unless it is a handle that has been closed.
Normally, the internal stat buffer, status, etc., are reset even for
_. This happens even on a failed fstat().
-T HANDLE and -B HANDLE currently *do* reset the stat status
(PL_laststatval) if there is no IO thingy, so having -T _ and -B _ not
do that makes things needlessly inconsistent.
|
|
|
|
|
|
| |
This was emitting two spaces before the ‘at’:
lstat() on filehandle at -e line 1.
|
| |
|
| |
|
|
|
|
|
|
| |
The result of stat(_) after a failed -r HANDLE would differ depending
on whether fatal warnings are on. This corrects that, by setting the
internal status before warning about an unopened filehandle.
|
|
|
|
|
|
|
| |
stat $gv records the handle so that -T _ can use it. But stat $ioref
hasn’t been doing that, until this commit.
PL_statgv can now hold an SVt_PVIO instead of a SVt_PVGV.
|
|
|
|
|
|
|
|
| |
In addition to a stat buffer, Perl keeps track internally of which
type of stat was done last, either stat or lstat, so that lstat _ can
die if the previous type was stat.
This was not being reset for stat $ioref. Filetest ops were fine.
|
|
|
|
|
|
|
|
|
|
|
|
| |
If PL_statgv is not set to null when freed, that same SV could be
reused for another GV, in which case -T _ will then use another handle
unrelated to the previous stat.
Similarly, if PL_statgv points to a fake glob that gets coerced into
a non-glob before it is freed, it will not follow the code path in
sv_free that sets PL_statgv to null. Furthermore, if it becomes a GV
again, it could be a completely different filehandle, unrelated to the
previous stat.
|
|
|
|
|
|
|
|
|
|
|
| |
-T _ uses the file name saved by a preceding stat. If there was no
preceding stat, the internal sv used to store the file name is unde-
fined, so SvPV producing an uninitialized warning. Normally a failed
-T will just return undefined and set $!. Normally stat on a filehan-
dle will set the internal stat file name to "".
This commit sets the internal file name to "" initially on startup,
instead of creating an undefined scalar.
|
|
|
|
|
|
|
|
|
|
|
|
| |
The same applies to %-.
This is something I broke when merging is_magical_gv with
gv_fetchpvn_flags.
gv_fetchpvn_flags must make sure its *+ glob is present in the symbol
table when it loads Tie::Hash::NamedCapture. If it adds it afterwards
it will clobber another *+ that Tie::Hash::NamedCapture has autovivi-
fied and tied in the mean time.
|
|
|
|
|
|
|
|
|
| |
This is something I broke when merging is_magical_gv with
gv_fetchpvn_flags.
gv_fetchpvn_flags must make sure its *! glob is present in the sym-
bol table it loads Errno. If it adds it afterwards it will clobber
another *! that Errno has autovivified and tied in the mean time.
|
| |
|
|
|
|
|
| |
I put this under a major change, but would be fine if it is moved to an
=item change.
|
|
|
|
|
| |
cc on solaris is smart enough to figure out that this return isn't
reached.
|
|
|
|
|
|
| |
This commit causes character classes of the form [^\p{...}] to have
their code points known at compile time instead of runtime. This allows
for better optimization and runtime execution speed.
|
|
|
|
|
|
|
|
|
| |
It turns out that this code is buggy, except for the fact that
<nonbitmap> currently can't contain conflicts. The trouble would have
started when Unicode properties were moved to being looked at at compile
time -- except when the class is to be inverted, so there isn't a
problem. But in preparation for handling this case, we fix the
potential bugs, as specified in the comments.
|
|
|
|
|
|
|
|
|
|
|
| |
This commit causes any Latin1-range characters from Unicode properties
to be placed at compile time into the bitmap of the ANYOF node that
implements those properties, and to remove the flag that says they
should be looked for at run time. This causes the optimizer to generate
a better start class, as it knows more fully which characters can be and
can't be in the start class, and speeds up runtime checking, as it can
just do a bitmap test for these, instead of having to go look at the
swash.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
An optimization introduced in 5.14 is for bracketed character classes of
the very special form like [Bb]. These can be optimized into an
EXACTFish node. In this case, they can be optimized to an EXACTFA node
since they are ASCII characters. If the surrounding options are /aa, it
is likely that any adjacent EXACTFish nodes will be EXACTFA, so optimize
to that node instead of the previous EXACTFU. This will allow the
optimizer to collapse any adjacent nodes. For example
qr/a[B]c/aai
will now get optimized to an EXACTFA of "abc". Previously it would
have gotten optimized to EXACTFA<a> . EXACTFU<b> . EXACTFA<c>.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Since 5.14, the single-char folds have been calculated at compile time,
either by doing it there, or for properties, setting the swash name to
include a foleded or non-folded version of the property. Thus this
patch could have been done much earlier.
Now, most of the properties are actually computed at compile time by
previous patches, but that isn't relevant to this one.
Thus there really doesn't need to be runtime folding for things that
aren't in the bitmap, except for those things under /d that match only
if the string is in UTF8.
|
|
|
|
|
|
|
| |
The variable 'value' is already used for something else. Using it as a
loop variable corrupts the other use. This commit changes to a
different name, and adds code to keep 'value', and 'prevvalue' in sync
with their other meanings.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This takes advantage of an earlier commit to use a swash that may be
shared across multiple character class instances. That means that if a
match in another class has to look up a value, that that same value is
automatically available without further lookup to all character classes
that share the swash. This means that the lookup result only needs be
cached once for all instances in the thread, saving time and memory.
Note that currently the only swashes that are shared are those that
consist solely of a single Unicode property definition. Some sort of
checksum would have to be computed if this were to be extended to
custom classes. But what this does is cause sharing for all Unicode
properties that aren't in bracketed classes (as they are implemented as
a bracketed class with a single element), as well as the few cases where
someone explicitly writes [\p{foo}] without anything else in the class.
|
|
|
|
|
|
|
|
|
|
|
|
| |
This changes the function that returns the swash associated with a
bracketed character class so that it returns the original swash and not
a copy. The function is renamed and made accessible only from within
regexec.c, and a new wrapper function with the original name is created
that just calls the other one and returns a copy of the swash.
Thus, all access from outside regexec.c will use a copy which if
overwritten will not harm others; while the option exists from within
regexec.c to use a shared version.
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
| |
What an ANYOF node matches could theoretically be millions of characters
long; This only outputs the first portion of very long ones.
|
|
|
|
|
| |
The non-bitmap portion of an ANYOF node may also be in the bitmap
portion. There is no sense in having duplicate output
|
|
|
|
|
|
| |
Instead of '...' separating the two components of the output, change it
to a single space, which is output only if the first component isn't
null.
|
|
|
|
|
| |
This changes the separator in the output of a range from a tab to a
hyphen, which is clearer.
|
|
|
|
| |
Remove trailing tabs
|
|
|
|
|
| |
These were calling put_byte() incorrectly, with a utf8 char instead of a
the ordinal.
|
|
|
|
| |
These lines were indented one stop too many for the enclosing block
|
|
|
|
|
| |
This code was assuming that there were several more bytes in the input
stream, when there may not be. This was discovered by valgrind.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
All Unicode properties actually turn into bracketed character classes,
whether explicitly done or not. A swash is generated for each property
in the class. If that is the only thing not in the class's bitmap, it
specifies completely the non-bitmap behavior of the class, and can be
passed explicitly to regexec.c. This avoids having to regenerate the
swash. It also means that the same swash is used for multiple instances
of a property. And that means the number of duplicated data structures
is greatly reduced. This currently doesn't extend to cases where
multiple Unicode properties are used in the same class
[\p{greek}\p{latin}] will not share the same swash as another character
class with the same components. This is because I don't know of a
an efficient method to determine if a new class being parsed has the
same components as one already generated. I suppose some sort of
checksum could be generated, but that is for future consideration.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This patch moves the processing of most Unicode property definitions
from execution (regexec.c) to compilation (regcomp.c). There is a cost
to do this. By deferring it to execution, it may be that the affected
path will never be taken, and hence the work won't have to be done;
whereas, it's always done if it gets done at compilation.
However, doing it at compilation, has many advantages. We can't
optimize what we don't know about, so this allows for better
optimization, as well as feature enhancements, such as set
manipulations, restricting matches to certain scripts, etc. A big one,
about to be committed allows for significantly reducing the number of
copies of the data structure used for each property. (Currently, every
mention in every regular expression of a given property will generate a
new instance of its hash, and so results of look-ups of code points in
one instance aren't automatically known to other instances, so the code
point has to be looked-up again.)
This commit leaves the processing to execution time when the class is to
be inverted. This was done purely to make the commit smaller, and will
be removed in a future commit; hence the redundant test here will be
removed shortly.
It also has to leave to execution time processing of properties whose
definition is not known yet. That can happen when the property is
user-defined. We call _core_swash_init(), and if it fails, we assume
that it's because it's such a property, and if it turns out that it was
an unknown property, we leave to execution time the raising of a warning
for it, just as before.
Currently, the processing of properties in inverted character classes is
also left to execution time. This restriction will be lifted in a
future commit, and this patch assumes that, and doesn't indent some code
that it otherwise would, in anticipation of the surrounding 'if' tests
being removed.
|
|
|
|
|
|
|
|
| |
Currently, any generated inversion list is stringified and passed in the
data structure to regexec.c as such. regexec.c then calls
_core_swash_init() to convert it into a swash and back into an inversion
list. This intermediate step is wasteful, and this commit dispenses
with it, based on preparatory commits in regexec.c and utf8.c
|