From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wi0-f182.google.com (mail-wi0-f182.google.com [209.85.212.182]) by krisdoz.my.domain (8.14.5/8.14.5) with ESMTP id sAOEadBB008317 for ; Mon, 24 Nov 2014 09:36:39 -0500 (EST) Received: by mail-wi0-f182.google.com with SMTP id h11so5938107wiw.15 for ; Mon, 24 Nov 2014 06:36:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:date:from:to:subject:message-id:mime-version:content-type :content-disposition:user-agent; bh=EZSWFBLhx/fXnj9Kw6rOQn+sRlIPhFFUFitxCLun21c=; b=jZS0shU+AfkAaqOhOB0v10ns+xt1OyGF0wGKIwmMEdbhrW5+/Pi33M+898QekZzAPt NhPp77WBRt3HJg7HGrqqsLaXsRf4H9JOTck0mMQGemqFlHoIJHkjOnBRVM6Jb9GO+U99 bV6+wZNA5xtthQGkrsBw+ejGluT94jzdD6NfGQCFvusfM0yjtRfA8KPRGV7A4S5dhw9E o+M3ws9ep1Znz9+Kc6RMFlL6rxTXzLG6H39znXI6usX8eMTzK3gQeUmXgJEkGnR2h4Ul uvqZjzlhLGhJPztLVktGg5ZT5gKFfibI5xS5lk8nJbyl+DSCQ53V4kik98DNCYprC6mQ oNAA== X-Received: by 10.194.94.9 with SMTP id cy9mr34743013wjb.117.1416839792462; Mon, 24 Nov 2014 06:36:32 -0800 (PST) Received: from ivaldir.etoilebsd.net ([2001:41d0:8:db4c::1]) by mx.google.com with ESMTPSA id wr9sm21253100wjb.42.2014.11.24.06.36.31 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 24 Nov 2014 06:36:31 -0800 (PST) Sender: Baptiste Daroussin Date: Mon, 24 Nov 2014 15:36:29 +0100 From: Baptiste Daroussin To: tech@mdocml.bsd.lv Subject: Allow gzipped .so and search .so in manpath Message-ID: <20141124143629.GB11567@ivaldir.etoilebsd.net> X-Mailinglist: mdocml-tech Reply-To: tech@mdocml.bsd.lv MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="oj4kGyHlBMXGt3Le" Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) --oj4kGyHlBMXGt3Le Content-Type: multipart/mixed; boundary="pAwQNkOnpTn9IO2O" Content-Disposition: inline --pAwQNkOnpTn9IO2O Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi, Here is a new patch that allows to open gzipped .so files as well as looking inside mpath for the files requested. This allows zshall manpage which contains: .so man1/zshmodules.1 to work with mandoc, tested on freebsd this .so find as expected /usr/local/man/man1/zshmodules.1.gz Best regards, Bapt --pAwQNkOnpTn9IO2O Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="mandoc-so_gzipped.diff" Content-Transfer-Encoding: quoted-printable Index: Makefile =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/mdocml/Makefile,v retrieving revision 1.445 diff -u -r1.445 Makefile --- Makefile 25 Oct 2014 01:03:52 -0000 1.445 +++ Makefile 24 Nov 2014 14:32:46 -0000 @@ -236,7 +236,7 @@ =20 MANPAGE_OBJS =3D manpage.o mansearch.o mansearch_const.o manpath.o =20 -DEMANDOC_OBJS =3D demandoc.o +DEMANDOC_OBJS =3D demandoc.o manpath.o =20 WWW_MANS =3D apropos.1.html \ demandoc.1.html \ Index: read.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/mdocml/read.c,v retrieving revision 1.96 diff -u -r1.96 read.c --- read.c 1 Nov 2014 06:03:13 -0000 1.96 +++ read.c 24 Nov 2014 14:32:46 -0000 @@ -19,6 +19,7 @@ #include "config.h" =20 #include +#include #if HAVE_MMAP #include #include @@ -41,6 +42,7 @@ #include "libmandoc.h" #include "mdoc.h" #include "man.h" +#include "manpath.h" #include "main.h" =20 #define REPARSE_LIMIT 1000 @@ -783,10 +785,61 @@ mparse_readfd(struct mparse *curp, int fd, const char *file) { struct buf blk; + char buf[PATH_MAX]; int with_mmap; int save_filenc; + size_t i; + struct manpaths paths; + struct stat st; + pid_t child_pid; + + child_pid =3D 0; + + if (-1 =3D=3D fd && *file !=3D '/') { + do { + /* First try locally */ + if ((fd =3D open(file, O_RDONLY, 0)) !=3D -1) + break; + + /* Try the gzip version */ + (void)snprintf(buf, sizeof(buf), "%s.gz", file); + if (stat(buf, &st) !=3D -1) + (void)mparse_open(curp, &fd, buf, &child_pid); + if (-1 !=3D fd) { + curp->file =3D buf; + break; + } + + /* Lookup in the manpath */ + manpath_parse(&paths, NULL, NULL, NULL); + for (i =3D 0; i < paths.sz; i++) { + (void)snprintf(buf, sizeof(buf), "%s/%s", + paths.paths[i], file); + if (-1 !=3D (fd =3D open(buf, O_RDONLY, 0))) { + curp->file =3D buf; + break; + } + (void)snprintf(buf, sizeof(buf), "%s/%s.gz", + paths.paths[i], file); + if (stat(buf, &st) !=3D -1) + (void)mparse_open(curp, &fd, buf, &child_pid); + if (-1 !=3D fd) { + curp->file =3D buf; + break; + } + } + manpath_free(&paths); + if (-1 !=3D fd) + break; =20 - if (-1 =3D=3D fd && -1 =3D=3D (fd =3D open(file, O_RDONLY, 0))) { + curp->file_status =3D MANDOCLEVEL_SYSERR; + if (curp->mmsg) + (*curp->mmsg)(MANDOCERR_SYSOPEN, + curp->file_status, + file, 0, 0, strerror(errno)); + return(curp->file_status); + } while (0); + } else if (-1 =3D=3D fd && -1 =3D=3D (fd =3D open(file, O_RDONLY, 0))) { curp->file_status =3D MANDOCLEVEL_SYSERR; if (curp->mmsg) (*curp->mmsg)(MANDOCERR_SYSOPEN, @@ -818,6 +871,8 @@ =20 if (STDIN_FILENO !=3D fd && -1 =3D=3D close(fd)) perror(file); + if (child_pid) + mparse_wait(curp, child_pid); =20 return(curp->file_status); } --pAwQNkOnpTn9IO2O-- --oj4kGyHlBMXGt3Le Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEARECAAYFAlRzQm0ACgkQ8kTtMUmk6EySUgCghICiiQ1j6WXKkIh2zxqd5mMw 9nUAoL7nmpPIhMV3bwzkreaNaOO+oKbD =5wFO -----END PGP SIGNATURE----- --oj4kGyHlBMXGt3Le-- -- To unsubscribe send an email to tech+unsubscribe@mdocml.bsd.lv