mhonarc-commits
[Top] [All Lists]

CVS: mhonarc/MHonArc/lib mhamain.pl,2.68,2.69 mhdb.pl,2.32,2.33 mhinit.pl,2...

2003-08-01 23:16:57
Update of /cvsroot/mhonarc/mhonarc/MHonArc/lib
In directory subversions:/tmp/cvs-serv31537/lib

Modified Files:
	mhamain.pl mhdb.pl mhinit.pl mhopt.pl mhrcfile.pl mhusage.pl 
Log Message:
* Added LANG resource to define locale.  Affects resource filename
  resolution and message subject and author sorting.


Index: mhamain.pl
===================================================================
RCS file: /cvsroot/mhonarc/mhonarc/MHonArc/lib/mhamain.pl,v
retrieving revision 2.68
retrieving revision 2.69
diff -C2 -r2.68 -r2.69
*** mhamain.pl	21 Jul 2003 16:32:02 -0000	2.68
--- mhamain.pl	2 Aug 2003 06:15:37 -0000	2.69
***************
*** 30,34 ****
  require 5;
  
! $VERSION = '2.6.6';
  $VINFO =<<EndOfInfo;
    MHonArc v$VERSION (Perl $] $^O)
--- 30,34 ----
  require 5;
  
! $VERSION = '2.6.6+';
  $VINFO =<<EndOfInfo;
    MHonArc v$VERSION (Perl $] $^O)

Index: mhdb.pl
===================================================================
RCS file: /cvsroot/mhonarc/mhonarc/MHonArc/lib/mhdb.pl,v
retrieving revision 2.32
retrieving revision 2.33
diff -C2 -r2.32 -r2.33
*** mhdb.pl	22 Feb 2003 04:40:11 -0000	2.32
--- mhdb.pl	2 Aug 2003 06:15:37 -0000	2.33
***************
*** 166,169 ****
--- 166,170 ----
  print_var($db,'IDXSIZE',        \$IDXSIZE);
  print_var($db,'KeepOnRmm',      \$KeepOnRmm);
+ print_var($db,'Lang',           \$Lang);
  print_var($db,'LocalDateFmt',   \$LocalDateFmt);
  print_var($db,'MAILTOURL',      \$MAILTOURL)  unless $IsDefault{'MAILTOURL'};

Index: mhinit.pl
===================================================================
RCS file: /cvsroot/mhonarc/mhonarc/MHonArc/lib/mhinit.pl,v
retrieving revision 2.47
retrieving revision 2.48
diff -C2 -r2.47 -r2.48
*** mhinit.pl	22 Feb 2003 04:40:11 -0000	2.47
--- mhinit.pl	2 Aug 2003 06:15:37 -0000	2.48
***************
*** 401,404 ****
--- 401,406 ----
  			 $ENV{'M2H_FASTTEMPFILES'} : 0;
  
+ $Lang        = $ENV{'M2H_LANG'} || $ENV{'LC_ALL'} || $ENV{'LANG'} || undef;
+ 
  @FMTFILE     = defined($ENV{'M2H_RCFILE'}) ?
  		    ($ENV{'M2H_RCFILE'}) : ();

Index: mhopt.pl
===================================================================
RCS file: /cvsroot/mhonarc/mhonarc/MHonArc/lib/mhopt.pl,v
retrieving revision 2.53
retrieving revision 2.54
diff -C2 -r2.53 -r2.54
*** mhopt.pl	4 Jul 2003 01:13:34 -0000	2.53
--- mhopt.pl	2 Aug 2003 06:15:37 -0000	2.54
***************
*** 84,87 ****
--- 84,88 ----
  	'idxsize=i',	# Maximum number of messages shown in indexes
  	'keeponrmm',	# Do not delete message files on archive remove
+ 	'lang=s',	# Set locale/language
  	'localdatefmt=s',
  			# Date specification for local date
