Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [PATCH] helpfiles: Also accept 'UTF-8' as an encoding name.



Sorry for the delay; I am rather busy these days.

Jun T. <takimoto-j@xxxxxxxxxxxxxxxxx> wrote:
>
> variables LESSCHASET, LESSCHARDEF and LC_CTYPE, and your $HOME/.lesskey

Got it!  LESSCHARSET=utf-8 was set here which was the culprit.
So LANG=C seems to work if all LESS* and LC_* variables
are reset.  I attach the patch with the simplification
(note that also the call in the makefile must be changed).
Also, I added a check when closing the pipeline.

--- 1/Doc/Makefile.in
+++ 1/Doc/Makefile.in
@@ -188,7 +188,7 @@
 runhelp: man
 	test x"$(runhelpdir)" = x"" || { \
 	    test -r $(sdir)/help.txt && test -r $(sdir)/help/zmodload; \
-	} || perl $(sdir_top)/Util/helpfiles $(lc_ctype) -- \
+	} || perl $(sdir_top)/Util/helpfiles \
 	    $(sdir)/zshbuiltins.1 $(sdir)/help $(sdir)/help.txt \
 	    || { rm -f $(sdir)/help.txt $(sdir)/help/zmodload; false; }
 .PHONY: runhelp
--- 1/Util/helpfiles
+++ 1/Util/helpfiles
@@ -16,9 +16,6 @@
 # If a third arg is given, the symlink is not created, but a
 # list of symlinks is put into the file specified by that arg.
 
-# Optionally, you can pass -fLC_CTYPE as an additional first argument.
-# If do that, this LC_CTYPE is used instead of one specified by a heuristic.
-
 # Example usage:
 #    cd ~/zsh-4.0.1				# or wherever
 #    mkdir Help
@@ -39,7 +36,7 @@
 # now <Esc>-h works for shell builtins.
 
 sub Usage {
-    print(STDERR "Usage: helpfiles [-fLC_CTYPE] zshbuiltins.1 dest-dir [link-file]\n");
+    print(STDERR "Usage: helpfiles zshbuiltins.1 dest-dir [link-file]\n");
     exit(1);
 }
 
@@ -53,38 +50,6 @@
 }
 
 &Usage() unless(@ARGV);
-delete($ENV{'LC_ALL'});
-$ENV{'LANG'} = 'C';
-if($ARGV[0] =~ /-f(.*)/) {
-    $lc_type = $1;
-    shift(@ARGV);
-    &Usage() unless(@ARGV);
-    if($lc_type eq '') {
-        $lc_type = shift(@ARGV);
-        &Usage() unless(@ARGV);
-    }
-} else {
-    open(LOCALE, '-|', 'locale', '-a') || &Die('cannot execute locale -a');
-    $lc_ctype = '';
-    $choice = 0;
-    while(<LOCALE>) {
-        if(/en.*utf8/i) {
-            $lc_ctype = $_;
-            last;
-        } elsif(/utf8/i) {
-            $lc_ctype = $_;
-            $choice = 2;
-        } elsif(($choice < 1) && (/(en)|\./i)) {
-            $lc_ctype = $_;
-            $choice = 1;
-        }
-    }
-    close(LOCALE);
-}
-&Info("using LC_CTYPE=$lc_ctype");
-$ENV{'LC_CTYPE'} = $lc_ctype unless($lc_ctype eq '');
-shift(@ARGV) if($ARGV[0] eq '--');
-&Usage() unless(@ARGV);
 $manfile = shift(@ARGV);
 &Usage() unless(@ARGV);
 $destdir = shift(@ARGV);
@@ -93,8 +58,10 @@
     mkdir($destdir) || &Die("$destdir is not a directory and cannot be created");
 }
 
-delete($ENV{'MANPL'});
-delete($ENV{'MANROFFSEQ'});
+foreach (keys %ENV) {
+	delete($ENV{$_}) if(/^((LC_)|(LESS)|(MAN))/);
+}
+$ENV{'LANG'} = 'C';
 $ENV{'MANWIDTH'} = '80';
 $ENV{'GROFF_NO_SGR'} = ''; # We need "classical" formatting of man pages.
 
@@ -231,7 +198,7 @@
 
 select STDOUT;
 close OUT;
-close MANPAGE;
+close(MANPAGE) || &Die('piping from man ', $manfile, ' failed')
 
 foreach $file (<*>) {
     open (IN, $file);



Messages sorted by: Reverse Date, Date, Thread, Author