Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.sbin/makemandb add -r flag to elide tty formatting
details: https://anonhg.NetBSD.org/src/rev/44c4d35a1eea
branches: trunk
changeset: 784836:44c4d35a1eea
user: christos <christos%NetBSD.org@localhost>
date: Sun Feb 10 23:58:27 2013 +0000
description:
add -r flag to elide tty formatting
diffstat:
usr.sbin/makemandb/apropos-utils.c | 11 ++++++++---
usr.sbin/makemandb/apropos-utils.h | 4 +++-
usr.sbin/makemandb/apropos.1 | 8 +++++---
usr.sbin/makemandb/apropos.c | 12 ++++++++----
4 files changed, 24 insertions(+), 11 deletions(-)
diffs (140 lines):
diff -r dd8bb410990f -r 44c4d35a1eea usr.sbin/makemandb/apropos-utils.c
--- a/usr.sbin/makemandb/apropos-utils.c Sun Feb 10 23:47:37 2013 +0000
+++ b/usr.sbin/makemandb/apropos-utils.c Sun Feb 10 23:58:27 2013 +0000
@@ -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@localhost>
* 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 @@
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;
diff -r dd8bb410990f -r 44c4d35a1eea usr.sbin/makemandb/apropos-utils.h
--- a/usr.sbin/makemandb/apropos-utils.h Sun Feb 10 23:47:37 2013 +0000
+++ b/usr.sbin/makemandb/apropos-utils.h Sun Feb 10 23:58:27 2013 +0000
@@ -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@localhost>
* All rights reserved.
@@ -79,6 +79,8 @@
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 *);
diff -r dd8bb410990f -r 44c4d35a1eea usr.sbin/makemandb/apropos.1
--- a/usr.sbin/makemandb/apropos.1 Sun Feb 10 23:47:37 2013 +0000
+++ b/usr.sbin/makemandb/apropos.1 Sun Feb 10 23:58:27 2013 +0000
@@ -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@localhost>
.\" 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 @@
.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.
diff -r dd8bb410990f -r 44c4d35a1eea usr.sbin/makemandb/apropos.c
--- a/usr.sbin/makemandb/apropos.c Sun Feb 10 23:47:37 2013 +0000
+++ b/usr.sbin/makemandb/apropos.c Sun Feb 10 23:58:27 2013 +0000
@@ -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@localhost>
* 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 @@
int nresults;
int pager;
int no_context;
+ int no_format;
const char *machine;
} apropos_flags;
@@ -90,7 +91,7 @@
* 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 @@
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 @@
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);
Home |
Main Index |
Thread Index |
Old Index