***************
*** 292,295 ****
--- 293,297 ----
      require 'mhfile.pl';
      require 'mhutil.pl';
+     require 'mhrcfile.pl';
      require 'mhscan.pl'  	if $SCAN;
      require 'mhsingle.pl'  	if $SINGLE;
***************
*** 299,302 ****
--- 301,307 ----
      print STDOUT "This is MHonArc v$VERSION, Perl $] $^O\n"  unless $QUIET;
  
+     ## Check for locale/lang setting
+     $Lang = $opt{'lang'}  if defined($opt{'lang'});
+ 
      ## Evaluate site local initialization
      delete($INC{'mhasiteinit.pl'});      # force re-evaluation
***************
*** 306,327 ****
      DEFRCFILE: {
  	if ($DefRcFile) {
! 	    read_fmt_file($DefRcFile);
! 	    last DEFRCFILE;
  	}
! 	if (defined $ENV{'HOME'}) {
  	    # check if in home directory
! 	    $tmp = join($DIRSEP, $ENV{'HOME'}, $DefRcName);
! 	    if (-e $tmp) {
! 		read_fmt_file($tmp);
! 		last DEFRCFILE;
! 	    }
  	}
  	local $_;
  	foreach (@INC) {
! 	    $tmp = join($DIRSEP, $_, $DefRcName);
! 	    if (-e $tmp) {
! 		read_fmt_file($tmp);
! 		last DEFRCFILE;
! 	    }
  	}
      }
--- 311,327 ----
      DEFRCFILE: {
  	if ($DefRcFile) {
! 	    last DEFRCFILE  if read_resource_file($DefRcFile);
  	}
! 	my $home_dir = $ENV{'HOME'};
! 	if (defined $home_dir) {
  	    # check if in home directory
! 	    last DEFRCFILE
! 		if read_resource_file(join($DIRSEP, $home_dir, $DefRcName), 1);
  	}
  	local $_;
  	foreach (@INC) {
! 	    next if ($_ eq $home_dir);
! 	    last DEFRCFILE
! 		if read_resource_file(join($DIRSEP, $_, $DefRcName), 1);
  	}
      }
***************
*** 430,439 ****
      }
  
!     ##	Read resource file(s) (I initially used the term 'format file').
      ##	Look for resource in outdir unless existing according to
      ##  current value.
      foreach (@FMTFILE) {
  	$_ = join($DIRSEP, $OUTDIR, $_) unless -e $_;
! 	&read_fmt_file($_);
      }
  
--- 430,452 ----
      }
  
!     ##	Read resource file(s)
      ##	Look for resource in outdir unless existing according to
      ##  current value.
      foreach (@FMTFILE) {
  	$_ = join($DIRSEP, $OUTDIR, $_) unless -e $_;
! 	&read_resource_file($_);
!     }
! 
!     ## Set locale
!     eval {
! 	require POSIX;
! 	if ($Lang) {
! 	    POSIX::setlocal(&POSIX::LC_ALL, $Lang);
! 	} else {
! 	    POSIX::setlocal(&POSIX::LC_ALL, '');
! 	}
!     };
!     if ($@ && $Lang) {
! 	qq/Warning: Setting locale appears to be not supported:\n$(_at_)\n/;
      }
  
***************
*** 758,770 ****
      require 'mhusage.pl';
      &mhusage();
- }
- 
- ##---------------------------------------------------------------------------
- ##	read_fmt_file() requires the library with the resource file
- ##	read subroutine and calls the routine.
- ##
- sub read_fmt_file {
-     require 'mhrcfile.pl';
-     &read_resource_file;  # implicit passing of @_
  }
  
--- 771,774 ----

Index: mhrcfile.pl
===================================================================
RCS file: /cvsroot/mhonarc/mhonarc/MHonArc/lib/mhrcfile.pl,v
retrieving revision 2.35
retrieving revision 2.36
diff -C2 -r2.35 -r2.36
*** mhrcfile.pl	22 Feb 2003 04:40:11 -0000	2.35
--- mhrcfile.pl	2 Aug 2003 06:15:37 -0000	2.36
***************
*** 29,36 ****
  
  ##---------------------------------------------------------------------------
