add -r flag to elide tty formatting
This commit is contained in:
parent
50c5afcad4
commit
9d0d34e51f
|
@ -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 <er.abhinav.upadhyay@gmail.com>
|
||||
* 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 *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;
|
||||
|
|
|
@ -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 <er.abhinav.upadhyay@gmail.com>
|
||||
* 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 *);
|
||||
|
|
|
@ -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 <er.abhinav.upadhyay@gmail.com>
|
||||
.\" 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.
|
||||
|
|
|
@ -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 <er.abhinav.upadhyay@gmail.com>
|
||||
* 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);
|
||||
|
|
Loading…
Reference in New Issue