From cdbe3d3df7ca08989c4aaead5164309466e519eb Mon Sep 17 00:00:00 2001 From: "Thomas E. Dickey" Date: Mon, 3 Sep 2012 22:21:48 +0000 Subject: [PATCH 1/1] ncurses 5.9 - patch 20120903 + simplify varargs logic in lib_printw.c; va_copy is no longer needed there. + modifications for mingw port to make wide-character display usable. --- NEWS | 7 ++- dist.mk | 4 +- ncurses/base/lib_printw.c | 16 +++---- ncurses/tinfo/lib_setup.c | 6 ++- ncurses/win32con/win_driver.c | 88 +++++++++++++++++++++++++++++++---- package/debian/changelog | 4 +- package/ncurses.spec | 2 +- 7 files changed, 101 insertions(+), 26 deletions(-) diff --git a/NEWS b/NEWS index 6edf990a..5c328a3d 100644 --- a/NEWS +++ b/NEWS @@ -25,7 +25,7 @@ -- sale, use or other dealings in this Software without prior written -- -- authorization. -- ------------------------------------------------------------------------------- --- $Id: NEWS,v 1.1950 2012/09/02 16:59:41 tom Exp $ +-- $Id: NEWS,v 1.1952 2012/09/03 17:59:39 tom Exp $ ------------------------------------------------------------------------------- This is a log of changes that ncurses has gone through since Zeyd started @@ -45,6 +45,11 @@ See the AUTHORS file for the corresponding full names. Changes through 1.9.9e did not credit all contributions; it is not possible to add this information. +20120903 + + simplify varargs logic in lib_printw.c; va_copy is no longer needed + there. + + modifications for mingw port to make wide-character display usable. + 20120902 + regenerate configure script (report by Sven Joachim, cf: 20120901). diff --git a/dist.mk b/dist.mk index dadfee81..0c68bb09 100644 --- a/dist.mk +++ b/dist.mk @@ -25,7 +25,7 @@ # use or other dealings in this Software without prior written # # authorization. # ############################################################################## -# $Id: dist.mk,v 1.890 2012/09/02 16:58:18 tom Exp $ +# $Id: dist.mk,v 1.891 2012/09/03 12:47:40 tom Exp $ # Makefile for creating ncurses distributions. # # This only needs to be used directly as a makefile by developers, but @@ -37,7 +37,7 @@ SHELL = /bin/sh # These define the major/minor/patch versions of ncurses. NCURSES_MAJOR = 5 NCURSES_MINOR = 9 -NCURSES_PATCH = 20120902 +NCURSES_PATCH = 20120903 # We don't append the patch to the version, since this only applies to releases VERSION = $(NCURSES_MAJOR).$(NCURSES_MINOR) diff --git a/ncurses/base/lib_printw.c b/ncurses/base/lib_printw.c index 3064c260..56528f6b 100644 --- a/ncurses/base/lib_printw.c +++ b/ncurses/base/lib_printw.c @@ -27,7 +27,7 @@ ****************************************************************************/ /**************************************************************************** - * Author: Thomas E. Dickey 1997 * + * Author: Thomas E. Dickey 1997-on * ****************************************************************************/ /* @@ -39,7 +39,7 @@ #include -MODULE_ID("$Id: lib_printw.c,v 1.22 2012/03/10 20:47:33 tom Exp $") +MODULE_ID("$Id: lib_printw.c,v 1.23 2012/09/03 17:55:28 tom Exp $") NCURSES_EXPORT(int) printw(const char *fmt,...) @@ -49,11 +49,10 @@ printw(const char *fmt,...) #ifdef TRACE va_list argq; - begin_va_copy(argq, argp); va_start(argq, fmt); T((T_CALLED("printw(%s%s)"), _nc_visbuf(fmt), _nc_varargs(fmt, argq))); - end_va_copy(argq); + va_end(argq); #endif va_start(argp, fmt); @@ -71,11 +70,10 @@ wprintw(WINDOW *win, const char *fmt,...) #ifdef TRACE va_list argq; - begin_va_copy(argq, argp); va_start(argq, fmt); T((T_CALLED("wprintw(%p,%s%s)"), (void *) win, _nc_visbuf(fmt), _nc_varargs(fmt, argq))); - end_va_copy(argq); + va_end(argq); #endif va_start(argp, fmt); @@ -93,11 +91,10 @@ mvprintw(int y, int x, const char *fmt,...) #ifdef TRACE va_list argq; - begin_va_copy(argq, argp); va_start(argq, fmt); T((T_CALLED("mvprintw(%d,%d,%s%s)"), y, x, _nc_visbuf(fmt), _nc_varargs(fmt, argq))); - end_va_copy(argq); + va_end(argq); #endif if ((code = move(y, x)) != ERR) { @@ -116,11 +113,10 @@ mvwprintw(WINDOW *win, int y, int x, const char *fmt,...) #ifdef TRACE va_list argq; - begin_va_copy(argq, argp); va_start(argq, fmt); T((T_CALLED("mvwprintw(%d,%d,%p,%s%s)"), y, x, (void *) win, _nc_visbuf(fmt), _nc_varargs(fmt, argq))); - end_va_copy(argq); + va_end(argq); #endif if ((code = wmove(win, y, x)) != ERR) { diff --git a/ncurses/tinfo/lib_setup.c b/ncurses/tinfo/lib_setup.c index eb0bffb1..51030b6b 100644 --- a/ncurses/tinfo/lib_setup.c +++ b/ncurses/tinfo/lib_setup.c @@ -48,7 +48,7 @@ #include #endif -MODULE_ID("$Id: lib_setup.c,v 1.148 2012/07/21 18:05:41 tom Exp $") +MODULE_ID("$Id: lib_setup.c,v 1.149 2012/09/03 16:19:14 tom Exp $") /**************************************************************************** * @@ -546,7 +546,9 @@ NCURSES_EXPORT(int) _nc_unicode_locale(void) { int result = 0; -#if HAVE_LANGINFO_CODESET +#if defined(__MINGW32__) && USE_WIDEC_SUPPORT + result = 1; +#elif HAVE_LANGINFO_CODESET char *env = nl_langinfo(CODESET); result = !strcmp(env, "UTF-8"); T(("_nc_unicode_locale(%s) ->%d", env, result)); diff --git a/ncurses/win32con/win_driver.c b/ncurses/win32con/win_driver.c index 9122513a..afc1a168 100644 --- a/ncurses/win32con/win_driver.c +++ b/ncurses/win32con/win_driver.c @@ -38,7 +38,7 @@ #include #define CUR my_term.type. -MODULE_ID("$Id: win_driver.c,v 1.11 2012/02/18 20:28:25 tom Exp $") +MODULE_ID("$Id: win_driver.c,v 1.13 2012/09/03 16:20:24 tom Exp $") #define WINMAGIC NCDRV_MAGIC(NCDRV_WINCONSOLE) @@ -102,7 +102,7 @@ MapColor(bool fore, int color) } static WORD -MapAttr(TERMINAL_CONTROL_BLOCK * TCB, WORD res, chtype ch) +MapAttr(TERMINAL_CONTROL_BLOCK * TCB, WORD res, attr_t ch) { if (ch & A_COLOR) { int p; @@ -134,8 +134,67 @@ MapAttr(TERMINAL_CONTROL_BLOCK * TCB, WORD res, chtype ch) return res; } +#if USE_WIDEC_SUPPORT +/* + * TODO: support surrogate pairs + * TODO: support combining characters + * TODO: support acsc + * TODO: check wcwidth of base character, fill if needed for double-width + * TODO: _nc_wacs should be part of sp. + */ static BOOL -con_write(TERMINAL_CONTROL_BLOCK * TCB, int y, int x, chtype *str, int n) +con_write16(TERMINAL_CONTROL_BLOCK * TCB, int y, int x, cchar_t *str, int n) +{ + CHAR_INFO ci[n]; + COORD loc, siz; + SMALL_RECT rec; + int i; + cchar_t ch; + SCREEN *sp; + + AssertTCB(); + + if (TCB == 0 || InvalidConsoleHandle(TCB->hdl)) + return FALSE; + + SetSP(); + + for (i = 0; i < n; i++) { + ch = str[i]; + ci[i].Char.UnicodeChar = CharOf(ch); + ci[i].Attributes = MapAttr(TCB, + PropOf(TCB)->SBI.wAttributes, + AttrOf(ch)); + if (AttrOf(ch) & A_ALTCHARSET) { + if (_nc_wacs) { + int which = CharOf(ch); + if (which > 0 + && which < ACS_LEN + && CharOf(_nc_wacs[which]) != 0) { + ci[i].Char.UnicodeChar = CharOf(_nc_wacs[which]); + } else { + ci[i].Char.UnicodeChar = ' '; + } + } + } + } + + loc.X = (short) 0; + loc.Y = (short) 0; + siz.X = (short) n; + siz.Y = 1; + + rec.Left = (short) x; + rec.Top = (short) y; + rec.Right = (short) (x + n - 1); + rec.Bottom = rec.Top; + + return WriteConsoleOutputW(TCB->hdl, ci, siz, loc, &rec); +} +#define con_write(tcb, y, x, str, n) con_write16(tcb, y, x, str, n) +#else +static BOOL +con_write8(TERMINAL_CONTROL_BLOCK * TCB, int y, int x, chtype *str, int n) { CHAR_INFO ci[n]; COORD loc, siz; @@ -176,6 +235,8 @@ con_write(TERMINAL_CONTROL_BLOCK * TCB, int y, int x, chtype *str, int n) return WriteConsoleOutput(TCB->hdl, ci, siz, loc, &rec); } +#define con_write(tcb, y, x, str, n) con_write8(tcb, y, x, str, n) +#endif #define MARK_NOCHANGE(win,row) \ win->_line[row].firstchar = _NOCHANGE; \ @@ -196,16 +257,27 @@ drv_doupdate(TERMINAL_CONTROL_BLOCK * TCB) if ((CurScreen(sp)->_clear || NewScreen(sp)->_clear)) { int x; +#if USE_WIDEC_SUPPORT + cchar_t empty[Width]; + wchar_t blank[2] = + { + L' ', L'\0' + }; + + for (x = 0; x < Width; x++) + setcchar(&empty[x], blank, 0, 0, 0); +#else chtype empty[Width]; for (x = 0; x < Width; x++) empty[x] = ' '; +#endif for (y = 0; y < nonempty; y++) { con_write(TCB, y, 0, empty, Width); memcpy(empty, CurScreen(sp)->_line[y].text, - Width * sizeof(chtype)); + Width * sizeof(empty[0])); } CurScreen(sp)->_clear = FALSE; NewScreen(sp)->_clear = FALSE; @@ -218,13 +290,13 @@ drv_doupdate(TERMINAL_CONTROL_BLOCK * TCB) x1 = NewScreen(sp)->_line[y].lastchar; n = x1 - x0 + 1; if (n > 0) { - memcpy(CurScreen(sp)->_line[y].text + x0, - NewScreen(sp)->_line[y].text + x0, - n * sizeof(chtype)); + memcpy(&CurScreen(sp)->_line[y].text[x0], + &NewScreen(sp)->_line[y].text[x0], + n * sizeof(CurScreen(sp)->_line[y].text[x0])); con_write(TCB, y, x0, - ((chtype *) CurScreen(sp)->_line[y].text) + x0, n); + &CurScreen(sp)->_line[y].text[x0], n); /* mark line changed successfully */ if (y <= NewScreen(sp)->_maxy) { diff --git a/package/debian/changelog b/package/debian/changelog index 726b844f..90f22122 100644 --- a/package/debian/changelog +++ b/package/debian/changelog @@ -1,8 +1,8 @@ -ncurses6 (5.9-20120902) unstable; urgency=low +ncurses6 (5.9-20120903) unstable; urgency=low * latest weekly patch - -- Thomas E. Dickey Sun, 02 Sep 2012 12:58:41 -0400 + -- Thomas E. Dickey Mon, 03 Sep 2012 08:47:49 -0400 ncurses6 (5.9-20120608) unstable; urgency=low diff --git a/package/ncurses.spec b/package/ncurses.spec index 654ffa99..cb377fee 100644 --- a/package/ncurses.spec +++ b/package/ncurses.spec @@ -1,7 +1,7 @@ Summary: shared libraries for terminal handling Name: ncurses6 Release: 5.9 -Version: 20120902 +Version: 20120903 License: X11 Group: Development/Libraries Source: ncurses-%{release}-%{version}.tgz -- 2.45.0