aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/apropos_db.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2011-11-28 09:44:05 +0000
committerIngo Schwarze <schwarze@openbsd.org>2011-11-28 09:44:05 +0000
commitfa15c8f0c4a383b1f7be983d2655c5d14dc23d15 (patch)
treeec0c00e9addccf0aa45deb362e3fff9aa3abb304 /apropos_db.c
parenta62b6c9ed7de00f4e5d9a067932be826e1c6f67e (diff)
downloadmandoc-fa15c8f0c4a383b1f7be983d2655c5d14dc23d15.tar.gz
mandoc-fa15c8f0c4a383b1f7be983d2655c5d14dc23d15.tar.zst
mandoc-fa15c8f0c4a383b1f7be983d2655c5d14dc23d15.zip
Tweak whatis(1):
* Bugfix: Use all arguments, not just the last one. * Use 'Nm~' instead of 'Nm,Nd~' to match OpenBSD behaviour. * For the progname, accept '^whatis', not '^whatis$' to ease testing. ok kristaps@
Diffstat (limited to 'apropos_db.c')
-rw-r--r--apropos_db.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/apropos_db.c b/apropos_db.c
index 4a83a3bb..b9dd0653 100644
--- a/apropos_db.c
+++ b/apropos_db.c
@@ -1,4 +1,4 @@
-/* $Id: apropos_db.c,v 1.14 2011/11/27 23:11:37 schwarze Exp $ */
+/* $Id: apropos_db.c,v 1.15 2011/11/28 09:44:05 schwarze Exp $ */
/*
* Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011 Ingo Schwarze <schwarze@openbsd.org>
@@ -599,10 +599,10 @@ termcomp(int argc, char *argv[], size_t *tt)
e = NULL;
*tt = 0;
- for (pos = 0; pos < argc; pos++) {
- sz = strlen(argv[pos]) + 16;
+ for (pos = argc - 1; pos >= 0; pos--) {
+ sz = strlen(argv[pos]) + 18;
buf = mandoc_realloc(buf, sz);
- strlcpy(buf, "~[[:<:]]", sz);
+ strlcpy(buf, "Nm~[[:<:]]", sz);
strlcat(buf, argv[pos], sz);
strlcat(buf, "[[:>:]]", sz);
if (NULL == (next = exprterm(buf, 0))) {
@@ -610,8 +610,7 @@ termcomp(int argc, char *argv[], size_t *tt)
exprfree(e);
return(NULL);
}
- if (NULL != e)
- e->next = next;
+ next->next = e;
e = next;
(*tt)++;
}