discuss@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: John McKay <adenosine3p+lists@gmail.com>
To: discuss@mandoc.bsd.lv
Subject: Arch Linux Improvements
Date: Sun, 30 Dec 2018 01:25:59 +0000	[thread overview]
Message-ID: <5c282663.1c69fb81.e8260.65b6@mx.google.com> (raw)

The man-pages package in Arch Linux has two versions of the manual
page for several topics. One is the version from the Linux man-pages
project and the other is from the POSIX reference. For example
/usr/share/man/man3/freeaddrinfo.3p.gz
/usr/share/man/man3/getaddrinfo.3.gz
both contain entries for freeaddrinfo(3).

This causes two difficulties when using mandoc on Arch Linux. The
first is that if you type
man freeaddrinfo
it pulls up the POSIX version. The POSIX versions of the pages are
typically not what you want as they have less detail and don't always
match the implementation described in the other page. The second
difficulty is that even if you specify
man -s 3 freeaddrinfo
it still brings up the POSIX version. While fixing the first
difficulty seems to be non-trivial (I have a patch that works for me,
but it's a bit of a hack and not portable to other systems), the
second difficulty seems much easier to fix. I have attached a patch
below.

The cause is twofold. In dbadd_mlink it adds the page both with the
section that is found in the containing folder and also the section
that is found by scanning the file name. Also, in lstmatch the section
names are compared using strcasestr. By only adding the page using the
file name's section and changing lstmatch to use strcasecmp the search
by section allows you to find the correct version of the page.

There are two side effects. If you have a manual page that's in the
correct folder but is named wrong you can no longer find it if you
search by section. You also cannot truncate the architecture name when
searching by architecture. None of the manual pages on my system have
names that don't match the folder they are in. I never search by
architecture so I don't know if it's common to shorten the name.

Any comments are greatly appreciated, especially concerning a fix for
the order that it uses to find the result shown.

Index: mandocdb.c
===================================================================
RCS file: /cvs/mandoc/mandocdb.c,v
retrieving revision 1.261
diff -c -u -r1.261 mandocdb.c
--- mandocdb.c	14 Dec 2018 01:18:26 -0000	1.261
+++ mandocdb.c	29 Dec 2018 23:15:01 -0000
@@ -2022,7 +2022,7 @@
 dbadd_mlink(const struct mlink *mlink)
 {
 	dba_page_alias(mlink->mpage->dba, mlink->name, NAME_FILE);
-	dba_page_add(mlink->mpage->dba, DBP_SECT, mlink->dsec);
 	dba_page_add(mlink->mpage->dba, DBP_SECT, mlink->fsec);
 	dba_page_add(mlink->mpage->dba, DBP_ARCH, mlink->arch);
 	dba_page_add(mlink->mpage->dba, DBP_FILE, mlink->file);
Index: mansearch.c
===================================================================
RCS file: /cvs/mandoc/mansearch.c,v
retrieving revision 1.80
diff -c -u -r1.80 mansearch.c
--- mansearch.c	13 Dec 2018 11:55:46 -0000	1.80
+++ mansearch.c	29 Dec 2018 23:15:01 -0000
@@ -534,7 +537,8 @@
         if (want == NULL || have == NULL || *have == '\0')
                 return 1;
         while (*have != '\0') {
-                if (strcasestr(have, want) != NULL)
+                if (strcasecmp(have, want) == 0)
                         return 1;
                 have = strchr(have, '\0') + 1;
         }
--
 To unsubscribe send an email to discuss+unsubscribe@mandoc.bsd.lv

             reply	other threads:[~2018-12-30  1:59 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-30  1:25 John McKay [this message]
2018-12-30  2:57 ` Ingo Schwarze
2018-12-30 22:01   ` John McKay

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=5c282663.1c69fb81.e8260.65b6@mx.google.com \
    --to=adenosine3p+lists@gmail.com \
    --cc=discuss@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).