r5605 - in /packages/libtext-roman-perl: ./ branches/ branches/upstream/ branches/upstream/current/ tags/

gwolf at users.alioth.debian.org gwolf at users.alioth.debian.org
Fri Jun 15 23:31:03 UTC 2007


Author: gwolf
Date: Fri Jun 15 23:31:03 2007
New Revision: 5605

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=5605
Log:
[svn-inject] Installing original source of libtext-roman-perl

Added:
    packages/libtext-roman-perl/
    packages/libtext-roman-perl/branches/
    packages/libtext-roman-perl/branches/upstream/
    packages/libtext-roman-perl/branches/upstream/current/
    packages/libtext-roman-perl/branches/upstream/current/Changes
    packages/libtext-roman-perl/branches/upstream/current/LICENSE
    packages/libtext-roman-perl/branches/upstream/current/MANIFEST
    packages/libtext-roman-perl/branches/upstream/current/Makefile.PL
    packages/libtext-roman-perl/branches/upstream/current/README
    packages/libtext-roman-perl/branches/upstream/current/Roman.pm
    packages/libtext-roman-perl/branches/upstream/current/test.pl
    packages/libtext-roman-perl/tags/

Added: packages/libtext-roman-perl/branches/upstream/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libtext-roman-perl/branches/upstream/current/Changes?rev=5605&op=file
==============================================================================
--- packages/libtext-roman-perl/branches/upstream/current/Changes (added)
+++ packages/libtext-roman-perl/branches/upstream/current/Changes Fri Jun 15 23:31:03 2007
@@ -1,0 +1,36 @@
+Revision history for Perl extension Text-Roman
+
+revision 3.3
+date: 2003/01/16 01:56:34;  author: ekkis;  state: Exp;  lines: +6 -6
+- needed to bump up version as I forgot test.pl in MANIFEST
+- cleaned up POD a little
+
+revision 3.02
+date: 2003/01/16 01:12:15;  author: ekkis;  state: Exp;  lines: +3 -3
+- upping revision number to succed older module in CPAN
+
+revision 1.4
+date: 2003/01/16 01:06:41;  author: ekkis;  state: Exp;  lines: +77 -8
+- added backward compatibility to module
+- added CHANGES section to POD + ACKNOWLEGEMENTS, AVAILABILITY, etc.
+
+revision 1.3
+date: 2003/01/15 22:22:30;  author: ekkis;  state: Exp;  lines: +81 -95
+- converted Milhar functions
+- finalised POD changes
+
+revision 1.2
+date: 2003/01/15 10:27:35;  author: ekkis;  state: Exp;  lines: +108 -183
+- now uses strict and warnings
+- inline POD
+- complete rewrite of roman(), isroman() and roman2int() using my own algorithms
+- now only exports_ok
+
+revision 1.1
+date: 2003/01/15 01:55:46;  author: ekkis;  state: Exp;
+branches:  1.1.1;
+Initial revision
+
+revision 1.1.1.1
+date: 2003/01/15 01:55:46;  author: ekkis;  state: Exp;  lines: +0 -0
+Initial import

Added: packages/libtext-roman-perl/branches/upstream/current/LICENSE
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libtext-roman-perl/branches/upstream/current/LICENSE?rev=5605&op=file
==============================================================================
--- packages/libtext-roman-perl/branches/upstream/current/LICENSE (added)
+++ packages/libtext-roman-perl/branches/upstream/current/LICENSE Fri Jun 15 23:31:03 2007
@@ -1,0 +1,25 @@
+Copyright (c) 2002, Erick Calder
+
+Permission is hereby granted, free of charge, to any person obtaining 
+a copy of this software and associated documentation files (the 
+"Software"), to deal in the Software without restriction, including 
+without limitation the rights to use, copy, modify, merge, publish, 
+distribute, sublicense, and/or sell copies of the Software, and to 
+permit persons to whom the Software is furnished to do so, subject 
+to the following conditions:
+
+The above copyright notice and this permission notice shall be included 
+in all copies or substantial portions of the Software.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+

