summaryrefslogtreecommitdiff
path: root/lib/Text
diff options
context:
space:
mode:
authormike@bill.iac.net <mike@bill.iac.net>1998-06-27 03:49:13 +0000
committerGurusamy Sarathy <gsar@cpan.org>1998-06-28 20:56:38 +0000
commitb174585de5ccc9973ba572393b2b34e1a6a5b749 (patch)
treec865df90cd1fdd39a865d0ef87571fd19da9790f /lib/Text
parent79e58eb31bcd807aa3590e1d48e9343596eec282 (diff)
downloadperl-b174585de5ccc9973ba572393b2b34e1a6a5b749.tar.gz
[ PATCH 5.004 68 ] Text::ParseWords, ^W fixed, version 3.1
Message-ID: <19980627034913.A32220@bill.minivend.com> p4raw-id: //depot/perl@1249
Diffstat (limited to 'lib/Text')
-rw-r--r--lib/Text/ParseWords.pm25
1 files changed, 16 insertions, 9 deletions
diff --git a/lib/Text/ParseWords.pm b/lib/Text/ParseWords.pm
index d3a89f03b8..95f0e9b41f 100644
--- a/lib/Text/ParseWords.pm
+++ b/lib/Text/ParseWords.pm
@@ -1,7 +1,7 @@
package Text::ParseWords;
-use vars qw($VERSION @ISA @EXPORT);
-$VERSION = "3.0";
+use vars qw($VERSION @ISA @EXPORT $PERL_SINGLE_QUOTE);
+$VERSION = "3.1";
require 5.000;
@@ -48,22 +48,28 @@ sub nested_quotewords {
sub parse_line {
+ # We will be testing undef strings
+ local($^W) = 0;
+
my($delimiter, $keep, $line) = @_;
my($quote, $quoted, $unquoted, $delim, $word, @pieces);
while (length($line)) {
- ($quote, $quoted, $unquoted, $delim) =
+
+ ($quote, $quoted, undef, $unquoted, $delim, undef) =
$line =~ m/^(["']) # a $quote
- ((?:\\.|[^\1\\])*?) # and $quoted text
- \1 # followed by the same quote
+ ((?:\\.|(?!\1)[^\\])*) # and $quoted text
+ \1 # followed by the same quote
+ ([\000-\377]*) # and the rest
| # --OR--
^((?:\\.|[^\\"'])*?) # an $unquoted text
- (\Z(?!\n)|$delimiter|(?!^)(?=["']))
+ (\Z(?!\n)|$delimiter|(?!^)(?=["']))
# plus EOL, delimiter, or quote
- /x; # extended layout
+ ([\000-\377]*) # the rest
+ /x; # extended layout
+ return() unless( $quote || length($unquoted) || length($delim));
- return() unless(length($&));
- $line = $';
+ $line = $+;
if ($keep) {
$quoted = "$quote$quoted$quote";
@@ -71,6 +77,7 @@ sub parse_line {
else {
$unquoted =~ s/\\(.)/$1/g;
$quoted =~ s/\\(.)/$1/g if ($quote eq '"');
+ $quoted =~ s/\\([\\'])/$1/g if ( $PERL_SINGLE_QUOTE && $quote eq "'");
}
$word .= ($quote) ? $quoted : $unquoted;