summaryrefslogtreecommitdiff
path: root/dquote_static.c
diff options
context:
space:
mode:
authorKarl Williamson <public@khwilliamson.com>2011-02-09 21:18:48 -0700
committerKarl Williamson <public@khwilliamson.com>2011-02-09 22:46:03 -0700
commit17a3df4c6a07533e2c03c46fdd27e3ee295d61d0 (patch)
treee0ee85739319695ef7c320b28890ad2f49ebade2 /dquote_static.c
parent3efe3cb8c0229e34f5e21774151ddbfdcf27adf4 (diff)
downloadperl-17a3df4c6a07533e2c03c46fdd27e3ee295d61d0.tar.gz
Fix up \cX for 5.14
Throughout 5.13 there was temporary code to deprecate and forbid certain values of X following a \c in qq strings. This patch fixes this to the final 5.14 semantics. These are: 1) a utf8 non-ASCII character will croak. This is the same behavior as pre-5.13, but it gives a correct error message, rather than the malformed utf8 message previously. 2) \c{ and \cX where X is above ASCII will generate a deprecated message. The intent is to remove these capabilities in 5.16. The original agreement was to croak on above ASCII, but that does violate our stability policy, so I'm deprecating it instead. 3) A non-deprecated warning is generated for all other \cX; this is the same as throughout the 5.13 series. I did not have the tuits to use \c{} as I had planned in 5.14, but \N{} can be used instead.
Diffstat (limited to 'dquote_static.c')
-rw-r--r--dquote_static.c28
1 files changed, 18 insertions, 10 deletions
diff --git a/dquote_static.c b/dquote_static.c
index b5a2cccee6..e23ec4623a 100644
--- a/dquote_static.c
+++ b/dquote_static.c
@@ -39,26 +39,34 @@ S_regcurly(pTHX_ register const char *s)
/* XXX Add documentation after final interface and behavior is decided */
/* May want to show context for error, so would pass Perl_bslash_c(pTHX_ const char* current, const char* start, const bool output_warning)
U8 source = *current;
-
- May want to add eg, WARN_REGEX
*/
STATIC char
-S_grok_bslash_c(pTHX_ const char source, const bool output_warning)
+S_grok_bslash_c(pTHX_ const char source, const bool utf8, const bool output_warning)
{
U8 result;
- if (! isASCII(source)) {
- Perl_croak(aTHX_ "Character following \"\\c\" must be ASCII");
+ if (utf8) {
+ /* Trying to deprecate non-ASCII usages. This construct has never
+ * worked for a utf8 variant. So, even though are accepting non-ASCII
+ * Latin1 in 5.14, no need to make them work under utf8 */
+ if (! isASCII(source)) {
+ Perl_croak(aTHX_ "Character following \"\\c\" must be ASCII");
+ }
}
result = toCTRL(source);
- if (! isCNTRL(result)) {
+ if (! isASCII(source)) {
+ Perl_ck_warner_d(aTHX_ packWARN2(WARN_DEPRECATED, WARN_SYNTAX),
+ "Character following \"\\c\" must be ASCII");
+ }
+ else if (! isCNTRL(result) && output_warning) {
if (source == '{') {
- Perl_croak(aTHX_ "It is proposed that \"\\c{\" no longer be valid. It has historically evaluated to\n \";\". If you disagree with this proposal, send email to perl5-porters@perl.org\nOtherwise, or in the meantime, you can work around this failure by changing\n\"\\c{\" to \";\"");
+ Perl_ck_warner_d(aTHX_ packWARN2(WARN_DEPRECATED, WARN_SYNTAX),
+ "\"\\c{\" is deprecated and is more clearly written as \";\"");
}
- else if (output_warning) {
+ else {
U8 clearer[3];
U8 i = 0;
if (! isALNUM(result)) {
@@ -67,8 +75,8 @@ S_grok_bslash_c(pTHX_ const char source, const bool output_warning)
clearer[i++] = result;
clearer[i++] = '\0';
- Perl_ck_warner_d(aTHX_ packWARN(WARN_DEPRECATED),
- "\"\\c%c\" more clearly written simply as \"%s\"",
+ Perl_ck_warner(aTHX_ packWARN(WARN_SYNTAX),
+ "\"\\c%c\" is more clearly written simply as \"%s\"",
source,
clearer);
}