[moved to tech@, source-changes is not ideal for discussions]

Marc Espie wrote on Tue, Apr 12, 2016 at 03:44:34PM +0200:
> On Tue, Apr 12, 2016 at 11:24:40PM +1000, Jonathan Gray wrote:
>> On Tue, Apr 12, 2016 at 02:36:09PM +0200, Marc Espie wrote:
>>> On Tue, Apr 12, 2016 at 08:18:33PM +1000, Jonathan Gray wrote:
>>>> On Tue, Apr 12, 2016 at 03:40:11AM -0600, Marc Espie wrote:

>>>>> CVSROOT:  /cvs
>>>>> Module name:      www
>>>>> Changes by:       es...@cvs.openbsd.org   2016/04/12 03:40:11
>>>>> 
>>>>> Modified files:
>>>>>   faq            : faq6.html 
>>>>> 
>>>>> Log message:
>>>>> pretty sure network doesn't care about carp(3p)

>>>> This wouldn't be a problem if the perl pages were searched last.

>>> And why would you want that ? because you care less about the
>>> perl manpages ?
>>> Changing the default will impact other people, even if that patch
>>> would work.

>> The behaviour was changed at some point.

True, probably with the switch from the old BSD man(1) to the new
mandoc-based man(1).

>> For example on an old machine with 5.6
>> /usr/share/man/man4/re.4 and /usr/share/man/man3p/re.3p both exist
>> man re shows re(4) not re(3p).
>> 
>> So I am proposing the default be changed back.  When that link
>> was added the search order was correct.

> I don't know how ingo orders

We are not talking about order here (which page is shown first when
more than one page is shown with -a; order is always numeric within
trees, like in SEE ALSO sections, and that won't change; try "man
-a chown" vs. "man chown") but about priority (which page is shown
when the user requested one single page only).

> things these days, but I would tend to think there is just
> plain old alphabetical order in sections ?

No.  The file name inside the respective manual page tree is taken,
for example "man4/re.4" or "man3p/re.3p", the first digit character
is identified, in the above example '4' and '3', respectively,
and then the search priority

  1 8 6 2 3 5 7 4 9

is applied.  Suffixes to the section number are ignored.  One reason
is that some operating systems use suffixes for almost all their
manuals.  For example:

   $ uname -a
  SunOS login 5.10 Generic_150400-17 sun4v sparc SUNW,SPARC-Enterprise-T5220
   $ cd /usr/share/man/
   $ ls -d man1*
  man1   man1b  man1c  man1f  man1m  man1s
   $ ls -d man3p*
  man3pam       man3perl      man3picltree  man3pool      man3project
  man3papi      man3picl      man3plot      man3proc
   $ ls -d man* | wc -l
  106

Then again, i don't mind moving 3p back to the end.  The patch appended
below does that for man(1).  I'll wait to see whether people want it
before doing the same for man.cgi(8).

> There used to be a config option in man.conf...

True, that's one of the things i dropped with the new, simpler
man.conf(5) format because i wasn't sure people actually need it.

If you want it, i can implement the following man.conf(5) directive:

  sections name name name ...

That would decide which sections get priority.

The default could be either of

  1 8 6 2 3 3p 5 7 4 9
  1 8 6 2 3 5 7 4 9 3p

whichever you prefer.

But unless people speak up and tell me that directive is useful,
i'll assume it is better to not bloat the config file format.

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 16:51:09 -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 = 11;
                } else if (outmode == OUTMODE_ALL)
                        argc = (int)sz;
 
@@ -366,11 +366,14 @@ 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')
                                        continue;
-                               prio = sec_prios[sec - '1'];
+                               if (strncmp(sec, "3p/", 3) == 0)
+                                       prio = 10;
+                               else
+                                       prio = sec_prios[sec[0] - '1'];
                                if (prio >= best_prio)
                                        continue;
                                best_prio = prio;
@@ -636,7 +639,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;

Reply via email to