Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/makemandb PR/50344: Stephen Fisher: apropos shows f...



details:   https://anonhg.NetBSD.org/src/rev/f572049d651e
branches:  trunk
changeset: 341807:f572049d651e
user:      christos <christos%NetBSD.org@localhost>
date:      Mon Nov 23 22:34:00 2015 +0000

description:
PR/50344: Stephen Fisher: apropos shows formatting on console with vt100 term
type. Can't print terminfo sequences directly; need to process them with
ti_puts() to handle padding. This removes the padding delays, and stricly
could break on slow terminal hardware, but they way the code is structured
makes it impossible to fix properly (since the formatting strings are
passed in the query).
XXX: pullup-7

diffstat:

 usr.sbin/makemandb/apropos-utils.c |  40 ++++++++++++++++++++++++++++++++-----
 1 files changed, 34 insertions(+), 6 deletions(-)

diffs (69 lines):

diff -r 4faf263133fb -r f572049d651e usr.sbin/makemandb/apropos-utils.c
--- a/usr.sbin/makemandb/apropos-utils.c        Mon Nov 23 22:20:57 2015 +0000
+++ b/usr.sbin/makemandb/apropos-utils.c        Mon Nov 23 22:34:00 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: apropos-utils.c,v 1.17 2014/10/18 08:33:31 snj Exp $   */
+/*     $NetBSD: apropos-utils.c,v 1.18 2015/11/23 22:34:00 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.17 2014/10/18 08:33:31 snj Exp $");
+__RCSID("$NetBSD: apropos-utils.c,v 1.18 2015/11/23 22:34:00 christos Exp $");
 
 #include <sys/queue.h>
 #include <sys/stat.h>
@@ -891,6 +891,33 @@
        return run_query_internal(db, snippet_args, args);
 }
 
+struct nv {
+       char *s;
+       size_t l;
+};
+
+static int
+term_putc(int c, void *p)
+{
+       struct nv *nv = p;
+       nv->s[nv->l++] = c;
+       return 0;
+}
+
+static char *
+term_fix_seq(TERMINAL *ti, const char *seq)
+{
+       char *res = estrdup(seq);
+       struct nv nv;
+
+       nv.s = res;
+       nv.l = 0;
+       ti_puts(ti, seq, 1, term_putc, &nv);
+       nv.s[nv.l] = '\0';
+
+       return res;
+}
+
 static void
 term_init(int fd, const char *sa[5])
 {
@@ -920,11 +947,12 @@
                        smul = rmul = "";
        }
 
-       sa[0] = estrdup(bold ? bold : smso);
-       sa[1] = estrdup(sgr0 ? sgr0 : rmso);
+       sa[0] = term_fix_seq(ti, bold ? bold : smso);
+       sa[1] = term_fix_seq(ti, sgr0 ? sgr0 : rmso);
        sa[2] = estrdup("...");
-       sa[3] = estrdup(smul);
-       sa[4] = estrdup(rmul);
+       sa[3] = term_fix_seq(ti, smul);
+       sa[4] = term_fix_seq(ti, rmul);
+
        if (ti)
                del_curterm(ti);
 }



Home | Main Index | Thread Index | Old Index