summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2016-04-13 15:38:45 +0000
committerIngo Schwarze <schwarze@openbsd.org>2016-04-13 15:38:45 +0000
commit62244156bb39ecbe6aed09712ecc48fc86ac1435 (patch)
treedc3a876a58b0826049c154973914e9d9c687c83e
parent8b6c257fdc7ee31687677a63487731c4efeab19f (diff)
downloadmandoc-62244156bb39ecbe6aed09712ecc48fc86ac1435.tar.gz
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.
-rw-r--r--cgi.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/cgi.c b/cgi.c
index dae3b827..b4982d75 100644
--- a/cgi.c
+++ b/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, struct manpage *r, size_t sz)
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) {