[Rt-commit] [svn] r1083 - in Text-Quoted: . t

jesse at pallas.eruditorum.org jesse at pallas.eruditorum.org
Wed Jun 16 13:39:57 EDT 2004


Author: jesse
Date: Wed Jun 16 13:39:56 2004
New Revision: 1083

Added:
   Text-Quoted/t/5.t
Modified:
   Text-Quoted/Changes
   Text-Quoted/META.yml
   Text-Quoted/Quoted.pm
Log:
Fixing warnings on empty quotable strings

Modified: Text-Quoted/Changes
==============================================================================
--- Text-Quoted/Changes	(original)
+++ Text-Quoted/Changes	Wed Jun 16 13:39:56 2004
@@ -1,5 +1,10 @@
 Revision history for Perl extension Text::Quoted.
 
+1.6  Wed Jun 16 13:36:00 EDT 2004
+
+	- New maintainer
+	- Better handle attempts to quote an empty or undef string
+
 1.0  Tue Dec  3 15:01:07 2002
 	- original version; created by h2xs 1.22 with options
 		-AX -n Text::Quoted

Modified: Text-Quoted/META.yml
==============================================================================
--- Text-Quoted/META.yml	(original)
+++ Text-Quoted/META.yml	Wed Jun 16 13:39:56 2004
@@ -1,11 +1,12 @@
 name: Text-Quoted
 module_name: Text::Quoted
-version: 1.5
+version: 1.6
 author: Jesse Vincent <jesse at bestpractical.com>
 license: perl
 distribution_type: module
 requires:
   Text::Autoformat: 0
+  Text::Tabs: 0
 no_index:
   directory:
     - inc

Modified: Text-Quoted/Quoted.pm
==============================================================================
--- Text-Quoted/Quoted.pm	(original)
+++ Text-Quoted/Quoted.pm	Wed Jun 16 13:39:56 2004
@@ -78,7 +78,7 @@
 
 Copyright (C) 2002-2003 Kasei Limited
 Copyright (C) 2003-2004 Simon Cozens
-Copyright (C) 2004 Best Practical Solutions
+Copyright (C) 2004 Best Practical Solutions, LLC
 
 This software is distributed WITHOUT ANY WARRANTY; without even the implied
 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
@@ -171,22 +171,24 @@
 
 my $separator = q/(?:[-_]{2,}|[=#*]{3,}|[+~]{4,})/;
 
-sub defn($) { return $_[0] if defined $_[0]; return ""; }
+sub defn($) { return $_[0] if (defined $_[0]); return "" }
 
 sub classify {
-    my $text = shift;
+    my $text = shift || ""; # If the user passes in a null string, we really want to end up with _something_
 
     # DETABIFY
     my @rawlines = split /\n/, $text;
     use Text::Tabs;
     @rawlines = expand(@rawlines);
 
+use Data::Dumper;print scalar Dumper \@rawlines;
+
     # PARSE EACH LINE
 
     my $pre = 0;
     my @lines;
     foreach (@rawlines) {
-        push @lines, { raw => $_ };
+        push @lines, { raw => $_};
         s/\A([ \t]*)($quoter?)([ \t]*)//;
         $lines[-1]{presig} = $lines[-1]{prespace} = defn $1;
         $lines[-1]{presig} .= $lines[-1]{quoter}     = defn $2;
@@ -230,7 +232,8 @@
             {
                 push @paras, $line;
                 $first     = 0;
-                $firstfrom = length( $line->{raw} ) - length( $line->{text} );
+		# We get warnings from undefined raw and text values if we don't supply alternates
+                $firstfrom = length( $line->{raw} ||0 ) - length( $line->{text} || 0);
             }
             else {
                 my $extraspace =

Added: Text-Quoted/t/5.t
==============================================================================
--- (empty file)
+++ Text-Quoted/t/5.t	Wed Jun 16 13:39:56 2004
@@ -0,0 +1,31 @@
+# Before `make install' is performed this script should be runnable with
+# `make test'. After `make install' it should work as `perl 1.t'
+
+#########################
+
+# change 'tests => 1' to 'tests => last_test_to_print';
+
+use Test::More tests => 3;
+BEGIN { use_ok('Text::Quoted') };
+
+#########################
+
+# Insert your test code below, the Test::More module is use()ed here so read
+# its man page ( perldoc Test::More ) for help writing this test script.
+
+$a = '';
+use Data::Dumper;
+
+$empty_deeply = [
+          {
+            'text' => undef,
+            'empty' => undef,
+            'quoter' => undef,
+            'raw' => undef
+          }
+        ];
+
+is_deeply(extract($a),$empty_deeply);
+$b = undef;
+is_deeply(extract($b),$empty_deeply);
+


More information about the Rt-commit mailing list