On Tue, Apr 12, 2016 at 20:27 +0200, Ingo Schwarze wrote:
> Hi Mike,
>
> Mike Belopuhov wrote on Tue, Apr 12, 2016 at 08:01:23PM +0200:
>
> > IMO it's a very bad idea to hardcode "3p/" like that.
> > Aren't there packages using other funny section names?
>
> Packages are in a different manual tree /usr/local/man/, which gets
> lower priority than /usr/share/man/ in the first place. But you
> are right, my first version of the patch left /usr/local/man/man3f/
> with the same priority as /usr/local/man/man3/, for example. Besides,
> on non-OpenBSD systems, this may matter even in the base system.
>
> > Can we simply prioritize letter-less sections?
>
> That's a neat idea!
>
> Patch updated, see below, forget about the first version.
>
Cool, but it begs the question why is 3p still on the "sections"
list in the fs_search? Just a lookup optimization?
> > I'd definitely move 4 and 5 closer like so (if you want to keep
> > games this high):
> > {"1", "8", "6", "5", "7", "4", "2", "3", "9", "3p"};
> > .7 man pages are closer to config files (.5) and other "sysop"
> > stuff.
>
> I wouldn't mind changing the order, even though the old one is
> traditional; i think this would make most sense:
>
> 1 user stuff
> 8 5 7 4 admin stuff
> 2 3 9 developer stuff
> 6 slacker stuff
>
I don't play games, so this is fine with me, however, given that
they're executables, just not located in /usr/bin, I'd still keep
them after .8.
> But maybe let's first decide about section suffixes before
> re-prioritizing section numbers, which is a different topic.
>
> Yours,
> Ingo
>
>
> Index: main.c
> ===================================================================
> RCS file: /cvs/src/usr.bin/mandoc/main.c,v
> retrieving revision 1.170
> diff -u -p -r1.170 main.c
> --- main.c 16 Jan 2016 21:56:32 -0000 1.170
> +++ main.c 12 Apr 2016 18:09:30 -0000
> @@ -112,9 +112,9 @@ main(int argc, char *argv[])
> unsigned char *uc;
> struct manpage *res, *resp;
> char *conf_file, *defpaths;
> - size_t isec, i, sz;
> + const char *sec;
> + size_t i, sz;
> int prio, best_prio;
> - char sec;
> enum outmode outmode;
> int fd;
> int show_usage;
> @@ -350,7 +350,7 @@ main(int argc, char *argv[])
>
> if (outmode == OUTMODE_ONE) {
> argc = 1;
> - best_prio = 10;
> + best_prio = 20;
> } else if (outmode == OUTMODE_ALL)
> argc = (int)sz;
>
> @@ -366,11 +366,13 @@ main(int argc, char *argv[])
> res[i].output);
> else if (outmode == OUTMODE_ONE) {
> /* Search for the best section. */
> - isec = strcspn(res[i].file, "123456789");
> - sec = res[i].file[isec];
> - if ('\0' == sec)
> + sec = res[i].file;
> + sec += strcspn(sec, "123456789");
> + if (sec[0] == '\0')
> continue;
> - prio = sec_prios[sec - '1'];
> + prio = sec_prios[sec[0] - '1'];
> + if (sec[1] != '/')
> + prio += 10;
> if (prio >= best_prio)
> continue;
> best_prio = prio;
> @@ -636,7 +638,7 @@ fs_search(const struct mansearch *cfg, c
> int argc, char **argv, struct manpage **res, size_t *ressz)
> {
> const char *const sections[] =
> - {"1", "8", "6", "2", "3", "3p", "5", "7", "4", "9"};
> + {"1", "8", "6", "2", "3", "5", "7", "4", "9", "3p"};
> const size_t nsec = sizeof(sections)/sizeof(sections[0]);
>
> size_t ipath, isec, lastsz;