Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
regcomp.c - Exclude split STRING from /x default modifiers.
We have a magic special case with split STRING where if the STRING is a single space character we trigger awk emaulation mode, which causes split to ignore leading whitespace, and to split on \s+. When default regex modifier support was added to perl we didn't notice that it doesn't make sense for the /x modifiers to change the behavior of a STRING pattern in split. STRING patterns are NOT parsed using the normal pattern parsing rules, for instance "\s+" would split on 's' characters, not on whitepace. The /x modifier is designed to change the rules for *pattern* parsing, most notably by adding support for comments and ignoring whitespace in pattern definitions. This feels to me like a feature that should only apply to cases where a true pattern is parsed, such as where \s+ would be treated as the special pattern for matching whitespace and not a literal 's' character. Historically there was NO way to create a string pattern with the /x pattern enabled, to enable /x the string MUST have been fed into a true pattern parsing construct like qr// m// or s///. By excluding STRING patterns from /x notation, we ensure that the special case of awk emulation for C<split " "> is preserved. Note that a default /x modifier *does* change the behavior of C<split / />, as the pattern in that case is parsed the same as C<split qr/ /> or C<m/ />. With changes by Yves Orton Fixes #18032
- Loading branch information
1 parent
4d119e9
commit 216a5aa
Showing
5 changed files
with
56 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"will produce"