discuss@mandoc.bsd.lv
 help / color / mirror / Atom feed
* Arch Linux Improvements
@ 2018-12-30  1:25 John McKay
  2018-12-30  2:57 ` Ingo Schwarze
  0 siblings, 1 reply; 3+ messages in thread
From: John McKay @ 2018-12-30  1:25 UTC (permalink / raw)
  To: discuss

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-12-30 22:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-30  1:25 Arch Linux Improvements John McKay
2018-12-30  2:57 ` Ingo Schwarze
2018-12-30 22:01   ` John McKay

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).