From fa15c8f0c4a383b1f7be983d2655c5d14dc23d15 Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Mon, 28 Nov 2011 09:44:05 +0000 Subject: 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@ --- apropos.c | 4 ++-- apropos_db.c | 11 +++++------ whatis.1 | 6 +++--- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/apropos.c b/apropos.c index 4bfdbf04..2ccdd5fe 100644 --- a/apropos.c +++ b/apropos.c @@ -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 * Copyright (c) 2011 Ingo Schwarze @@ -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 * Copyright (c) 2011 Ingo Schwarze @@ -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 a3f60fb8..f9b2bb1d 100644 --- a/whatis.1 +++ b/whatis.1 @@ -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 .\" @@ -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 -- cgit v1.2.3-56-ge451