Added: packages/libtext-roman-perl/branches/upstream/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libtext-roman-perl/branches/upstream/current/MANIFEST?rev=5605&op=file
==============================================================================
--- packages/libtext-roman-perl/branches/upstream/current/MANIFEST (added)
+++ packages/libtext-roman-perl/branches/upstream/current/MANIFEST Fri Jun 15 23:31:03 2007
@@ -1,0 +1,7 @@
+Roman.pm
+Makefile.PL
+test.pl
+MANIFEST
+README
+LICENSE
+Changes

Added: packages/libtext-roman-perl/branches/upstream/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libtext-roman-perl/branches/upstream/current/Makefile.PL?rev=5605&op=file
==============================================================================
--- packages/libtext-roman-perl/branches/upstream/current/Makefile.PL (added)
+++ packages/libtext-roman-perl/branches/upstream/current/Makefile.PL Fri Jun 15 23:31:03 2007
@@ -1,0 +1,8 @@
+use ExtUtils::MakeMaker;
+
+WriteMakefile(
+    NAME		    => 'Text::Roman',
+    VERSION_FROM	=> 'Roman.pm',
+	AUTHOR			=> 'Erick Calder <ecalder at cpan.org>',
+	ABSTRACT_FROM	=> 'Roman.pm',
+	);

Added: packages/libtext-roman-perl/branches/upstream/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libtext-roman-perl/branches/upstream/current/README?rev=5605&op=file
==============================================================================
--- packages/libtext-roman-perl/branches/upstream/current/README (added)
+++ packages/libtext-roman-perl/branches/upstream/current/README Fri Jun 15 23:31:03 2007
@@ -1,0 +1,31 @@
+Text-Roman version 3.3
+======================
+
+This module allows conversions between Roman and Arabic algarisms.
+
+INSTALLATION
+
+To install this module type the following:
+
+   perl Makefile.PL
+   make
+   make test
+   make install
+
+DOCUMENTATION
+
+Full documentation available in the POD.
+
+NOTES
+
+I have completely rewritten this module, implementing simpler
+algorithms to perform the same functionality, adding a test
+suite, a Changes file, etc.  and providing more comprehensive
+documentation.  For a history of the module and credits to others
+involved please the the man page.  Questions/suggestions may 
+now come to me (see AUTHOR section in the docs).
+
+WARNING
+
+Be advised that whilst this release supports the old interface,
+it is now considered deprecated.  Please consult docs before using!

