summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2016-04-15 00:14:17 +0000
committerIngo Schwarze <schwarze@openbsd.org>2016-04-15 00:14:17 +0000
commit7ccf676d918d4d24100f3b87a668afd042dc5de3 (patch)
tree0f3f2c08fb90b75cb1c2bd58b44f81cffbbf8db6
parent40ae11d5b5fea96050cf3e796db9a26e9b7512a4 (diff)
downloadmandoc-7ccf676d918d4d24100f3b87a668afd042dc5de3.tar.gz
omit list of other results when there is only one match
-rw-r--r--cgi.c43
1 files changed, 23 insertions, 20 deletions
diff --git a/cgi.c b/cgi.c
index 4de5a117..c622d9ec 100644
--- a/cgi.c
+++ b/cgi.c
@@ -588,34 +588,37 @@ pg_searchres(const struct req *req, struct manpage *r, size_t sz)
resp_begin_html(200, NULL);
resp_searchform(req);
- puts("<DIV CLASS=\"results\">");
- puts("<TABLE>");
- for (i = 0; i < sz; i++) {
- printf("<TR>\n"
- "<TD CLASS=\"title\">\n"
- "<A HREF=\"/%s%s%s/%s",
- scriptname, *scriptname == '\0' ? "" : "/",
- req->q.manpath, r[i].file);
- printf("\">");
- html_print(r[i].names);
- printf("</A>\n"
- "</TD>\n"
- "<TD CLASS=\"desc\">");
- html_print(r[i].output);
- puts("</TD>\n"
- "</TR>");
- }
+ if (sz > 1) {
+ puts("<DIV CLASS=\"results\">");
+ puts("<TABLE>");
- puts("</TABLE>\n"
- "</DIV>");
+ for (i = 0; i < sz; i++) {
+ printf("<TR>\n"
+ "<TD CLASS=\"title\">\n"
+ "<A HREF=\"/%s%s%s/%s",
+ scriptname, *scriptname == '\0' ? "" : "/",
+ req->q.manpath, r[i].file);
+ printf("\">");
+ html_print(r[i].names);
+ printf("</A>\n"
+ "</TD>\n"
+ "<TD CLASS=\"desc\">");
+ html_print(r[i].output);
+ puts("</TD>\n"
+ "</TR>");
+ }
+
+ puts("</TABLE>\n"
+ "</DIV>");
+ }
/*
* In man(1) mode, show one of the pages
* even if more than one is found.
*/
- if (req->q.equal) {
+ if (req->q.equal || sz == 1) {
puts("<HR>");
iuse = 0;
priouse = 20;