diff options
author | Karl Williamson <public@khwilliamson.com> | 2011-02-19 15:56:29 -0700 |
---|---|---|
committer | Karl Williamson <public@khwilliamson.com> | 2011-02-19 22:18:56 -0700 |
commit | 94b03d7d32658fc20267c9aa8d5e423ce506f5a7 (patch) | |
tree | 5b136469324cddfa635b099dd1258912edc7ba88 /toke.c | |
parent | 07075d1946764ff3c2713c8e5a6c5d7e5a7514f2 (diff) | |
download | perl-94b03d7d32658fc20267c9aa8d5e423ce506f5a7.tar.gz |
Allow suffix form for /a /d /l /u
This patch contains the code changes for doing this, but not most of the
pod changes, nor the new .t tests required. There were already tests in
place to make sure that this didn't break backcompat.
Diffstat (limited to 'toke.c')
-rw-r--r-- | toke.c | 60 |
1 files changed, 58 insertions, 2 deletions
@@ -8765,24 +8765,80 @@ S_pmflag(pTHX_ const char* const valid_flags, U32 * pmfl, char** s) { * otherwise FALSE */ const char c = **s; + if (! strchr(valid_flags, c)) { if (isALNUM(c)) { - Perl_ck_warner_d(aTHX_ packWARN(WARN_SYNTAX), - "Having no space between pattern and following word is deprecated"); + goto deprecate; } return FALSE; } switch (c) { + CASE_STD_PMMOD_FLAGS_PARSE_SET(pmfl); case GLOBAL_PAT_MOD: *pmfl |= PMf_GLOBAL; break; case CONTINUE_PAT_MOD: *pmfl |= PMf_CONTINUE; break; case ONCE_PAT_MOD: *pmfl |= PMf_KEEP; break; case KEEPCOPY_PAT_MOD: *pmfl |= RXf_PMf_KEEPCOPY; break; case NONDESTRUCT_PAT_MOD: *pmfl |= PMf_NONDESTRUCT; break; + case LOCALE_PAT_MOD: + + /* In 5.14, qr//lt is legal but deprecated; the 't' means they + * can't be regex modifiers. + * In 5.14, s///le is legal and ambiguous. Try to disambiguate as + * much as easily done. s///lei, for example, has to mean regex + * modifiers if it's not an error (as does any word character + * following the 'e'). Otherwise, we resolve to the backwards- + * compatible, but less likely 's/// le ...', i.e. as meaning + * less-than-or-equal. The reason it's not likely is that s// + * returns a number, and so '<=' should be used for comparing, not + * 'le'. */ + if (*((*s) + 1) == 't') { + goto deprecate; + } + else if (*((*s) + 1) == 'e' && ! isALNUM(*((*s) + 2))) + { + Perl_ck_warner_d(aTHX_ packWARN(WARN_AMBIGUOUS), + "Ambiguous use of 's//le...' resolved as 's// le...'; Rewrite as 's//el' if you meant 'use locale rules and evaluate rhs as an expression'. In Perl 5.16, it will be resolved the other way"); + return FALSE; + } + set_regex_charset(pmfl, REGEX_LOCALE_CHARSET); + break; + case UNICODE_PAT_MOD: + /* In 5.14, qr//unless and qr//until are legal but deprecated; the + * 'n' means they can't be regex modifiers */ + if (*((*s) + 1) == 'n') { + goto deprecate; + } + set_regex_charset(pmfl, REGEX_UNICODE_CHARSET); + break; + case ASCII_RESTRICT_PAT_MOD: + /* In 5.14, qr//and is legal but deprecated; the 'n' means they + * can't be regex modifiers */ + if (*((*s) + 1) == 'n') { + goto deprecate; + } + if (*((*s) + 1) == ASCII_RESTRICT_PAT_MOD) { + /* Doubled modifier implies more restricted */ + set_regex_charset(pmfl, REGEX_ASCII_MORE_RESTRICTED_CHARSET); + (*s)++; + } + else { + set_regex_charset(pmfl, REGEX_ASCII_RESTRICTED_CHARSET); + } + break; + case DEPENDS_PAT_MOD: + set_regex_charset(pmfl, REGEX_DEPENDS_CHARSET); + break; } + (*s)++; return TRUE; + + deprecate: + Perl_ck_warner_d(aTHX_ packWARN(WARN_SYNTAX), + "Having no space between pattern and following word is deprecated"); + return FALSE; } STATIC char * |