Renamed $MOFILE to $MO_FILE, and $MOfile to $mo_file, for readability.

This commit is contained in:
依瑪貓 2019-09-09 19:53:18 +08:00
parent db7e22c83b
commit 9c1cdeed1e
2 changed files with 36 additions and 37 deletions

View File

@ -1,5 +1,5 @@
This file contains message digests of all files listed in MANIFEST,
signed via the Module::Signature module, version 0.55.
signed via the Module::Signature module, version 0.81.
To verify the content in this distribution, first make sure you have
Module::Signature installed, then type:
@ -26,7 +26,7 @@ SHA1 ec92e11b76afaa05f67d83a6e32056505a45c99e Makefile.PL
SHA1 b699f73f5fa33123b2f4f1b210665e295900c74d README
SHA1 3db402b52e04cf5a6e60291c23aac8c16f2db810 THANKS
SHA1 85dd5ac895cc0a5b95827060999578d8ce8d41dd TODO
SHA1 f9deac7b12cc6a3cb18b7f5282f9e6a1e1a624b9 lib/Locale/Maketext/Gettext.pm
SHA1 b10574ec35614c629b52b87c6d92b4683a5c1a6d lib/Locale/Maketext/Gettext.pm
SHA1 b88b6bad1e8cb0ba825594c233c006c1b297646f lib/Locale/Maketext/Gettext/Functions.pm
SHA1 f89afd70fdcbaeeab44fada7ed3087d5c7f6f018 script/maketext
SHA1 525f414c7a0aadc61240a4b0959ca2cda7514c75 t/00-signature.t
@ -57,9 +57,8 @@ SHA1 bcc89cdc393507d51b5a76e40954db72914b60d8 t/locale/zh_TW/LC_MESSAGES/test2.m
SHA1 20f810c6229d0bd4064b27f9b3d86b61a20f0821 t/locale/zh_TW/LC_MESSAGES/test_be.mo
SHA1 eb13887b005e3c3e9fab774dfea22de5c01ad1ef t/locale/zh_TW/LC_MESSAGES/test_utf8.mo
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
iEYEARECAAYFAkpFc8MACgkQi9gubzC5S1w3kQCfY4bdMI9M6+sTT+y//sHibPDP
LUUAnRvtrXrg1Tov/anLHx0Xur3TmAQQ
=Au1F
iF0EARECAB0WIQSBin4eTeP7OclnnAOL2C5vMLlLXAUCXXY83QAKCRCL2C5vMLlL
XHVLAKCdSD4iKO//dkJljfF6dt3dIFTU5gCeKI8Kry3iISYdbcwVwMP80gff9Wg=
=fz/R
-----END PGP SIGNATURE-----

View File

