[interchange-cvs] interchange - kwalsh modified code/Filter/roman.filter

interchange-cvs at icdevgroup.org interchange-cvs at icdevgroup.org
Tue Jun 28 14:59:03 EDT 2005


User:      kwalsh
Date:      2005-06-28 18:59:03 GMT
Modified:  code/Filter roman.filter
Log:
    * Set the filter's Visibility to "private".

    * Added some sanity checks.  They are largely unnecessary, but they
      make me feel better about the code. :-)

Revision  Changes    Path
1.2       +8 -4      interchange/code/Filter/roman.filter


rev 1.2, prev_rev 1.1
Index: roman.filter
===================================================================
RCS file: /var/cvs/interchange/code/Filter/roman.filter,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- roman.filter	27 Jun 2005 19:46:51 -0000	1.1
+++ roman.filter	28 Jun 2005 18:59:03 -0000	1.2
@@ -1,17 +1,21 @@
 # Copyright (c) 2005 Cursor Software Limited (http://www.cursor.biz/)
 # Copyright (c) 2005 Interchange Development Group (http://www.icdevgroup.org/)
 # Licensed under the GNU GPL. See file LICENSE for details.
-# $Id: roman.filter,v 1.1 2005/06/27 19:46:51 kwalsh Exp $
+# $Id: roman.filter,v 1.2 2005/06/28 18:59:03 kwalsh Exp $
 
 CodeDef roman Filter
 CodeDef roman Description Integer to Roman numerals
-CodeDef roman Routine <<EOR
+CodeDef roman Visibility  private
+CodeDef roman Routine     <<EOR
 sub {
     my $val = shift;
+
     $val =~ s/\D+//g;
-    $val =~ m/(\d*?)(\d{1,3})$/;
+    return '' unless $val;
+
+    $val =~ m/(\d*?)(\d{1,3})$/ or return '';
 
-    my $buf = 'M' x $1;
+    my $buf = 'M' x ($1 || 0);
     my @digits = reverse(split('',$2));
 
     my @numerals = (








More information about the interchange-cvs mailing list