This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Karl Williamson [Mon, 12 Nov 2018 04:54:41 +0000 (21:54 -0700)]
regcomp.c: Add assertion
Karl Williamson [Wed, 14 Nov 2018 16:09:38 +0000 (09:09 -0700)]
regcomp.c: Fix up RE_TRACK_PATTERN_OFFSETS
These need to be changed around as a result of removing the sizing pass
from pattern compilation.
The first element in the array is the number of offsets. This had
become wrong. And it is used instead of the program length when it is
available.
Karl Williamson [Sat, 20 Oct 2018 23:24:53 +0000 (17:24 -0600)]
regcomp.c: Avoid some conditionals
A pattern being UTF-8 implies it is /u. By proper initialization of if
it is /u or not, we can avoid the existing additional tests for UTF-8 in
those places where we care about /u but don't care about UTF-8ness.
Karl Williamson [Mon, 29 Oct 2018 03:24:22 +0000 (21:24 -0600)]
regcomp.c: Make sure UTF-8 regex pattern uses /u
When a pattern is in UTF-8, Unicode rules should be selected. This
commit makes sure that this happens and that the displayable form of the
pattern shows /u.
I don't know of any bugs this fixes.
Karl Williamson [Thu, 8 Nov 2018 03:22:36 +0000 (20:22 -0700)]
PATCH: [perl #133642] Double free
This was caused by doing a SAVEFREEPV twice. The solution is to not do
this twice.
But this means that if the process unexpectedly dies, there is a
potential memory leak. That potential already exists with other
variables, and has its own ticket #133589.
Karl Williamson [Thu, 8 Nov 2018 03:07:51 +0000 (20:07 -0700)]
regcomp.c: Refactor to remove an else and a NOT_REACHED
This just simplifies things a bit.
Karl Williamson [Thu, 8 Nov 2018 03:20:53 +0000 (20:20 -0700)]
regcomp.c: calculate variants instead of assuming worst case
When converting a byte pattern to UTF-8, the needed size may increase due
to some bytes (the UTF-8 variants) occupying two bytes instead of one
under UTF-8.
Prior to this commit, the pattern was assumed to contain only variants,
and enough memory was allocated for the worst case.
This commit actually calculates how much space is needed and allocates
only that.
There is extra work involved in doing this calculation. But the pattern
is parsed per-word. For short strings, it doesn't much matter either
way. But for very long strings, it seems to me the consequences of
potentially allocating way too much memory out weighs the negative of
this extra work. If field experience proves me wrong, then revert this
commit.
Karl Williamson [Thu, 8 Nov 2018 03:11:50 +0000 (20:11 -0700)]
XXX utf8.c: calculate vairants instead of assuming worst case
When converting a byte string to UTF-8, the needed size may increase due
to some bytes (the UTF-8 variants) occupying two bytes instead of one
under UTF-8.
Prior to this commit, the string was assumed to contain only variants,
and enough memory was allocated for the worst case, then the excess was
returned at the end.
This commit actually calculates how much space is needed and allocates
only that, so there is no need to trim afterwards.
There is extra work involved in doing this calculation. But the string
is parsed per-word. For short strings, it doesn't much matter either
way. But for very long strings, it seems to me the consequences of
potentially allocating way too much memory out weighs the negative of
this extra work.
Karl Williamson [Mon, 12 Nov 2018 04:48:53 +0000 (21:48 -0700)]
regcomp.sym: longj field is a boolean
The comments could lead one to thinking one could specify any of the
argument fields that nodes can have. But in fact, the value is a
boolean, 0 meaning to use the normal offset field of all regnodes; and 1
meaning to use the ARG field that some regnodes have. If a regnode had
more than just the one argument field, the one that corresponds to that
would be used.
This commit enforces that, and changes regcomp.sym to not use '2',
which is misleading.
It clarifies the comments about this and what '.' means in the flags
field
Karl Williamson [Thu, 8 Nov 2018 01:44:56 +0000 (18:44 -0700)]
t/re/reg_mesg.t: Add test
Verify this still works after the recent removal of the sizing pass
Karl Williamson [Mon, 12 Nov 2018 04:42:51 +0000 (21:42 -0700)]
-Drv now turns on all regex debugging
This commit makes the v (verbose) modifier to -Dr do something: turn on
all possible regex debugging.
Karl Williamson [Mon, 12 Nov 2018 04:38:29 +0000 (21:38 -0700)]
regcomp.h: Delete duplicate macro defn
Karl Williamson [Sun, 11 Nov 2018 22:59:14 +0000 (15:59 -0700)]
perl.h: White-space, comment
Karl Williamson [Sun, 11 Nov 2018 18:31:17 +0000 (11:31 -0700)]
re/re_tests: Add test
Karl Williamson [Thu, 8 Nov 2018 01:40:37 +0000 (18:40 -0700)]
handy.h: Add some comments
This allows us to remove a comment in regcomp.c
Karl Williamson [Wed, 14 Nov 2018 16:21:04 +0000 (09:21 -0700)]
perlrun: Clarify -Dv
Karl Williamson [Tue, 6 Nov 2018 16:51:53 +0000 (09:51 -0700)]
t/re/pat.t: Add a test
Dominic Hargreaves [Thu, 15 Nov 2018 12:13:05 +0000 (12:13 +0000)]
lgtm.yml: classify charclass_invlists.h as generated
This file represents a significant chunk of the line count of the project
and so excluding it results in more realistic statistics.
James E Keenan [Wed, 14 Nov 2018 21:29:46 +0000 (16:29 -0500)]
Add ext/File-Find/t to list of badly-behaved test directories.
For: RT # 133658
Dominic Hargreaves [Tue, 6 Nov 2018 16:55:41 +0000 (16:55 +0000)]
Enable LGTM.com integration
Committer: Update MANIFEST. Provide additional email address for
contributor.
Karl Williamson [Wed, 25 Jul 2018 02:26:39 +0000 (20:26 -0600)]
Add more parallelism to t/harness
This commit causes test files in cpan/, etc to run in parallel provided
there is no file in the test directory whose name begins with zero.
Experience shows that things like 01test, 02test, ... are supposed to be
executed serially. Sometimes there is a single file beginning with 0,
and this is supposed to be executed first as setup for the remaining
tests (which probably could be executed in parallel, but that
enhancement is much harder to do, so isn't tried here)
This is a heuristic, and this commit adds the ability to explicitly
specify directories to the serial list that don't correspond to the
above rule. One directory is currently on that list: ext/Pod-Html/t.
It follows a different paradigm to order things. We could rename the
tests to follow the normal paradigm since this is in ext/, but I thought
it best to keep it as an example of what to do should the need for other
exceptions arise.
This can save a bunch of wallclock time on slower systems with many
cores, such as dromedary. On that system, the test suite finishes 17%
faster with this commit on the first run. (This is a savings of over
100 wallclock seconds; a very noticeable improvement.) On subsequent
runs when it knows approximately how long each test takes and sorts the
order accordingly, the suite runs 8% faster.
On machines with few cores, there isn't much of a difference.
Dan Dedrick [Fri, 13 Oct 2017 01:49:39 +0000 (21:49 -0400)]
Fix missing build dependency for pods
When building perl with highly parallel options (e.g. -j 32) on a machine
with many cores (e.g. 32) ocassionaly it fails with the following type
of error.
make[1]: Entering directory '.../cpan/podlators'
Can't locate Getopt/Long.pm in @INC (you may need to install the Getopt::Long module) (@INC contains: .../cpan/AutoLoader/lib .../dist/Carp/lib .../dist/PathTools .../dist/PathTools/lib .../cpan/ExtUtils-Install/lib .../cpan/ExtUtils-MakeMaker/lib .../cpan/ExtUtils-Manifest/lib .../cpan/File-Path/lib .../ext/re .../dist/Term-ReadLine/lib .../dist/Exporter/lib .../ext/File-Find/lib .../cpan/Text-Tabs/lib .../dist/constant/lib .../cpan/version/lib .../lib ../../lib .) at .../cpan/ExtUtils-MakeMaker/lib/ExtUtils/Command/MM.pm line 109.
Makefile:445: recipe for target 'manifypods' failed
make[1]: *** [manifypods] Error 2
The scripts pod2man, pod2text, podchecker, podselect, and pod2usage all use
Getopt-Long and since they are all part of nonxs modules this needs to be
added here to prevent these build races.
Sawyer X [Sun, 11 Nov 2018 08:54:10 +0000 (10:54 +0200)]
Adding Zak for March release
James E Keenan [Sat, 10 Nov 2018 02:21:30 +0000 (21:21 -0500)]
Ensure same count of tests on different OSes.
On OpenBSD (in at least one instance), $different was false, thereby causing 30 tests not to be run but without reflecting that skipping in the test count displayed at the end of output.
Let's put this in a SKIP block similar to those used elsewhere in the file.
Sawyer X [Sat, 10 Nov 2018 10:06:59 +0000 (12:06 +0200)]
Bump Data::Dumper to 2.173 (no real change):
The change will happen in the Makefile.PL which is generated and
released. It is generated automatically, so we can't actually inject
the parts that we want.
The way I handle it at the moment is:
* Build perl
* Copy Data::Dumper to other directory
* Grab MANIFEST.SKIP and Makefile.PL from previous release
* Add the DEFINE we need to fix this:
# In WriteMakefile(...)
DEFINE => '-DUSE_PPPORT_H',
* perl Makefile.PL && make && make test && make dist
* Retest the tarball
* Release to CPAN
But we need this bump anyway, so this commit.
Karl Williamson [Mon, 5 Nov 2018 18:01:35 +0000 (11:01 -0700)]
ext/re/t/qr.t: Rmv extraneous Debug statement
It looks like this statement to turn on Debugging was used to help debug
the issues that this test now tests, and should have been removed when
the file was first commited. But no harm came, as no debugging output
got generated.
This was changed by commit
15cab4d70522286feb2fcb1e7313b2f995343181,
"Remove references to passes from regex compiler". It unknowingly fixed
a bug wherein a Debug statement didn't get output. That cause qr.t to
output that debugging statement.
The fix is to simply remove the call for Debugging from qr.t
David Mitchell [Mon, 5 Nov 2018 12:29:27 +0000 (12:29 +0000)]
Don't localise array / hash slice ref assignment
RT #133538
The experimental ref assignment aliasing feature, when applied to
array or hash slices, was treating the slice as if it was always localized;
e.g.
\(@a[3,5,7]) = \(....);
was being interpreted as
local \(@a[3,5,7]) = \(....);
The fix is simple: check for the OPpLVAL_INTRO flag actually being set
on the op, rather than unconditionally localising the array/hash
elements.
Tony Cook [Wed, 24 Jan 2018 04:10:10 +0000 (15:10 +1100)]
(perl #132147) bump *DBM_File versions
Tony Cook [Wed, 24 Jan 2018 04:03:39 +0000 (15:03 +1100)]
(perl #132147) add security warnings to the *DBM_File modules
Tomasz Konojacki [Mon, 15 Oct 2018 03:24:27 +0000 (05:24 +0200)]
pp_divide: use modulo instead of multiplication
On most architectures with hardware integer division (like
x86 or aarch64), division instruction returns both the remainder
and the quotient. It means that performing modulo operation
immediately after division using the same operands is 100% free.
Essentially this commit changes "div" and "mul" into a single "div"
instruction, which results in minor speed up.
[perl #133511]
Tony Cook [Thu, 4 Oct 2018 04:41:03 +0000 (14:41 +1000)]
(perl #127606) adjust dependency paths on installation on darwin
SIP (System Integrity Protection) on OS X prevents the
DYLD_LIBRARY_PATH environment variable from being propagated through
/bin/sh, causes many tests to fail (and some more recent build issues)
for -Duseshrplib builds.
To avoid that, we change the way libperl.dylib is linked to perl, so
for the initial build the library's id is at the build location rather
than the install location, and the generated executable also expects
to find libperl in that location.
This obviously won't work once we copy both to the installation
directory, so we adjust both the id of the library and the dependency
path in the executable to point to the new location of the library.
A previous attempt set -rpath and used @rpath in the id, but this made
the embedding test fail.
James E Keenan [Thu, 1 Nov 2018 21:17:03 +0000 (17:17 -0400)]
Correct spelling error
David Cantrell [Thu, 1 Nov 2018 11:10:49 +0000 (11:10 +0000)]
perlfunc: highlight -X behaviour on dangling symlinks
Tony Cook [Thu, 1 Nov 2018 02:54:28 +0000 (13:54 +1100)]
bump $File::Spec::*::VERSION
Tony Cook [Thu, 1 Nov 2018 02:44:52 +0000 (13:44 +1100)]
prevent t/Functions.t from warning on undefined values when none supplied
James E Keenan [Wed, 31 Oct 2018 23:03:19 +0000 (19:03 -0400)]
Handle OSes where filesystems can be mounted with 'noatime' option
Adapted from http://cvsweb.netbsd.org/bsdweb.cgi/pkgsrc/lang/perl5/patches/patch-ta?rev=1.6&content-type=text/x-cvsweb-markup
For readability, change a 'skip' whose block lacked tests to be skipped
with a simple 'pass'.
For RT 132663
Karl Williamson [Wed, 31 Oct 2018 16:22:03 +0000 (10:22 -0600)]
PATCH: [perl #133620] heap buffer overflow
This happens when an alternate parse string is constructed, and the
error message needs to be translated into the terms of the original one,
the error is just past the right edge. The translation was not getting
done. Simply use the original terms.
James E Keenan [Mon, 29 Oct 2018 21:56:20 +0000 (17:56 -0400)]
Move subroutine definition to end of file.
Thereby improving readability of main program.
James E Keenan [Mon, 29 Oct 2018 21:39:48 +0000 (17:39 -0400)]
Regularize indents within subroutine definition.
Over decades, the code within the subroutine acquired many different
combinations of tabs and whitespace for indents, thereby making the code
less readable. Standardize on 4 whitespaces.
For readability, comment end of two blocks.
James E Keenan [Mon, 29 Oct 2018 21:34:22 +0000 (17:34 -0400)]
Fully encapsulate check_utime_result()
This will permit us to move the subroutine's definition to the end of
the file, thereby improving readability of main program.
James E Keenan [Mon, 29 Oct 2018 21:19:07 +0000 (17:19 -0400)]
Remove code commented out since March 2002.
Align indents after removal of comments.
James E Keenan [Mon, 29 Oct 2018 21:07:09 +0000 (17:07 -0400)]
Repeatedly hard-coding an integer is a mistake.
Place
500000000 in variable $ut.
James E Keenan [Mon, 29 Oct 2018 21:00:50 +0000 (17:00 -0400)]
Make descriptions more self-documenting
So that while debugging we can see which 'atime' and 'utime' cases we
are handling.
James E Keenan [Mon, 29 Oct 2018 20:44:31 +0000 (16:44 -0400)]
Add notes so it's easier to see where we are in test file.
James E Keenan [Mon, 29 Oct 2018 20:35:35 +0000 (16:35 -0400)]
Use t/test.pl's note() function
... rather than print(), for informational statements.
H.Merijn Brand [Tue, 30 Oct 2018 16:41:37 +0000 (17:41 +0100)]
Add minix hints to MANIFEST
H.Merijn Brand [Tue, 30 Oct 2018 16:39:33 +0000 (17:39 +0100)]
Add initial support for Minix3
Patch by Sevan Janiyan
Include a hints file for Minix, derived from the NetBSD one but stripped
back to remove most of the legacy parts.
Pali [Fri, 28 Sep 2018 11:17:01 +0000 (13:17 +0200)]
Define also Perl's calloc() macro
Functions malloc(), realloc() and free() are already redefined to
PerlMem_malloc(), PerlMem_realloc() and PerlMem_free(). But calloc() not.
This leads to the problem that memory by calloc() is allocated by system
C library, but freed by Perl's PerlMem_free() which just cause memory
corruptions.
James E Keenan [Mon, 29 Oct 2018 00:29:14 +0000 (20:29 -0400)]
Note locales available and those used in tests.
This will facilitate diagnosis of problems on platforms where tests in
this file are failing.
Phil Pearl (Lobbes) [Fri, 26 Oct 2018 17:34:26 +0000 (13:34 -0400)]
remove extra 'be' in perlre pod
Committer: Add author.
Dagfinn Ilmari Mannsåker [Thu, 23 Nov 2017 11:29:19 +0000 (11:29 +0000)]
Cast away const from AIX' accessx() path argument
Unlike every other platform's access() or equivalent (and as required
by POSIX), AIX doesn't declare the path argument to access() and
accessx() as const char*, so cast the const away.
Tony Cook [Mon, 22 Oct 2018 04:22:47 +0000 (15:22 +1100)]
(perl #133604) fix binmode on Win32 :crlf layers
On Win32 the :crlf layer is special - it replaces the use of the normal
:perlio buffering layer.
So while binmode :raw with :crlf present on non-Win32 removes the
CRLF layer, on Win32 it simply switches the :crlf layer's CRLF flag off
to prevent translation.
Unfortunately the :crlf skipped doing something else expected by :raw -
it didn't turn off the layer UTF8 flag. This broke the tests I added
in
9704d779004.
Tony Cook [Mon, 22 Oct 2018 02:24:48 +0000 (13:24 +1100)]
(perl #133604) test for binmode removing :utf8
Tony Cook [Sun, 21 Oct 2018 22:44:57 +0000 (09:44 +1100)]
(perl #133604) skip a new test on Win32 that fails only on Win32
9704d779 added tests for the apparently completely untested behaviour
of recv() and send() on handles marked as :utf8.
On Win32 the binmode calls used to strip :utf8 for further testing
don't remote :utf8, and the following calls to send() and recv() die.
Hopefully this patch will be reverted soon once binmode is fixed.
Tony Cook [Sat, 20 Oct 2018 23:40:46 +0000 (10:40 +1100)]
Using #ifdef inside macro arguments confuses VC++ 2008
This caused compilation errors for me when building with the
Windows 7 SDK packaged version of MSVC.
Aaron Crane [Sat, 20 Oct 2018 15:07:16 +0000 (16:07 +0100)]
Bump version of Module::CoreList in Maintainers.pl
Aaron Crane [Sat, 20 Oct 2018 14:43:30 +0000 (15:43 +0100)]
Bump the Perl version for 5.29.5
Aaron Crane [Sat, 20 Oct 2018 14:32:02 +0000 (15:32 +0100)]
Create new perldelta for 5.29.5-to-be
Aaron Crane [Sat, 20 Oct 2018 14:28:55 +0000 (15:28 +0100)]
Tick off 5.29.4 release
Aaron Crane [Sat, 20 Oct 2018 14:28:31 +0000 (15:28 +0100)]
Epigraph for 5.29.4 release
Aaron Crane [Sat, 20 Oct 2018 14:25:18 +0000 (15:25 +0100)]
Merge branch 'release-5.29.4' into blead
Aaron Crane [Sat, 20 Oct 2018 12:29:17 +0000 (13:29 +0100)]
Finalize perldelta for 5.29.4
Aaron Crane [Sat, 20 Oct 2018 12:29:01 +0000 (13:29 +0100)]
Update Module::Corelist for 5.29.4
Karl Williamson [Sat, 20 Oct 2018 06:10:25 +0000 (00:10 -0600)]
Merge branch 'remove sizing pass' into blead
Karl Williamson [Sat, 20 Oct 2018 03:41:35 +0000 (21:41 -0600)]
perldelta
Karl Williamson [Fri, 19 Oct 2018 20:55:35 +0000 (14:55 -0600)]
regcomp.c: White space only
This out/indents the blocks that were removed/added by the previous
commit
Karl Williamson [Fri, 19 Oct 2018 17:39:57 +0000 (11:39 -0600)]
Remove references to passes from regex compiler
The previous commit removed the sizing pass, but to minimize the
difference listing, it left in all the references it could to the
various passes, with the first pass set to FALSE. This commit now
removes those references, as well as to some variables that are no
longer used.
Karl Williamson [Fri, 19 Oct 2018 15:48:34 +0000 (09:48 -0600)]
Remove sizing pass from regular expression compiler
This commit removes the sizing pass for regular expression compilation.
It attempts to be the minimum required to do this. Future patches are
in the works that improve it,, and there is certainly lots more that
could be done.
This is being done now for security reasons, as there have been several
bugs leading to CVEs where the sizing pass computed the size improperly,
and a crafted pattern could allow an attack. This means that simple
bugs can too easily become attack vectors.
This is NOT the AST that people would like, but it should make it easier
to move the code in that direction.
Instead of a sizing pass, as the pattern is parsed, new space is
malloc'd for each regnode found. To minimize the number of such mallocs
that actually go out and request memory, an initial guess is made, based
on the length of the pattern being compiled. The guessed amount is
malloc'd and then immediately released. Hopefully that memory won't be
gobbled up by another process before we actually gain control of it.
The guess is currently simply the number of bytes in the pattern.
Patches and/or suggestions are welcome on improving the guess or this
method.
This commit does not mean, however, that only one pass is done in all
cases. Currently there are several situations that require extra
passes. These are:
a) If the pattern isn't UTF-8, but encounters a construct that
requires it to become UTF-8, the parse is immediately stopped,
the translation is done, and the parse restarted. This is
unchanged from how it worked prior to this commit.
b) If the pattern uses /d rules and it encounters a construct that
requires it to become /u, the parse is immediately stopped and
restarted using /u rules. A future enhancement is to only
restart if something has been encountered that would generate
something different than what has already been generated, as
many operations are the same under both /d and /u. Prior to
this commit, in rare circumstances was the parse immediately
restarted. Only those few that changed the sizing did so.
Instead the sizing pass was allowed to complete and then the
generation pass ran, using /u. Some CVEs were caused by faulty
implementation here.
c) Very large patterns may need to have long jumps in their
program. Prior to this commit, that was determined in the
sizing pass, and all jumps were made long during generation.
Now, the first time the need for a long jump is detected, the
parse is immediately restarted, and all jumps are made long. I
haven't investigated enough to be sure, but it might be
sufficient to just redo the current jump, making it long, and
then switch to using just long jumps, without having to restart
the parse from the beginning.
d) If a reference that could be to capturing parentheses doesn't
find such parentheses, a flag is set. For references that could
be octal constants, they are assumed to be those constants
instead of a capturing group. At the end of the parse, if the
flag indicates either that the assumption(s) were wrong or that
it is a fatal reference to a non-existent group, the pattern is
reparsed knowing the total number of these groups.
e) If (?R) or (?0) are encountered, the flag listed in item d)
above is set to force a reparse. I did have code in place that
avoided doing the reparse, but I wasn't confident enough that
our test suite exercises that area of the code enough to have
exposed all the potential interaction bugs, and I think this
construct is used rarely enough to not worry about avoiding the
reparse at this point in the development.
f) If (?|pattern) is encountered, the behavior is the same as in
item e) above. The pattern will end up being reparsed after the
total number of parenthesized groups are known. I decided not
to invest the effort at this time in trying to get this to work
without a reparse.
It might be that if we are continuing the parse to just count
parentheses, and we encounter a construct that normally would restart
the parse immediately, that we could defer that restart. This would cut
down the maximum number of parses required. As of this commit, the
worst case is we find something that requires knowing all the
parentheses; later we have to switch to /u rules and so the parse is
restarted. Still later we have to switch to long jumps, and the parse
is restarted again. Still later we have to upgrade to UTF-8, and the
parse is restarted yet again. Then the parse is completed, and the
final total of parentheses is known, so everything is redone a final
time. Deferring those intermediate restarts would save a bunch of
reparsing.
Prior to this commit, warnings were issued only during the code
generation pass, which didn't get called unless the sizing pass(es)
completed successfully. But now, we don't know if the pass will
succeed, fail, or whether it will have to be restarted. To avoid
outputting the same warning more than once, the position in the parse of
the last warning generated is kept (across parses). The code looks at
that position when it is about to generate a warning. If the parsing
has previously gotten that far, it assumes that the warning has already
been generated, and suppresses it this time. The current state of
parsing is such that I believe this assumption is valid. If the parses
had divergent paths, that assumption could become invalid.
Karl Williamson [Fri, 19 Oct 2018 17:49:01 +0000 (11:49 -0600)]
regcomp.c: Avoid potential NULL ptr dereference
This commit cause the passed in variable to be non-NULL before
dereferencing it, as defensive coding practice. A future commit causes
this to matter.
Karl Williamson [Fri, 19 Oct 2018 17:47:05 +0000 (11:47 -0600)]
regcomp.c: Test that code block exists before cleaning
This is defensive coding progress, to avoid dereferencing a NULL ptr.
Karl Williamson [Fri, 19 Oct 2018 01:58:45 +0000 (19:58 -0600)]
regcomp.c: Extract code into a function
This should have no changes in behavior, and is for a future commit
where this code will be called from a second place.
Karl Williamson [Fri, 19 Oct 2018 01:02:51 +0000 (19:02 -0600)]
regcomp.c: Test for having /u earlier for \p{}
When \p{} or \p{} are encountered during parsing, that indicates that
the pattern should be compiled not under /d, but under /u, as these are
Unicode constructs. This commit moves the test for that to somewhat
earlier. This saves only a little work currently, but in a future
commit it saves a lot more wasted work.
Karl Williamson [Wed, 17 Oct 2018 17:54:49 +0000 (11:54 -0600)]
regcomp.c: Remove variable in favor of struct element
The code has a structure element that means the same thing part way
through a function as a variable. Just use the struct element all the
way through
Karl Williamson [Tue, 16 Oct 2018 18:16:10 +0000 (12:16 -0600)]
regcomp.c: Move fcn call out of loop
The loop in this case is by a goto label, and the function determines if
there are runtime code blocks in the pattern. That doesn't change if we
have to reparse, so the return from the function doesn't change, so we
only have to call it once.
Karl Williamson [Tue, 16 Oct 2018 03:31:13 +0000 (21:31 -0600)]
regcomp.c: Extract code into a function
This is in preparation for a later commit where the code will become
more complex and be called from more than one place.
Karl Williamson [Mon, 15 Oct 2018 03:12:15 +0000 (21:12 -0600)]
regcomp.c: Consolidate checks for warnings fatality
This adds code so that whenever a warning is about to be emitted, it
first checks to see if the warning is fatal, and if so mortalizes the SV
that otherwise would leak.
This partially fixes ticket [perl #133589]. It doesn't help if the
warnings are called through a subroutine outside of regcomp.c
Karl Williamson [Sun, 14 Oct 2018 23:07:57 +0000 (17:07 -0600)]
regcomp.c: Add macro for warnings output
This macro does nothing for now. It is being added in this separate
commit to lessen the number of differences in the future commit that
will need it, so that these don't distract from the main intent of that
commit.
The code is moving away from emitting all warnings in the code
generation pass, to emitting them as soon as encountered. But to avoid
emitting them more than once should the pattern have to be reparsed,
they will not be emitted unless the parse has gotten further this time
than it got earlier. This commit prepares for that.
Karl Williamson [Sun, 14 Oct 2018 22:59:50 +0000 (16:59 -0600)]
regcomp.c: Defer setting the OP variant of a regnode
This is in preparation for a future commit. We have allocated space and
know that the regnode will be some time of ANYOF one. But we don't need
to know which one precisely until later than we had been setting it.
Karl Williamson [Sun, 14 Oct 2018 22:50:59 +0000 (16:50 -0600)]
regcomp.c: Defer setting regnode operand
Don't set this until we know that we are actually going to have a
regnode that requires this operand.
Karl Williamson [Sun, 14 Oct 2018 22:43:06 +0000 (16:43 -0600)]
regcomp.c: Defer setting flags of a regnode
This is in preparation for a future commit where we won't know what the
regnode is until later in the code.
Karl Williamson [Sun, 14 Oct 2018 22:19:27 +0000 (16:19 -0600)]
regcomp.c: Move some declarations
This is in preparation for some blocks to be removed in a future commit,
so the declarations have to be at the top of the enclosing block
Karl Williamson [Sun, 14 Oct 2018 22:10:01 +0000 (16:10 -0600)]
regcomp.c: Add some const's to static fcn
Since it's static, the compiler can figure out these are consts, but
knowing this helped me read the code
Karl Williamson [Sun, 14 Oct 2018 22:02:09 +0000 (16:02 -0600)]
regcomp.c: Use an equivalent 'if' condition
By inspection of the code, I see that this 'if' won't get executed
unless the variable is non-null. The function whose return sets it
will raise an error if it would otherwise return NULL unexpectedly.
Karl Williamson [Sun, 14 Oct 2018 21:56:57 +0000 (15:56 -0600)]
regcomp.c: Reorder 'if' clauses
This is for sake of clarity so that the comment applies to the adjacent
clause.
Karl Williamson [Sun, 14 Oct 2018 21:50:55 +0000 (15:50 -0600)]
regcomp.c: Rmv unnecessary else
The 'if' if executed aborts, so control would never reach here unless
the 'else' would be taken.
Karl Williamson [Sun, 14 Oct 2018 21:12:41 +0000 (15:12 -0600)]
regcomp.c: Use SvREFCNT_inc_NN()
We know this is non-null as it panics a little ways above unless that's
the case.
Karl Williamson [Sun, 14 Oct 2018 20:30:50 +0000 (14:30 -0600)]
regcomp.c: Use an equivalent 'if' condition
By inspection of the code, I see that this 'if' won't get executed
unless the variable is non-null. The function whose return sets it
will raise an error if it would otherwise return NULL unexpectedly.
Karl Williamson [Sun, 14 Oct 2018 19:56:21 +0000 (13:56 -0600)]
regcomp.c: Combine expression into a macro
This expression will change in a future commit, so this isolates that
change
Karl Williamson [Sun, 14 Oct 2018 19:34:47 +0000 (13:34 -0600)]
regcomp.c: Split variable into two
This commit causes there to now be two variables that count the number
of parentheses in a pattern:
a) the current number as the pattern is parsed
b) the total number, not known until the pattern has been completely
parsed
This will prove useful in later commits.
Karl Williamson [Mon, 15 Oct 2018 02:16:03 +0000 (20:16 -0600)]
Consolidate code into a single macro
If we die during the code generation phase, we set the regex SV to be
freed during cleanup.
This consolidates many of those instances into one macro, so that it can
be easily changed. And instead of tieing it to the particular phase, we
clean up whenever that SV actually exists. This requires initializing
it to NULL.
Karl Williamson [Sun, 14 Oct 2018 18:52:07 +0000 (12:52 -0600)]
regcomp.c: Omit warning if error about to be raised
This commit changes the code to skip a warning when it knows an error is
about to happen. Currently this doesn't matter, as the warning would be
emitted only in a later pass, and the error would actually happen first,
so the warning doesn't get output at all. But future commits will
change that, so this commit is in preparation for that.
Karl Williamson [Sun, 14 Oct 2018 18:01:07 +0000 (12:01 -0600)]
regcomp.c: Add ability to not warn during substitute parse
Under certain conditions, regcomp.c will pretend something other than
the input pattern is to be parsed. There is a mechanism to seamlessly
show the original code when that substitute expression contains the
original as a subset. But there are cases where the entire substitute
is constructed by regcomp.c, and has none of the original pattern in
it. Since it is our construction, it should be legal, devoid of
warnings, but if somehow something happened to generate a warning, it
could lead to seg faults, etc.
This commit adds and uses a mechanism to turn off warnings while parsing
these constructs. Should a warning attempt to be output, instead of a
seg fault, a panic error message giving debugging details is output.
Karl Williamson [Sun, 14 Oct 2018 16:55:51 +0000 (10:55 -0600)]
regcomp.c: Generalize conditions to output warnings
Warnings are deferred until the code generation pass. This doesn't
change that, but makes the condition into a mcaro call so that can be
changed in a future commit.
Karl Williamson [Sat, 13 Oct 2018 06:37:45 +0000 (00:37 -0600)]
regcomp.c: Move some more code to earlier
It is better defensive coding to restore as soon as possible, rather
than deferring it.
Karl Williamson [Sat, 13 Oct 2018 06:29:15 +0000 (00:29 -0600)]
regcomp.c: Move some code to earlier
It is better defensive coding to restore as soon as possible, rather
than deferring it.
Karl Williamson [Mon, 8 Oct 2018 14:00:39 +0000 (08:00 -0600)]
regcomp.c: Consolidate 2nd pass for warnings
Warnings have to generally be delayed being output until the 2nd pass,
as the first pass can be restarted multiple times, and so the same
warning could be output multiple times if the restarted code outputs a
warning.
Prior to this commit, there was an assert that the warnings are being
output in the 2nd pass. This commit changes it so that the assert is
turned into an 'if' in common code, and the dispersed 'if's that
formerly were used are removed as much as possible. If that removes an
indented block, this commit also outdents the block contents.
Karl Williamson [Mon, 8 Oct 2018 13:22:47 +0000 (07:22 -0600)]
regcomp.c: Add macro for warning experimental features
This consolidates the code that warns that an experimental feature is
being called into a common macro.
Karl Williamson [Mon, 8 Oct 2018 13:06:52 +0000 (07:06 -0600)]
regcomp.c: Put common code in a macro
This trivial code is extracted into a common macro in preparation for a
future commit when it will become non-trivial, and hence that logic will
only have to occur once.
Karl Williamson [Sun, 7 Oct 2018 14:03:47 +0000 (08:03 -0600)]
regcomp.c: Rename macro and label
These move away from talking about pass 1, in preparation for future
commits.
Karl Williamson [Wed, 17 Oct 2018 17:21:20 +0000 (11:21 -0600)]
regcomp.c: Use another macro consistently
Sometimes the code refers to the union member explicitly, and sometimes
it uses the macro that evaluates to that member. This commit changes to
consistently use the latter.