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
This commit is contained in:
parent
6cf6af127d
commit
62025e09ce
@ -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>
|
||||
* 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 @@ run_query_pager(sqlite3 *db, query_args *args)
|
||||
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 @@ term_init(int fd, const char *sa[5])
|
||||
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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user