[Pkg-zsh-commits] [zsh] 10/11: 32105: support combinations of man or nroff with colcrt or col.

Axel Beckert abe at deuxchevaux.org
Sun Dec 15 00:38:28 UTC 2013


This is an automated email from the git hooks/post-receive script.

abe pushed a commit to branch upstream
in repository zsh.

commit beb40845d9977b662c191b354cf6ecb4dabe3df5
Author: Martin Vaeth <vaeth at mathematik.uni-wuerzburg.de>
Date:   Fri Dec 13 22:55:05 2013 -0800

    32105: support combinations of man or nroff with colcrt or col.
---
 ChangeLog      |  3 +++
 Util/helpfiles | 38 +++++++++++++++++++++++++++++++++-----
 2 files changed, 36 insertions(+), 5 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index ae9c163..24cd4b8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2013-12-13  Barton E. Schaefer  <schaefer at zsh.org>
 
+	* Martin Vaeth: 32105: Util/helpfiles: support all combinations of
+	man or nroff with colcrt or col.
+
 	* Aaron Peschel: 32103: Completion/Unix/Type/_hosts: parse
 	host:port format in ssh known_hosts files.
 
diff --git a/Util/helpfiles b/Util/helpfiles
index ebd8bd1..9005648 100755
--- a/Util/helpfiles
+++ b/Util/helpfiles
@@ -65,13 +65,40 @@ $ENV{'LANG'} = 'C';
 $ENV{'MANWIDTH'} = '80';
 $ENV{'GROFF_NO_SGR'} = ''; # We need "classical" formatting of man pages.
 
-unless(open(MANPAGE, '-|', "man $manfile | colcrt -")) {
-    close(MANPAGE);
-    open(MANPAGE, '-|', "man $manfile | col -bx")
+$mantmp = $destdir . '/man.tmp';
+$coltmpbase = 'col.tmp';
+$coltmp = $destdir . '/' . $coltmpbase;
+$args = "$manfile >$mantmp";
+unlink($mantmp);
+&Info('attempting man ', $args);
+if(system('man ' . $args) || !(-s $mantmp)) {
+    unlink($mantmp);
+    &Info('attempting nroff -man ', $args);
+    if(system('nroff -man ' . $args) || !(-s $mantmp)) {
+        unlink($mantmp);
+        &Die('man and nroff -man both failed for ', $manfile);
+    }
+}
+$args = "$mantmp >$coltmp";
+unlink($coltmp);
+&Info('attempting colcrt ', $args);
+if(system('colcrt ' . $args) || !(-s $coltmp)) {
+    unlink($coltmp);
+    &Info('attempting col -bx <', $args);
 # The x is necessary so that spaces don't turn into tabs, which messes
 # up the calculations of indentation on machines which randomly wrap lines
 # round to the previous line (so you see what we're up against).
-     || &Die('can run neither "man | colcrt -" nor "man | col -bx"');
+    if(system('col -bx <' . $args) || !(-s $coltmp)) {
+        unlink($mantmp);
+        unlink($coltmp);
+        &Die('colcrt and col -bx both failed');
+    }
+}
+unlink($mantmp) || &Die('cannot remove tempfile ', $mantmp);
+
+unless(open(MANPAGE, '<', $coltmp)) {
+    unlink($coltmp);
+    &Die('generated tmpfile cannot be read');
 }
 
 unless($linkfile eq '') {
@@ -198,7 +225,8 @@ BUILTINS: while (<MANPAGE>) {
 
 select STDOUT;
 close OUT;
-close(MANPAGE) || &Die('piping from man ', $manfile, ' failed');
+close(MANPAGE);
+unlink($coltmpbase) || &Die('cannot remove tempfile ', $coltmpbase);
 
 foreach $file (<*>) {
     open (IN, $file);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/collab-maint/zsh.git



More information about the Pkg-zsh-commits mailing list