summaryrefslogtreecommitdiffstats
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
commit0dc7ca4abf72bcae5cbcea1c36e8fe686fbf5b16 (patch)
tree46d100e8643ea51017727f8cbcb27e6bf83a2cf4
parent591006fe672adf9c166b9440176e03ed1554191e (diff)
downloadmandoc-0dc7ca4abf72bcae5cbcea1c36e8fe686fbf5b16.tar.gz
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@
-rw-r--r--apropos.c2
-rw-r--r--apropos_db.c9
-rw-r--r--whatis.12
3 files changed, 6 insertions, 7 deletions
diff --git a/apropos.c b/apropos.c
index 95c92d03..0d97c82a 100644
--- a/apropos.c
+++ b/apropos.c
@@ -53,7 +53,7 @@ main(int argc, char *argv[])
else
++progname;
- whatis = 0 == strcmp(progname, "whatis");
+ whatis = 0 == strncmp(progname, "whatis", 6);
memset(&paths, 0, sizeof(struct manpaths));
memset(&opts, 0, sizeof(struct opts));
diff --git a/apropos_db.c b/apropos_db.c
index 5e473a6b..f1adf29c 100644
--- a/apropos_db.c
+++ b/apropos_db.c
@@ -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)++;
}
diff --git a/whatis.1 b/whatis.1
index 9415e265..8b320033 100644
--- a/whatis.1
+++ b/whatis.1
@@ -92,7 +92,7 @@ is identical to running
.Xr apropos 1
as follows:
.Pp
-.Dl $ apropos -- -i '~[[:<:]]term[[:>:]]'
+.Dl $ apropos -- -i 'Nm~[[:<:]]term[[:>:]]'
.Sh ENVIRONMENT
.Bl -tag -width Ds
.It Ev MANPATH