[interchange] Test regex match in picture_format()

Mark Johnson interchange-cvs at icdevgroup.org
Mon Jan 24 22:24:28 UTC 2011


commit a6c3c1dc495aa142ea7b24c110905eefc5ae1aed
Author: Mark Johnson <mark at endpoint.com>
Date:   Mon Jan 24 17:20:49 2011 -0500

    Test regex match in picture_format()
    
    Bug exposed on price pictures that do not use a point separator,
    such as Yen.

 lib/Vend/Util.pm |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/lib/Vend/Util.pm b/lib/Vend/Util.pm
index 7e2860c..d6ae6a9 100644
--- a/lib/Vend/Util.pm
+++ b/lib/Vend/Util.pm
@@ -335,8 +335,10 @@ sub picture_format {
     $pic	= reverse $pic;
 	$point	= '.' unless defined $point;
 	$sep	= ',' unless defined $sep;
-	$pic =~ /(#+)\Q$point/;
-	my $len = length($1);
+	my $len = $pic =~ /(#+)\Q$point/
+		? length($1)
+		: 0
+	;
 	$amount = sprintf('%.' . $len . 'f', $amount);
 	$amount =~ tr/0-9//cd;
 	my (@dig) = split m{}, $amount;



More information about the interchange-cvs mailing list