Source-Changes-HG archive

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

[src/trunk]: src/lib/libcurses winwrite - using addch() on individual bytes o...



details:   https://anonhg.NetBSD.org/src/rev/233447ec4577
branches:  trunk
changeset: 449913:233447ec4577
user:      uwe <uwe%NetBSD.org@localhost>
date:      Thu Mar 28 23:24:22 2019 +0000

description:
winwrite - using addch() on individual bytes of e.g. UTF-8 encoding
doesn't work that well.  addstr() the whole buffer instead.  This is
still not enirely correct b/c printf can run out of stdio buffer
mid-character for very long output, but deal with it later.

diffstat:

 lib/libcurses/printw.c |  17 +++++++----------
 1 files changed, 7 insertions(+), 10 deletions(-)

diffs (39 lines):

diff -r 5a302a109fda -r 233447ec4577 lib/libcurses/printw.c
--- a/lib/libcurses/printw.c    Thu Mar 28 20:26:49 2019 +0000
+++ b/lib/libcurses/printw.c    Thu Mar 28 23:24:22 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: printw.c,v 1.25 2019/03/21 21:28:55 uwe Exp $  */
+/*     $NetBSD: printw.c,v 1.26 2019/03/28 23:24:22 uwe Exp $  */
 
 /*
  * Copyright (c) 1981, 1993, 1994
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)printw.c   8.3 (Berkeley) 5/4/94";
 #else
-__RCSID("$NetBSD: printw.c,v 1.25 2019/03/21 21:28:55 uwe Exp $");
+__RCSID("$NetBSD: printw.c,v 1.26 2019/03/28 23:24:22 uwe Exp $");
 #endif
 #endif                         /* not lint */
 
@@ -118,15 +118,12 @@
 {
        WINDOW *win = cookie;
        const char *buf = vbuf;
-       size_t c;
+       int status;
 
-       for (c = 0; c < n; c++) {
-#ifdef DEBUG
-               __CTRACE(__CTRACE_MISC, "__winwrite: %c\n", *buf);
-#endif
-               if (waddch(win, (chtype) (*buf++ & __CHARTEXT)) == ERR)
-                       return -1;
-       }
+       status = waddnstr(win, buf, n);
+       if (status == ERR)
+           return -1;
+
        return (ssize_t)n;
 }
 /*



Home | Main Index | Thread Index | Old Index