[Bps-public-commit] Text-Quoted branch, set-quote-char, updated. 363cd4a4467ac78dd4c491a706d4fe1d47ed759c

? sunnavy sunnavy at bestpractical.com
Thu Mar 22 01:30:18 EDT 2012


The branch, set-quote-char has been updated
       via  363cd4a4467ac78dd4c491a706d4fe1d47ed759c (commit)
      from  d80716bfa36340fc76698fa4e7a2eee40fccd6da (commit)

Summary of changes:
 Quoted.pm  |    7 ++++++-
 t/basics.t |   19 ++++++++++++++++++-
 2 files changed, 24 insertions(+), 2 deletions(-)

- Log -----------------------------------------------------------------
commit 363cd4a4467ac78dd4c491a706d4fe1d47ed759c
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Thu Mar 22 13:29:43 2012 +0800

    allow to set undef to exclude all quote chars

diff --git a/Quoted.pm b/Quoted.pm
index 8cecf2d..d3d98ad 100644
--- a/Quoted.pm
+++ b/Quoted.pm
@@ -245,7 +245,12 @@ sub expand_tabs {
 sub set_quote_char {
     my $regex = shift;
     $quotechar = $regex;
-    $quotechunk = qr/(?!$separator *\z)(?:$quotechar(?!\w)|\w*>+)/;
+    if ($quotechar) {
+        $quotechunk = qr/(?!$separator *\z)(?:$quotechar(?!\w)|\w*>+)/;
+    }
+    else {
+        $quotechunk = qr/(?!$separator *\z)\w*>+/;
+    }
     $quoter     = qr/$quotechunk(?:[ \t]*$quotechunk)*/;
 }
 
diff --git a/t/basics.t b/t/basics.t
index 5526079..61e6772 100644
--- a/t/basics.t
+++ b/t/basics.t
@@ -1,7 +1,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 9;
+use Test::More tests => 10;
 BEGIN { use_ok('Text::Quoted') };
 
 use Data::Dumper;
@@ -173,3 +173,20 @@ $a_dump = [
 
 is_deeply(extract($a),$a_dump,"customize quote char");
 
+Text::Quoted::set_quote_char( undef );
+$a = <<'EOF';
+a
+# b
+c
+EOF
+
+$a_dump = [
+    {
+        'text'   => "a\n# b\nc",
+        'quoter' => '',
+        'raw'    => "a\n# b\nc"
+    },
+];
+
+is_deeply( extract($a), $a_dump, "customize quote char to exclude all" );
+

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list