From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28760 invoked by alias); 13 Dec 2013 23:46:57 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 32105 Received: (qmail 26921 invoked from network); 13 Dec 2013 23:46:51 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.2 X-Injected-Via-Gmane: http://gmane.org/ To: zsh-workers@zsh.org From: Martin Vaeth Subject: Re: PATCH: Util/helpfiles failing on old-fashioned unix Date: Fri, 13 Dec 2013 23:46:25 +0000 (UTC) Message-ID: References: <20131123174827.249f9678@pws-pc.ntlworld.com> <131123114714.ZM18477@torch.brasslantern.com> <131123210612.ZM31978@torch.brasslantern.com> <20131124175649.27c2559a@pws!> <-pc.ntlworld.com@samsung.com> <131125001818.ZM26494@torch.brasslantern.com> <691AC9C6-D832-42FC-B983-60C682AA5515@kba.biglobe.ne.jp> <20131125154954.14283de2@pwslap01u.europe.root.pri> <131125085631.ZM17483@torch.brasslantern.com> <20131212221744.GA27563@ma.sdf.org> Reply-To: vaeth@mathematik.uni-wuerzburg.de X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: lounge.imp.fu-berlin.de User-Agent: slrn/pre1.0.0-26 (Linux) Martin Vaeth wrote: > > Perhaps the only clean way is to use a temporary file first for the > man/nroff output and then for the colcrc/col output. The following patch does this (avoiding the problematic pipeline): --- 1/Util/helpfiles +++ 1/Util/helpfiles @@ -65,13 +65,40 @@ $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 @@ 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);