! ##	read_resource_file() parses the resource file.
! ##	(The code for this routine could probably be simplified).
  ##
  sub read_resource_file {
      my($file) = shift;
      my($line, $tag, $label, $acro, $hr, $type, $routine, $plfile,
--- 29,90 ----
  
  ##---------------------------------------------------------------------------
! ##	read_resource_file() reads the specifed resource file and any
! ##	language variations.
  ##
  sub read_resource_file {
+     my $filename = shift;
+     my $nowarn	 = shift;
+     my $lang	 = shift || $Lang;
+     my @files = get_lang_file_list($filename, $lang);
+ 
+     my $file;
+     my $found = 0;
+     foreach $file (get_lang_file_list($filename, $lang)) {
+ 	if (-r $file) {
+ 	    parse_resource_file($file);
+ 	    ++$found;
+ 	} elsif (-e _) {
+ 	    qq/Warning: "$file" is not readable\n/;
+ 	}
+     }
+     if (!$found && !$nowarn) {
+ 	qq/Warning: Unable to read resource file "$filename"\n/;
+     }
+     $found;
+ }
+ 
+ ##---------------------------------------------------------------------------
+ ##	get_lang_file_list() returns list of filenames that include
+ ##	language setting.
+ ##
+ sub get_lang_file_list {
+     my $pathname =  shift;
+     my $lang     =  lc (shift || $Lang);
+        $lang     =~ s/\s+//g;
+     return ($pathname)  unless $lang;
+ 
+     my $codeset = '';
+     if ($lang =~ s/\.(.*)$//) {
+ 	$codeset = '.' . lc($1);
+     }
+ 
+     my @files   = ($pathname);
+     my $curbase = $pathname . '.';
+     my $tag;
+     foreach $tag (split(/[\-_]/, $lang)) {
+ 	next  unless $tag =~ /\S/;
+ 	$curbase .= $tag;
+ 	push(@files, $curbase);
+ 	push(@files, $curbase.$codeset)  if ($codeset);
+ 	$curbase .= '_';
+     }
+     @files;
+ }
+ 
+ ##---------------------------------------------------------------------------
+ ##	parse_resource_file() parses the resource file.
+ ##	(The code for this routine could probably be simplified).
+ ##
+ sub parse_resource_file {
      my($file) = shift;
      my($line, $tag, $label, $acro, $hr, $type, $routine, $plfile,
***************
*** 363,366 ****
--- 417,425 ----
  	if ($elem eq 'keeponrmm') {		# Keep files on rmm
  	    $KeepOnRmm = 1;
+ 	    last FMTSW;
+ 	}
+ 	if ($elem eq 'lang') {			# Locale/language
+ 	    $Lang = &get_elem_last_line($handle, $elem);
+ 	    $Lang =~ s/\s+//g;
  	    last FMTSW;
  	}

Index: mhusage.pl
===================================================================
RCS file: /cvsroot/mhonarc/mhonarc/MHonArc/lib/mhusage.pl,v
retrieving revision 2.22
retrieving revision 2.23
diff -C2 -r2.22 -r2.23
*** mhusage.pl	9 Jan 2003 23:42:28 -0000	2.22
--- mhusage.pl	2 Aug 2003 06:15:37 -0000	2.23
***************
*** 107,110 ****
--- 107,111 ----
    -keeponrmm               : Do not delete message files when message is
                               removed from archive.
+   -lang <locale>           : Set locale/language.
    -localdatefmt <fmt>      : Format for local date
    -lock                    : Do archive locking (default)

---------------------------------------------------------------------
To sign-off this list, send email to majordomo(_at_)mhonarc(_dot_)org with the
message text UNSUBSCRIBE MHONARC-DEV