-# Time-stamp: "2001-05-25 07:49:06 MDT"
+# Time-stamp: "2000-11-14 22:27:26 MST"
require 5;
package Locale::Maketext;
BEGIN { unless(defined &DEBUG) { *DEBUG = sub () {0} } }
# define the constant 'DEBUG' at compile-time
-$VERSION = "1.01";
+$VERSION = "1.02";
@ISA = ();
$MATCH_SUPERS = 1;
# if it's a locale ID, try converting to a lg tag (untainted),
# otherwise nix it.
- push @languages, map &I18N::LangTags::super_languages($_), @languages
+ push @languages, map I18N::LangTags::super_languages($_), @languages
if $MATCH_SUPERS;
- @languages = map { $_, &I18N::LangTags::alternate_language_tags($_) }
+ @languages = map { $_, I18N::LangTags::alternate_language_tags($_) }
@languages; # catch alternation
+ push @languages, I18N::LangTags::panic_languages(@languages)
+ if defined &I18N::LangTags::panic_languages;
+
push @languages, $base_class->fallback_languages;
# You are free to override fallback_languages to return empty-list!
|
~. # ~[, ~], ~~, ~other
|
- \x5B # [
+ \[ # [ presumably opening a group
|
- \x5D # ]
+ \] # ] presumably closing a group
|
- ~ # terminal ~?
+ ~ # terminal ~ ?
|
$
)>xgs
if(length $c[-1]) {
# Now actually processing the preceding literal
$big_pile .= $c[-1];
- if($USE_LITERALS and $c[-1] !~ m<[^\x20-\x7E]>s) {
+ if($USE_LITERALS and (
+ (ord('A') == 65)
+ ? $c[-1] !~ m<[^\x20-\x7E]>s
+ # ASCII very safe chars
+ : $c[-1] !~ m/[^ !"\#\$%&'()*+,\-.\/0-9:;<=>?\@A-Z[\\\]^_`a-z{|}~\x07]/s
+ # EBCDIC very safe chars
+ )) {
# normal case -- all very safe chars
$c[-1] =~ s/'/\\'/g;
push @code, q{ '} . $c[-1] . "',\n";
#$c[-1] =~ s/\s+$//s;
($m,@params) = split(",", $c[-1], -1); # was /\s*,\s*/
- foreach($m, @params) { tr/\x7F/,/ }
- # A bit of a hack -- we've turned "~,"'s into \x7F's, so turn
- # 'em into real commas here.
+ # A bit of a hack -- we've turned "~,"'s into DELs, so turn
+ # 'em into real commas here.
+ if (ord('A') == 65) { # ASCII, etc
+ foreach($m, @params) { tr/\x7F/,/ }
+ } else { # EBCDIC (1047, 0037, POSIX-BC)
+ # Thanks to Peter Prymmer for the EBCDIC handling
+ foreach($m, @params) { tr/\x07/,/ }
+ }
+ # Special-case handling of some method names:
if($m eq '_*' or $m =~ m<^_(-?\d+)$>s) {
# Treat [_1,...] as [,_1,...], etc.
unshift @params, $m;
$m = '';
+ } elsif($m eq '*') {
+ $m = 'quant'; # "*" for "times": "4 cars" is 4 times "cars"
+ } elsif($m eq '#') {
+ $m = 'numf'; # "#" for "number": [#,_1] for "the number _1"
}
# Most common case: a simple, legal-looking method name
} elsif($p =~ m<^_(-?\d+)$>s) {
# _3 meaning $_[3]
$code[-1] .= '$_[' . (0 + $1) . '], ';
- } elsif($USE_LITERALS and $p !~ m<[^\x20-\x7E]>s) {
+ } elsif($USE_LITERALS and (
+ (ord('A') == 65)
+ ? $p !~ m<[^\x20-\x7E]>s
+ # ASCII very safe chars
+ : $p !~ m/[^ !"\#\$%&'()*+,\-.\/0-9:;<=>?\@A-Z[\\\]^_`a-z{|}~\x07]/s
+ # EBCDIC very safe chars
+ )) {
# Normal case: a literal containing only safe characters
$p =~ s/'/\\'/g;
$code[-1] .= q{'} . $p . q{', };
} elsif($1 eq '~,') { # "~,"
if($in_group) {
- $c[-1] .= "\x7F";
- # This is a hack, based on the assumption that no-one will actually
- # want a \x7f inside a bracket group. Let's hope that's it's true.
+ # This is a hack, based on the assumption that no-one will actually
+ # want a DEL inside a bracket group. Let's hope that's it's true.
+ if (ord('A') == 65) { # ASCII etc
+ $c[-1] .= "\x7F";
+ } else { # EBCDIC (cp 1047, 0037, POSIX-BC)
+ $c[-1] .= "\x07";
+ }
} else {
$c[-1] .= '~,';
}
scalar(keys %{$class . '::Lexicon'}), " entries\n" if DEBUG;
}
- # Implements depth(height?)-first recursive searching of superclasses
+ # Implements depth(height?)-first recursive searching of superclasses.
+ # In hindsight, I suppose I could have just used Class::ISA!
foreach my $superclass (@{$class . "::ISA"}) {
print " Super-class search into $superclass\n" if DEBUG;
next if $seen_r->{$superclass}++;
###########################################################################
1;
-