Source-Changes-HG archive

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

[src/netbsd-7]: src/usr.sbin/makemandb Pull up following revision(s) (request...



details:   https://anonhg.NetBSD.org/src/rev/85fe1edf3a6e
branches:  netbsd-7
changeset: 799878:85fe1edf3a6e
user:      snj <snj%NetBSD.org@localhost>
date:      Fri Apr 15 07:47:29 2016 +0000

description:
Pull up following revision(s) (requested by christos in ticket #1142):
        usr.sbin/makemandb/apropos-utils.c: revisions 1.18, 1.19
CID 1341551: Don't bother formatting if ti == NULL
--
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).

diffstat:

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

diffs (72 lines):

diff -r 7f37b20a01cc -r 85fe1edf3a6e usr.sbin/makemandb/apropos-utils.c
--- a/usr.sbin/makemandb/apropos-utils.c        Tue Apr 12 06:36:33 2016 +0000
+++ b/usr.sbin/makemandb/apropos-utils.c        Fri Apr 15 07:47:29 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: apropos-utils.c,v 1.16 2014/08/01 12:55:00 wiz Exp $   */
+/*     $NetBSD: apropos-utils.c,v 1.16.2.1 2016/04/15 07:47:29 snj 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.16 2014/08/01 12:55:00 wiz Exp $");
+__RCSID("$NetBSD: apropos-utils.c,v 1.16.2.1 2016/04/15 07:47:29 snj Exp $");
 
 #include <sys/queue.h>
 #include <sys/stat.h>
@@ -891,6 +891,36 @@
        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;
+
+       if (ti == NULL)
+           return res;
+
+       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 +950,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