mirror of
https://github.com/PCRE2Project/pcre2.git
synced 2025-10-20 04:25:35 +08:00
doc: fix silly confusion about re "strict" (#493)
in Perl, `use strict` has no effect on this feature but instead the "strict" mode referenced applies to `use re 'strict'`
This commit is contained in:

committed by
GitHub

parent
012ab39bd8
commit
6f5a4d9fd0
@@ -228,7 +228,7 @@ handled by PCRE2, either by the interpreter or the JIT. An example is
|
|||||||
.P
|
.P
|
||||||
23. From release 10.45, PCRE2 gives an error if \ex is not followed by a
|
23. From release 10.45, PCRE2 gives an error if \ex is not followed by a
|
||||||
hexadecimal digit or a curly bracket. It used to interpret this as the NUL
|
hexadecimal digit or a curly bracket. It used to interpret this as the NUL
|
||||||
character. Perl still generates NUL, but warns in its warning and strict modes.
|
character. Perl still generates NUL, but warns in its warning mode.
|
||||||
.
|
.
|
||||||
.
|
.
|
||||||
.SH AUTHOR
|
.SH AUTHOR
|
||||||
|
@@ -433,7 +433,7 @@ By default, after \ex that is not followed by {, one or two hexadecimal
|
|||||||
digits are read (letters can be in upper or lower case). If the character that
|
digits are read (letters can be in upper or lower case). If the character that
|
||||||
follows \ex is neither { nor a hexadecimal digit, an error occurs. This is
|
follows \ex is neither { nor a hexadecimal digit, an error occurs. This is
|
||||||
different from Perl's default behaviour, which generates a NUL character, but
|
different from Perl's default behaviour, which generates a NUL character, but
|
||||||
is in line with Perl's "strict" behaviour.
|
is in line with the behaviour of Perl's 'strict' mode in re.
|
||||||
.P
|
.P
|
||||||
Any number of hexadecimal digits may appear between \ex{ and }. If a character
|
Any number of hexadecimal digits may appear between \ex{ and }. If a character
|
||||||
other than a hexadecimal digit appears between \ex{ and }, or if there is no
|
other than a hexadecimal digit appears between \ex{ and }, or if there is no
|
||||||
|
@@ -2060,8 +2060,8 @@ else
|
|||||||
/* Perl has the surprising/broken behaviour that \x without following
|
/* Perl has the surprising/broken behaviour that \x without following
|
||||||
hex digits is treated as an escape for NUL. Their source code laments
|
hex digits is treated as an escape for NUL. Their source code laments
|
||||||
this but keeps it for backwards compatibility. A warning is printed
|
this but keeps it for backwards compatibility. A warning is printed
|
||||||
when "use warnings" is enabled, and it's forbidden when "use strict"
|
when "use warnings" is enabled. Because we don't have warnings, we
|
||||||
is enabled. Because we don't have warnings, we simply forbid it. */
|
simply forbid it. */
|
||||||
if (ptr >= ptrend || (cc = XDIGIT(*ptr)) == 0xff)
|
if (ptr >= ptrend || (cc = XDIGIT(*ptr)) == 0xff)
|
||||||
{
|
{
|
||||||
/* Not a hex digit */
|
/* Not a hex digit */
|
||||||
@@ -2072,9 +2072,9 @@ else
|
|||||||
c = cc;
|
c = cc;
|
||||||
|
|
||||||
/* With "use re 'strict'" Perl actually requires exactly two digits (error
|
/* With "use re 'strict'" Perl actually requires exactly two digits (error
|
||||||
for both \xA and \xAAA). This seems overly strict, and there seems
|
for \x, \xA and \xAAA). While \x was already rejected, this seems overly
|
||||||
little incentive to align with that, given the backwards-compatibility
|
strict, and there seems little incentive to align with that, given the
|
||||||
cost.
|
backwards-compatibility cost.
|
||||||
|
|
||||||
For comparison, note that other engines disagree. For example:
|
For comparison, note that other engines disagree. For example:
|
||||||
- Java allows 1 or 2 hex digits. Error if 0 digits. No error if >2 digits
|
- Java allows 1 or 2 hex digits. Error if 0 digits. No error if >2 digits
|
||||||
|
Reference in New Issue
Block a user