diff options
-rw-r--r-- | cgi.c | 3 | ||||
-rw-r--r-- | main.c | 6 | ||||
-rw-r--r-- | mansearch.c | 10 | ||||
-rw-r--r-- | mansearch.h | 3 |
4 files changed, 18 insertions, 4 deletions
@@ -1,4 +1,4 @@ -/* $Id: cgi.c,v 1.100 2014/10/28 17:36:19 schwarze Exp $ */ +/* $Id: cgi.c,v 1.101 2014/11/11 19:04:55 schwarze Exp $ */ /* * Copyright (c) 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2014 Ingo Schwarze <schwarze@usta.de> @@ -977,6 +977,7 @@ pg_search(const struct req *req) search.sec = req->q.sec; search.outkey = "Nd"; search.argmode = req->q.equal ? ARG_NAME : ARG_EXPR; + search.firstmatch = 1; paths.sz = 1; paths.paths = mandoc_malloc(sizeof(char *)); @@ -1,4 +1,4 @@ -/* $Id: main.c,v 1.198 2014/11/11 02:43:41 schwarze Exp $ */ +/* $Id: main.c,v 1.199 2014/11/11 19:04:55 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010, 2011, 2012, 2014 Ingo Schwarze <schwarze@openbsd.org> @@ -294,6 +294,10 @@ main(int argc, char *argv[]) if (argc == 0) usage(search.argmode); + if (search.argmode == ARG_NAME && + outmode == OUTMODE_ONE) + search.firstmatch = 1; + /* Access the mandoc database. */ manpath_parse(&paths, conf_file, defpaths, auxpaths); diff --git a/mansearch.c b/mansearch.c index 9c88fac8..938d48c4 100644 --- a/mansearch.c +++ b/mansearch.c @@ -1,4 +1,4 @@ -/* $Id: mansearch.c,v 1.48 2014/09/03 18:09:14 schwarze Exp $ */ +/* $Id: mansearch.c,v 1.49 2014/11/11 19:04:55 schwarze Exp $ */ /* * Copyright (c) 2012 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2013, 2014 Ingo Schwarze <schwarze@openbsd.org> @@ -352,6 +352,14 @@ mansearch(const struct mansearch *search, sqlite3_finalize(s2); sqlite3_close(db); ohash_delete(&htab); + + /* + * In man(1) mode, prefer matches in earlier trees + * over matches in later trees. + */ + + if (cur && search->firstmatch) + break; } qsort(*res, cur, sizeof(struct manpage), manpage_compare); rc = 1; diff --git a/mansearch.h b/mansearch.h index 0aab4e76..444f6621 100644 --- a/mansearch.h +++ b/mansearch.h @@ -1,4 +1,4 @@ -/* $Id: mansearch.h,v 1.18 2014/09/03 18:09:14 schwarze Exp $ */ +/* $Id: mansearch.h,v 1.19 2014/11/11 19:04:55 schwarze Exp $ */ /* * Copyright (c) 2012 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2013, 2014 Ingo Schwarze <schwarze@openbsd.org> @@ -94,6 +94,7 @@ struct mansearch { const char *sec; /* mansection/NULL */ const char *outkey; /* show content of this macro */ enum argmode argmode; /* interpretation of arguments */ + int firstmatch; /* first matching database only */ }; __BEGIN_DECLS |