diff options
author | 2011-11-28 09:44:05 +0000 | |
---|---|---|
committer | 2011-11-28 09:44:05 +0000 | |
commit | fa15c8f0c4a383b1f7be983d2655c5d14dc23d15 (patch) | |
tree | ec0c00e9addccf0aa45deb362e3fff9aa3abb304 | |
parent | a62b6c9ed7de00f4e5d9a067932be826e1c6f67e (diff) | |
download | mandoc-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@
-rw-r--r-- | apropos.c | 4 | ||||
-rw-r--r-- | apropos_db.c | 11 | ||||
-rw-r--r-- | whatis.1 | 6 |
3 files changed, 10 insertions, 11 deletions
@@ -1,4 +1,4 @@ -/* $Id: apropos.c,v 1.20 2011/11/27 18:54:01 kristaps Exp $ */ +/* $Id: apropos.c,v 1.21 2011/11/28 09:44:05 schwarze Exp $ */ /* * Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2011 Ingo Schwarze <schwarze@openbsd.org> @@ -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 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)++; } @@ -1,4 +1,4 @@ -.\" $Id: whatis.1,v 1.1 2011/11/27 18:54:01 kristaps Exp $ +.\" $Id: whatis.1,v 1.2 2011/11/28 09:44:05 schwarze Exp $ .\" .\" Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv> .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: November 27 2011 $ +.Dd $Mdocdate: November 28 2011 $ .Dt WHATIS 1 .Os .Sh NAME @@ -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 |