Module Name: src
Committed By: christos
Date: Mon Jan 14 18:04:58 UTC 2013
Modified Files:
src/usr.sbin/makemandb: Makefile apropos.c
Log Message:
Fix the #ifdef NOTYET, namely use the terminal standout mode to highlight the
search terms.
To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/usr.sbin/makemandb/Makefile
cvs rdiff -u -r1.8 -r1.9 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/Makefile
diff -u src/usr.sbin/makemandb/Makefile:1.4 src/usr.sbin/makemandb/Makefile:1.5
--- src/usr.sbin/makemandb/Makefile:1.4 Mon Jan 14 13:01:59 2013
+++ src/usr.sbin/makemandb/Makefile Mon Jan 14 13:04:58 2013
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.4 2013/01/14 18:01:59 christos Exp $
+# $NetBSD: Makefile,v 1.5 2013/01/14 18:04:58 christos Exp $
.include <bsd.own.mk>
@@ -26,8 +26,8 @@ MDOCMLLIB= ${MDOCMLOBJDIR}/libmandoc.a
DPADD.makemandb+= ${MDOCMLLIB} ${LIBARCHIVE} ${LIBBZ2} ${LIBLZMA}
LDADD.makemandb+= -L${MDOCMLOBJDIR} -lmandoc -larchive -lbz2 -llzma
-DPADD+= ${LIBSQLITE3} ${LIBM} ${LIBZ} ${LIBUTIL}
-LDADD+= -lsqlite3 -lm -lz -lutil
+DPADD+= ${LIBSQLITE3} ${LIBM} ${LIBZ} ${LIBTERMLIB} ${LIBUTIL}
+LDADD+= -lsqlite3 -lm -lz -ltermlib -lutil
stopwords.c: stopwords.txt
( set -e; ${TOOL_NBPERF} -n stopwords_hash -s -p ${.ALLSRC}; \
Index: src/usr.sbin/makemandb/apropos.c
diff -u src/usr.sbin/makemandb/apropos.c:1.8 src/usr.sbin/makemandb/apropos.c:1.9
--- src/usr.sbin/makemandb/apropos.c:1.8 Sat Oct 6 11:33:59 2012
+++ src/usr.sbin/makemandb/apropos.c Mon Jan 14 13:04:58 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: apropos.c,v 1.8 2012/10/06 15:33:59 wiz Exp $ */
+/* $NetBSD: apropos.c,v 1.9 2013/01/14 18:04:58 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.8 2012/10/06 15:33:59 wiz Exp $");
+__RCSID("$NetBSD: apropos.c,v 1.9 2013/01/14 18:04:58 christos Exp $");
#include <err.h>
#include <search.h>
@@ -40,6 +40,7 @@ __RCSID("$NetBSD: apropos.c,v 1.8 2012/1
#include <string.h>
#include <unistd.h>
#include <util.h>
+#include <term.h>
#include "apropos-utils.h"
#include "sqlite3.h"
@@ -65,12 +66,40 @@ __dead static void usage(void);
#define _PATH_PAGER "/usr/bin/more -s"
+static int
+term_init(int fd, const char *sa[3])
+{
+ if (!isatty(fd))
+ return 0;
+
+ TERMINAL *ti;
+ int error;
+ if (ti_setupterm(&ti, NULL, fd, &error) == -1)
+ return 0;
+
+ const char *rmso = ti_getstr(ti, "rmso");
+ if (rmso == NULL)
+ goto out;
+
+ const char *smso = ti_getstr(ti, "smso");
+ if (smso == NULL)
+ goto out;
+
+ sa[0] = estrdup(smso);
+ sa[1] = estrdup(rmso);
+ sa[2] = estrdup("...");
+ del_curterm(ti);
+ return 1;
+out:
+ del_curterm(ti);
+ return 0;
+
+}
+
int
main(int argc, char *argv[])
{
-#ifdef NOTYET
- static const char *snippet_args[] = {"\033[1m", "\033[0m", "..."};
-#endif
+ const char *snippet_args[3];
query_args args;
char *query = NULL; // the user query
char *errmsg = NULL;
@@ -175,12 +204,12 @@ main(int argc, char *argv[])
args.callback_data = &cbdata;
args.errmsg = &errmsg;
-#ifdef NOTYET
- rc = run_query(db, snippet_args, &args);
-#else
- rc = run_query_pager(db, &args);
-#endif
+ if (term_init(STDOUT_FILENO, snippet_args))
+ rc = run_query(db, snippet_args, &args);
+ else
+ rc = run_query_pager(db, &args);
+
free(query);
close_db(db);
if (errmsg) {