* mdocml: Give manuals in purely numerical sections priority over manuals
@ 2016-04-13 12:26 schwarze
0 siblings, 0 replies; 2+ messages in thread
From: schwarze @ 2016-04-13 12:26 UTC (permalink / raw)
To: source
Log Message:
-----------
Give manuals in purely numerical sections priority over manuals of
the same name in sections with an alphabetical suffix (on OpenBSD,
mostly 3p), restoring behaviour of the traditional BSD man(1) that
got lost in the switch to the mandoc-based implementation.
Issue reported by jsg@, using an idea by mikeb@ for the solution,
and at least afresh1@ and jasper@ also seem in favour of the direction.
Modified Files:
--------------
mdocml:
main.c
Revision Data
-------------
Index: main.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/main.c,v
retrieving revision 1.263
retrieving revision 1.264
diff -Lmain.c -Lmain.c -u -p -r1.263 -r1.264
--- main.c
+++ main.c
@@ -123,9 +123,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;
@@ -389,7 +389,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;
@@ -405,11 +405,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;
@@ -681,7 +683,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;
--
To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv
^ permalink raw reply [flat|nested] 2+ messages in thread
* mdocml: Give manuals in purely numerical sections priority over manuals
@ 2016-04-13 15:39 schwarze
0 siblings, 0 replies; 2+ messages in thread
From: schwarze @ 2016-04-13 15:39 UTC (permalink / raw)
To: source
Log Message:
-----------
Give manuals in purely numerical sections priority over manuals of
the same name in sections with an alphabetical suffix; same logic
as in main.c rev. 1.264.
Modified Files:
--------------
mdocml:
cgi.c
Revision Data
-------------
Index: cgi.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/cgi.c,v
retrieving revision 1.119
retrieving revision 1.120
diff -Lcgi.c -Lcgi.c -u -p -r1.119 -r1.120
--- cgi.c
+++ cgi.c
@@ -554,10 +554,10 @@ static void
pg_searchres(const struct req *req, struct manpage *r, size_t sz)
{
char *arch, *archend;
- size_t i, iuse, isec;
+ const char *sec;
+ size_t i, iuse;
int archprio, archpriouse;
int prio, priouse;
- char sec;
for (i = 0; i < sz; i++) {
if (validate_filename(r[i].file))
@@ -616,20 +616,22 @@ pg_searchres(const struct req *req, stru
if (req->q.equal) {
puts("<HR>");
iuse = 0;
- priouse = 10;
+ priouse = 20;
archpriouse = 3;
for (i = 0; i < sz; i++) {
- isec = strcspn(r[i].file, "123456789");
- sec = r[i].file[isec];
- if ('\0' == sec)
+ sec = r[i].file;
+ sec += strcspn(sec, "123456789");
+ if (sec[0] == '\0')
continue;
- prio = sec_prios[sec - '1'];
- if (NULL == req->q.arch) {
+ prio = sec_prios[sec[0] - '1'];
+ if (sec[1] != '/')
+ prio += 10;
+ if (req->q.arch == NULL) {
archprio =
- (NULL == (arch = strchr(
- r[i].file + isec, '/'))) ? 3 :
- (NULL == (archend = strchr(
- arch + 1, '/'))) ? 0 :
+ ((arch = strchr(sec + 1, '/'))
+ == NULL) ? 3 :
+ ((archend = strchr(arch + 1, '/'))
+ == NULL) ? 0 :
strncmp(arch, "amd64/",
archend - arch) ? 2 : 1;
if (archprio < archpriouse) {
--
To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-04-13 15:39 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-13 12:26 mdocml: Give manuals in purely numerical sections priority over manuals schwarze
2016-04-13 15:39 schwarze
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).