Burak Gürsoy avatar Burak Gürsoy committed 83fd644

Fix RT#79465.
Remove legacy crap.
Fix pod spellings.

Comments (0)

Files changed (2)

 Revision history for Perl extension Lingua::Any::Numbers.
 
-0.44 Sun Jul  8 01:50:04 2012
-    => Bump version.
+0.44 Sun Sep  9 03:52:37 2012
+    => Fix RT#79465 (Kevin Ryde).
+    => Remove legacy checks.
 
 0.43 Tue Apr  5 02:03:43 2011
    => Use the right class to fix the test.

lib/Lingua/Any/Numbers.pm

 );
 
 use constant LCLASS         => 0;
-
-use constant PREHISTORIC    =>  $] < 5.006;
-use constant LEGACY         => ($] < 5.008) && ! PREHISTORIC;
-
 use constant RE_LEGACY_PERL => qr{
    Perl \s+ (.+?) \s+ required
    --this \s+ is \s+ only \s+ (.+?),
    \s+ stopped
 }xmsi;
-use constant RE_LEGACY_VSTR => qr{
-   syntax \s+ error \s+ at \s+ (.+?)
-   \s+ line \s+ (?:.+?),
-   \s+ near \s+ "use \s+ (.+?)"
-}xmsi;
-use constant RE_UTF8_FILE => qr{ Unrecognized \s+ character \s+ \\ \d+ \s+ }xmsi;
 use File::Spec;
 use base qw( Exporter );
 use Carp qw(croak);
 my %LMAP;
 my $DEFAULT    = 'EN';
 my $USE_LOCALE = 0;
+# blacklist non-language modules
+my %NOT_LANG   = map { $_ => 1 } qw(
+   Any
+   Base
+   Conlang
+   Slavic
+);
 
 _probe(); # fetch/examine/compile all available modules
 
 }
 
 sub available {
-   return keys %LMAP;
+   my @ids = sort keys %LMAP;
+   return @ids;
 }
 
 sub language_handler {
    my @compile;
    foreach my $module ( _probe_inc() ) {
       my $class = $module->[LCLASS];
-      # PL driver is problematic under 5.5.4
-      if ( PREHISTORIC && $class->isa('Lingua::PL::Numbers') ) {
-         _w("Disabling $class under legacy perl ($])") && next;
-      }
 
       (my $inc = $class) =~ s{::}{/}xmsg;
       $inc .= q{.pm};
 
 sub _probe_error {
    my($e, $class) = @_;
-
    if ( $e =~ RE_LEGACY_PERL ) { # JA -> 5.6.2
       return _w( _eprobe( $class, $1, $2 ) );
    }
-
-   if ( $e =~ RE_LEGACY_VSTR ) { # HU -> 5.005_04
-      return _w( _eprobe( $class, $2, $] ) );
-   }
-
-   if ( $e =~ RE_UTF8_FILE ) { # JA -> 5.005_04
-      return _w( _eprobe( $class, $] ) );
-   }
-
-   return croak("An error occurred while including sub modules: $e");
+   croak("An error occurred while including sub modules: $e");
 }
 
 sub _probe_inc {
       my $DIRH = Symbol::gensym();
       opendir $DIRH, $path or croak "opendir($path): $!";
       while ( my $dir = readdir $DIRH ) {
-         next if $dir =~ m{ \A [.] }xms || $dir eq 'Any' || $dir eq 'Slavic';
+         next if $dir =~ m{ \A [.] }xms || $NOT_LANG{ $dir };
          my @rs = _probe_exists($path, $dir);
          next if ! @rs; # bogus
          foreach my $e ( @rs ) {
    my $words   = delete $test{'Lingua::' . $id . '::Nums2Words' };
    my $ords    = delete $test{'Lingua::' . $id . '::Nums2Ords' };
    my $numbers = delete $test{'Lingua::' . $id . '::Numbers' };
+
    if ( ! $numbers && ( $ords || $words ) ) {
       my $file  = sprintf 'Lingua/%s/Numbers.pm', $id;
       my $c     = sprintf 'Lingua::%s::Numbers', $id;
 
       return;
    }
+
    $lang->{ $id } = $e; # restore
+
    return;
 }
 
 supported modules listed in the L</SEE ALSO> section.
 
 L<Task::Lingua::Any::Numbers> can be installed to get all the available modules
-related to L<Lingua::Any::Numbers> on CPAN.
+related to L<Lingua::Any::Numbers> on C<CPAN>.
 
 =head1 IMPORT PARAMETERS
 
 All functions and aliases can be imported individually, 
-but there are some pre-defined import tags:
+but there are some predefined import tags:
 
    :all        Import everything (including aliases)
    :standard   available(), to_string(), to_ordinal().
    :std2       Alias to :standard2
    :long       available_languages(), number_to_string(), number_to_ordinal()
 
-=head1 IMPORT PRAGMAS
+=head1 C<IMPORT PRAGMAS>
 
 Some parameters enable/disable module features. C<+> is prefixed to enable
-these options. Pragmas have global effect (i.e.: not lexical), they can not
+these options. C<Pragmas> have global effect (i.e.: not lexical), they can not
 be disabled afterwards.
 
 =head2 locale
    print to_string(81); # will use locale
 
 However, the second parameter to the functions take precedence. If the language
-parameter is used, C<locale> pragma will be discarded.
+parameter is used, C<locale> C<pragma> will be discarded.
 
 Install all the C<Lingua::*::Numbers> modules to take advantage of the
-locale pragma.
+locale C<pragma>.
 
 It is also possible to enable C<locale> usage through the functions.
 See L</FUNCTIONS>.
 
 =over 4
 
-=item num2str
+=item C<num2str>
 
 =item number_to_string
 
 
 =over 4
 
-=item num2ord
+=item C<num2ord>
 
 =item number_to_ordinal
 
 =head2 language_handler
 
 Returns the name of the language handler class if you pass a language id and
-a class for that language id is loaded. Returns undef otherwise.
+a class for that language id is loaded. Returns C<undef> otherwise.
 
 This function can not be imported. Use a fully qualified name to call:
 
 
 =item *
 
-Some modules return C<UTF8>, while others return arbitrary encodings.
-C<ascii> is ok, but others will be problematic. A future release can 
+Some modules return C<UTF8>, while others return arbitrary C<encodings>.
+C<ascii> is all right, but others will be problematic. A future release can
 convert all to C<UTF8>.
 
 =item *
 
 =head2 BOGUS MODULES
 
-Some modules on CPAN suggest to convert numbers into words by their
+Some modules on C<CPAN> suggest to convert numbers into words by their
 names, but they do something different instead. Here is a list of
 the bogus modules:
 
    Lingua::FA::Number
 
-=head1 SUPPORT
-
-=head2 BUG REPORTS
-
-All bug reports and wishlist items B<must> be reported via
-the CPAN RT system. It is accessible at
-L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Lingua-Any-Numbers>.
-
-=head2 DISCUSSION FORUM
-
-C<CPAN::Forum> is a place for discussing C<CPAN>
-modules. It also has a C<Lingua::Any::Numbers> section at
-L<http://www.cpanforum.com/dist/Lingua-Any-Numbers>.
-
-=head2 RATINGS
-
-If you like or hate or have some suggestions about
-C<Lingua::Any::Numbers>, you can comment/rate the distribution via 
-the C<CPAN Ratings> system: 
-L<http://cpanratings.perl.org/dist/Lingua-Any-Numbers>.
-
 =cut
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.