Module Name: src
Committed By: christos
Date: Sun Feb 10 23:58:28 UTC 2013
Modified Files:
src/usr.sbin/makemandb: apropos-utils.c apropos-utils.h apropos.1
apropos.c
Log Message:
add -r flag to elide tty formatting
To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/usr.sbin/makemandb/apropos-utils.c
cvs rdiff -u -r1.6 -r1.7 src/usr.sbin/makemandb/apropos-utils.h \
src/usr.sbin/makemandb/apropos.1
cvs rdiff -u -r1.11 -r1.12 src/usr.sbin/makemandb/apropos.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.sbin/makemandb/apropos-utils.c
diff -u src/usr.sbin/makemandb/apropos-utils.c:1.10 src/usr.sbin/makemandb/apropos-utils.c:1.11
--- src/usr.sbin/makemandb/apropos-utils.c:1.10 Sun Feb 10 18:24:18 2013
+++ src/usr.sbin/makemandb/apropos-utils.c Sun Feb 10 18:58:27 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: apropos-utils.c,v 1.10 2013/02/10 23:24:18 christos Exp $ */
+/* $NetBSD: apropos-utils.c,v 1.11 2013/02/10 23:58:27 christos Exp $ */
/*-
* Copyright (c) 2011 Abhinav Upadhyay <[email protected]>
* All rights reserved.
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: apropos-utils.c,v 1.10 2013/02/10 23:24:18 christos Exp $");
+__RCSID("$NetBSD: apropos-utils.c,v 1.11 2013/02/10 23:58:27 christos Exp $");
#include <sys/queue.h>
#include <sys/stat.h>
@@ -921,7 +921,12 @@ run_query_term(sqlite3 *db, query_args *
orig_data.callback = args->callback;
orig_data.data = args->callback_data;
const char *snippet_args[5];
- term_init(STDOUT_FILENO, snippet_args);
+ if (args->flags & APROPOS_NOFORMAT) {
+ snippet_args[0] = snippet_args[1] = snippet_args[3] =
+ snippet_args[4] = "";
+ snippet_args[2] = "...";
+ } else
+ term_init(STDOUT_FILENO, snippet_args);
ta.smul = snippet_args[3];
ta.rmul = snippet_args[4];
ta.orig_data = (void *) &orig_data;
Index: src/usr.sbin/makemandb/apropos-utils.h
diff -u src/usr.sbin/makemandb/apropos-utils.h:1.6 src/usr.sbin/makemandb/apropos-utils.h:1.7
--- src/usr.sbin/makemandb/apropos-utils.h:1.6 Sun Feb 10 18:24:18 2013
+++ src/usr.sbin/makemandb/apropos-utils.h Sun Feb 10 18:58:27 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: apropos-utils.h,v 1.6 2013/02/10 23:24:18 christos Exp $ */
+/* $NetBSD: apropos-utils.h,v 1.7 2013/02/10 23:58:27 christos Exp $ */
/*-
* Copyright (c) 2011 Abhinav Upadhyay <[email protected]>
* All rights reserved.
@@ -79,6 +79,8 @@ typedef struct query_args {
const char *, size_t); // The callback function
void *callback_data; // data to pass to the callback function
char **errmsg; // buffer for storing the error msg
+ int flags;
+#define APROPOS_NOFORMAT 1
} query_args;
char *lower(char *);
Index: src/usr.sbin/makemandb/apropos.1
diff -u src/usr.sbin/makemandb/apropos.1:1.6 src/usr.sbin/makemandb/apropos.1:1.7
--- src/usr.sbin/makemandb/apropos.1:1.6 Sat Oct 6 11:33:59 2012
+++ src/usr.sbin/makemandb/apropos.1 Sun Feb 10 18:58:28 2013
@@ -1,4 +1,4 @@
-.\" $NetBSD: apropos.1,v 1.6 2012/10/06 15:33:59 wiz Exp $
+.\" $NetBSD: apropos.1,v 1.7 2013/02/10 23:58:28 christos Exp $
.\"
.\" Copyright (c) 2011 Abhinav Upadhyay <[email protected]>
.\" All rights reserved.
@@ -29,7 +29,7 @@
.\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd October 5, 2012
+.Dd February 10, 2013
.Dt APROPOS 1
.Os
.Sh NAME
@@ -37,7 +37,7 @@
.Nd search the complete content of all man pages
.Sh SYNOPSIS
.Nm
-.Op Fl 123456789Ccp
+.Op Fl 123456789Ccpr
.Op Fl n Ar Number of results
.Op Fl S Ar machine
.Op Fl s Ar section
@@ -94,6 +94,8 @@ The default limit is 10.
.It Fl p
Display all matching results and pipe them through a pager (defaulting to
.Xr more 1 ) .
+.It Fl r
+On tty output don't issue any formatting escape codes.
.It Fl S Ar machine
Limit the search to the pages for the specified machine architecture.
By default pages for all architectures are shown in the search results.
Index: src/usr.sbin/makemandb/apropos.c
diff -u src/usr.sbin/makemandb/apropos.c:1.11 src/usr.sbin/makemandb/apropos.c:1.12
--- src/usr.sbin/makemandb/apropos.c:1.11 Sun Feb 10 18:24:18 2013
+++ src/usr.sbin/makemandb/apropos.c Sun Feb 10 18:58:28 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: apropos.c,v 1.11 2013/02/10 23:24:18 christos Exp $ */
+/* $NetBSD: apropos.c,v 1.12 2013/02/10 23:58:28 christos Exp $ */
/*-
* Copyright (c) 2011 Abhinav Upadhyay <[email protected]>
* All rights reserved.
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: apropos.c,v 1.11 2013/02/10 23:24:18 christos Exp $");
+__RCSID("$NetBSD: apropos.c,v 1.12 2013/02/10 23:58:28 christos Exp $");
#include <err.h>
#include <search.h>
@@ -49,6 +49,7 @@ typedef struct apropos_flags {
int nresults;
int pager;
int no_context;
+ int no_format;
const char *machine;
} apropos_flags;
@@ -90,7 +91,7 @@ main(int argc, char *argv[])
* index element in sec_nums is set to the string representing that
* section number.
*/
- while ((ch = getopt(argc, argv, "123456789Ccn:pS:s:")) != -1) {
+ while ((ch = getopt(argc, argv, "123456789Ccn:prS:s:")) != -1) {
switch (ch) {
case '1':
case '2':
@@ -116,6 +117,9 @@ main(int argc, char *argv[])
aflags.pager = 1;
aflags.nresults = -1; // Fetch all records
break;
+ case 'r':
+ aflags.no_format = 1;
+ break;
case 'S':
aflags.machine = optarg;
break;
@@ -171,7 +175,7 @@ main(int argc, char *argv[])
args.callback = &query_callback;
args.callback_data = &cbdata;
args.errmsg = &errmsg;
-
+ args.flags = aflags.no_format ? APROPOS_NOFORMAT : 0;
if (isatty(STDOUT_FILENO))
rc = run_query_term(db, &args);