From edcebb2ccc1d9dff61cbd2cf688598e28aa576b0 Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Tue, 11 Nov 2014 19:04:55 +0000 Subject: In man(1) mode without -a, stop searching after the first manual tree that contained at least one match in order to not prefer mdoc(1) from ports over mdoc(7). As a bonus, this results in a speedup. --- mansearch.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'mansearch.c') 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 * Copyright (c) 2013, 2014 Ingo Schwarze @@ -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; -- cgit v1.2.3