From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from scc-mailout.scc.kit.edu (scc-mailout.scc.kit.edu [129.13.185.202]) by krisdoz.my.domain (8.14.3/8.14.3) with ESMTP id pAS0ZOVK004077 for ; Sun, 27 Nov 2011 19:35:24 -0500 (EST) Received: from hekate.usta.de (asta-nat.asta.uni-karlsruhe.de [172.22.63.82]) by scc-mailout-02.scc.kit.edu with esmtp (Exim 4.72 #1) id 1RUpBq-0004zn-NE; Mon, 28 Nov 2011 01:35:22 +0100 Received: from donnerwolke.usta.de ([172.24.96.3]) by hekate.usta.de with esmtp (Exim 4.72) (envelope-from ) id 1RUpBq-0002tP-Mw for tech@mdocml.bsd.lv; Mon, 28 Nov 2011 01:35:22 +0100 Received: from iris.usta.de ([172.24.96.5] helo=usta.de) by donnerwolke.usta.de with esmtp (Exim 4.72) (envelope-from ) id 1RUpBq-0004vl-Lm for tech@mdocml.bsd.lv; Mon, 28 Nov 2011 01:35:22 +0100 Received: from schwarze by usta.de with local (Exim 4.72) (envelope-from ) id 1RUpBq-0006Z1-BA for tech@mdocml.bsd.lv; Mon, 28 Nov 2011 01:35:22 +0100 Date: Mon, 28 Nov 2011 01:35:21 +0100 From: Ingo Schwarze To: tech@mdocml.bsd.lv Subject: Re: whatis(1) Message-ID: <20111128003521.GB15140@iris.usta.de> References: <4ED22A28.6040401@bsd.lv> <20111127181301.GA15140@iris.usta.de> <4ED287DE.3030001@bsd.lv> X-Mailinglist: mdocml-tech Reply-To: tech@mdocml.bsd.lv MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4ED287DE.3030001@bsd.lv> User-Agent: Mutt/1.5.21 (2010-09-15) Hi Kristaps, Kristaps Dzonsons wrote on Sun, Nov 27, 2011 at 07:56:30PM +0100: > To get the ball rolling, I just checked in whatis.1 and the code > modified to use your regexp. I simplified the call into > apropos_db.h with termcomp() instead of exprcomp(), as this mode > might be useful for man.cgi too. The search expression is now case > insensitive and ~[[:<:]]term[[:>:]]. (Thanks!) I have merged this to OpenBSD, with a few tweaks, see below: - One real bug: termcomp() returned the wrong end of the singly linked list it built, such that only the last word given on the command line was used. - Whatever MacOS may be doing, i tweaked the the regex from "Nm,Nd~" to "Nm~", which is current OpenBSD behaviour. When we replace tools, we should not change behaviour at the same time, but propose changes separately - if we want them. In this case, i'm not even convinced the change makes sense. If you ask "whatis mandoc", you clearly want "mandoc(1)" as an answer; but why should you get "eqn(7), roff(7), tbl(7)" as well? That's, i think, what plain apropos(1) is for. Maybe that's even a bug in MacOS? - I suggest to check only the beginning of the command name, such that you can e.g. install as "whatis.m" for testing purposes. OK to commit these three tweaks to bsd.lv, too? > NOTE: this fixed a subtle bug in apropos_db.h in compiling case > insensitive regular expression. Indeed, thanks! Ingo ----- 8< ----- schnipp ----- >8 ----- 8< ----- schnapp ----- >8 ----- CVSROOT: /cvs Module name: src Changes by: schwarze@cvs.openbsd.org 2011/11/27 17:16:38 Modified files: usr.bin/mandoc : apropos.c apropos_db.c apropos_db.h main.c Log message: Implement whatis(1) as a special apropos(1) mode as a part of the mandoc(1) binary; not yet enabled for the general public. Intended to replace src/usr.bin/whatis at a later time. Coded by kristaps@, with a few tweaks by me. To test this: $ mandocdb # unless you have already done so earlier $ sudo ln -s /usr/bin/mandoc /usr/bin/whatis.m $ whatis.m mandoc apropos whatis $ whatis.m man ----- 8< ----- schnipp ----- >8 ----- 8< ----- schnapp ----- >8 ----- --- /co/mdocml/apropos.c Sun Nov 27 23:51:01 2011 +++ ./apropos.c Mon Nov 28 01:16:38 2011 @@ -53,7 +49,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)); --- /co/mdocml/apropos_db.c Mon Nov 28 00:11:37 2011 +++ ./apropos_db.c Mon Nov 28 01:16:38 2011 @@ -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)++; } -- To unsubscribe send an email to tech+unsubscribe@mdocml.bsd.lv