From: Karl Williamson Date: Tue, 19 Mar 2019 18:14:26 +0000 (-0600) Subject: Change error wording for empty \x{} X-Git-Tag: v5.29.9~11 X-Git-Url: https://perl5.git.perl.org/perl5.git/commitdiff_plain/e750debb242ae6fdd7b786405ba167620fb77a2d Change error wording for empty \x{} An empty \x{} is unfortunately legal (returning a NUL) except in the scope of "use re 'strict'". Since this is an experimental feature, things like wording changes are allowed. It is unlikely anyone is relying on the precise wording of this fatal error under 'strict', and now all the messages for similar errors are similarly worded. --- diff --git a/dquote.c b/dquote.c index 7070244..17857dd 100644 --- a/dquote.c +++ b/dquote.c @@ -253,7 +253,7 @@ Perl_grok_bslash_x(pTHX_ char **s, const char * const send, UV *uv, if (numbers_len == 0) { if (strict) { (*s)++; /* Move past the } */ - *error_msg = "Number with no digits"; + *error_msg = "Empty \\x{}"; return FALSE; } *s = e + 1; diff --git a/pod/perldelta.pod b/pod/perldelta.pod index 7a013af..4d94cce 100644 --- a/pod/perldelta.pod +++ b/pod/perldelta.pod @@ -311,6 +311,16 @@ fatal error message "Empty \o{}". Previously it was "Number with no digits". This means the same wording is used for this kind of error as with similar constructs such as C<\p{}>. +=item * + +Within the scope of the experimental feature C, +specifying C<\x{}> without anything between the braces now yields the +fatal error message "Empty \x{}". Previously it was "Number with no +digits". This means the same wording is used for this kind of error as +with similar constructs such as C<\p{}>. It is legal, though not wise +to have an empty C<\x> outside of C; it silently generates +a NUL character. + =back =head1 Utility Changes diff --git a/pod/perldiag.pod b/pod/perldiag.pod index 1ab19d4..8163dde 100644 --- a/pod/perldiag.pod +++ b/pod/perldiag.pod @@ -2163,8 +2163,11 @@ unlikely to be what you want. =item Empty \%c{} in regex; marked by S<<-- HERE> in m/%s/ -(F) You used something like C<\b{}>, C<\B{}>, C<\o{}>, C<\p>, C<\P> -without specifying anything for it to operate on. +(F) You used something like C<\b{}>, C<\B{}>, C<\o{}>, C<\p>, C<\P>, or +C<\x> without specifying anything for it to operate on. + +Unfortunately, for backwards compatibility reasons, an empty C<\x> is +legal outside S> and expands to a NUL character. =item ${^ENCODING} is no longer supported diff --git a/t/re/reg_mesg.t b/t/re/reg_mesg.t index 872b388..667621e 100644 --- a/t/re/reg_mesg.t +++ b/t/re/reg_mesg.t @@ -241,7 +241,7 @@ my @death = '/(?[ \o{} ])/' => 'Empty \o{} {#} m/(?[ \o{}{#} ])/', '/(?[ \x{defg} ])/' => 'Non-hex character {#} m/(?[ \x{defg{#}} ])/', '/(?[ \xabcdef ])/' => 'Use \\x{...} for more than two hex characters {#} m/(?[ \xabc{#}def ])/', - '/(?[ \x{} ])/' => 'Number with no digits {#} m/(?[ \x{}{#} ])/', + '/(?[ \x{} ])/' => 'Empty \x{} {#} m/(?[ \x{}{#} ])/', '/(?[ \cK + ) ])/' => 'Unexpected \')\' {#} m/(?[ \cK + ){#} ])/', '/(?[ \cK + ])/' => 'Incomplete expression within \'(?[ ])\' {#} m/(?[ \cK + {#}])/', '/(?[ ( ) ])/' => 'Incomplete expression within \'(?[ ])\' {#} m/(?[ ( ){#} ])/', @@ -342,9 +342,9 @@ my @death_only_under_strict = ( 'm/[\o{789}]/' => 'Non-octal character \'8\'. Resolved as "\o{7}"', => 'Non-octal character {#} m/[\o{78{#}9}]/', 'm/\x{}/' => "", - => 'Number with no digits {#} m/\x{}{#}/', + => 'Empty \x{} {#} m/\x{}{#}/', 'm/[\x{}]/' => "", - => 'Number with no digits {#} m/[\x{}{#}]/', + => 'Empty \x{} {#} m/[\x{}{#}]/', 'm/\x{ABCDEFG}/' => 'Illegal hexadecimal digit \'G\' ignored', => 'Non-hex character {#} m/\x{ABCDEFG{#}}/', 'm/[\x{ABCDEFG}]/' => 'Illegal hexadecimal digit \'G\' ignored',