From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 1396 invoked from network); 4 Sep 2021 16:16:37 -0000 Received: from bsd.lv (HELO mandoc.bsd.lv) (66.111.2.12) by inbox.vuxu.org with ESMTPUTF8; 4 Sep 2021 16:16:37 -0000 Received: from fantadrom.bsd.lv (localhost [127.0.0.1]) by mandoc.bsd.lv (OpenSMTPD) with ESMTP id d3d60465 for ; Sat, 4 Sep 2021 11:16:35 -0500 (EST) Received: from scc-mailout-kit-01.scc.kit.edu (scc-mailout-kit-01.scc.kit.edu [129.13.231.81]) by mandoc.bsd.lv (OpenSMTPD) with ESMTP id 41bf279d for ; Sat, 4 Sep 2021 11:16:34 -0500 (EST) Received: from hekate.asta.kit.edu ([141.3.145.153] helo=hekate.usta.de) by scc-mailout-kit-01.scc.kit.edu with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (envelope-from ) id 1mMYLJ-0006XI-DE; Sat, 04 Sep 2021 18:16:33 +0200 Received: from donnerwolke.asta.kit.edu ([141.3.145.61] helo=donnerwolke.usta.de) by hekate.usta.de with esmtp (Exim 4.92.2) (envelope-from ) id 1mMYLI-00015r-EL; Sat, 04 Sep 2021 18:16:32 +0200 Received: from athene.asta.kit.edu ([141.3.145.60] helo=athene.usta.de) by donnerwolke.usta.de with esmtp (Exim 4.84_2) (envelope-from ) id 1mMYLI-0006Dk-9p; Sat, 04 Sep 2021 18:16:32 +0200 Received: from localhost (athene.usta.de [local]) by athene.usta.de (OpenSMTPD) with ESMTPA id 2dd0007b; Sat, 4 Sep 2021 18:16:32 +0200 (CEST) Date: Sat, 4 Sep 2021 18:16:32 +0200 From: Ingo Schwarze To: Soeren Tempel Cc: tech@mandoc.bsd.lv Subject: Re: Discrepancy in mansearch and fs_lookup behavior Message-ID: <20210904161632.GC61031@athene.usta.de> References: <1ZRQZL79I0W2O.3ILLDNAL4JXUP@8pit.net> <20210901203523.GB15706@athene.usta.de> <2E058N5M5N7IG.2Z5CUW18DPHPS@8pit.net> <20210904131832.GB61031@athene.usta.de> X-Mailinglist: mandoc-tech Reply-To: tech@mandoc.bsd.lv MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210904131832.GB61031@athene.usta.de> User-Agent: Mutt/1.12.2 (2019-09-21) Hi Soeren, Ingo Schwarze wrote on Sat, Sep 04, 2021 at 03:18:32PM +0200: > Hang on a moment for the remaining issue with the .gz extension > probably breaking the prio code, i'll try to figure that out and > send a patch for that, too. I believe the patch below fixes the issue that main() does not properly prioritize gzipped files according to their file name extensions. Does it make sense to you, and does it work for you? The main() program is growing to become a bit unwieldy, but i'm not going to do any major refactoring right now. Yours, Ingo Index: main.c =================================================================== RCS file: /cvs/src/usr.bin/mandoc/main.c,v retrieving revision 1.259 diff -u -r1.259 main.c --- main.c 4 Sep 2021 12:47:04 -0000 1.259 +++ main.c 4 Sep 2021 16:04:44 -0000 @@ -131,7 +131,7 @@ struct mparse *mp; /* Opaque parser object. */ const char *conf_file; /* -C: alternate config file. */ const char *os_s; /* -I: Operating system for display. */ - const char *progname, *sec; + const char *progname, *sec, *ep; char *defpaths; /* -M: override manpaths. */ char *auxpaths; /* -m: additional manpaths. */ char *oarg; /* -O: output option string. */ @@ -514,11 +514,16 @@ sec++; /* Prefer without suffix. */ if (*sec != '/') prio += 10; /* Wrong dir name. */ - if (search.sec != NULL && - (strlen(sec) <= ssz + 3 || - strcmp(sec + strlen(sec) - ssz, - search.sec) != 0)) - prio += 20; /* Wrong file ext. */ + if (search.sec != NULL) { + ep = strchr(sec, '\0'); + if (ep - sec > 3 && + strncmp(ep - 3, ".gz", 3) == 0) + ep -= 3; + if ((size_t)(ep - sec) < ssz + 3 || + strncmp(ep - ssz, search.sec, + ssz) != 0) /* Wrong file */ + prio += 20; /* extension. */ + } if (prio >= best_prio) continue; best_prio = prio; -- To unsubscribe send an email to tech+unsubscribe@mandoc.bsd.lv