From ff8805995c4600c46115ece11c83d63b9a28c1e8 Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Fri, 15 Apr 2016 00:14:17 +0000 Subject: omit list of other results when there is only one match --- cgi.c | 45 ++++++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/cgi.c b/cgi.c index 3dc21f9a..65ca0289 100644 --- a/cgi.c +++ b/cgi.c @@ -1,4 +1,4 @@ -/* $Id: cgi.c,v 1.122 2016/04/14 23:48:48 schwarze Exp $ */ +/* $Id: cgi.c,v 1.123 2016/04/15 00:14:17 schwarze Exp $ */ /* * Copyright (c) 2011, 2012 Kristaps Dzonsons * Copyright (c) 2014, 2015, 2016 Ingo Schwarze @@ -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("
"); - puts(""); - for (i = 0; i < sz; i++) { - printf("\n" - "\n" - "\n" - ""); - } + if (sz > 1) { + puts("
"); + puts("
\n" - "q.manpath, r[i].file); - printf("\">"); - html_print(r[i].names); - printf("\n" - ""); - html_print(r[i].output); - puts("
"); - puts("
\n" - "
"); + for (i = 0; i < sz; i++) { + printf("\n" + "\n" + "q.manpath, r[i].file); + printf("\">"); + html_print(r[i].names); + printf("\n" + "\n" + ""); + html_print(r[i].output); + puts("\n" + ""); + } + + puts("\n" + ""); + } /* * 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("
"); iuse = 0; priouse = 20; -- cgit v1.2.3-56-ge451