Added: packages/libtext-roman-perl/branches/upstream/current/Roman.pm
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libtext-roman-perl/branches/upstream/current/Roman.pm?rev=5605&op=file
==============================================================================
--- packages/libtext-roman-perl/branches/upstream/current/Roman.pm (added)
+++ packages/libtext-roman-perl/branches/upstream/current/Roman.pm Fri Jun 15 23:31:03 2007
@@ -1,0 +1,239 @@
+#!/usr/bin/perl
+
+=head1 NAME
+
+Text::Roman - Allows conversion between Roman and Arabic algarisms.
+
+=head1 SYNOPSIS
+
+ use Text::Roman qw/
+    isroman roman2int int2roman ismilhar milhar2int
+    roman mroman2int ismroman
+    /;
+	
+ print int2roman(123);
+
+ $roman	= "XXXV";
+ print roman2int($roman) if isroman($roman);
+
+ $milhar = 'L_X_XXIII';     # = 60,023
+ print milhar2int($milhar) if ismilhar($milhar);
+
+=cut
+
+# --- prologue ----------------------------------------------------------------
+
+package Text::Roman;
+
+require 5.000;
+
+use warnings;
+use strict;
+use Exporter;
+
+use vars qw/$VERSION @ISA @EXPORT_OK/;
+$VERSION    = substr q$Revision: 3.3 $, 10;
+ at ISA        = qw/Exporter/;
+ at EXPORT_OK  = qw/
+    int2roman roman2int isroman milhar2int ismilhar
+    roman mroman2int ismroman
+    /;
+
+use vars qw/@RSN @RCN %R2A %A2R/;
+
+ at RSN = qw/I V X L C D M/;                       # Roman Simple Numerals
+ at RCN = qw/IV IX XL XC CD CM/;                   # Roman Complex Numerals
+ at R2A{@RSN, @RCN} = qw/
+    1 5 10 50 100 500 1000 4 9 40 90 400 900
+    /;                                          # numeric values
+%A2R = reverse %R2A;                            # reverse for convenience
+
+# --- module interface --------------------------------------------------------
+
+=head1 DESCRIPTION
+
+This package supports both conventional Roman algarisms (which range from 1 to 3999) and Milhar Romans, a variation which uses a bar across the algarism to indicate multiplication by 1,000.  For the purposes of this module, acceptable syntax consists of an underscore suffixed to the algarism e.g. IV_V = 4,005.  The term Milhar apparently derives from the Portuguese word for "thousands" and the range of this notation extends the range of Roman numbers to 3999 x 1000 + 3999 = 4,002,999.
+
+Note: the functions in this package treat Roman algarisms in a case-insensitive manner such that "VI" == "vI" == "Vi" == "vi".
+
+The following functions may be imported into the caller package by name:
+
+=head2 isroman
+
+Tests a string to be a valid Roman algarism.  Returns a boolean value.
+
+=cut
+
+sub isroman {
+    local $_ = shift || $_;                             # roman algarism
+    
+    return if ! /^[@RSN]+$/;
+    return if /([IXCM])\1{3,}|([VLD])\2+/i;             # tests repeatability
+    my @re = qw/IXI|XCX|CMC/;
+    for (1 .. $#RSN) {
+        push @re, "$RSN[$_ - 1]$RSN[$_]$RSN[$_ - 1]";   # tests IVI
+        push @re, "$RSN[$_]$RSN[$_ - 1]$RSN[$_]";       # and VIV conditions
+        }
+    my $re = join "|", @re;
+    !/$re/;
+    }
+
+=head2 int2roman
+
+Converts an integer expressed in Arabic numerals, to its corresponding Roman algarism.  If the integer provided is out of the range expressible in Roman notation, an I<undef> is returned.
+
+=cut
+
+sub int2roman {
+    my $n = shift || $_;     # number, arabic numerals
+    return unless $n > 0 && $n < 4000;
+
+    my $ret = "";
+    for (reverse sort { $a <=> $b } values %R2A) {
+        $ret .= $A2R{$_} x int($n / $_);
+        $n %= $_;
+        }
+    $ret;
+    }
+
+=head2 roman2int
+
+Does the converse of I<int2roman()>, converting a Roman algarism to its integer value.
+
+=cut
+
+sub roman2int {
+    local $_ = uc(shift || $_);    # roman algarism
+
+    return unless isroman();
+
+    my ($r, $ret, $_ret) = ($_, 0, 0);
+    while ($r) {
+        $r =~ s/^$_// && ($ret += $R2A{$&}, last) for @RCN, @RSN;
+        return unless $ret > $_ret;
+        $_ret = $ret;
+        }
+    $ret;
+    }
+
+=head2 ismilhar
+
+Determines whether a string qualifies as a Milhar Roman algarism.
+
+=cut
+
+sub ismilhar {
+    local $_ = shift || $_;
+    return unless /^[_ at RSN]+$/;
+
+    my @r = split /_/;
+    isroman() || return for @r;
+    1;
+    }
+
+=head2 milhar2int
+
+Converts a Milhar Roman algarism to an integer.
+
+=cut
+
+sub milhar2int {
+    local $_ = shift || $_;
+
+    return unless ismilhar();
+
+    my @r = split /_/;
+    my $ret = roman2int(pop @r);
+    $ret += 1000 * roman2int() for @r;
+    $ret;
+    }
+
+=head2 ismroman mroman2int roman
+
+These functions belong to the module's old interface and are considered deprecated.  Do not use them in new code and they will eventually be discontinued; they map as follows:
+
+=over
+
+=item ismroman   => B<ismilhar>
+
+=item mroman2int => B<milhar2int>
+
+=item roman      => B<int2roman>
+
+=back
+
+=cut
+
+1;
+
+__END__
+
+=head1 CHANGES
+
+Some changes worth noting from this module's previous incarnation:
+
+=over
+
+=item I<namespace imports>
+
+The call to B<use> must now explicitly request function names imported into its namespace.
+
+=item I<argument defaults/void context>
+
+All functions now will operate on B<$_> when no arguments are passed, and will set B<$_> when called in a void context.  This allows for writing code like:
+
+    @x = qw/V III XI IV/;
+    roman2int() for @x;
+    print join("-", @x);
+
+instead of the uglier:
+
+    @x = qw/V III XI IV/;
+    $_ = roman2int($_) for @x;
+    print join("-", @x);
+
+=back
+
+=head1 SPECIFICATION
+
+Roman algarisms may be described using the following BNF-like formula:
+
+    a   = I{1,3}
+    b   = V\a?|IV|\a
+    e   = X{1,3}\b?|X{0,3}IX|\b
+    ee  = IX|\b
+    f   = L\e?|XL\ee?|\e
+    g   = C{1,3}\f?|C{0,3}XC\ee?|\f
+    gg  = XC\ee?|\f
+    h   = D\g?|CD\gg?|\g
+    j   = M{1,3}\h?|M{0,3}CM\gg?|\h
+
+=head1 REFERENCES
+
+For a description of the Roman numeral system see: F<http://www.novaroma.org/via_romana/numbers.html>.  A reference to Milhar Roman alagarisms (in Portuguese) may be found at: F<http://www.estado.estadao.com.br/redac/norn-nro.html>.  
+
+=head1 AUTHOR
+
+Erick Calder <ecalder at cpan.org>
+
+=head1 ACKNOWLEDGEMENTS
+
+This module was originally written by Peter de Padua Krauss <krauss at ifqsc.sc.usp.br> and submitted to CPAN by Stanislaw Pusep <stanis at linuxmail.org> who has relinquished control to me since the original author has never maintained it and can no longer be reached.
+
+I have completely rewritten the module, implementing simpler algorithms to perform the same functionality, adding a test suite, a Changes file, etc.  and providing more comprehensive documentation.
+
+=head1 AVAILABILITY + SUPPORT
+
+For questions, comments and support please feel free to e-mail me.  This module may be found on the CPAN.  Additionally, both the module and its RPM package are available from:
+
+F<http://perl.arix.com>
+
+=head1 DATE
+
+$Date: 2003/01/16 01:56:34 $
+
+=head1 VERSION
+
+$Revision: 3.3 $
+
+=cut

Added: packages/libtext-roman-perl/branches/upstream/current/test.pl
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libtext-roman-perl/branches/upstream/current/test.pl?rev=5605&op=file
==============================================================================
--- packages/libtext-roman-perl/branches/upstream/current/test.pl (added)
+++ packages/libtext-roman-perl/branches/upstream/current/test.pl Fri Jun 15 23:31:03 2007
@@ -1,0 +1,22 @@
+#!/usr/bin/perl
+
+use Test::Simple tests => 7;
+
+use Text::Roman qw/isroman roman2int int2roman ismilhar milhar2int/;
+ok(1, 'use Text::Roman');
+
+#	test reciprocity
+
+$n = 3999;
+$r[$_] = int2roman($_) for 1 .. $n;
+ok(1, "array created");
+for (1 .. $n) {
+    die "$_: $r[$_] != $ar" unless ($ar = roman2int($r[$_])) == $_;
+    }
+ok(1, "reciprocity tested");
+
+ok(isroman("IV"), "is roman");
+ok(!isroman("IVI"), "is not roman");
+ok(milhar2int("IV_VIII") == 4008, "milhar converted");
+
+ok(1, "done");




More information about the Pkg-perl-cvs-commits mailing list