From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailout.scc.kit.edu (mailout.scc.kit.edu [129.13.185.202]); by fantadrom.bsd.lv (OpenSMTPD) with ESMTP id be8e5419; for ; Wed, 26 Nov 2014 21:03:39 -0500 (EST) Received: from hekate.usta.de (asta-nat.asta.uni-karlsruhe.de [172.22.63.82]) by scc-mailout-02.scc.kit.edu with esmtp (Exim 4.72 #1) id 1XtoQk-0007tG-11; Thu, 27 Nov 2014 03:03:38 +0100 Received: from donnerwolke.usta.de ([172.24.96.3]) by hekate.usta.de with esmtp (Exim 4.77) (envelope-from ) id 1XtoQj-00006Z-Vw; Thu, 27 Nov 2014 03:03:37 +0100 Received: from iris.usta.de ([172.24.96.5] helo=usta.de) by donnerwolke.usta.de with esmtp (Exim 4.72) (envelope-from ) id 1XtoQj-0006jp-Uc; Thu, 27 Nov 2014 03:03:37 +0100 Received: from schwarze by usta.de with local (Exim 4.77) (envelope-from ) id 1XtoQj-0007Ev-Tn; Thu, 27 Nov 2014 03:03:37 +0100 Date: Thu, 27 Nov 2014 03:03:37 +0100 From: Ingo Schwarze To: Baptiste Daroussin Cc: tech@mdocml.bsd.lv Subject: Re: Allow gzipped .so and search .so in manpath Message-ID: <20141127020337.GJ26411@iris.usta.de> References: <20141124143629.GB11567@ivaldir.etoilebsd.net> <20141126201033.GG26411@iris.usta.de> <20141126202413.GF82931@ivaldir.etoilebsd.net> <20141127001242.GH26411@iris.usta.de> X-Mailinglist: mdocml-tech Reply-To: tech@mdocml.bsd.lv MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20141127001242.GH26411@iris.usta.de> User-Agent: Mutt/1.5.21 (2010-09-15) Hi Baptiste, Ingo Schwarze wrote on Thu, Nov 27, 2014 at 01:12:42AM +0100: > There is still a minor problem in makewhatis(8) with database > generation when .so to .gz is involved, but i'll get round to that. Fixed, see the commit below. Yours, Ingo Log Message: ----------- Make makewhatis(8) understand .so links to .gz pages. Drop the FORM_GZ annotation in the mpages table; it is conceptually wrong because it ought to be in the mlinks table: An uncompressed .so link file can point to a compressed manual page file and vice versa. Besides, it is no longer needed because mparse_open() handles it all. Sprinkle some KNF while here. Modified Files: -------------- mdocml: mandocdb.c mansearch.c mansearch.h Revision Data ------------- Index: mansearch.c =================================================================== RCS file: /home/cvs/mdocml/mdocml/mansearch.c,v retrieving revision 1.50 retrieving revision 1.51 diff -Lmansearch.c -Lmansearch.c -u -p -r1.50 -r1.51 --- mansearch.c +++ mansearch.c @@ -410,7 +410,6 @@ buildnames(struct manpage *mpage, sqlite { char *newnames, *prevsec, *prevarch; const char *oldnames, *sep1, *name, *sec, *sep2, *arch, *fsec; - const char *gzip; size_t i; int c; @@ -473,7 +472,7 @@ buildnames(struct manpage *mpage, sqlite /* Also save the first file name encountered. */ - if (NULL != mpage->file) + if (mpage->file != NULL) continue; if (form & FORM_SRC) { @@ -483,22 +482,18 @@ buildnames(struct manpage *mpage, sqlite sep1 = "cat"; fsec = "0"; } - if (form & FORM_GZ) - gzip = ".gz"; - else - gzip = ""; - sep2 = '\0' == *arch ? "" : "/"; - mandoc_asprintf(&mpage->file, "%s/%s%s%s%s/%s.%s%s", - path, sep1, sec, sep2, arch, name, fsec, gzip); + sep2 = *arch == '\0' ? "" : "/"; + mandoc_asprintf(&mpage->file, "%s/%s%s%s%s/%s.%s", + path, sep1, sec, sep2, arch, name, fsec); } - if (SQLITE_DONE != c) + if (c != SQLITE_DONE) fprintf(stderr, "%s\n", sqlite3_errmsg(db)); sqlite3_reset(s); /* Append one final section to the names. */ - if (NULL != prevsec) { - sep2 = '\0' == *prevarch ? "" : "/"; + if (prevsec != NULL) { + sep2 = *prevarch == '\0' ? "" : "/"; mandoc_asprintf(&newnames, "%s(%s%s%s)", mpage->names, prevsec, sep2, prevarch); free(mpage->names); Index: mandocdb.c =================================================================== RCS file: /home/cvs/mdocml/mdocml/mandocdb.c,v retrieving revision 1.170 retrieving revision 1.171 diff -Lmandocdb.c -Lmandocdb.c -u -p -r1.170 -r1.171 --- mandocdb.c +++ mandocdb.c @@ -1093,13 +1093,13 @@ mpages_merge(struct mchars *mc, struct m str_info.free = hash_free; str_info.key_offset = offsetof(struct str, key); - if (0 == nodb) + if ( ! nodb) SQL_EXEC("BEGIN TRANSACTION"); mpage = ohash_first(&mpages, &pslot); - while (NULL != mpage) { + while (mpage != NULL) { mlinks_undupe(mpage); - if (NULL == mpage->mlinks) { + if (mpage->mlinks == NULL) { mpage = ohash_next(&mpages, &pslot); continue; } @@ -1123,17 +1123,23 @@ mpages_merge(struct mchars *mc, struct m * source code, unless it is already known to be * formatted. Fall back to formatted mode. */ - if (FORM_CAT != mpage->mlinks->dform || - FORM_CAT != mpage->mlinks->fform) { + if (mpage->mlinks->dform != FORM_CAT || + mpage->mlinks->fform != FORM_CAT) { lvl = mparse_readfd(mp, fd, mpage->mlinks->file); if (lvl < MANDOCLEVEL_FATAL) mparse_result(mp, &mdoc, &man, &sodest); } - if (NULL != sodest) { + if (sodest != NULL) { mlink_dest = ohash_find(&mlinks, ohash_qlookup(&mlinks, sodest)); - if (NULL != mlink_dest) { + if (mlink_dest == NULL) { + mandoc_asprintf(&cp, "%s.gz", sodest); + mlink_dest = ohash_find(&mlinks, + ohash_qlookup(&mlinks, cp)); + free(cp); + } + if (mlink_dest != NULL) { /* The .so target exists. */ @@ -1154,7 +1160,7 @@ mpages_merge(struct mchars *mc, struct m if (mpage_dest->pageid) dbadd_mlink_name(mlink); - if (NULL == mlink->next) + if (mlink->next == NULL) break; mlink = mlink->next; } @@ -1166,17 +1172,17 @@ mpages_merge(struct mchars *mc, struct m mpage->mlinks = NULL; } goto nextpage; - } else if (NULL != mdoc) { + } else if (mdoc != NULL) { mpage->form = FORM_SRC; mpage->sec = mdoc_meta(mdoc)->msec; mpage->sec = mandoc_strdup( - NULL == mpage->sec ? "" : mpage->sec); + mpage->sec == NULL ? "" : mpage->sec); mpage->arch = mdoc_meta(mdoc)->arch; mpage->arch = mandoc_strdup( - NULL == mpage->arch ? "" : mpage->arch); + mpage->arch == NULL ? "" : mpage->arch); mpage->title = mandoc_strdup(mdoc_meta(mdoc)->title); - } else if (NULL != man) { + } else if (man != NULL) { mpage->form = FORM_SRC; mpage->sec = mandoc_strdup(man_meta(man)->msec); @@ -1193,8 +1199,6 @@ mpages_merge(struct mchars *mc, struct m mpage->title = mandoc_strdup(mpage->mlinks->name); } - if (mpage->mlinks->gzip) - mpage->form |= FORM_GZ; putkey(mpage, mpage->sec, TYPE_sec); if (*mpage->arch != '\0') putkey(mpage, mpage->arch, TYPE_arch); Index: mansearch.h =================================================================== RCS file: /home/cvs/mdocml/mdocml/mansearch.h,v retrieving revision 1.20 retrieving revision 1.21 diff -Lmansearch.h -Lmansearch.h -u -p -r1.20 -r1.21 --- mansearch.h +++ mansearch.h @@ -70,7 +70,6 @@ #define FORM_CAT 0 /* manual page is preformatted */ #define FORM_SRC 1 /* format is mdoc(7) or man(7) */ -#define FORM_GZ 2 /* compressed with gzip(1) */ #define FORM_NONE 4 /* format is unknown */ enum argmode { -- To unsubscribe send an email to tech+unsubscribe@mdocml.bsd.lv