From: schwarze@mandoc.bsd.lv
To: source@mandoc.bsd.lv
Subject: mandoc: In man(1) mode with a specific section requested, try harder to
Date: Fri, 3 May 2019 11:15:12 -0500 (EST) [thread overview]
Message-ID: <e3fef587fd9d451f@fantadrom.bsd.lv> (raw)
Log Message:
-----------
In man(1) mode with a specific section requested,
try harder to find the best match.
Use this order of preference:
1. The section in both the directory name and the file name matches exactly.
2. The section in the file name matches exactly.
3. The section in the directory name matches exactly.
4. Neither of them matches exactly.
The latter can happen when mansearch() finds substring matches
or when the second .Dt argument mismatches the dir and file names.
Lorenzo Beretta <loreb at github> reported that this caused real
problems on Void Linux, like "man 3 readline" showing readline(3m).
See https://github.com/void-linux/void-packages/issues/9868 for details.
Modified Files:
--------------
mandoc:
TODO
main.c
Revision Data
-------------
Index: main.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/main.c,v
retrieving revision 1.324
retrieving revision 1.325
diff -Lmain.c -Lmain.c -u -p -r1.324 -r1.325
--- main.c
+++ main.c
@@ -125,7 +125,7 @@ main(int argc, char *argv[])
char *conf_file, *defpaths, *auxpaths;
char *oarg, *tagarg;
unsigned char *uc;
- size_t i, sz;
+ size_t i, sz, ssz;
int prio, best_prio;
enum outmode outmode;
int fd, startdir;
@@ -434,7 +434,7 @@ main(int argc, char *argv[])
if (outmode == OUTMODE_ONE) {
argc = 1;
- best_prio = 20;
+ best_prio = 40;
} else if (outmode == OUTMODE_ALL)
argc = (int)sz;
@@ -453,10 +453,21 @@ main(int argc, char *argv[])
sec = res[i].file;
sec += strcspn(sec, "123456789");
if (sec[0] == '\0')
- continue;
+ continue; /* No section at all. */
prio = sec_prios[sec[0] - '1'];
- if (sec[1] != '/')
- prio += 10;
+ if (search.sec != NULL) {
+ ssz = strlen(search.sec);
+ if (strncmp(sec, search.sec, ssz) == 0)
+ sec += ssz;
+ } else
+ 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 (prio >= best_prio)
continue;
best_prio = prio;
Index: TODO
===================================================================
RCS file: /home/cvs/mandoc/mandoc/TODO,v
retrieving revision 1.292
retrieving revision 1.293
diff -LTODO -LTODO -u -p -r1.292 -r1.293
--- TODO
+++ TODO
@@ -217,18 +217,6 @@ are mere guesses, and some may be wrong.
--- missing misc features ----------------------------------------------
-- man 3am readline
- does not work because man(1) only accepts digit + one letter,
- otherwise explicit -s is currently required
- https://github.com/void-linux/void-packages/issues/9868
- loc * exist * algo * size * imp ***
-
-- man 3 readline may show readline(3m)
- because in manpage_compare, "3" and "3am" compare equal
- https://github.com/void-linux/void-packages/issues/9868
- probably requires putting string version of section into struct manpage
- loc * exist ** algo * size * imp ***
-
- dead .so links should be entered into the database to avoid:
man -M. lvm-config
man: outdated mandoc.db lacks lvm-config(8) entry, run makewhatis /co/void-man
--
To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv
reply other threads:[~2019-05-03 16:15 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=e3fef587fd9d451f@fantadrom.bsd.lv \
--to=schwarze@mandoc.bsd.lv \
--cc=source@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).