From 1edeced67c1cacefe83444e5fd403dab73529ebf Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Wed, 11 Jul 2012 11:23:32 -0700 Subject: [PATCH] Fix vtputc() and simplify show_line by using it again This re-introduces vtputc() as the way to show characters, which reinstates the control character handing, and simplifies show_line() in the process. vtputc now takes an "int" that is either a unicode character or a signed char (so negative values in the range [-1, -128] are considered to be the same as [128, 255]). This allows us to use it regardless of what the source of data is. Signed-off-by: Linus Torvalds --- display.c | 34 ++++++++++------------------------ 1 file changed, 10 insertions(+), 24 deletions(-) diff --git a/display.c b/display.c index 326dc9e..5323c30 100644 --- a/display.c +++ b/display.c @@ -164,10 +164,17 @@ void vtmove(int row, int col) * This routine only puts printing characters into the virtual * terminal buffers. Only column overflow is checked. */ -static void vtputc(unsigned char c) +static void vtputc(int c) { struct video *vp; /* ptr to line being updated */ + /* In case somebody passes us a signed char.. */ + if (c < 0) { + c += 256; + if (c < 0) + return; + } + vp = vscreen[vtrow]; if (vtcol >= term.t_ncol) { @@ -436,32 +443,11 @@ static int reframe(struct window *wp) static void show_line(struct line *lp) { unsigned i = 0, len = llength(lp); - struct video *vp; - - vp = vscreen[vtrow]; while (i < len) { unicode_t c; - int n; - - if (vtcol >= term.t_ncol) { - vp->v_text[term.t_ncol - 1] = '$'; - return; - } - n = utf8_to_unicode(lp->l_text, i, len, &c); - /* - * Change tabs into spaces, and don't increment - * the text source until we hit tabmask - */ - ++vtcol; - if (c == '\t') { - c = ' '; - if (vtcol & tabmask) - n = 0; - } - if (vtcol > 0) - vp->v_text[vtcol-1] = c; - i += n; + i += utf8_to_unicode(lp->l_text, i, len, &c); + vtputc(c); } }