@ -21,9 +21,9 @@ use Encode qw(encode decode FB_DEFAULT);
use File::Spec::Functions qw(catfile);
no strict qw(refs);
use vars qw(%Lexicons %ENCODINGS $REREAD_MO $MOFILE);
use vars qw(%Lexicons %ENCODINGS $REREAD_MO $MO_FILE);
$REREAD_MO = 0;
$MOFILE = "";
$MO_FILE = "";
use vars qw(@SYSTEM_LOCALEDIRS);
@SYSTEM_LOCALEDIRS = qw(/usr/share/locale /usr/lib/locale
/usr/local/share/locale /usr/local/lib/locale);
@ -102,9 +102,9 @@ sub subclass_init : method {
$self->SUPER::fail_with($self->can("failure_handler_auto"));
# Initialize the ENCODE_FAILURE setting
$self->{"ENCODE_FAILURE"} = FB_DEFAULT;
# Initialize the MOFILE value of this instance
$self->{"MOFILE"} = "";
${"$class\::MOFILE"} = "" if !defined ${"$class\::MOFILE"};
# Initialize the MO_FILE value of this instance
$self->{"MO_FILE"} = "";
${"$class\::MO_FILE"} = "" if !defined ${"$class\::MO_FILE"};
# Find the locale name, for this subclass
$self->{"LOCALE"} = $class;
$self->{"LOCALE"} =~ s/^.*:://;
@ -141,7 +141,7 @@ sub bindtextdomain : method {
# textdomain: Set the current text domain
sub textdomain : method {
local ($_, %_);
my ($self, $class, $DOMAIN, $LOCALEDIR, $MOfile);
my ($self, $class, $DOMAIN, $LOCALEDIR, $mo_file);
($self, $DOMAIN) = @_;
# This is not a static method
@ -160,41 +160,41 @@ sub textdomain : method {
# Clear it
$self->{"Lexicon"} = {};
%{"$class\::Lexicon"} = qw();
$self->{"MOFILE"} = "";
${"$class\::MOFILE"} = "";
$self->{"MO_FILE"} = "";
${"$class\::MO_FILE"} = "";
# The format is "{LOCALEDIR}/{LOCALE}/{CATEGORY}/{DOMAIN}.mo"
# Search the system locale directories if the domain was not
# registered yet
if (!exists ${$self->{"LOCALEDIRS"}}{$DOMAIN}) {
undef $MOfile;
undef $mo_file;
foreach $LOCALEDIR (@SYSTEM_LOCALEDIRS) {
$_ = catfile($LOCALEDIR, $self->{"LOCALE"},
$self->{"CATEGORY"}, "$DOMAIN.mo");
if (-f $_ && -r $_) {
$MOfile = $_;
$mo_file = $_;
last;
}
}
# Not found at last
return $DOMAIN if !defined $MOfile;
return $DOMAIN if !defined $mo_file;
# This domain was registered
} else {
$MOfile = catfile(${$self->{"LOCALEDIRS"}}{$DOMAIN},
$mo_file = catfile(${$self->{"LOCALEDIRS"}}{$DOMAIN},
$self->{"LOCALE"}, $self->{"CATEGORY"}, "$DOMAIN.mo");
}
# Record it
${"$class\::MOFILE"} = $MOfile;
$self->{"MOFILE"} = $MOfile;
${"$class\::MO_FILE"} = $mo_file;
$self->{"MO_FILE"} = $mo_file;
# Read the MO file
# Cached
if (!exists $ENCODINGS{$MOfile} || !exists $Lexicons{$MOfile}) {
if (!exists $ENCODINGS{$mo_file} || !exists $Lexicons{$mo_file}) {
my $enc;
# Read it
%_ = read_mo($MOfile);
%_ = read_mo($mo_file);
# Successfully read
if (scalar(keys %_) > 0) {
@ -211,13 +211,13 @@ sub textdomain : method {
}
# Cache them
$Lexicons{$MOfile} = \%_;
$ENCODINGS{$MOfile} = $enc;
$Lexicons{$mo_file} = \%_;
$ENCODINGS{$mo_file} = $enc;
}
# Respect the existing output encoding
if (defined $ENCODINGS{$MOfile}) {
$self->{"MO_ENCODING"} = $ENCODINGS{$MOfile};
if (defined $ENCODINGS{$mo_file}) {
$self->{"MO_ENCODING"} = $ENCODINGS{$mo_file};
} else {
delete $self->{"MO_ENCODING"};
}
@ -229,8 +229,8 @@ sub textdomain : method {
delete $self->{"ENCODING"};
}
}
$self->{"Lexicon"} = $Lexicons{$MOfile};
%{"$class\::Lexicon"} = %{$Lexicons{$MOfile}};
$self->{"Lexicon"} = $Lexicons{$mo_file};
%{"$class\::Lexicon"} = %{$Lexicons{$mo_file}};
$self->clear_isa_scan;
return $DOMAIN;
@ -260,8 +260,8 @@ sub maketext : method {
# single localization subclass whenever possible.
# Maketext uses class lexicon in order to track the inheritance.
# It is hard to change it.
if (${"$class\::MOFILE"} ne $self->{"MOFILE"}) {
${"$class\::MOFILE"} = $self->{"MOFILE"};
if (${"$class\::MO_FILE"} ne $self->{"MO_FILE"}) {
${"$class\::MO_FILE"} = $self->{"MO_FILE"};
%{"$class\::Lexicon"} = %{$self->{"Lexicon"}};
}
@ -299,14 +299,14 @@ sub pmaketext : method {
# Refer to gettext documentation section 8.3
sub read_mo($) {
local ($_, %_);
my ($MOfile, $len, $FH, $content, $tmpl);
$MOfile = $_[0];
my ($mo_file, $len, $FH, $content, $tmpl);
$mo_file = $_[0];
# Avild being stupid
return unless -f $MOfile && -r $MOfile;
return unless -f $mo_file && -r $mo_file;
# Read the MO file
$len = (stat $MOfile)[7];
open $FH, $MOfile or return; # GNU gettext never fails!
$len = (stat $mo_file)[7];
open $FH, $mo_file or return; # GNU gettext never fails!
binmode $FH;
defined($_ = read $FH, $content, $len)
or return;
@ -535,7 +535,7 @@ If you want to have more control to the detail:
Use Locale::Maketext::Gettext to read and parse the MO file:
use Locale::Maketext::Gettext;
%Lexicon = read_mo($MOfile);
%Lexicon = read_mo($mo_file);
=head1 DESCRIPTION
@ -653,7 +653,7 @@ are running a vital daemon, such as an X display server.
=over
=item %Lexicon = read_mo($MOfile);
=item %Lexicon = read_mo($mo_file);
Read and parse the MO file. Returns the read %Lexicon. The returned
lexicon is in its original encoding.