tech@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: Ingo Schwarze <schwarze@usta.de>
To: Soeren Tempel <soeren@soeren-tempel.net>
Cc: tech@mandoc.bsd.lv
Subject: Re: Discrepancy in mansearch and fs_lookup behavior
Date: Sun, 5 Sep 2021 14:47:38 +0200	[thread overview]
Message-ID: <20210905124738.GE98312@athene.usta.de> (raw)
In-Reply-To: <3QJNXCTXZORDT.22DQHFTHANJXN@8pit.net>

Hi Soeren,

Soeren Tempel wrote on Sat, Sep 04, 2021 at 07:51:58PM +0200:
> Ingo Schwarze <schwarze@usta.de> wrote:

>> 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?

> Yes, the patch does make sense and it does work well for me:
> 
> 	man 3 open   -> Perl open(3pm) man page
> 	man 3p open  -> POSIX open(3p) man page
> 	man 3pm open -> Perl open(3pm) man page
> 
> Thanks a lot for fixing this so quickly!

Thank you for reporting and testing!

The patch is now committed, see the commit below.

> BTW: Is there any chance that you could make a new release soonish? Has
> been a while since the last release and CVS has accumulated quite a few
> useful fixes since 1.14.5.

Yes, the next release is long overdue.  I have been paying attention
to not do major reorganizations that might destabilize the code base
for quite some time now.  I'm trying to get those bugs fixed that
are easy to fix with a low risk, then draft the release notes,
then send out a beta to downstream maintainers for testing without
too much additional delay.

My list of pending patches is already free from mandoc entries.
My list of urgent bug reports still contains one or two entries
related to tbl(7).  After that, a final pass over the TODO file
makes sense, to see whether anything trivial remains in there -
but the bulk of the TODO entries will certainly not be addressed
before the upcoming release.

Yours,
  Ingo


Log Message:
-----------
during prioritization for man(1), correctly extract the section name
from the file name extension of gzipped manual page files; bug found 
on Alpine Linux by Soeren Tempel <soeren at soeren hyphen tempel dot net>,
who also tested this patch

Modified Files:
--------------
    mandoc:
        main.c

Revision Data
-------------
Index: main.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/main.c,v
retrieving revision 1.357
retrieving revision 1.358
diff -Lmain.c -Lmain.c -u -p -r1.357 -r1.358
--- main.c
+++ main.c
@@ -132,7 +132,7 @@ main(int argc, char *argv[])
 	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. */
@@ -536,11 +536,16 @@ main(int argc, char *argv[])
 					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


      reply	other threads:[~2021-09-05 12:47 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-30 19:26 Sören Tempel
2021-09-01 20:35 ` Ingo Schwarze
2021-09-02 19:09   ` Ingo Schwarze
2021-09-04 10:12   ` Sören Tempel
2021-09-04 13:18     ` Ingo Schwarze
2021-09-04 16:16       ` Ingo Schwarze
2021-09-04 17:51         ` Sören Tempel
2021-09-05 12:47           ` Ingo Schwarze [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210905124738.GE98312@athene.usta.de \
    --to=schwarze@usta.de \
    --cc=soeren@soeren-tempel.net \
    --cc=tech@mandoc.bsd.lv \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).