CVS commit: src/lib/libcurses
Module Name:src Committed By: rillig Date: Sun Aug 15 15:12:36 UTC 2021 Modified Files: src/lib/libcurses: get_wstr.c getstr.c in_wchstr.c inchstr.c instr.c inwstr.c Log Message: libcurses: fix usage of __warn_references Since that macro can expand to an empty token list, it adds its own semicolon as needed. Removing the extra semicolon fixes the lint warnings about empty declarations. These empty declarations are a GCC extension. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/lib/libcurses/get_wstr.c \ src/lib/libcurses/in_wchstr.c src/lib/libcurses/inwstr.c cvs rdiff -u -r1.27 -r1.28 src/lib/libcurses/getstr.c cvs rdiff -u -r1.10 -r1.11 src/lib/libcurses/inchstr.c cvs rdiff -u -r1.7 -r1.8 src/lib/libcurses/instr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/get_wstr.c diff -u src/lib/libcurses/get_wstr.c:1.8 src/lib/libcurses/get_wstr.c:1.9 --- src/lib/libcurses/get_wstr.c:1.8 Sun Jun 9 07:40:14 2019 +++ src/lib/libcurses/get_wstr.c Sun Aug 15 15:12:36 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: get_wstr.c,v 1.8 2019/06/09 07:40:14 blymn Exp $ */ +/* $NetBSD: get_wstr.c,v 1.9 2021/08/15 15:12:36 rillig Exp $ */ /* * Copyright (c) 2005 The NetBSD Foundation Inc. @@ -36,7 +36,7 @@ #include #ifndef lint -__RCSID("$NetBSD: get_wstr.c,v 1.8 2019/06/09 07:40:14 blymn Exp $"); +__RCSID("$NetBSD: get_wstr.c,v 1.9 2021/08/15 15:12:36 rillig Exp $"); #endif /* not lint */ #include "curses.h" @@ -61,7 +61,7 @@ getn_wstr(wchar_t *wstr, int n) * Get a string from stdscr starting at (cury, curx). */ __warn_references(get_wstr, - "warning: this program uses get_wstr(), which is unsafe."); + "warning: this program uses get_wstr(), which is unsafe.") int get_wstr(wchar_t *wstr) { @@ -83,7 +83,7 @@ mvgetn_wstr(int y, int x, wchar_t *wstr, * Get a string from stdscr starting at (y, x). */ __warn_references(mvget_wstr, - "warning: this program uses mvget_wstr(), which is unsafe."); + "warning: this program uses mvget_wstr(), which is unsafe.") int mvget_wstr(int y, int x, wchar_t *wstr) { @@ -109,7 +109,7 @@ mvwgetn_wstr(WINDOW *win, int y, int x, * Get a string from the given window starting at (y, x). */ __warn_references(mvget_wstr, - "warning: this program uses mvget_wstr(), which is unsafe."); + "warning: this program uses mvget_wstr(), which is unsafe.") int mvwget_wstr(WINDOW *win, int y, int x, wchar_t *wstr) { @@ -124,7 +124,7 @@ mvwget_wstr(WINDOW *win, int y, int x, w * Get a string starting at (cury, curx). */ __warn_references(wget_wstr, - "warning: this program uses wget_wstr(), which is unsafe."); + "warning: this program uses wget_wstr(), which is unsafe.") int wget_wstr(WINDOW *win, wchar_t *wstr) { Index: src/lib/libcurses/in_wchstr.c diff -u src/lib/libcurses/in_wchstr.c:1.8 src/lib/libcurses/in_wchstr.c:1.9 --- src/lib/libcurses/in_wchstr.c:1.8 Sun Jun 9 07:40:14 2019 +++ src/lib/libcurses/in_wchstr.c Sun Aug 15 15:12:36 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: in_wchstr.c,v 1.8 2019/06/09 07:40:14 blymn Exp $ */ +/* $NetBSD: in_wchstr.c,v 1.9 2021/08/15 15:12:36 rillig Exp $ */ /* * Copyright (c) 2005 The NetBSD Foundation Inc. @@ -36,7 +36,7 @@ #include #ifndef lint -__RCSID("$NetBSD: in_wchstr.c,v 1.8 2019/06/09 07:40:14 blymn Exp $"); +__RCSID("$NetBSD: in_wchstr.c,v 1.9 2021/08/15 15:12:36 rillig Exp $"); #endif /* not lint */ #include "curses.h" @@ -47,7 +47,7 @@ __RCSID("$NetBSD: in_wchstr.c,v 1.8 2019 * Return an array of wide characters at cursor position from stdscr. */ __warn_references(in_wchstr, - "warning: this program uses in_wchstr(), which is unsafe."); + "warning: this program uses in_wchstr(), which is unsafe.") int in_wchstr(cchar_t *wchstr) { @@ -65,7 +65,7 @@ in_wchnstr(cchar_t *wchstr, int n) * Return an array of wide characters at position (y, x) from stdscr. */ __warn_references(mvin_wchstr, - "warning: this program uses mvin_wchstr(), which is unsafe."); + "warning: this program uses mvin_wchstr(), which is unsafe.") int mvin_wchstr(int y, int x, cchar_t *wchstr) { @@ -83,7 +83,7 @@ mvin_wchnstr(int y, int x, cchar_t *wchs * Return an array wide characters at position (y, x) from the given window. */ __warn_references(mvwin_wchstr, - "warning: this program uses mvwin_wchstr(), which is unsafe."); + "warning: this program uses mvwin_wchstr(), which is unsafe.") int mvwin_wchstr(WINDOW *win, int y, int x, cchar_t *wchstr) { @@ -107,7 +107,7 @@ mvwin_wchnstr(WINDOW *win, int y, int x, * Return an array of characters at cursor position. */ __warn_references(win_wchstr, - "warning: this program uses win_wchstr(), which is unsafe."); + "warning: this program uses win_wchstr(), which is unsafe.") int win_wchstr(WINDOW *win, cchar_t *wchstr) { Index: src/lib/libcurses/inwstr.c diff -u src/lib/libcurses/inwstr.c
CVS commit: src/lib/libcurses
Module Name:src Committed By: christos Date: Sun Aug 15 12:39:39 UTC 2021 Modified Files: src/lib/libcurses: curses_private.h slk.c Log Message: This is a mess; always define MB_LEN_MAX so both the regular and libhack version of curses compiles. Really we should not be defining MB_LEN_MAX here, and include in curses_private.h to get it. To generate a diff of this commit: cvs rdiff -u -r1.73 -r1.74 src/lib/libcurses/curses_private.h cvs rdiff -u -r1.13 -r1.14 src/lib/libcurses/slk.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/curses_private.h diff -u src/lib/libcurses/curses_private.h:1.73 src/lib/libcurses/curses_private.h:1.74 --- src/lib/libcurses/curses_private.h:1.73 Sat Mar 14 21:12:47 2020 +++ src/lib/libcurses/curses_private.h Sun Aug 15 08:39:39 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: curses_private.h,v 1.73 2020/03/15 01:12:47 uwe Exp $ */ +/* $NetBSD: curses_private.h,v 1.74 2021/08/15 12:39:39 christos Exp $ */ /*- * Copyright (c) 1998-2000 Brett Lymn @@ -299,8 +299,14 @@ struct __screen { bool slk_hidden; struct __slk_label *slk_labels; -#ifdef HAVE_WCHAR +/* + * XXX: This conflicts with the value in (32) + * which should be used here instead of defining a different value, + * but I am not changing it because it is also used in the WCOL() + * macro and I don't understand the effects of it. + */ #define MB_LEN_MAX 8 +#ifdef HAVE_WCHAR #define MAX_CBUF_SIZE MB_LEN_MAX int cbuf_head; /* header to cbuf */ int cbuf_tail; /* tail to cbuf */ Index: src/lib/libcurses/slk.c diff -u src/lib/libcurses/slk.c:1.13 src/lib/libcurses/slk.c:1.14 --- src/lib/libcurses/slk.c:1.13 Sun Aug 15 07:54:12 2021 +++ src/lib/libcurses/slk.c Sun Aug 15 08:39:39 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: slk.c,v 1.13 2021/08/15 11:54:12 christos Exp $ */ +/* $NetBSD: slk.c,v 1.14 2021/08/15 12:39:39 christos Exp $ */ /*- * Copyright (c) 2017 The NetBSD Foundation, Inc. @@ -31,13 +31,12 @@ #include #ifndef lint -__RCSID("$NetBSD: slk.c,v 1.13 2021/08/15 11:54:12 christos Exp $"); +__RCSID("$NetBSD: slk.c,v 1.14 2021/08/15 12:39:39 christos Exp $"); #endif/* not lint */ #include #include #include -#include #ifdef HAVE_WCHAR #include #endif
CVS commit: src/lib/libcurses
Module Name:src Committed By: christos Date: Sun Aug 15 11:54:12 UTC 2021 Modified Files: src/lib/libcurses: slk.c Log Message: need limits.h To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/lib/libcurses/slk.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/slk.c diff -u src/lib/libcurses/slk.c:1.12 src/lib/libcurses/slk.c:1.13 --- src/lib/libcurses/slk.c:1.12 Sun Aug 15 07:44:39 2021 +++ src/lib/libcurses/slk.c Sun Aug 15 07:54:12 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: slk.c,v 1.12 2021/08/15 11:44:39 christos Exp $ */ +/* $NetBSD: slk.c,v 1.13 2021/08/15 11:54:12 christos Exp $ */ /*- * Copyright (c) 2017 The NetBSD Foundation, Inc. @@ -31,12 +31,13 @@ #include #ifndef lint -__RCSID("$NetBSD: slk.c,v 1.12 2021/08/15 11:44:39 christos Exp $"); +__RCSID("$NetBSD: slk.c,v 1.13 2021/08/15 11:54:12 christos Exp $"); #endif/* not lint */ #include #include #include +#include #ifdef HAVE_WCHAR #include #endif
CVS commit: src/lib/libcurses
Module Name:src Committed By: christos Date: Sun Aug 15 11:44:39 UTC 2021 Modified Files: src/lib/libcurses: slk.c Log Message: Use MBL_LEN_MAX (constant) so that SSP works To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/lib/libcurses/slk.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/slk.c diff -u src/lib/libcurses/slk.c:1.11 src/lib/libcurses/slk.c:1.12 --- src/lib/libcurses/slk.c:1.11 Thu Jun 24 11:41:25 2021 +++ src/lib/libcurses/slk.c Sun Aug 15 07:44:39 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: slk.c,v 1.11 2021/06/24 15:41:25 martin Exp $ */ +/* $NetBSD: slk.c,v 1.12 2021/08/15 11:44:39 christos Exp $ */ /*- * Copyright (c) 2017 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include #ifndef lint -__RCSID("$NetBSD: slk.c,v 1.11 2021/06/24 15:41:25 martin Exp $"); +__RCSID("$NetBSD: slk.c,v 1.12 2021/08/15 11:44:39 christos Exp $"); #endif/* not lint */ #include @@ -818,7 +818,7 @@ __slk_draw(SCREEN *screen, int labnum) { const struct __slk_label *l; int retval, inc, lcnt, tx; - char ts[MB_CUR_MAX]; + char ts[MB_LEN_MAX]; #ifdef HAVE_WCHAR cchar_t cc; wchar_t wc[2];
CVS commit: src/lib/libcurses
Module Name:src Committed By: nia Date: Tue Aug 3 07:58:50 UTC 2021 Modified Files: src/lib/libcurses: curses_attributes.3 curses_standout.3 Log Message: curses: clarify standout as the "best" _supported_ highlighting mode of the current terminal To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/lib/libcurses/curses_attributes.3 cvs rdiff -u -r1.9 -r1.10 src/lib/libcurses/curses_standout.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/curses_attributes.3 diff -u src/lib/libcurses/curses_attributes.3:1.10 src/lib/libcurses/curses_attributes.3:1.11 --- src/lib/libcurses/curses_attributes.3:1.10 Mon Aug 2 11:11:20 2021 +++ src/lib/libcurses/curses_attributes.3 Tue Aug 3 07:58:50 2021 @@ -1,4 +1,4 @@ -.\" $NetBSD: curses_attributes.3,v 1.10 2021/08/02 11:11:20 nia Exp $ +.\" $NetBSD: curses_attributes.3,v 1.11 2021/08/03 07:58:50 nia Exp $ .\" Copyright (c) 2002 The NetBSD Foundation, Inc. .\" All rights reserved. .\" @@ -102,7 +102,8 @@ The attributes that can be manipulated a .It A_NORMAL no special attributes are applied .It A_STANDOUT -characters are displayed in the "best" highlighting mode of the terminal +characters are displayed in the "best" supported highlighting mode of the +terminal .It A_UNDERLINE characters are displayed underlined .It A_REVERSE @@ -193,7 +194,8 @@ The additional wide attributes that can .Pp .Bl -tag -width "COLOR_PAIR(n)" -compact -offset indent .It WA_STANDOUT -characters are displayed in the "best" highlighting mode of the terminal +characters are displayed in the "best" supported highlighting mode of the +terminal .It WA_UNDERLINE characters are displayed underlined .It WA_REVERSE Index: src/lib/libcurses/curses_standout.3 diff -u src/lib/libcurses/curses_standout.3:1.9 src/lib/libcurses/curses_standout.3:1.10 --- src/lib/libcurses/curses_standout.3:1.9 Mon Aug 2 11:11:20 2021 +++ src/lib/libcurses/curses_standout.3 Tue Aug 3 07:58:50 2021 @@ -1,4 +1,4 @@ -.\" $NetBSD: curses_standout.3,v 1.9 2021/08/02 11:11:20 nia Exp $ +.\" $NetBSD: curses_standout.3,v 1.10 2021/08/03 07:58:50 nia Exp $ .\" Copyright (c) 2002 The NetBSD Foundation, Inc. .\" All rights reserved. .\" @@ -55,7 +55,7 @@ These functions manipulate the standout attribute on .Dv stdscr or on the specified window. -The standout attribute applies the "best highlighting mode" +The standout attribute applies the "best" supported highlighting mode supported by the current terminal, which may be an alias of other attributes. .Pp
CVS commit: src/lib/libcurses
Module Name:src Committed By: nia Date: Mon Aug 2 11:11:20 UTC 2021 Modified Files: src/lib/libcurses: curses_attributes.3 curses_standout.3 Log Message: curses: clarify documentation regarding the standout attribute To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/lib/libcurses/curses_attributes.3 cvs rdiff -u -r1.8 -r1.9 src/lib/libcurses/curses_standout.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/curses_attributes.3 diff -u src/lib/libcurses/curses_attributes.3:1.9 src/lib/libcurses/curses_attributes.3:1.10 --- src/lib/libcurses/curses_attributes.3:1.9 Thu Oct 25 10:36:56 2018 +++ src/lib/libcurses/curses_attributes.3 Mon Aug 2 11:11:20 2021 @@ -1,4 +1,4 @@ -.\" $NetBSD: curses_attributes.3,v 1.9 2018/10/25 10:36:56 uwe Exp $ +.\" $NetBSD: curses_attributes.3,v 1.10 2021/08/02 11:11:20 nia Exp $ .\" Copyright (c) 2002 The NetBSD Foundation, Inc. .\" All rights reserved. .\" @@ -25,7 +25,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd October 25, 2018 +.Dd July 27, 2021 .Dt CURSES_ATTRIBUTES 3 .Os .Sh NAME @@ -102,7 +102,7 @@ The attributes that can be manipulated a .It A_NORMAL no special attributes are applied .It A_STANDOUT -characters are displayed in standout mode +characters are displayed in the "best" highlighting mode of the terminal .It A_UNDERLINE characters are displayed underlined .It A_REVERSE @@ -193,7 +193,7 @@ The additional wide attributes that can .Pp .Bl -tag -width "COLOR_PAIR(n)" -compact -offset indent .It WA_STANDOUT -characters are displayed in standout mode +characters are displayed in the "best" highlighting mode of the terminal .It WA_UNDERLINE characters are displayed underlined .It WA_REVERSE @@ -336,7 +336,10 @@ extension. .Sh HISTORY These functions first appeared in .Nx 1.5 . -.Sh BUGS +.Sh CAVEATS Some terminals do not support characters with both color and other attributes set. In this case, the other attribute is displayed instead of the color attribute. +.Pp +The standout attribute is a higher level alias and should not be mixed with +other attributes. Index: src/lib/libcurses/curses_standout.3 diff -u src/lib/libcurses/curses_standout.3:1.8 src/lib/libcurses/curses_standout.3:1.9 --- src/lib/libcurses/curses_standout.3:1.8 Mon Jul 26 20:17:09 2021 +++ src/lib/libcurses/curses_standout.3 Mon Aug 2 11:11:20 2021 @@ -1,4 +1,4 @@ -.\" $NetBSD: curses_standout.3,v 1.8 2021/07/26 20:17:09 nia Exp $ +.\" $NetBSD: curses_standout.3,v 1.9 2021/08/02 11:11:20 nia Exp $ .\" Copyright (c) 2002 The NetBSD Foundation, Inc. .\" All rights reserved. .\" @@ -25,7 +25,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd July 26, 2021 +.Dd July 27, 2021 .Dt CURSES_STANDOUT 3 .Os .Sh NAME @@ -55,6 +55,9 @@ These functions manipulate the standout attribute on .Dv stdscr or on the specified window. +The standout attribute applies the "best highlighting mode" +supported by the current terminal, which may be an alias of +other attributes. .Pp The .Fn standout @@ -101,3 +104,9 @@ Single Unix Specification. .Sh HISTORY The Curses package appeared in .Bx 4.0 . +.Sh CAVEATS +On some terminals, characters with standout set may have the same appearance +as characters with the reverse video or bold attribute set. +However, on legacy terminals, standout may be the only attribute that can be +used to emphasize characters. +The standout attribute should not be mixed with other attributes.
CVS commit: src/lib/libcurses
Module Name:src Committed By: nia Date: Mon Jul 26 20:17:10 UTC 2021 Modified Files: src/lib/libcurses: curses_standout.3 Log Message: The BUGS sections is incorrect again for "modern" terminals. For example, wscons and xterm both display standout differently to bold. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/lib/libcurses/curses_standout.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/curses_standout.3 diff -u src/lib/libcurses/curses_standout.3:1.7 src/lib/libcurses/curses_standout.3:1.8 --- src/lib/libcurses/curses_standout.3:1.7 Tue Nov 29 17:33:48 2016 +++ src/lib/libcurses/curses_standout.3 Mon Jul 26 20:17:09 2021 @@ -1,4 +1,4 @@ -.\" $NetBSD: curses_standout.3,v 1.7 2016/11/29 17:33:48 christos Exp $ +.\" $NetBSD: curses_standout.3,v 1.8 2021/07/26 20:17:09 nia Exp $ .\" Copyright (c) 2002 The NetBSD Foundation, Inc. .\" All rights reserved. .\" @@ -25,7 +25,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd November 29, 2016 +.Dd July 26, 2021 .Dt CURSES_STANDOUT 3 .Os .Sh NAME @@ -101,8 +101,3 @@ Single Unix Specification. .Sh HISTORY The Curses package appeared in .Bx 4.0 . -.Sh BUGS -On modern terminals that support other attributes, there is no difference -between characters displayed with the standout attribute set and those -displayed with one of the other attributes set (usually bold). -It is best to avoid using standout if the terminal supports other attributes.
CVS commit: src/lib/libcurses
Module Name:src Committed By: blymn Date: Sun Jun 27 23:57:08 UTC 2021 Modified Files: src/lib/libcurses: cr_put.c Log Message: Fix PR lib/55931 Only reset outcol if we actually emit a \n as cursor_down may not may not put the cursor at the start of the next line. To generate a diff of this commit: cvs rdiff -u -r1.34 -r1.35 src/lib/libcurses/cr_put.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/cr_put.c diff -u src/lib/libcurses/cr_put.c:1.34 src/lib/libcurses/cr_put.c:1.35 --- src/lib/libcurses/cr_put.c:1.34 Mon May 20 22:17:41 2019 +++ src/lib/libcurses/cr_put.c Sun Jun 27 23:57:08 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: cr_put.c,v 1.34 2019/05/20 22:17:41 blymn Exp $ */ +/* $NetBSD: cr_put.c,v 1.35 2021/06/27 23:57:08 blymn Exp $ */ /* * Copyright (c) 1981, 1993, 1994 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)cr_put.c 8.3 (Berkeley) 5/4/94"; #else -__RCSID("$NetBSD: cr_put.c,v 1.34 2019/05/20 22:17:41 blymn Exp $"); +__RCSID("$NetBSD: cr_put.c,v 1.35 2021/06/27 23:57:08 blymn Exp $"); #endif #endif/* not lint */ @@ -93,6 +93,8 @@ fgoto(int in_refresh) #ifdef DEBUG __CTRACE(__CTRACE_OUTPUT, "fgoto: in_refresh=%d\n", in_refresh); + __CTRACE(__CTRACE_OUTPUT, "fgoto: outcol=%d, outline=%d, destcol=%d, destline=%d\n", + outcol, outline, destcol, destline); #endif /* DEBUG */ if (destcol >= COLS) { destline += destcol / COLS; @@ -214,6 +216,8 @@ plod(int cnt, int in_refresh) #ifdef DEBUG __CTRACE(__CTRACE_OUTPUT, "plod: cnt=%d, in_refresh=%d\n", cnt, in_refresh); + __CTRACE(__CTRACE_OUTPUT, "plod: plodding from col %d, row %d to col %d, row %d\n", + outcol, outline, destcol, destline); #endif /* DEBUG */ plodcnt = plodflg = cnt; soutcol = outcol; @@ -331,6 +335,7 @@ plod(int cnt, int in_refresh) plodput('\n'); outline++; } + outcol = 0; } dontcr:while (outline < destline) { @@ -341,7 +346,14 @@ dontcr:while (outline < destline) { plodput('\n'); if (plodcnt < 0) goto out; - if (__NONL || __pfast == 0) + /* + * If the terminal does a CR with NL or we are in + * a mode where a \n will result in an implicit \r + * then adjust the outcol to match iff we actually + * emitted said \n. + */ + if ((__NONL || __pfast == 0) && + (!cursor_down || (*cursor_down == '\n'))) outcol = 0; } #ifdef notdef
CVS commit: src/lib/libcurses
Module Name:src Committed By: christos Date: Sun Jun 27 16:24:52 UTC 2021 Modified Files: src/lib/libcurses: Makefile Log Message: Fix SSP build To generate a diff of this commit: cvs rdiff -u -r1.94 -r1.95 src/lib/libcurses/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/Makefile diff -u src/lib/libcurses/Makefile:1.94 src/lib/libcurses/Makefile:1.95 --- src/lib/libcurses/Makefile:1.94 Mon Mar 23 09:37:36 2020 +++ src/lib/libcurses/Makefile Sun Jun 27 12:24:52 2021 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.94 2020/03/23 13:37:36 roy Exp $ +# $NetBSD: Makefile,v 1.95 2021/06/27 16:24:52 christos Exp $ # @(#)Makefile 8.2 (Berkeley) 1/2/94 .include @@ -9,6 +9,9 @@ CPPFLAGS+=-I${.CURDIR} -I${NETBSDSRCDIR} .if defined(DEBUG_CURSES) CPPFLAGS+=-g -DDEBUG .endif + +COPTS.slk.c += -Wno-stack-protector + .if defined(SMALL) CPPFLAGS+=-DSMALL .endif
CVS commit: src/lib/libcurses
Module Name:src Committed By: martin Date: Thu Jun 24 15:41:25 UTC 2021 Modified Files: src/lib/libcurses: slk.c Log Message: Fix printf format for size_t To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/lib/libcurses/slk.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/slk.c diff -u src/lib/libcurses/slk.c:1.10 src/lib/libcurses/slk.c:1.11 --- src/lib/libcurses/slk.c:1.10 Thu Jun 24 05:53:05 2021 +++ src/lib/libcurses/slk.c Thu Jun 24 15:41:25 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: slk.c,v 1.10 2021/06/24 05:53:05 blymn Exp $ */ +/* $NetBSD: slk.c,v 1.11 2021/06/24 15:41:25 martin Exp $ */ /*- * Copyright (c) 2017 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include #ifndef lint -__RCSID("$NetBSD: slk.c,v 1.10 2021/06/24 05:53:05 blymn Exp $"); +__RCSID("$NetBSD: slk.c,v 1.11 2021/06/24 15:41:25 martin Exp $"); #endif/* not lint */ #include @@ -568,7 +568,7 @@ __slk_wset(SCREEN *screen, int labnum, c } #ifdef DEBUG - __CTRACE(__CTRACE_INPUT, "__slk_wset: wcsrtombs %ld\n", len); + __CTRACE(__CTRACE_INPUT, "__slk_wset: wcsrtombs %zu\n", len); #endif len++; /* We need to store the NULL character. */ if ((str = malloc(len)) == NULL)
CVS commit: src/lib/libcurses
Module Name:src Committed By: blymn Date: Thu Jun 24 05:53:05 UTC 2021 Modified Files: src/lib/libcurses: slk.c Log Message: Make sure we don't use wide char routines when DISABLE_WCHAR is in effect. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/lib/libcurses/slk.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/slk.c diff -u src/lib/libcurses/slk.c:1.9 src/lib/libcurses/slk.c:1.10 --- src/lib/libcurses/slk.c:1.9 Tue Jun 22 07:26:45 2021 +++ src/lib/libcurses/slk.c Thu Jun 24 05:53:05 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: slk.c,v 1.9 2021/06/22 07:26:45 blymn Exp $ */ +/* $NetBSD: slk.c,v 1.10 2021/06/24 05:53:05 blymn Exp $ */ /*- * Copyright (c) 2017 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include #ifndef lint -__RCSID("$NetBSD: slk.c,v 1.9 2021/06/22 07:26:45 blymn Exp $"); +__RCSID("$NetBSD: slk.c,v 1.10 2021/06/24 05:53:05 blymn Exp $"); #endif/* not lint */ #include @@ -818,9 +818,11 @@ __slk_draw(SCREEN *screen, int labnum) { const struct __slk_label *l; int retval, inc, lcnt, tx; + char ts[MB_CUR_MAX]; +#ifdef HAVE_WCHAR cchar_t cc; wchar_t wc[2]; - char ts[MB_CUR_MAX]; +#endif if (screen->slk_hidden) return OK; @@ -855,23 +857,35 @@ __slk_draw(SCREEN *screen, int labnum) __CTRACE(__CTRACE_INPUT, "__slk_draw: label len %d, wcwidth %d\n", screen->slk_label_len, wcwidth(l->label[lcnt])); #endif +#ifdef HAVE_WCHAR wc[0] = l->label[lcnt]; wc[1] = L'\0'; if (setcchar(&cc, wc, screen->slk_window->wattr, 0, NULL) == ERR) return ERR; +#endif if (l->x + wcwidth(l->label[lcnt] + tx) >= screen->slk_label_len) { /* last character that will fit * so insert it to avoid scroll */ +#ifdef HAVE_WCHAR retval = mvwins_wch(screen->slk_window, 0, l->x + tx, &cc); +#else + retval = mvwinsch(screen->slk_window, + 0, l->x + tx, l->label[lcnt]); +#endif } else { +#ifdef HAVE_WCHAR retval = mvwadd_wch(screen->slk_window, 0, l->x + tx, &cc); +#else + retval = mvwaddch(screen->slk_window, + 0, l->x + tx, l->label[lcnt]); +#endif } tx += wcwidth(l->label[lcnt]); lcnt += inc;
CVS commit: src/lib/libcurses
Module Name:src Committed By: blymn Date: Tue Jun 22 07:49:09 UTC 2021 Modified Files: src/lib/libcurses: addbytes.c Log Message: Rework the fix for lib/56224. Move the scroll check to _cursesi_addwchar Perform the scroll check before updating the cursor location when processing \n. To generate a diff of this commit: cvs rdiff -u -r1.56 -r1.57 src/lib/libcurses/addbytes.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/addbytes.c diff -u src/lib/libcurses/addbytes.c:1.56 src/lib/libcurses/addbytes.c:1.57 --- src/lib/libcurses/addbytes.c:1.56 Tue Jun 15 22:18:55 2021 +++ src/lib/libcurses/addbytes.c Tue Jun 22 07:49:09 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: addbytes.c,v 1.56 2021/06/15 22:18:55 blymn Exp $ */ +/* $NetBSD: addbytes.c,v 1.57 2021/06/22 07:49:09 blymn Exp $ */ /* * Copyright (c) 1987, 1993, 1994 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)addbytes.c 8.4 (Berkeley) 5/4/94"; #else -__RCSID("$NetBSD: addbytes.c,v 1.56 2021/06/15 22:18:55 blymn Exp $"); +__RCSID("$NetBSD: addbytes.c,v 1.57 2021/06/22 07:49:09 blymn Exp $"); #endif #endif/* not lint */ @@ -171,14 +171,6 @@ _cursesi_waddbytes(WINDOW *win, const ch break; } - /* if scrollok is false and we are at the bottom of - * screen and this character would take us past the - * end of the line then we are done. - */ - if ((win->curx + wcwidth(wc) >= win->maxx) && - (!(win->flags & __SCROLLOK)) && - (win->cury == win->scr_b)) - break; #ifdef DEBUG __CTRACE(__CTRACE_INPUT, "ADDBYTES WIDE(0x%x [%s], %x) at (%d, %d), ate %d bytes\n", @@ -371,16 +363,17 @@ _cursesi_addwchar(WINDOW *win, __LINE ** *x = 0; return OK; case L'\n': - wclrtoeol(win); - *x = 0; - (*lnp)->flags &= ~__ISPASTEOL; if (*y == win->scr_b) { if (!(win->flags & __SCROLLOK)) return ERR; +wclrtoeol(win); scroll(win); } else { +wclrtoeol(win); (*y)++; } + *x = 0; + (*lnp)->flags &= ~__ISPASTEOL; return OK; case L'\t': cc.vals[0] = L' '; @@ -395,7 +388,7 @@ _cursesi_addwchar(WINDOW *win, __LINE ** if ((*y == win->scr_b) && !(win->flags & __SCROLLOK)) { if ((*lnp)->flags & __ISPASTEOL) { - return OK; + return ERR; } if (*x + newx > win->maxx - 1) @@ -489,6 +482,12 @@ _cursesi_addwchar(WINDOW *win, __LINE ** "_cursesi_addwchar: clear EOL (%d,%d)\n", *y, *x); #endif /* DEBUG */ + if (*y == win->scr_b) { + if (!(win->flags & __SCROLLOK)) +return ERR; + scroll(win); + } + (*lnp)->flags |= __ISDIRTY; newx = *x + win->ch_off; if (newx < *(*lnp)->firstchp) @@ -505,11 +504,7 @@ _cursesi_addwchar(WINDOW *win, __LINE ** *(*lnp)->lastchp = newx; __touchline(win, *y, sx, (int) win->maxx - 1); sx = *x = 0; - if (*y == win->scr_b) { - if (!(win->flags & __SCROLLOK)) -return ERR; - scroll(win); - } else { + if (*y != win->scr_b) { (*y)++; } lp = &win->alines[*y]->line[0]; @@ -588,16 +583,23 @@ _cursesi_addwchar(WINDOW *win, __LINE ** #ifdef DEBUG __CTRACE(__CTRACE_INPUT, "_cursesi_addwchar: do line wrap\n"); #endif /* DEBUG */ + if (*y == win->scr_b) { +#ifdef DEBUG + __CTRACE(__CTRACE_INPUT, "_cursesi_addwchar: at bottom of screen\n"); +#endif /* DEBUG */ + if (!(win->flags & __SCROLLOK)) +return ERR; +#ifdef DEBUG + __CTRACE(__CTRACE_INPUT, "_cursesi_addwchar: do a scroll\n"); +#endif /* DEBUG */ + scroll(win); + } newx = win->maxx - 1 + win->ch_off; if (newx > *(*lnp)->lastchp) *(*lnp)->lastchp = newx; __touchline(win, *y, sx, (int) win->maxx - 1); *x = sx = 0; - if (*y == win->scr_b) { - if (!(win->flags & __SCROLLOK)) -return ERR; - scroll(win); - } else { + if (*y != win->scr_b) { (*y)++; } lp = &win->alines[*y]->line[0];
CVS commit: src/lib/libcurses
Module Name:src Committed By: blymn Date: Tue Jun 22 07:26:45 UTC 2021 Modified Files: src/lib/libcurses: slk.c Log Message: Fix how the slk are drawn by making sure we use ins_wchar in the bottom left of the screen to avoid a scroll because this may cause an ERR if scrollok is false. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/lib/libcurses/slk.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/slk.c diff -u src/lib/libcurses/slk.c:1.8 src/lib/libcurses/slk.c:1.9 --- src/lib/libcurses/slk.c:1.8 Sun Jul 28 00:51:59 2019 +++ src/lib/libcurses/slk.c Tue Jun 22 07:26:45 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: slk.c,v 1.8 2019/07/28 00:51:59 uwe Exp $ */ +/* $NetBSD: slk.c,v 1.9 2021/06/22 07:26:45 blymn Exp $ */ /*- * Copyright (c) 2017 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include #ifndef lint -__RCSID("$NetBSD: slk.c,v 1.8 2019/07/28 00:51:59 uwe Exp $"); +__RCSID("$NetBSD: slk.c,v 1.9 2021/06/22 07:26:45 blymn Exp $"); #endif/* not lint */ #include @@ -555,9 +555,21 @@ __slk_wset(SCREEN *screen, int labnum, c if (screen == NULL) return ERR; +#ifdef DEBUG + __CTRACE(__CTRACE_INPUT, "__slk_wset: entry\n"); +#endif olabel = label; - if ((len = wcsrtombs(NULL, &olabel, 0, &screen->sp)) == -1) + if ((len = wcsrtombs(NULL, &olabel, 0, &screen->sp)) == -1) { +#ifdef DEBUG + __CTRACE(__CTRACE_INPUT, "__slk_wset: conversion failed on char 0x%x\n", + (uint16_t) *olabel); +#endif return ERR; + } + +#ifdef DEBUG + __CTRACE(__CTRACE_INPUT, "__slk_wset: wcsrtombs %ld\n", len); +#endif len++; /* We need to store the NULL character. */ if ((str = malloc(len)) == NULL) return ERR; @@ -567,6 +579,10 @@ __slk_wset(SCREEN *screen, int labnum, c result = __slk_set(screen, labnum, str, justify); out: free(str); +#ifdef DEBUG + __CTRACE(__CTRACE_INPUT, "__slk_wset: return %s\n", + (result == OK)?"OK":"ERR"); +#endif return result; } #endif /* HAVE_WCHAR */ @@ -801,19 +817,69 @@ static int __slk_draw(SCREEN *screen, int labnum) { const struct __slk_label *l; + int retval, inc, lcnt, tx; + cchar_t cc; + wchar_t wc[2]; + char ts[MB_CUR_MAX]; if (screen->slk_hidden) return OK; + retval = OK; /* quiet gcc... */ + l = &screen->slk_labels[labnum]; if (screen->is_term_slk) return ti_putp(screen->term, ti_tiparm(screen->term, t_plab_norm(screen->term), labnum + 1, l->label)); - else if (screen->slk_window != NULL) - return mvwaddnstr(screen->slk_window, 0, l->x, - l->label, screen->slk_label_len); - else + else if (screen->slk_window != NULL) { + if ((labnum != screen->slk_nlabels - 1) || + (screen->slk_window->flags & __SCROLLOK) || + ((l->x + screen->slk_label_len) < screen->slk_window->maxx)) { + retval = mvwaddnstr(screen->slk_window, 0, l->x, + l->label, screen->slk_label_len); + } else { + lcnt = 0; + tx = 0; + while (lcnt < screen->slk_label_len) { +inc = wctomb(ts, l->label[lcnt]); +if (inc < 0) { + /* conversion failed, skip? */ + lcnt++; + continue; +} + +#ifdef DEBUG + __CTRACE(__CTRACE_INPUT, "__slk_draw: last label, (%d,%d) char[%d] 0x%x\n", + l->x + tx, 0, lcnt, l->label[lcnt]); + __CTRACE(__CTRACE_INPUT, "__slk_draw: label len %d, wcwidth %d\n", + screen->slk_label_len, wcwidth(l->label[lcnt])); +#endif +wc[0] = l->label[lcnt]; +wc[1] = L'\0'; +if (setcchar(&cc, wc, +screen->slk_window->wattr, 0, +NULL) == ERR) + return ERR; + +if (l->x + wcwidth(l->label[lcnt] + tx) >= +screen->slk_label_len) { + /* last character that will fit + * so insert it to avoid scroll + */ + retval = mvwins_wch(screen->slk_window, + 0, l->x + tx, &cc); +} else { + retval = mvwadd_wch(screen->slk_window, + 0, l->x + tx, &cc); +} +tx += wcwidth(l->label[lcnt]); +lcnt += inc; + } + } + + return retval; + } else return ERR; }
CVS commit: src/lib/libcurses
Module Name:src Committed By: blymn Date: Tue Jun 22 07:22:44 UTC 2021 Modified Files: src/lib/libcurses: ins_wch.c Log Message: Fix the debug output to stop spamming out the aline for row 0, we may not be working on that row so the output is pointless. To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/lib/libcurses/ins_wch.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/ins_wch.c diff -u src/lib/libcurses/ins_wch.c:1.15 src/lib/libcurses/ins_wch.c:1.16 --- src/lib/libcurses/ins_wch.c:1.15 Mon Jul 6 22:46:50 2020 +++ src/lib/libcurses/ins_wch.c Tue Jun 22 07:22:44 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: ins_wch.c,v 1.15 2020/07/06 22:46:50 uwe Exp $ */ +/* $NetBSD: ins_wch.c,v 1.16 2021/06/22 07:22:44 blymn Exp $ */ /* * Copyright (c) 2005 The NetBSD Foundation Inc. @@ -36,7 +36,7 @@ #include #ifndef lint -__RCSID("$NetBSD: ins_wch.c,v 1.15 2020/07/06 22:46:50 uwe Exp $"); +__RCSID("$NetBSD: ins_wch.c,v 1.16 2021/06/22 07:22:44 blymn Exp $"); #endif /* not lint */ #include @@ -95,19 +95,14 @@ wins_wch(WINDOW *win, const cchar_t *wch if (!wch) return OK; cw = wcwidth(wch->vals[0]); +#ifdef DEBUG + __CTRACE(__CTRACE_INPUT, "wins_wch: wcwidth %d\n", cw); +#endif if (cw < 0) cw = 1; if (!cw) return wadd_wch( win, wch ); -#ifdef DEBUG - __CTRACE(__CTRACE_INPUT, "--before--\n"); - for (x = 0; x < win->maxx; x++) - __CTRACE(__CTRACE_INPUT, "wins_wch: (0,%d)=(%x,%x,%p)\n", x, - win->alines[0]->line[x].ch, - win->alines[0]->line[x].attr, - win->alines[0]->line[x].nsp); -#endif /* DEBUG */ x = win->curx; y = win->cury; #ifdef DEBUG @@ -217,17 +212,7 @@ wins_wch(WINDOW *win, const cchar_t *wch temp1->nsp = NULL; ex++, temp1++; } -#ifdef DEBUG - { - __CTRACE(__CTRACE_INPUT, "--after---\n"); - for (x = 0; x < win->maxx; x++) - __CTRACE(__CTRACE_INPUT, - "wins_wch: (0,%d)=(%x,%x,%p)\n", x, - win->alines[0]->line[x].ch, - win->alines[0]->line[x].attr, - win->alines[0]->line[x].nsp); - } -#endif /* DEBUG */ + newx = win->maxx - 1 + win->ch_off; if (newx > *lnp->lastchp) *lnp->lastchp = newx;
CVS commit: src/lib/libcurses
Module Name:src Committed By: blymn Date: Tue Jun 15 22:18:55 UTC 2021 Modified Files: src/lib/libcurses: addbytes.c Log Message: Correct a previous fix for PR lib/56224. Use wdwitch to determine the width of a wide character on the screen not the number from mbrtowc which is the number of bytes in the character. Thanks to Michael Forney for spotting this. To generate a diff of this commit: cvs rdiff -u -r1.55 -r1.56 src/lib/libcurses/addbytes.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/addbytes.c diff -u src/lib/libcurses/addbytes.c:1.55 src/lib/libcurses/addbytes.c:1.56 --- src/lib/libcurses/addbytes.c:1.55 Sun Jun 6 05:06:44 2021 +++ src/lib/libcurses/addbytes.c Tue Jun 15 22:18:55 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: addbytes.c,v 1.55 2021/06/06 05:06:44 blymn Exp $ */ +/* $NetBSD: addbytes.c,v 1.56 2021/06/15 22:18:55 blymn Exp $ */ /* * Copyright (c) 1987, 1993, 1994 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)addbytes.c 8.4 (Berkeley) 5/4/94"; #else -__RCSID("$NetBSD: addbytes.c,v 1.55 2021/06/06 05:06:44 blymn Exp $"); +__RCSID("$NetBSD: addbytes.c,v 1.56 2021/06/15 22:18:55 blymn Exp $"); #endif #endif/* not lint */ @@ -175,7 +175,7 @@ _cursesi_waddbytes(WINDOW *win, const ch * screen and this character would take us past the * end of the line then we are done. */ - if ((win->curx + n >= win->maxx) && + if ((win->curx + wcwidth(wc) >= win->maxx) && (!(win->flags & __SCROLLOK)) && (win->cury == win->scr_b)) break;
CVS commit: src/lib/libcurses
Module Name:src Committed By: mcf Date: Thu Jun 10 07:15:40 UTC 2021 Modified Files: src/lib/libcurses: setterm.c Log Message: Add missing newline to debug trace message ok blymn@ To generate a diff of this commit: cvs rdiff -u -r1.68 -r1.69 src/lib/libcurses/setterm.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/setterm.c diff -u src/lib/libcurses/setterm.c:1.68 src/lib/libcurses/setterm.c:1.69 --- src/lib/libcurses/setterm.c:1.68 Fri Oct 26 22:22:24 2018 +++ src/lib/libcurses/setterm.c Thu Jun 10 07:15:40 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: setterm.c,v 1.68 2018/10/26 22:22:24 uwe Exp $ */ +/* $NetBSD: setterm.c,v 1.69 2021/06/10 07:15:40 mcf Exp $ */ /* * Copyright (c) 1981, 1993, 1994 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)setterm.c 8.8 (Berkeley) 10/25/94"; #else -__RCSID("$NetBSD: setterm.c,v 1.68 2018/10/26 22:22:24 uwe Exp $"); +__RCSID("$NetBSD: setterm.c,v 1.69 2021/06/10 07:15:40 mcf Exp $"); #endif #endif /* not lint */ @@ -103,7 +103,7 @@ _cursesi_setterm(char *type, SCREEN *scr t_lines(screen->term) = 1; } #ifdef DEBUG - __CTRACE(__CTRACE_INIT, "setterm: filtered %d", screen->filtered); + __CTRACE(__CTRACE_INIT, "setterm: filtered %d\n", screen->filtered); #endif if ((p = getenv("ESCDELAY")) != NULL)
CVS commit: src/lib/libcurses
Module Name:src Committed By: blymn Date: Sun Jun 6 05:06:44 UTC 2021 Modified Files: src/lib/libcurses: addbytes.c Log Message: Fix for PR lib/56224 Correct addstr behaviour so it truncates the string in the case where a string is added on the bottom line of a window where scrolling is disabled as per the SUSv2 specification. To generate a diff of this commit: cvs rdiff -u -r1.54 -r1.55 src/lib/libcurses/addbytes.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/addbytes.c diff -u src/lib/libcurses/addbytes.c:1.54 src/lib/libcurses/addbytes.c:1.55 --- src/lib/libcurses/addbytes.c:1.54 Sat Feb 13 14:30:37 2021 +++ src/lib/libcurses/addbytes.c Sun Jun 6 05:06:44 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: addbytes.c,v 1.54 2021/02/13 14:30:37 rillig Exp $ */ +/* $NetBSD: addbytes.c,v 1.55 2021/06/06 05:06:44 blymn Exp $ */ /* * Copyright (c) 1987, 1993, 1994 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)addbytes.c 8.4 (Berkeley) 5/4/94"; #else -__RCSID("$NetBSD: addbytes.c,v 1.54 2021/02/13 14:30:37 rillig Exp $"); +__RCSID("$NetBSD: addbytes.c,v 1.55 2021/06/06 05:06:44 blymn Exp $"); #endif #endif/* not lint */ @@ -170,6 +170,15 @@ _cursesi_waddbytes(WINDOW *win, const ch } else if (wc == 0) { break; } + + /* if scrollok is false and we are at the bottom of + * screen and this character would take us past the + * end of the line then we are done. + */ + if ((win->curx + n >= win->maxx) && + (!(win->flags & __SCROLLOK)) && + (win->cury == win->scr_b)) + break; #ifdef DEBUG __CTRACE(__CTRACE_INPUT, "ADDBYTES WIDE(0x%x [%s], %x) at (%d, %d), ate %d bytes\n", @@ -214,6 +223,19 @@ _cursesi_addbyte(WINDOW *win, __LINE **l case '\t': tabsize = win->screen->TABSIZE; newx = tabsize - (*x % tabsize); + /* if at the bottom of the window and + not allowed to scroll then just do + what we can */ + if ((*y == win->scr_b) && + !(win->flags & __SCROLLOK)) { +if ((*lp)->flags & __ISPASTEOL) { + return OK; +} + +if (*x + newx > win->maxx - 1) + newx = win->maxx - *x - 1; + } + for (i = 0; i < newx; i++) { if (waddbytes(win, blank, 1) == ERR) return ERR; @@ -366,6 +388,20 @@ _cursesi_addwchar(WINDOW *win, __LINE ** cc.attributes = win->wattr; tabsize = win->screen->TABSIZE; newx = tabsize - (*x % tabsize); + + /* if at the bottom of the window and + not allowed to scroll then just do + what we can */ + if ((*y == win->scr_b) && + !(win->flags & __SCROLLOK)) { +if ((*lnp)->flags & __ISPASTEOL) { + return OK; +} + +if (*x + newx > win->maxx - 1) + newx = win->maxx - *x - 1; + } + for (i = 0; i < newx; i++) { if (wadd_wch(win, &cc) == ERR) return ERR;
CVS commit: src/lib/libcurses
Module Name:src Committed By: mcf Date: Tue Jun 1 00:59:02 UTC 2021 Modified Files: src/lib/libcurses: newwin.c Log Message: Fix initial line hash calculation for subwindows lp->hash is not initialized at this point. Since the hash is calculated in chunks using __hash_more(), it needs to be initialized to 0 first (just as in doupdate()). Detected with valgrind while running python's test suite when debugging an unrelated issue. ok uwe@ To generate a diff of this commit: cvs rdiff -u -r1.59 -r1.60 src/lib/libcurses/newwin.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/newwin.c diff -u src/lib/libcurses/newwin.c:1.59 src/lib/libcurses/newwin.c:1.60 --- src/lib/libcurses/newwin.c:1.59 Sat May 15 11:06:07 2021 +++ src/lib/libcurses/newwin.c Tue Jun 1 00:59:01 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: newwin.c,v 1.59 2021/05/15 11:06:07 uwe Exp $ */ +/* $NetBSD: newwin.c,v 1.60 2021/06/01 00:59:01 mcf Exp $ */ /* * Copyright (c) 1981, 1993, 1994 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)newwin.c 8.3 (Berkeley) 7/27/94"; #else -__RCSID("$NetBSD: newwin.c,v 1.59 2021/05/15 11:06:07 uwe Exp $"); +__RCSID("$NetBSD: newwin.c,v 1.60 2021/06/01 00:59:01 mcf Exp $"); #endif #endif/* not lint */ @@ -252,6 +252,7 @@ __set_subwin(WINDOW *orig, WINDOW *win) lp->hash = __hash((char *)(void *)lp->line, (size_t)(win->maxx * __LDATASIZE)); #else + lp->hash = 0; for (cp = lp->line, j = 0; j < win->maxx; j++, cp++) { lp->hash = __hash_more( &cp->ch, sizeof( wchar_t ), lp->hash );
CVS commit: src/lib/libcurses
Module Name:src Committed By: nia Date: Sat May 29 09:11:14 UTC 2021 Modified Files: src/lib/libcurses: resize.c Log Message: wresize: don't bound pads to the size of the screen allows avoiding a workaround in aiomixer, ok blymn uwe To generate a diff of this commit: cvs rdiff -u -r1.30 -r1.31 src/lib/libcurses/resize.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/resize.c diff -u src/lib/libcurses/resize.c:1.30 src/lib/libcurses/resize.c:1.31 --- src/lib/libcurses/resize.c:1.30 Fri Nov 2 04:17:39 2018 +++ src/lib/libcurses/resize.c Sat May 29 09:11:14 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: resize.c,v 1.30 2018/11/02 04:17:39 blymn Exp $ */ +/* $NetBSD: resize.c,v 1.31 2021/05/29 09:11:14 nia Exp $ */ /* * Copyright (c) 2001 @@ -33,7 +33,7 @@ #if 0 static char sccsid[] = "@(#)resize.c blymn 2001/08/26"; #else -__RCSID("$NetBSD: resize.c,v 1.30 2018/11/02 04:17:39 blymn Exp $"); +__RCSID("$NetBSD: resize.c,v 1.31 2021/05/29 09:11:14 nia Exp $"); #endif #endif/* not lint */ @@ -62,7 +62,25 @@ wresize(WINDOW *win, int req_nlines, int __CTRACE(__CTRACE_WINDOW, "wresize: (%p, %d, %d)\n", win, nlines, ncols); #endif - if (win->orig == NULL) { + if (win->orig != NULL) { + /* subwins must fit inside the parent - check this */ + if (win->begy > win->orig->begy + win->orig->maxy) + win->begy = win->orig->begy + win->orig->maxy - 1; + if (win->begy + nlines > win->orig->begy + win->orig->maxy) + nlines = 0; + if (nlines <= 0) + nlines += win->orig->begy + win->orig->maxy - win->begy; + if (nlines < 1) + nlines = 1; + if (win->begx > win->orig->begx + win->orig->maxx) + win->begx = win->orig->begx + win->orig->maxx - 1; + if (win->begx + ncols > win->orig->begx + win->orig->maxx) + ncols = 0; + if (ncols <= 0) + ncols += win->orig->begx + win->orig->maxx - win->begx; + if (ncols < 1) + ncols = 1; + } else if (!(win->flags & __ISPAD)) { /* bound "our" windows by the screen size */ if (win == curscr || win == __virtscr || win == stdscr) { if (nlines > LINES) @@ -91,24 +109,6 @@ wresize(WINDOW *win, int req_nlines, int if (ncols < 1) ncols = 1; } - } else { - /* subwins must fit inside the parent - check this */ - if (win->begy > win->orig->begy + win->orig->maxy) - win->begy = win->orig->begy + win->orig->maxy - 1; - if (win->begy + nlines > win->orig->begy + win->orig->maxy) - nlines = 0; - if (nlines <= 0) - nlines += win->orig->begy + win->orig->maxy - win->begy; - if (nlines < 1) - nlines = 1; - if (win->begx > win->orig->begx + win->orig->maxx) - win->begx = win->orig->begx + win->orig->maxx - 1; - if (win->begx + ncols > win->orig->begx + win->orig->maxx) - ncols = 0; - if (ncols <= 0) - ncols += win->orig->begx + win->orig->maxx - win->begx; - if (ncols < 1) - ncols = 1; } if ((__resizewin(win, nlines, ncols)) == ERR)
CVS commit: src/lib/libcurses
Module Name:src Committed By: uwe Date: Sat May 15 11:06:08 UTC 2021 Modified Files: src/lib/libcurses: newwin.c Log Message: __newwin - fix BGWCOL initialization. >From Michael Forney in PR lib/56174 To generate a diff of this commit: cvs rdiff -u -r1.58 -r1.59 src/lib/libcurses/newwin.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/newwin.c diff -u src/lib/libcurses/newwin.c:1.58 src/lib/libcurses/newwin.c:1.59 --- src/lib/libcurses/newwin.c:1.58 Tue Jul 14 04:39:39 2020 +++ src/lib/libcurses/newwin.c Sat May 15 11:06:07 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: newwin.c,v 1.58 2020/07/14 04:39:39 uwe Exp $ */ +/* $NetBSD: newwin.c,v 1.59 2021/05/15 11:06:07 uwe Exp $ */ /* * Copyright (c) 1981, 1993, 1994 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)newwin.c 8.3 (Berkeley) 7/27/94"; #else -__RCSID("$NetBSD: newwin.c,v 1.58 2020/07/14 04:39:39 uwe Exp $"); +__RCSID("$NetBSD: newwin.c,v 1.59 2021/05/15 11:06:07 uwe Exp $"); #endif #endif/* not lint */ @@ -144,9 +144,7 @@ __newwin(SCREEN *screen, int nlines, int win->bch = ' '; if (__using_color) - win->battr = __default_color; - else - win->battr = 0; + win->battr |= __default_color; win->nextp = win; win->ch_off = 0; win->orig = NULL; @@ -386,6 +384,7 @@ __makenew(SCREEN *screen, int nlines, in win->flags = (__IDLINE | __IDCHAR); win->delay = -1; win->wattr = 0; + win->battr = 0; #ifdef HAVE_WCHAR win->bnsp = NULL; SET_BGWCOL(*win, 1);
CVS commit: src/lib/libcurses
Module Name:src Committed By: mrg Date: Sat May 8 04:29:07 UTC 2021 Modified Files: src/lib/libcurses: refresh.c Log Message: avoid accessing stack garbage. on arm64eb resuming vi(1) would often crash. in makech(), the 'csp' variable is either set to current window data, or a local stack variable's address '&blank'. the window data has many lines of info stored, and 'csp++' is used per line here. unfortunately, a case existed where 'csp++' operated on csp initialised from '&blank' which eventually crashes when, on my display with 160 columns and 'csp + 155' exceeds the mapped stack and crashes. match the '!_cursesi_screen->curwin' conditional that initialises csp, and avoid csp++ here. assert() that csp != &blank in both places that modify csp. thanks to jdc@ and mlelstv@. XXX: possibly also should avoid the putch() here as well. To generate a diff of this commit: cvs rdiff -u -r1.112 -r1.113 src/lib/libcurses/refresh.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/refresh.c diff -u src/lib/libcurses/refresh.c:1.112 src/lib/libcurses/refresh.c:1.113 --- src/lib/libcurses/refresh.c:1.112 Mon Feb 24 12:20:29 2020 +++ src/lib/libcurses/refresh.c Sat May 8 04:29:07 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: refresh.c,v 1.112 2020/02/24 12:20:29 rin Exp $ */ +/* $NetBSD: refresh.c,v 1.113 2021/05/08 04:29:07 mrg Exp $ */ /* * Copyright (c) 1981, 1993, 1994 @@ -34,13 +34,14 @@ #if 0 static char sccsid[] = "@(#)refresh.c 8.7 (Berkeley) 8/13/94"; #else -__RCSID("$NetBSD: refresh.c,v 1.112 2020/02/24 12:20:29 rin Exp $"); +__RCSID("$NetBSD: refresh.c,v 1.113 2021/05/08 04:29:07 mrg Exp $"); #endif #endif/* not lint */ #include #include #include +#include #include "curses.h" #include "curses_private.h" @@ -1322,6 +1323,7 @@ makech(int wy) csp->ch = (wchar_t)btowc((int)' '); SET_WCOL( *csp, 1 ); #endif /* HAVE_WCHAR */ + assert(csp != &blank); csp++; } return OK; @@ -1368,7 +1370,10 @@ makech(int wy) { if (putch(nsp, csp, wy, wx) == ERR) return ERR; -csp++; +if (!_cursesi_screen->curwin) { + assert(csp != &blank); + csp++; +} } else { putattr(nsp); putattr_out(nsp);
CVS commit: src/lib/libcurses
Module Name:src Committed By: rillig Date: Sat Feb 13 10:37:00 UTC 2021 Modified Files: src/lib/libcurses: curses.h Log Message: curses.h: proofread, indent a bit more consistently To generate a diff of this commit: cvs rdiff -u -r1.129 -r1.130 src/lib/libcurses/curses.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/curses.h diff -u src/lib/libcurses/curses.h:1.129 src/lib/libcurses/curses.h:1.130 --- src/lib/libcurses/curses.h:1.129 Mon Mar 23 13:37:36 2020 +++ src/lib/libcurses/curses.h Sat Feb 13 10:37:00 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: curses.h,v 1.129 2020/03/23 13:37:36 roy Exp $ */ +/* $NetBSD: curses.h,v 1.130 2021/02/13 10:37:00 rillig Exp $ */ /* * Copyright (c) 1981, 1993, 1994 @@ -61,14 +61,14 @@ typedef wchar_t attr_t; #ifdef HAVE_WCHAR /* * The complex character structure required by the X/Open reference and used - * in * functions such as in_wchstr(). It includes a string of up to 8 wide + * in functions such as in_wchstr(). It includes a string of up to 8 wide * characters and its length, an attribute, and a color-pair. */ #define CURSES_CCHAR_MAX 8 #define CCHARW_MAX 5 typedef struct { attr_t attributes; /* character attributes */ - unsigned elements; /* number of wide char in + unsigned elements; /* number of wide chars in vals[] */ wchar_t vals[CURSES_CCHAR_MAX]; /* wide chars including non-spacing */ @@ -86,12 +86,12 @@ typedef chtype cchar_t; #ifndef _CURSES_PRIVATE -#define _puts(s)tputs(s, 0, __cputchar) -#define _putchar(c) __cputchar(c) +#define _puts(s) tputs(s, 0, __cputchar) +#define _putchar(c) __cputchar(c) /* Old-style terminal modes access. */ -#define crmode()cbreak() -#define nocrmode() nocbreak() +#define crmode() cbreak() +#define nocrmode() nocbreak() #endif /* _CURSES_PRIVATE */ @@ -107,7 +107,7 @@ typedef chtype cchar_t; /* First function key (block of 64 follow) */ #defineKEY_F0 0x108 -/* Function defining other function key values*/ +/* Function defining other function key values */ #defineKEY_F(n) (KEY_F0+(n)) #defineKEY_DL 0x148/* Delete Line */ @@ -132,7 +132,7 @@ typedef chtype cchar_t; #defineKEY_LL 0x15B/* Home Down */ /* - * "Keypad" keys arranged like this: + * "Keypad" keys are arranged like this: * * A1 up A3 * left B2 right @@ -170,7 +170,7 @@ typedef chtype cchar_t; #defineKEY_RESTART0x177/* Restart key */ #defineKEY_RESUME 0x178/* Resume key */ #defineKEY_SAVE 0x179/* Save key */ -#defineKEY_SBEG 0x17A/* Shift begin key */ +#defineKEY_SBEG 0x17A/* Shift Begin key */ #defineKEY_SCANCEL0x17B/* Shift Cancel key */ #defineKEY_SCOMMAND 0x17C/* Shift Command key */ #defineKEY_SCOPY 0x17D/* Shift Copy key */ @@ -204,12 +204,12 @@ typedef chtype cchar_t; #defineKEY_MOUSE 0x199/* Mouse event has occurred */ #defineKEY_RESIZE 0x200/* Resize event has occurred */ #defineKEY_MAX0x240/* maximum extended key value */ -#defineKEY_CODE_YES 0x241/* A function key pressed */ +#defineKEY_CODE_YES 0x241/* A function key was pressed */ #include /* - * A window an array of __LINE structures pointed to by the 'lines' pointer. + * A window is an array of __LINE structures pointed to by the 'lines' pointer. * A line is an array of __LDATA structures pointed to by the 'line' pointer. */ @@ -638,7 +638,7 @@ __END_DECLS } while(0 /* CONSTCOND */) -/* Public function prototypes. */ +/* Public functions. */ __BEGIN_DECLS int assume_default_colors(short, short); int baudrate(void); @@ -1034,9 +1034,9 @@ bool is_pad(const WINDOW *); typedef unsigned long mmask_t; typedef struct { - short id; /* ID to distinguish multiple devices */ - int x, y, z; /* event coordinates */ - mmask_t bstate; /* button state bits */ + short id; /* ID to distinguish multiple devices */ + int x, y, z; /* event coordinates */ + mmask_t bstate; /* button state bits */ } MEVENT; bool has_mouse(void); @@ -1052,10 +1052,10 @@ int mouseinterval(int); const char *curses_version(void); /* Private functions that are needed for user programs prototypes. */ -int __cputchar(int); -int __waddbytes(WINDOW *, const char *, int, attr_t); +int __cputchar(int); +int __waddbytes(WINDOW *, const char *, int, attr_t); #ifdef HAVE_WCHAR -int __cputwchar( wchar_t ); +int __cputwchar(wchar_t); #endif /* HAVE_WCHAR */ __END_DECLS
CVS commit: src/lib/libcurses
Module Name:src Committed By: rillig Date: Sun Feb 7 23:00:57 UTC 2021 Modified Files: src/lib/libcurses: curses_screen.3 Log Message: curses_screen.3: fix typo To generate a diff of this commit: cvs rdiff -u -r1.27 -r1.28 src/lib/libcurses/curses_screen.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/curses_screen.3 diff -u src/lib/libcurses/curses_screen.3:1.27 src/lib/libcurses/curses_screen.3:1.28 --- src/lib/libcurses/curses_screen.3:1.27 Sat Feb 6 13:58:09 2021 +++ src/lib/libcurses/curses_screen.3 Sun Feb 7 23:00:57 2021 @@ -1,4 +1,4 @@ -.\" $NetBSD: curses_screen.3,v 1.27 2021/02/06 13:58:09 rillig Exp $ +.\" $NetBSD: curses_screen.3,v 1.28 2021/02/07 23:00:57 rillig Exp $ .\" .\" Copyright (c) 2002 .\" Brett Lymn (bl...@netbsd.org, brett_l...@yahoo.com.au) @@ -204,7 +204,7 @@ A subsequent call to .Fn initscr or .Fn newterm -performs the following additonal actions: +performs the following additional actions: .Bl -bullet -compact .It Disable use of clear, cud, cud1, cup, cuu, cuu1 and vpa.
CVS commit: src/lib/libcurses
Module Name:src Committed By: rillig Date: Sat Feb 6 19:41:14 UTC 2021 Modified Files: src/lib/libcurses: addbytes.c Log Message: libcurses: fix spelling in comment To generate a diff of this commit: cvs rdiff -u -r1.52 -r1.53 src/lib/libcurses/addbytes.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/addbytes.c diff -u src/lib/libcurses/addbytes.c:1.52 src/lib/libcurses/addbytes.c:1.53 --- src/lib/libcurses/addbytes.c:1.52 Sun Jun 9 07:40:14 2019 +++ src/lib/libcurses/addbytes.c Sat Feb 6 19:41:14 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: addbytes.c,v 1.52 2019/06/09 07:40:14 blymn Exp $ */ +/* $NetBSD: addbytes.c,v 1.53 2021/02/06 19:41:14 rillig Exp $ */ /* * Copyright (c) 1987, 1993, 1994 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)addbytes.c 8.4 (Berkeley) 5/4/94"; #else -__RCSID("$NetBSD: addbytes.c,v 1.52 2019/06/09 07:40:14 blymn Exp $"); +__RCSID("$NetBSD: addbytes.c,v 1.53 2021/02/06 19:41:14 rillig Exp $"); #endif #endif/* not lint */ @@ -602,7 +602,7 @@ _cursesi_addwchar(WINDOW *win, __LINE ** } else { win->curx = *x; - /* clear the remining of the current characer */ + /* clear the remaining of the current character */ if (*x && *x < win->maxx) { ex = sx + cw; tp = &win->alines[*y]->line[ex];
CVS commit: src/lib/libcurses
Module Name:src Committed By: rillig Date: Sat Feb 6 13:58:09 UTC 2021 Modified Files: src/lib/libcurses: curses_screen.3 Log Message: libncurses: fix grammar in manual page To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 src/lib/libcurses/curses_screen.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/curses_screen.3 diff -u src/lib/libcurses/curses_screen.3:1.26 src/lib/libcurses/curses_screen.3:1.27 --- src/lib/libcurses/curses_screen.3:1.26 Thu Mar 12 11:38:28 2020 +++ src/lib/libcurses/curses_screen.3 Sat Feb 6 13:58:09 2021 @@ -1,4 +1,4 @@ -.\" $NetBSD: curses_screen.3,v 1.26 2020/03/12 11:38:28 roy Exp $ +.\" $NetBSD: curses_screen.3,v 1.27 2021/02/06 13:58:09 rillig Exp $ .\" .\" Copyright (c) 2002 .\" Brett Lymn (bl...@netbsd.org, brett_l...@yahoo.com.au) @@ -295,7 +295,7 @@ The Curses package appeared in .Bx 4.0 . The .Fn resizeterm -function is a +function is an .Em ncurses extension to the Curses library and was added in .Nx 1.6 . @@ -306,7 +306,7 @@ and .Fn set_tabsize functions are .Em ncurses -extension to the Curses library and was added in +extensions to the Curses library and were added in .Nx 8.0 . .Sh BUGS There is currently an issue with cursor movement in a 1 line sized window
CVS commit: src/lib/libcurses
Module Name:src Committed By: uwe Date: Tue Jul 14 04:39:39 UTC 2020 Modified Files: src/lib/libcurses: newwin.c Log Message: newwin - fix crash with negative ncols. When support for negative nrows/ncols was added, one s/ncols/maxx/ was missed so we ended up passing negative (i.e. huge unsigned) length when hashing the line contents. Reported by Naman Jain in PR lib/55484 To generate a diff of this commit: cvs rdiff -u -r1.57 -r1.58 src/lib/libcurses/newwin.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/newwin.c diff -u src/lib/libcurses/newwin.c:1.57 src/lib/libcurses/newwin.c:1.58 --- src/lib/libcurses/newwin.c:1.57 Sun Jun 9 07:40:14 2019 +++ src/lib/libcurses/newwin.c Tue Jul 14 04:39:39 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: newwin.c,v 1.57 2019/06/09 07:40:14 blymn Exp $ */ +/* $NetBSD: newwin.c,v 1.58 2020/07/14 04:39:39 uwe Exp $ */ /* * Copyright (c) 1981, 1993, 1994 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)newwin.c 8.3 (Berkeley) 7/27/94"; #else -__RCSID("$NetBSD: newwin.c,v 1.57 2019/06/09 07:40:14 blymn Exp $"); +__RCSID("$NetBSD: newwin.c,v 1.58 2020/07/14 04:39:39 uwe Exp $"); #endif #endif/* not lint */ @@ -174,7 +174,7 @@ __newwin(SCREEN *screen, int nlines, int #endif /* HAVE_WCHAR */ } lp->hash = __hash((char *)(void *)lp->line, - (size_t)(ncols * __LDATASIZE)); + (size_t)(maxx * __LDATASIZE)); } return (win); }
CVS commit: src/lib/libcurses
Module Name:src Committed By: uwe Date: Mon Jul 6 23:33:38 UTC 2020 Modified Files: src/lib/libcurses: get_wch.c getch.c Log Message: Pads are not to be automatically refreshed on input. X/Open Curses says in the documentation for newpad(): Automatic refreshes of pads (e.g., from scrolling or echoing of input) do not occur. And in the documentation for get*(): If the current or specified window is not a pad, and it has been moved or modified since the last refresh operation, then it will be refreshed before another character is read. >From Michael Forney in PR lib/55457 To generate a diff of this commit: cvs rdiff -u -r1.23 -r1.24 src/lib/libcurses/get_wch.c cvs rdiff -u -r1.74 -r1.75 src/lib/libcurses/getch.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/get_wch.c diff -u src/lib/libcurses/get_wch.c:1.23 src/lib/libcurses/get_wch.c:1.24 --- src/lib/libcurses/get_wch.c:1.23 Sun Jun 9 07:40:14 2019 +++ src/lib/libcurses/get_wch.c Mon Jul 6 23:33:38 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: get_wch.c,v 1.23 2019/06/09 07:40:14 blymn Exp $ */ +/* $NetBSD: get_wch.c,v 1.24 2020/07/06 23:33:38 uwe Exp $ */ /* * Copyright (c) 2005 The NetBSD Foundation Inc. @@ -36,7 +36,7 @@ #include #ifndef lint -__RCSID("$NetBSD: get_wch.c,v 1.23 2019/06/09 07:40:14 blymn Exp $"); +__RCSID("$NetBSD: get_wch.c,v 1.24 2020/07/06 23:33:38 uwe Exp $"); #endif /* not lint */ #include @@ -499,7 +499,7 @@ wget_wch(WINDOW *win, wint_t *ch) && __echoit) return ERR; - if (is_wintouched(win)) + if (!(win->flags & __ISPAD) && is_wintouched(win)) wrefresh(win); #ifdef DEBUG __CTRACE(__CTRACE_INPUT, "wget_wch: __echoit = %d, " Index: src/lib/libcurses/getch.c diff -u src/lib/libcurses/getch.c:1.74 src/lib/libcurses/getch.c:1.75 --- src/lib/libcurses/getch.c:1.74 Thu May 14 11:50:04 2020 +++ src/lib/libcurses/getch.c Mon Jul 6 23:33:38 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: getch.c,v 1.74 2020/05/14 11:50:04 simonb Exp $ */ +/* $NetBSD: getch.c,v 1.75 2020/07/06 23:33:38 uwe Exp $ */ /* * Copyright (c) 1981, 1993, 1994 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)getch.c 8.2 (Berkeley) 5/4/94"; #else -__RCSID("$NetBSD: getch.c,v 1.74 2020/05/14 11:50:04 simonb Exp $"); +__RCSID("$NetBSD: getch.c,v 1.75 2020/07/06 23:33:38 uwe Exp $"); #endif #endif /* not lint */ @@ -818,11 +818,11 @@ wgetch(WINDOW *win) && __echoit) return ERR; - if (is_wintouched(win)) - wrefresh(win); - else { - if ((_cursesi_screen->curscr->cury != (win->begy + win->cury)) - || (_cursesi_screen->curscr->curx != (win->begx + win->curx))) { + if (!(win->flags & __ISPAD)) { + if (is_wintouched(win)) + wrefresh(win); + else if ((_cursesi_screen->curscr->cury != (win->begy + win->cury)) + || (_cursesi_screen->curscr->curx != (win->begx + win->curx))) { #ifdef DEBUG __CTRACE(__CTRACE_INPUT, "wgetch: curscr cury %d cury %d curscr curx %d curx %d\n", _cursesi_screen->curscr->cury, win->begy + win->cury,
CVS commit: src/lib/libcurses
Module Name:src Committed By: uwe Date: Mon Jul 6 22:46:50 UTC 2020 Modified Files: src/lib/libcurses: ins_wch.c ins_wstr.c insch.c insstr.c Log Message: mvwins*(WINDOW *win, ...) functions - call wins* on win, not stdscr. >From Naman Jain in PR lib/55460. To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/lib/libcurses/ins_wch.c \ src/lib/libcurses/ins_wstr.c cvs rdiff -u -r1.25 -r1.26 src/lib/libcurses/insch.c cvs rdiff -u -r1.7 -r1.8 src/lib/libcurses/insstr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/ins_wch.c diff -u src/lib/libcurses/ins_wch.c:1.14 src/lib/libcurses/ins_wch.c:1.15 --- src/lib/libcurses/ins_wch.c:1.14 Sun Jun 9 07:40:14 2019 +++ src/lib/libcurses/ins_wch.c Mon Jul 6 22:46:50 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ins_wch.c,v 1.14 2019/06/09 07:40:14 blymn Exp $ */ +/* $NetBSD: ins_wch.c,v 1.15 2020/07/06 22:46:50 uwe Exp $ */ /* * Copyright (c) 2005 The NetBSD Foundation Inc. @@ -36,7 +36,7 @@ #include #ifndef lint -__RCSID("$NetBSD: ins_wch.c,v 1.14 2019/06/09 07:40:14 blymn Exp $"); +__RCSID("$NetBSD: ins_wch.c,v 1.15 2020/07/06 22:46:50 uwe Exp $"); #endif /* not lint */ #include @@ -75,7 +75,7 @@ mvwins_wch(WINDOW *win, int y, int x, co if (wmove(win, y, x) == ERR) return ERR; - return wins_wch(stdscr, wch); + return wins_wch(win, wch); } /* Index: src/lib/libcurses/ins_wstr.c diff -u src/lib/libcurses/ins_wstr.c:1.14 src/lib/libcurses/ins_wstr.c:1.15 --- src/lib/libcurses/ins_wstr.c:1.14 Sun Jun 9 07:40:14 2019 +++ src/lib/libcurses/ins_wstr.c Mon Jul 6 22:46:50 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ins_wstr.c,v 1.14 2019/06/09 07:40:14 blymn Exp $ */ +/* $NetBSD: ins_wstr.c,v 1.15 2020/07/06 22:46:50 uwe Exp $ */ /* * Copyright (c) 2005 The NetBSD Foundation Inc. @@ -36,7 +36,7 @@ #include #ifndef lint -__RCSID("$NetBSD: ins_wstr.c,v 1.14 2019/06/09 07:40:14 blymn Exp $"); +__RCSID("$NetBSD: ins_wstr.c,v 1.15 2020/07/06 22:46:50 uwe Exp $"); #endif /* not lint */ #include @@ -96,7 +96,7 @@ mvwins_wstr(WINDOW *win, int y, int x, c if (wmove(win, y, x) == ERR) return ERR; - return wins_wstr(stdscr, wstr); + return wins_wstr(win, wstr); } /* @@ -109,7 +109,7 @@ mvwins_nwstr(WINDOW *win, int y, int x, if (wmove(win, y, x) == ERR) return ERR; - return wins_nwstr(stdscr, wstr, n); + return wins_nwstr(win, wstr, n); } Index: src/lib/libcurses/insch.c diff -u src/lib/libcurses/insch.c:1.25 src/lib/libcurses/insch.c:1.26 --- src/lib/libcurses/insch.c:1.25 Sun Jun 9 07:40:14 2019 +++ src/lib/libcurses/insch.c Mon Jul 6 22:46:50 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: insch.c,v 1.25 2019/06/09 07:40:14 blymn Exp $ */ +/* $NetBSD: insch.c,v 1.26 2020/07/06 22:46:50 uwe Exp $ */ /* * Copyright (c) 1981, 1993, 1994 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)insch.c 8.2 (Berkeley) 5/4/94"; #else -__RCSID("$NetBSD: insch.c,v 1.25 2019/06/09 07:40:14 blymn Exp $"); +__RCSID("$NetBSD: insch.c,v 1.26 2020/07/06 22:46:50 uwe Exp $"); #endif #endif/* not lint */ @@ -79,7 +79,7 @@ mvwinsch(WINDOW *win, int y, int x, chty if (wmove(win, y, x) == ERR) return ERR; - return winsch(stdscr, ch); + return winsch(win, ch); } #endif Index: src/lib/libcurses/insstr.c diff -u src/lib/libcurses/insstr.c:1.7 src/lib/libcurses/insstr.c:1.8 --- src/lib/libcurses/insstr.c:1.7 Sun Jun 9 07:40:14 2019 +++ src/lib/libcurses/insstr.c Mon Jul 6 22:46:50 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: insstr.c,v 1.7 2019/06/09 07:40:14 blymn Exp $ */ +/* $NetBSD: insstr.c,v 1.8 2020/07/06 22:46:50 uwe Exp $ */ /* * Copyright (c) 2005 The NetBSD Foundation Inc. @@ -36,7 +36,7 @@ #include #ifndef lint -__RCSID("$NetBSD: insstr.c,v 1.7 2019/06/09 07:40:14 blymn Exp $"); +__RCSID("$NetBSD: insstr.c,v 1.8 2020/07/06 22:46:50 uwe Exp $"); #endif /* not lint */ #include @@ -103,7 +103,7 @@ mvwinsstr(WINDOW *win, int y, int x, con if (wmove(win, y, x) == ERR) return ERR; - return winsstr(stdscr, str); + return winsstr(win, str); } /* @@ -117,7 +117,7 @@ mvwinsnstr(WINDOW *win, int y, int x, co if (wmove(win, y, x) == ERR) return ERR; - return winsnstr(stdscr, str, n); + return winsnstr(win, str, n); } #endif
CVS commit: src/lib/libcurses
Module Name:src Committed By: uwe Date: Fri Jul 3 23:28:51 UTC 2020 Modified Files: src/lib/libcurses: touchwin.c Log Message: wtouchln - verify/clip input parameters >From Naman Jain in PR lib/55454 To generate a diff of this commit: cvs rdiff -u -r1.31 -r1.32 src/lib/libcurses/touchwin.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/touchwin.c diff -u src/lib/libcurses/touchwin.c:1.31 src/lib/libcurses/touchwin.c:1.32 --- src/lib/libcurses/touchwin.c:1.31 Wed Apr 24 07:09:44 2019 +++ src/lib/libcurses/touchwin.c Fri Jul 3 23:28:51 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: touchwin.c,v 1.31 2019/04/24 07:09:44 blymn Exp $ */ +/* $NetBSD: touchwin.c,v 1.32 2020/07/03 23:28:51 uwe Exp $ */ /* * Copyright (c) 1981, 1993, 1994 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)touchwin.c 8.2 (Berkeley) 5/4/94"; #else -__RCSID("$NetBSD: touchwin.c,v 1.31 2019/04/24 07:09:44 blymn Exp $"); +__RCSID("$NetBSD: touchwin.c,v 1.32 2020/07/03 23:28:51 uwe Exp $"); #endif #endif/* not lint */ @@ -177,8 +177,13 @@ wtouchln(WINDOW *win, int line, int n, i __CTRACE(__CTRACE_LINE, "wtouchln: (%p) %d, %d, %d\n", win, line, n, changed); #endif - if (line + n > win->maxy) - line = win->maxy - n; + if (line < 0 || win->maxy <= line) + return ERR; + if (n < 0) + return ERR; + if (n > win->maxy - line) + n = win->maxy - line; + for (y = line; y < line + n; y++) { if (changed == 1) _cursesi_touchline_force(win, y, 0,
CVS commit: src/lib/libcurses
Module Name:src Committed By: uwe Date: Thu Jul 2 23:43:01 UTC 2020 Modified Files: src/lib/libcurses: cchar.c Log Message: setcchar - don't lose combining marks to a typo. We copy len wchars but set the length field to 1, instead of len. >From Naman Jain in PR lib/55443 To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/lib/libcurses/cchar.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/cchar.c diff -u src/lib/libcurses/cchar.c:1.11 src/lib/libcurses/cchar.c:1.12 --- src/lib/libcurses/cchar.c:1.11 Thu Nov 22 22:16:45 2018 +++ src/lib/libcurses/cchar.c Thu Jul 2 23:43:01 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: cchar.c,v 1.11 2018/11/22 22:16:45 uwe Exp $ */ +/* $NetBSD: cchar.c,v 1.12 2020/07/02 23:43:01 uwe Exp $ */ /* * Copyright (c) 2005 The NetBSD Foundation Inc. @@ -36,7 +36,7 @@ #include #ifndef lint -__RCSID("$NetBSD: cchar.c,v 1.11 2018/11/22 22:16:45 uwe Exp $"); +__RCSID("$NetBSD: cchar.c,v 1.12 2020/07/02 23:43:01 uwe Exp $"); #endif /* not lint */ #include @@ -113,7 +113,7 @@ setcchar(cchar_t *wcval, const wchar_t * wcval->attributes = attrs & ~__COLOR; if (__using_color && color_pair) wcval->attributes |= COLOR_PAIR(color_pair); - wcval->elements = 1; + wcval->elements = len; memcpy(&wcval->vals, wch, len * sizeof(wchar_t)); }
CVS commit: src/lib/libcurses
Module Name:src Committed By: uwe Date: Wed Jul 1 02:57:02 UTC 2020 Modified Files: src/lib/libcurses: line.c Log Message: hline, vline - don't lose attributes when using default character. Make default (wide) and non-wide behavior match. If the character argument has (only) attributes set, use them with the default line character. In the wide case don't do the fallback in hline - it just calls hline_set that needs to do it anyway. Fix the latter to check the wcwidth of the right character and avoid division by zero. To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/lib/libcurses/line.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/line.c diff -u src/lib/libcurses/line.c:1.15 src/lib/libcurses/line.c:1.16 --- src/lib/libcurses/line.c:1.15 Wed Jul 1 02:14:41 2020 +++ src/lib/libcurses/line.c Wed Jul 1 02:57:01 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: line.c,v 1.15 2020/07/01 02:14:41 uwe Exp $ */ +/* $NetBSD: line.c,v 1.16 2020/07/01 02:57:01 uwe Exp $ */ /*- * Copyright (c) 1998-1999 Brett Lymn @@ -31,7 +31,7 @@ #include #ifndef lint -__RCSID("$NetBSD: line.c,v 1.15 2020/07/01 02:14:41 uwe Exp $"); +__RCSID("$NetBSD: line.c,v 1.16 2020/07/01 02:57:01 uwe Exp $"); #endif/* not lint */ #include @@ -101,15 +101,10 @@ whline(WINDOW *win, chtype ch, int count wmove(win, ocury, ocurx); return OK; #else - cchar_t cch, *cchp; + cchar_t cch; - if (ch & __CHARTEXT) { - __cursesi_chtype_to_cchar(ch, &cch); - cchp = & cch; - } else - cchp = WACS_HLINE; - - return whline_set(win, cchp, count); + __cursesi_chtype_to_cchar(ch, &cch); + return whline_set(win, &cch, count); #endif } @@ -174,15 +169,10 @@ wvline(WINDOW *win, chtype ch, int count wmove(win, ocury, ocurx); return OK; #else - cchar_t cch, *cchp; - - if (ch & __CHARTEXT) { - __cursesi_chtype_to_cchar(ch, &cch); - cchp = & cch; - } else - cchp = WACS_VLINE; + cchar_t cch; - return wvline_set(win, cchp, count); + __cursesi_chtype_to_cchar(ch, &cch); + return wvline_set(win, &cch, count); #endif } @@ -224,8 +214,14 @@ int whline_set(WINDOW *win, const cchar_ int ocury, ocurx, wcn, i, cw; cchar_t cc; - cw = wcwidth( wch->vals[ 0 ]); - if (cw < 0) + cc = *wch; + if (!cc.vals[0]) { + cc.vals[0] = WACS_HLINE->vals[0]; + cc.attributes |= WACS_HLINE->attributes; + } + + cw = wcwidth(cc.vals[0]); + if (cw <= 0) cw = 1; if ( ( win->maxx - win->curx ) < cw ) return ERR; @@ -236,9 +232,6 @@ int whline_set(WINDOW *win, const cchar_ ocury = win->cury; ocurx = win->curx; - memcpy( &cc, wch, sizeof( cchar_t )); - if (!(wch->vals[ 0 ])) - cc.vals[ 0 ] |= WACS_HLINE->vals[0]; for (i = 0; i < wcn; i++ ) { #ifdef DEBUG __CTRACE(__CTRACE_LINE, "whline_set: (%d,%d)\n", @@ -298,9 +291,11 @@ int wvline_set(WINDOW *win, const cchar_ ocury = win->cury; ocurx = win->curx; - memcpy(&cc, wch, sizeof(cchar_t)); - if (!(wch->vals[0])) - cc.vals[0] |= WACS_VLINE->vals[0]; + cc = *wch; + if (!cc.vals[0]) { + cc.vals[0] = WACS_VLINE->vals[0]; + cc.attributes |= WACS_VLINE->attributes; + } for (i = 0; i < wcn; i++) { mvwadd_wch(win, ocury + i, ocurx, &cc); #ifdef DEBUG
CVS commit: src/lib/libcurses
Module Name:src Committed By: uwe Date: Wed Jul 1 02:14:41 UTC 2020 Modified Files: src/lib/libcurses: line.c Log Message: Oops. Fix y/x typo in the previous whline() fix for !HAVE_WCHAR. To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/lib/libcurses/line.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/line.c diff -u src/lib/libcurses/line.c:1.14 src/lib/libcurses/line.c:1.15 --- src/lib/libcurses/line.c:1.14 Tue Jun 30 21:27:18 2020 +++ src/lib/libcurses/line.c Wed Jul 1 02:14:41 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: line.c,v 1.14 2020/06/30 21:27:18 uwe Exp $ */ +/* $NetBSD: line.c,v 1.15 2020/07/01 02:14:41 uwe Exp $ */ /*- * Copyright (c) 1998-1999 Brett Lymn @@ -31,7 +31,7 @@ #include #ifndef lint -__RCSID("$NetBSD: line.c,v 1.14 2020/06/30 21:27:18 uwe Exp $"); +__RCSID("$NetBSD: line.c,v 1.15 2020/07/01 02:14:41 uwe Exp $"); #endif/* not lint */ #include @@ -90,7 +90,7 @@ whline(WINDOW *win, chtype ch, int count int ocury, ocurx, n, i; n = min(count, win->maxx - win->curx); - ocury = win->curx; + ocury = win->cury; ocurx = win->curx; if (!(ch & __CHARTEXT))
CVS commit: src/lib/libcurses
Module Name:src Committed By: uwe Date: Tue Jun 30 21:27:18 UTC 2020 Modified Files: src/lib/libcurses: line.c Log Message: Fix indentation in the copyright. Make it match its siblings in other files. To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/lib/libcurses/line.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/line.c diff -u src/lib/libcurses/line.c:1.13 src/lib/libcurses/line.c:1.14 --- src/lib/libcurses/line.c:1.13 Tue Jun 30 21:10:13 2020 +++ src/lib/libcurses/line.c Tue Jun 30 21:27:18 2020 @@ -1,8 +1,8 @@ -/* $NetBSD: line.c,v 1.13 2020/06/30 21:10:13 uwe Exp $ */ +/* $NetBSD: line.c,v 1.14 2020/06/30 21:27:18 uwe Exp $ */ /*- * Copyright (c) 1998-1999 Brett Lymn - * (bl...@baea.com.au, brett_l...@yahoo.com.au) + * (bl...@baea.com.au, brett_l...@yahoo.com.au) * All rights reserved. * * This code has been donated to The NetBSD Foundation by the Author. @@ -31,7 +31,7 @@ #include #ifndef lint -__RCSID("$NetBSD: line.c,v 1.13 2020/06/30 21:10:13 uwe Exp $"); +__RCSID("$NetBSD: line.c,v 1.14 2020/06/30 21:27:18 uwe Exp $"); #endif/* not lint */ #include
CVS commit: src/lib/libcurses
Module Name:src Committed By: uwe Date: Tue Jun 30 21:10:13 UTC 2020 Modified Files: src/lib/libcurses: line.c Log Message: whline - save/restore the y coordinate too. Reaching the right side of the screen can cause a line wrap. Forgot to apply the fix to the !HAVE_WCHAR case. PR lib/55434 To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/lib/libcurses/line.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/line.c diff -u src/lib/libcurses/line.c:1.12 src/lib/libcurses/line.c:1.13 --- src/lib/libcurses/line.c:1.12 Tue Jun 30 21:02:24 2020 +++ src/lib/libcurses/line.c Tue Jun 30 21:10:13 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: line.c,v 1.12 2020/06/30 21:02:24 uwe Exp $ */ +/* $NetBSD: line.c,v 1.13 2020/06/30 21:10:13 uwe Exp $ */ /*- * Copyright (c) 1998-1999 Brett Lymn @@ -31,7 +31,7 @@ #include #ifndef lint -__RCSID("$NetBSD: line.c,v 1.12 2020/06/30 21:02:24 uwe Exp $"); +__RCSID("$NetBSD: line.c,v 1.13 2020/06/30 21:10:13 uwe Exp $"); #endif/* not lint */ #include @@ -87,17 +87,18 @@ int whline(WINDOW *win, chtype ch, int count) { #ifndef HAVE_WCHAR - int ocurx, n, i; + int ocury, ocurx, n, i; n = min(count, win->maxx - win->curx); + ocury = win->curx; ocurx = win->curx; if (!(ch & __CHARTEXT)) ch |= ACS_HLINE; for (i = 0; i < n; i++) - mvwaddch(win, win->cury, ocurx + i, ch); + mvwaddch(win, ocury, ocurx + i, ch); - wmove(win, win->cury, ocurx); + wmove(win, ocury, ocurx); return OK; #else cchar_t cch, *cchp;
CVS commit: src/lib/libcurses
Module Name:src Committed By: uwe Date: Tue Jun 30 21:02:24 UTC 2020 Modified Files: src/lib/libcurses: line.c Log Message: whline_set - save/restore the y coordinate too. Reaching the right side of the screen can cause a line wrap. PR lib/55434 To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/lib/libcurses/line.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/line.c diff -u src/lib/libcurses/line.c:1.11 src/lib/libcurses/line.c:1.12 --- src/lib/libcurses/line.c:1.11 Sun Jun 9 07:40:14 2019 +++ src/lib/libcurses/line.c Tue Jun 30 21:02:24 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: line.c,v 1.11 2019/06/09 07:40:14 blymn Exp $ */ +/* $NetBSD: line.c,v 1.12 2020/06/30 21:02:24 uwe Exp $ */ /*- * Copyright (c) 1998-1999 Brett Lymn @@ -31,7 +31,7 @@ #include #ifndef lint -__RCSID("$NetBSD: line.c,v 1.11 2019/06/09 07:40:14 blymn Exp $"); +__RCSID("$NetBSD: line.c,v 1.12 2020/06/30 21:02:24 uwe Exp $"); #endif/* not lint */ #include @@ -220,7 +220,7 @@ int whline_set(WINDOW *win, const cchar_ #ifndef HAVE_WCHAR return ERR; #else - int ocurx, wcn, i, cw; + int ocury, ocurx, wcn, i, cw; cchar_t cc; cw = wcwidth( wch->vals[ 0 ]); @@ -232,6 +232,7 @@ int whline_set(WINDOW *win, const cchar_ #ifdef DEBUG __CTRACE(__CTRACE_LINE, "whline_set: line of %d\n", wcn); #endif /* DEBUG */ + ocury = win->cury; ocurx = win->curx; memcpy( &cc, wch, sizeof( cchar_t )); @@ -240,12 +241,12 @@ int whline_set(WINDOW *win, const cchar_ for (i = 0; i < wcn; i++ ) { #ifdef DEBUG __CTRACE(__CTRACE_LINE, "whline_set: (%d,%d)\n", - win->cury, ocurx + i * cw); + ocury, ocurx + i * cw); #endif /* DEBUG */ - mvwadd_wch(win, win->cury, ocurx + i * cw, &cc); + mvwadd_wch(win, ocury, ocurx + i * cw, &cc); } - wmove(win, win->cury, ocurx); + wmove(win, ocury, ocurx); __sync(win); return OK; #endif /* HAVE_WCHAR */
CVS commit: src/lib/libcurses
Module Name:src Committed By: simonb Date: Thu May 14 11:50:05 UTC 2020 Modified Files: src/lib/libcurses: getch.c Log Message: KNF nit. To generate a diff of this commit: cvs rdiff -u -r1.73 -r1.74 src/lib/libcurses/getch.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/getch.c diff -u src/lib/libcurses/getch.c:1.73 src/lib/libcurses/getch.c:1.74 --- src/lib/libcurses/getch.c:1.73 Sun Jun 9 07:40:14 2019 +++ src/lib/libcurses/getch.c Thu May 14 11:50:04 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: getch.c,v 1.73 2019/06/09 07:40:14 blymn Exp $ */ +/* $NetBSD: getch.c,v 1.74 2020/05/14 11:50:04 simonb Exp $ */ /* * Copyright (c) 1981, 1993, 1994 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)getch.c 8.2 (Berkeley) 5/4/94"; #else -__RCSID("$NetBSD: getch.c,v 1.73 2019/06/09 07:40:14 blymn Exp $"); +__RCSID("$NetBSD: getch.c,v 1.74 2020/05/14 11:50:04 simonb Exp $"); #endif #endif /* not lint */ @@ -876,8 +876,7 @@ wgetch(WINDOW *win) __save_termios(); if (win->flags & __KEYPAD) { - switch (win->delay) - { + switch (win->delay) { case -1: inp = inkey (win->flags & __NOTIMEOUT ? 0 : 1, 0); break; @@ -891,8 +890,7 @@ wgetch(WINDOW *win) break; } } else { - switch (win->delay) - { + switch (win->delay) { case -1: if (__delay() == ERR) return ERR;
CVS commit: src/lib/libcurses
Module Name:src Committed By: wiz Date: Mon Mar 23 16:14:20 UTC 2020 Modified Files: src/lib/libcurses: curses_mouse.3 Log Message: Fix synopsis, use more markup. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/lib/libcurses/curses_mouse.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/curses_mouse.3 diff -u src/lib/libcurses/curses_mouse.3:1.1 src/lib/libcurses/curses_mouse.3:1.2 --- src/lib/libcurses/curses_mouse.3:1.1 Mon Mar 23 15:32:56 2020 +++ src/lib/libcurses/curses_mouse.3 Mon Mar 23 16:14:20 2020 @@ -1,4 +1,4 @@ -.\" $NetBSD: curses_mouse.3,v 1.1 2020/03/23 15:32:56 roy Exp $ +.\" $NetBSD: curses_mouse.3,v 1.2 2020/03/23 16:14:20 wiz Exp $ .\" .\" Copyright (c) 2020 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -52,18 +52,20 @@ .Ft int .Fn ungetmouse "MEVENT *event" .Ft mmask_t -.Fn mousemask "mmask_t newmask, mmask_t *oldmask" +.Fn mousemask "mmask_t newmask" "mmask_t *oldmask" .Ft bool -.Fn wenclose "const WINDOW *win, int y, int x" +.Fn wenclose "const WINDOW *win" "int y" "int x" .Ft bool -.Fn mouse_trafo "int *y, int *x, bool" +.Fn mouse_trafo "int *y" "int *x" "bool to_screen" .Ft bool -.Fn wmouse_trafo "const WINDOW *win, int *y, int *x, bool to_screen" +.Fn wmouse_trafo "const WINDOW *win" "int *y" "int *x" "bool to_screen" .Ft int .Fn mouseinterval "int erval" .Sh DESCRIPTION This is the curses interface to mouse events. -Mouse events are reported via the KEY_MOUSE value in the +Mouse events are reported via the +.Dv KEY_MOUSE +value in the .Xr wgetch 3 input stream. .Pp @@ -116,8 +118,7 @@ depending on the value of .Fa to_screen . If the co-ordinates are not enclosed by the window .Fa win -then false is returned, -otherwise the +then false is returned, otherwise the .Fa x and .Fa y
CVS commit: src/lib/libcurses
Module Name:src Committed By: roy Date: Mon Mar 23 15:32:56 UTC 2020 Added Files: src/lib/libcurses: curses_mouse.3 Log Message: Add missing man page for curses mouse functions. To generate a diff of this commit: cvs rdiff -u -r0 -r1.1 src/lib/libcurses/curses_mouse.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Added files: Index: src/lib/libcurses/curses_mouse.3 diff -u /dev/null src/lib/libcurses/curses_mouse.3:1.1 --- /dev/null Mon Mar 23 15:32:56 2020 +++ src/lib/libcurses/curses_mouse.3 Mon Mar 23 15:32:56 2020 @@ -0,0 +1,161 @@ +.\" $NetBSD: curses_mouse.3,v 1.1 2020/03/23 15:32:56 roy Exp $ +.\" +.\" Copyright (c) 2020 The NetBSD Foundation, Inc. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to The NetBSD Foundation +.\" by Roy Marples. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\"notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\"notice, this list of conditions and the following disclaimer in the +.\"documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS +.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS +.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +.\" POSSIBILITY OF SUCH DAMAGE. +.\" +.\" +.Dd March 22, 2020 +.Dt CURSES_MOUSE 3 +.Os +.Sh NAME +.Nm has_mouse , +.Nm getmouse , +.Nm ungetmouse , +.Nm mousemask , +.Nm wenclose , +.Nm mouse_trafo , +.Nm wmouse_trafo , +.Nm mouseinterval +.Nd Curses mouse interface +.Sh LIBRARY +.Lb libcurses +.Sh SYNOPSIS +.In curses.h +.Ft bool +.Fn has_mouse "void" +.Ft int +.Fn getmouse "MEVENT *event" +.Ft int +.Fn ungetmouse "MEVENT *event" +.Ft mmask_t +.Fn mousemask "mmask_t newmask, mmask_t *oldmask" +.Ft bool +.Fn wenclose "const WINDOW *win, int y, int x" +.Ft bool +.Fn mouse_trafo "int *y, int *x, bool" +.Ft bool +.Fn wmouse_trafo "const WINDOW *win, int *y, int *x, bool to_screen" +.Ft int +.Fn mouseinterval "int erval" +.Sh DESCRIPTION +This is the curses interface to mouse events. +Mouse events are reported via the KEY_MOUSE value in the +.Xr wgetch 3 +input stream. +.Pp +The +.Fn has_mouse +function returns true if the mouse support has been initialised for the +terminal, otherwise false. +.Pp +The +.Fn getmouse +function reads a mouse event. +The +.Fa x +and +.Fa y +values are screen relative and the state mask will have exactly one bit set +to represent the event type. +The +.Fn ungetmouse +function behave like +.Xr ungetch 3 +and pushes the mouse event into the input stream. +.Pp +The +.Fn mousemask +function sets the mouse events to be reported. +By default, there are no mouse events reported. +It returns a mask indicating which of the specified mouse events can be +reported, zero indicating a failure. +If oldmask is given, it is filled with the previous mouse event mask. +.Pp +The +.Fn wenclose +function returns true if the screen relative +.Fa x +and +.Fa y +co-ordinates are enclosed by the window +.Fa win , +otherwise false. +.Pp +The +.Fn wmouse_trafo +function transforms the +.Fa x +and +.Fa y +co-ordinates from screen relative to window relative or vice versa +depending on the value of +.Fa to_screen . +If the co-ordinates are not enclosed by the window +.Fa win +then false is returned, +otherwise the +.Fa x +and +.Fa y +values are transformed and true is returned. +The +.Fn mouse_trainfo +function calls +.Fn wmouse_trainfo +using +.Va stdscr +for +.Fa win . +.Pp +The +.Fn mouseinterval +function sets the maximum time that can elapse between press and release +events, which determins a click. +The value is in thousands of seconds. +The default value is one fifth of a second. +The returned value is the old value. +.Sh RETURN VALUES +Unless otherwise noted, the functions that return an int will return one of +the following values: +.Pp +.Bl -tag -width ERR -compact +.It Er OK +The function completed successfully. +.It Er ERR +An error occurred in the function. +.El +.Sh SEE ALSO +.Xr wsmouse 4 +.Sh STANDARDS +These functions are ncurs
CVS commit: src/lib/libcurses
Module Name:src Committed By: uwe Date: Sun Mar 15 01:18:43 UTC 2020 Modified Files: src/lib/libcurses: clrtobot.c clrtoeol.c erase.c Log Message: werase, wclrtobot, wclrtoeol - make code even more similar. Rename attr to battr to match bch and WINDOW::battr. No functional change intended. To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 src/lib/libcurses/clrtobot.c cvs rdiff -u -r1.30 -r1.31 src/lib/libcurses/clrtoeol.c cvs rdiff -u -r1.31 -r1.32 src/lib/libcurses/erase.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/clrtobot.c diff -u src/lib/libcurses/clrtobot.c:1.26 src/lib/libcurses/clrtobot.c:1.27 --- src/lib/libcurses/clrtobot.c:1.26 Fri Mar 13 02:57:26 2020 +++ src/lib/libcurses/clrtobot.c Sun Mar 15 01:18:43 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: clrtobot.c,v 1.26 2020/03/13 02:57:26 roy Exp $ */ +/* $NetBSD: clrtobot.c,v 1.27 2020/03/15 01:18:43 uwe Exp $ */ /* * Copyright (c) 1981, 1993, 1994 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)clrtobot.c 8.2 (Berkeley) 5/4/94"; #else -__RCSID("$NetBSD: clrtobot.c,v 1.26 2020/03/13 02:57:26 roy Exp $"); +__RCSID("$NetBSD: clrtobot.c,v 1.27 2020/03/15 01:18:43 uwe Exp $"); #endif #endif/* not lint */ @@ -66,7 +66,17 @@ wclrtobot(WINDOW *win) int minx, startx, starty, y; __LDATA *sp, *end, *maxx; wchar_t bch; - attr_t attr; + attr_t battr; + +#ifdef HAVE_WCHAR + bch = (wchar_t)btowc((int)win->bch); +#else + bch = win->bch; +#endif + if (win != curscr) + battr = win->battr & __ATTRIBUTES; + else + battr = 0; #ifdef __GNUC__ maxx = NULL; /* XXX gcc -Wuninitialized */ @@ -78,28 +88,20 @@ wclrtobot(WINDOW *win) starty = win->cury; startx = win->curx; } -#ifdef HAVE_WCHAR - bch = (wchar_t)btowc((int)win->bch); -#else - bch = win->bch; -#endif - if (win != curscr) - attr = win->battr & __ATTRIBUTES; - else - attr = 0; for (y = starty; y < win->maxy; y++) { minx = -1; end = &win->alines[y]->line[win->maxx]; for (sp = &win->alines[y]->line[startx]; sp < end; sp++) { - if (!(__NEED_ERASE(sp, bch, attr))) + if (!(__NEED_ERASE(sp, bch, battr))) continue; maxx = sp; if (minx == -1) minx = (int)(sp - win->alines[y]->line); - sp->attr = attr | (sp->attr & __ALTCHARSET); + sp->ch = bch; + sp->attr = battr | (sp->attr & __ALTCHARSET); #ifdef HAVE_WCHAR if (_cursesi_copy_nsp(win->bnsp, sp) == ERR) return ERR; Index: src/lib/libcurses/clrtoeol.c diff -u src/lib/libcurses/clrtoeol.c:1.30 src/lib/libcurses/clrtoeol.c:1.31 --- src/lib/libcurses/clrtoeol.c:1.30 Fri Mar 13 02:57:26 2020 +++ src/lib/libcurses/clrtoeol.c Sun Mar 15 01:18:43 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: clrtoeol.c,v 1.30 2020/03/13 02:57:26 roy Exp $ */ +/* $NetBSD: clrtoeol.c,v 1.31 2020/03/15 01:18:43 uwe Exp $ */ /* * Copyright (c) 1981, 1993, 1994 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)clrtoeol.c 8.2 (Berkeley) 5/4/94"; #else -__RCSID("$NetBSD: clrtoeol.c,v 1.30 2020/03/13 02:57:26 roy Exp $"); +__RCSID("$NetBSD: clrtoeol.c,v 1.31 2020/03/15 01:18:43 uwe Exp $"); #endif #endif/* not lint */ @@ -66,7 +66,17 @@ wclrtoeol(WINDOW *win) int minx, x, y; __LDATA *end, *maxx, *sp; wchar_t bch; - attr_t attr; + attr_t battr; + +#ifdef HAVE_WCHAR + bch = (wchar_t)btowc((int)win->bch); +#else + bch = win->bch; +#endif + if (win != curscr) + battr = win->battr & __ATTRIBUTES; + else + battr = 0; y = win->cury; x = win->curx; @@ -83,24 +93,17 @@ wclrtoeol(WINDOW *win) end = &win->alines[y]->line[win->maxx]; minx = -1; maxx = &win->alines[y]->line[x]; -#ifdef HAVE_WCHAR - bch = (wchar_t)btowc((int)win->bch); -#else - bch = win->bch; -#endif - if (win != curscr) - attr = win->battr & __ATTRIBUTES; - else - attr = 0; for (sp = maxx; sp < end; sp++) { - if (!(__NEED_ERASE(sp, bch, attr))) + if (!(__NEED_ERASE(sp, bch, battr))) continue; + maxx = sp; if (minx == -1) minx = (int)(sp - win->alines[y]->line); - sp->attr = attr | (sp->attr & __ALTCHARSET); + sp->ch = bch; + sp->attr = battr | (sp->attr & __ALTCHARSET); #ifdef HAVE_WCHAR if (_cursesi_copy_nsp(win->bnsp, sp) == ERR) return ERR; Index: src/lib/libcurses/erase.c diff -u src/lib/libcurses/erase.c:1.31 src/lib/libcurses/erase.c:1.32 --- src/lib/libcurses/erase.c:1.31 Fri Mar 13 02:57:26 2020 +++ src/lib/libcurses/erase.c Sun Mar 15 01:18:43 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: erase.c,v 1.31 2020/03/13 02:57:26 roy Exp $ */ +/* $NetBSD: erase.c,v 1.32 2020/03/15 01:18:43 uwe Exp $ */ /* * Copyright (c) 1981, 1993, 1994 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)erase.c 8.2 (Berkeley) 5/4/94"; #else -__RCSID("$NetBSD: erase.c,v 1.31 2020/03/13 02:57:26 roy Exp $"); +__RCSID("$NetBSD: erase.c,v 1.32 2020/03/15 01:18:43 uwe Exp $"); #endif #endif/* not lint */ @@ -67,7 +67,7 @@ werase(WINDOW *win) int y; __L
CVS commit: src/lib/libcurses
Module Name:src Committed By: uwe Date: Sun Mar 15 01:12:47 UTC 2020 Modified Files: src/lib/libcurses: curses_private.h Log Message: __NEED_ERASE - don't shadow __LDATA::attr with macro parameter name. To generate a diff of this commit: cvs rdiff -u -r1.72 -r1.73 src/lib/libcurses/curses_private.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/curses_private.h diff -u src/lib/libcurses/curses_private.h:1.72 src/lib/libcurses/curses_private.h:1.73 --- src/lib/libcurses/curses_private.h:1.72 Fri Mar 13 02:57:26 2020 +++ src/lib/libcurses/curses_private.h Sun Mar 15 01:12:47 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: curses_private.h,v 1.72 2020/03/13 02:57:26 roy Exp $ */ +/* $NetBSD: curses_private.h,v 1.73 2020/03/15 01:12:47 uwe Exp $ */ /*- * Copyright (c) 1998-2000 Brett Lymn @@ -339,14 +339,14 @@ void __CTRACE(int, const char *, ...) _ /* Common erase logic */ #ifdef HAVE_WCHAR -#define __NEED_ERASE(sp, bch, attr)\ - ((sp)->ch != (bch) || \ - ((sp)->attr & WA_ATTRIBUTES) != (attr) || \ - (sp)->nsp != NULL ||\ - WCOL(*sp) < 0) +#define __NEED_ERASE(_sp, _bch, _battr)\ + ((_sp)->ch != (_bch) || \ + ((_sp)->attr & WA_ATTRIBUTES) != (_battr) || \ + (_sp)->nsp != NULL ||\ + WCOL(*_sp) < 0) #else -#define __NEED_ERASE(sp, bch, attr)\ - ((sp)->ch != (bch) || (sp)->attr != (attr)) +#define __NEED_ERASE(_sp, _bch, _battr)\ + ((_sp)->ch != (_bch) || (_sp)->attr != (_battr)) #endif /* Private functions. */
CVS commit: src/lib/libcurses
Module Name:src Committed By: roy Date: Fri Mar 13 02:57:26 UTC 2020 Modified Files: src/lib/libcurses: clrtobot.c clrtoeol.c curses.h curses_private.h erase.c Log Message: curses: wrap the erase logic in a macro Easier to use, it's in one place and now hopefully everyone is happy. X To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.26 src/lib/libcurses/clrtobot.c cvs rdiff -u -r1.29 -r1.30 src/lib/libcurses/clrtoeol.c cvs rdiff -u -r1.127 -r1.128 src/lib/libcurses/curses.h cvs rdiff -u -r1.71 -r1.72 src/lib/libcurses/curses_private.h cvs rdiff -u -r1.30 -r1.31 src/lib/libcurses/erase.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/clrtobot.c diff -u src/lib/libcurses/clrtobot.c:1.25 src/lib/libcurses/clrtobot.c:1.26 --- src/lib/libcurses/clrtobot.c:1.25 Thu Mar 12 12:17:15 2020 +++ src/lib/libcurses/clrtobot.c Fri Mar 13 02:57:26 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: clrtobot.c,v 1.25 2020/03/12 12:17:15 roy Exp $ */ +/* $NetBSD: clrtobot.c,v 1.26 2020/03/13 02:57:26 roy Exp $ */ /* * Copyright (c) 1981, 1993, 1994 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)clrtobot.c 8.2 (Berkeley) 5/4/94"; #else -__RCSID("$NetBSD: clrtobot.c,v 1.25 2020/03/12 12:17:15 roy Exp $"); +__RCSID("$NetBSD: clrtobot.c,v 1.26 2020/03/13 02:57:26 roy Exp $"); #endif #endif/* not lint */ @@ -87,15 +87,12 @@ wclrtobot(WINDOW *win) attr = win->battr & __ATTRIBUTES; else attr = 0; + for (y = starty; y < win->maxy; y++) { minx = -1; end = &win->alines[y]->line[win->maxx]; for (sp = &win->alines[y]->line[startx]; sp < end; sp++) { - if (sp->ch == bch && -#ifdef HAVE_WCHAR - sp->nsp == NULL && WCOL(*sp) >= 0 && -#endif - (sp->attr & WA_ATTRIBUTES) == attr) + if (!(__NEED_ERASE(sp, bch, attr))) continue; maxx = sp; @@ -115,6 +112,7 @@ wclrtobot(WINDOW *win) (int)(maxx - win->alines[y]->line)); startx = 0; } + __sync(win); return OK; } Index: src/lib/libcurses/clrtoeol.c diff -u src/lib/libcurses/clrtoeol.c:1.29 src/lib/libcurses/clrtoeol.c:1.30 --- src/lib/libcurses/clrtoeol.c:1.29 Thu Mar 12 12:17:15 2020 +++ src/lib/libcurses/clrtoeol.c Fri Mar 13 02:57:26 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: clrtoeol.c,v 1.29 2020/03/12 12:17:15 roy Exp $ */ +/* $NetBSD: clrtoeol.c,v 1.30 2020/03/13 02:57:26 roy Exp $ */ /* * Copyright (c) 1981, 1993, 1994 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)clrtoeol.c 8.2 (Berkeley) 5/4/94"; #else -__RCSID("$NetBSD: clrtoeol.c,v 1.29 2020/03/12 12:17:15 roy Exp $"); +__RCSID("$NetBSD: clrtoeol.c,v 1.30 2020/03/13 02:57:26 roy Exp $"); #endif #endif/* not lint */ @@ -92,14 +92,10 @@ wclrtoeol(WINDOW *win) attr = win->battr & __ATTRIBUTES; else attr = 0; + for (sp = maxx; sp < end; sp++) { - if (sp->ch == bch && -#ifdef HAVE_WCHAR - sp->nsp == NULL && WCOL(*sp) >= 0 && -#endif - (sp->attr & WA_ATTRIBUTES) == attr) + if (!(__NEED_ERASE(sp, bch, attr))) continue; - maxx = sp; if (minx == -1) minx = (int)(sp - win->alines[y]->line); @@ -111,6 +107,7 @@ wclrtoeol(WINDOW *win) SET_WCOL(*sp, 1); #endif } + #ifdef DEBUG __CTRACE(__CTRACE_ERASE, "CLRTOEOL: y = %d, minx = %d, maxx = %d, " "firstch = %d, lastch = %d\n", Index: src/lib/libcurses/curses.h diff -u src/lib/libcurses/curses.h:1.127 src/lib/libcurses/curses.h:1.128 --- src/lib/libcurses/curses.h:1.127 Thu Mar 12 12:17:15 2020 +++ src/lib/libcurses/curses.h Fri Mar 13 02:57:26 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: curses.h,v 1.127 2020/03/12 12:17:15 roy Exp $ */ +/* $NetBSD: curses.h,v 1.128 2020/03/13 02:57:26 roy Exp $ */ /* * Copyright (c) 1981, 1993, 1994 @@ -275,9 +275,7 @@ typedef struct __screen SCREEN; #define WA_VERTICAL 0x0010 /* Vertical highlight */ #define WA_LEFT 0x0020 /* Left highlight */ #define WA_RIGHT 0x0040 /* Right highlight */ -#else /* HAVE_WCHAR */ -#define WA_ATTRIBUTES 0 /* Just to make our code easier */ -#endif /* !HAVE_WCHAR */ +#endif /* HAVE_WCHAR */ /* * Alternate character set definitions Index: src/lib/libcurses/curses_private.h diff -u src/lib/libcurses/curses_private.h:1.71 src/lib/libcurses/curses_private.h:1.72 --- src/lib/libcurses/curses_private.h:1.71 Sun Jun 9 07:40:14 2019 +++ src/lib/libcurses/curses_private.h Fri Mar 13 02:57:26 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: curses_private.h,v 1.71 2019/06/09 07:40:14 blymn Exp $ */ +/* $NetBSD: curses_private.h,v 1.72 2020/03/13 02:57:26 roy Exp $ */ /*- * Copyright (c) 1998-2000 Brett Lymn @@ -337,6 +337,18 @@ extern SCREEN *_cursesi_screen; void __CTRACE(int, const char *, ...) __attribute__((__format__(__printf__, 2, 3))); #endif +/* Common erase logic */ +#ifdef HAVE_WCHAR +#define __NEED_ERASE(sp, bch, attr)\ + ((sp)->ch != (bch) || \ + ((sp)->attr & WA_ATTRIBUTES) != (attr) || \ + (sp)->nsp != NUL
CVS commit: src/lib/libcurses
Module Name:src Committed By: roy Date: Thu Mar 12 15:50:12 UTC 2020 Modified Files: src/lib/libcurses: initscr.c Log Message: curses: use perror rather than err in initscr libhack lacks err and perror is more portable. To generate a diff of this commit: cvs rdiff -u -r1.34 -r1.35 src/lib/libcurses/initscr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/initscr.c diff -u src/lib/libcurses/initscr.c:1.34 src/lib/libcurses/initscr.c:1.35 --- src/lib/libcurses/initscr.c:1.34 Wed Mar 11 21:33:38 2020 +++ src/lib/libcurses/initscr.c Thu Mar 12 15:50:11 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: initscr.c,v 1.34 2020/03/11 21:33:38 roy Exp $ */ +/* $NetBSD: initscr.c,v 1.35 2020/03/12 15:50:11 roy Exp $ */ /* * Copyright (c) 1981, 1993, 1994 @@ -34,11 +34,10 @@ #if 0 static char sccsid[] = "@(#)initscr.c 8.2 (Berkeley) 5/4/94"; #else -__RCSID("$NetBSD: initscr.c,v 1.34 2020/03/11 21:33:38 roy Exp $"); +__RCSID("$NetBSD: initscr.c,v 1.35 2020/03/12 15:50:11 roy Exp $"); #endif #endif /* not lint */ -#include #include #include "curses.h" @@ -66,8 +65,15 @@ initscr(void) sp = Def_term; /* LINTED const castaway; newterm does not modify sp! */ - if ((_cursesi_screen = newterm((char *) sp, stdout, stdin)) == NULL) - errx(EXIT_FAILURE, "initscr"); /* POSIX says exit on failure */ + if ((_cursesi_screen = newterm((char *) sp, stdout, stdin)) == NULL) { + /* + * POSIX says we should write a diagnostic and exit on error. + * As such some applications don't bother checking the return + * value at all. + */ + perror("initscr"); + exit(EXIT_FAILURE); + } set_term(_cursesi_screen); wrefresh(curscr);
CVS commit: src/lib/libcurses
Module Name:src Committed By: roy Date: Thu Mar 12 12:17:15 UTC 2020 Modified Files: src/lib/libcurses: clrtobot.c clrtoeol.c curses.h erase.c Log Message: curses: normalise erase logic with clrtoeol and clrtobot Define WA_ATTRIBUTES as 0 for the non wide case just to make our code easier to write. To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/lib/libcurses/clrtobot.c cvs rdiff -u -r1.28 -r1.29 src/lib/libcurses/clrtoeol.c cvs rdiff -u -r1.126 -r1.127 src/lib/libcurses/curses.h cvs rdiff -u -r1.29 -r1.30 src/lib/libcurses/erase.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/clrtobot.c diff -u src/lib/libcurses/clrtobot.c:1.24 src/lib/libcurses/clrtobot.c:1.25 --- src/lib/libcurses/clrtobot.c:1.24 Fri Jan 6 13:53:18 2017 +++ src/lib/libcurses/clrtobot.c Thu Mar 12 12:17:15 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: clrtobot.c,v 1.24 2017/01/06 13:53:18 roy Exp $ */ +/* $NetBSD: clrtobot.c,v 1.25 2020/03/12 12:17:15 roy Exp $ */ /* * Copyright (c) 1981, 1993, 1994 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)clrtobot.c 8.2 (Berkeley) 5/4/94"; #else -__RCSID("$NetBSD: clrtobot.c,v 1.24 2017/01/06 13:53:18 roy Exp $"); +__RCSID("$NetBSD: clrtobot.c,v 1.25 2020/03/12 12:17:15 roy Exp $"); #endif #endif/* not lint */ @@ -65,6 +65,7 @@ wclrtobot(WINDOW *win) { int minx, startx, starty, y; __LDATA *sp, *end, *maxx; + wchar_t bch; attr_t attr; #ifdef __GNUC__ @@ -77,6 +78,11 @@ wclrtobot(WINDOW *win) starty = win->cury; startx = win->curx; } +#ifdef HAVE_WCHAR + bch = (wchar_t)btowc((int)win->bch); +#else + bch = win->bch; +#endif if (win != curscr) attr = win->battr & __ATTRIBUTES; else @@ -85,28 +91,23 @@ wclrtobot(WINDOW *win) minx = -1; end = &win->alines[y]->line[win->maxx]; for (sp = &win->alines[y]->line[startx]; sp < end; sp++) { -#ifndef HAVE_WCHAR - if (sp->ch != win->bch || sp->attr != attr) { -#else - if (sp->ch != (wchar_t)btowc((int)win->bch) || - (sp->attr & WA_ATTRIBUTES) != attr || sp->nsp) { -#endif /* HAVE_WCHAR */ -maxx = sp; -if (minx == -1) - minx = (int)(sp - win->alines[y]->line); -if (sp->attr & __ALTCHARSET) - sp->attr = attr | __ALTCHARSET; -else - sp->attr = attr; + if (sp->ch == bch && #ifdef HAVE_WCHAR -sp->ch = (wchar_t)btowc((int)win->bch); -if (_cursesi_copy_nsp(win->bnsp, sp) == ERR) - return ERR; -SET_WCOL(*sp, 1); -#else -sp->ch = win->bch; -#endif /* HAVE_WCHAR */ - } + sp->nsp == NULL && WCOL(*sp) >= 0 && +#endif + (sp->attr & WA_ATTRIBUTES) == attr) +continue; + + maxx = sp; + if (minx == -1) +minx = (int)(sp - win->alines[y]->line); + sp->attr = attr | (sp->attr & __ALTCHARSET); + sp->ch = bch; +#ifdef HAVE_WCHAR + if (_cursesi_copy_nsp(win->bnsp, sp) == ERR) +return ERR; + SET_WCOL(*sp, 1); +#endif } if (minx != -1) Index: src/lib/libcurses/clrtoeol.c diff -u src/lib/libcurses/clrtoeol.c:1.28 src/lib/libcurses/clrtoeol.c:1.29 --- src/lib/libcurses/clrtoeol.c:1.28 Fri Jan 6 13:53:18 2017 +++ src/lib/libcurses/clrtoeol.c Thu Mar 12 12:17:15 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: clrtoeol.c,v 1.28 2017/01/06 13:53:18 roy Exp $ */ +/* $NetBSD: clrtoeol.c,v 1.29 2020/03/12 12:17:15 roy Exp $ */ /* * Copyright (c) 1981, 1993, 1994 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)clrtoeol.c 8.2 (Berkeley) 5/4/94"; #else -__RCSID("$NetBSD: clrtoeol.c,v 1.28 2017/01/06 13:53:18 roy Exp $"); +__RCSID("$NetBSD: clrtoeol.c,v 1.29 2020/03/12 12:17:15 roy Exp $"); #endif #endif/* not lint */ @@ -65,6 +65,7 @@ wclrtoeol(WINDOW *win) { int minx, x, y; __LDATA *end, *maxx, *sp; + wchar_t bch; attr_t attr; y = win->cury; @@ -82,31 +83,34 @@ wclrtoeol(WINDOW *win) end = &win->alines[y]->line[win->maxx]; minx = -1; maxx = &win->alines[y]->line[x]; +#ifdef HAVE_WCHAR + bch = (wchar_t)btowc((int)win->bch); +#else + bch = win->bch; +#endif if (win != curscr) attr = win->battr & __ATTRIBUTES; else attr = 0; - for (sp = maxx; sp < end; sp++) -#ifndef HAVE_WCHAR - if (sp->ch != win->bch || sp->attr != attr) { -#else - if (sp->ch != (wchar_t)btowc((int) win->bch ) || - (sp->attr & WA_ATTRIBUTES) != attr || sp->nsp - || (WCOL(*sp) < 0)) { -#endif /* HAVE_WCHAR */ - maxx = sp; - if (minx == -1) -minx = (int) (sp - win->alines[y]->line); - sp->attr = attr | (sp->attr & __ALTCHARSET); + for (sp = maxx; sp < end; sp++) { + if (sp->ch == bch && #ifdef HAVE_WCHAR - sp->ch = (wchar_t)btowc((int) win->bch); - if (_cursesi_copy_nsp(win->bnsp, sp) == ERR) -return ERR; - SET_WCOL(*sp, 1); -#else - sp->ch = win->bch; -#endif /* HAVE_WCHAR */ - } + sp->nsp == NULL && WCOL(*sp) >= 0 && +#endif + (sp->attr & WA_ATTRIBUTES) == attr) + continue; + + maxx = sp; + if (minx == -1) + minx = (int)(sp - win->alines[y
CVS commit: src/lib/libcurses
Module Name:src Committed By: roy Date: Thu Mar 12 11:38:28 UTC 2020 Modified Files: src/lib/libcurses: curses_screen.3 Log Message: curses: note the change in initscr in our fine man page. To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.26 src/lib/libcurses/curses_screen.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/curses_screen.3 diff -u src/lib/libcurses/curses_screen.3:1.25 src/lib/libcurses/curses_screen.3:1.26 --- src/lib/libcurses/curses_screen.3:1.25 Tue Oct 2 17:35:44 2018 +++ src/lib/libcurses/curses_screen.3 Thu Mar 12 11:38:28 2020 @@ -1,4 +1,4 @@ -.\" $NetBSD: curses_screen.3,v 1.25 2018/10/02 17:35:44 roy Exp $ +.\" $NetBSD: curses_screen.3,v 1.26 2020/03/12 11:38:28 roy Exp $ .\" .\" Copyright (c) 2002 .\" Brett Lymn (bl...@netbsd.org, brett_l...@yahoo.com.au) @@ -30,7 +30,7 @@ .\" SUCH DAMAGE. .\" .\" -.Dd October 2, 2018 +.Dd March 12, 2020 .Dt CURSES_SCREEN 3 .Os .Sh NAME @@ -267,7 +267,10 @@ of the current screen to .Sh RETURN VALUES Functions returning pointers will return .Dv NULL -if an error is detected. +if an error is detected with the exception of +.Fn initscr +which will log a diagnostic to standard error output and then call +.Xr exit 3 . The functions that return an int will return one of the following values: .Pp
CVS commit: src/lib/libcurses
Module Name:src Committed By: roy Date: Wed Mar 11 23:47:40 UTC 2020 Modified Files: src/lib/libcurses: erase.c Log Message: curses: Fix werase(3) wide character support We need to consider erasing all attributes, not just WA_ATTRIBUTES. Fixes PR lib/23910. While here, make the function a little more readable. To generate a diff of this commit: cvs rdiff -u -r1.28 -r1.29 src/lib/libcurses/erase.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/erase.c diff -u src/lib/libcurses/erase.c:1.28 src/lib/libcurses/erase.c:1.29 --- src/lib/libcurses/erase.c:1.28 Sun Jun 9 07:40:14 2019 +++ src/lib/libcurses/erase.c Wed Mar 11 23:47:40 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: erase.c,v 1.28 2019/06/09 07:40:14 blymn Exp $ */ +/* $NetBSD: erase.c,v 1.29 2020/03/11 23:47:40 roy Exp $ */ /* * Copyright (c) 1981, 1993, 1994 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)erase.c 8.2 (Berkeley) 5/4/94"; #else -__RCSID("$NetBSD: erase.c,v 1.28 2019/06/09 07:40:14 blymn Exp $"); +__RCSID("$NetBSD: erase.c,v 1.29 2020/03/11 23:47:40 roy Exp $"); #endif #endif/* not lint */ @@ -79,27 +79,31 @@ werase(WINDOW *win) for (y = 0; y < win->maxy; y++) { start = win->alines[y]->line; end = &start[win->maxx]; - for (sp = start; sp < end; sp++) + for (sp = start; sp < end; sp++) { #ifndef HAVE_WCHAR - if (sp->ch != win->bch || sp->attr != 0) { + if (sp->ch == win->bch && sp->attr == 0) +continue; #else - if (sp->ch != ( wchar_t )btowc(( int ) win->bch ) || - (sp->attr & WA_ATTRIBUTES) != 0 || sp->nsp) { -#endif /* HAVE_WCHAR */ -if (sp->attr & __ALTCHARSET) - sp->attr = attr | __ALTCHARSET; -else - sp->attr = attr; -#ifdef HAVE_WCHAR -sp->ch = ( wchar_t )btowc(( int ) win->bch); -if (_cursesi_copy_nsp(win->bnsp, sp) == ERR) - return ERR; -SET_WCOL( *sp, 1 ); + if (sp->ch == (wchar_t)btowc((int)win->bch) && + sp->attr == 0 && + sp->nsp == NULL) +continue; +#endif + if (sp->attr & __ALTCHARSET) +sp->attr = attr | __ALTCHARSET; + else +sp->attr = attr; +#ifndef HAVE_WCHAR + sp->ch = win->bch; #else -sp->ch = win->bch; + sp->ch = (wchar_t)btowc((int)win->bch); + if (_cursesi_copy_nsp(win->bnsp, sp) == ERR) +return ERR; + SET_WCOL(*sp, 1); #endif /* HAVE_WCHAR */ - } + } } + /* * Mark the whole window as changed in case we have overlapping * windows - this will result in the (intended) clearing of the
CVS commit: src/lib/libcurses
Module Name:src Committed By: roy Date: Wed Mar 11 21:33:38 UTC 2020 Modified Files: src/lib/libcurses: initscr.c Log Message: curses: application should exit if initscr(3) fails POSIX defines this behaviour here: https://pubs.opengroup.org/onlinepubs/7908799/xcurses/initscr.html Partial fix for PR lib/23910 To generate a diff of this commit: cvs rdiff -u -r1.33 -r1.34 src/lib/libcurses/initscr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/initscr.c diff -u src/lib/libcurses/initscr.c:1.33 src/lib/libcurses/initscr.c:1.34 --- src/lib/libcurses/initscr.c:1.33 Tue Oct 2 17:35:44 2018 +++ src/lib/libcurses/initscr.c Wed Mar 11 21:33:38 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: initscr.c,v 1.33 2018/10/02 17:35:44 roy Exp $ */ +/* $NetBSD: initscr.c,v 1.34 2020/03/11 21:33:38 roy Exp $ */ /* * Copyright (c) 1981, 1993, 1994 @@ -34,10 +34,11 @@ #if 0 static char sccsid[] = "@(#)initscr.c 8.2 (Berkeley) 5/4/94"; #else -__RCSID("$NetBSD: initscr.c,v 1.33 2018/10/02 17:35:44 roy Exp $"); +__RCSID("$NetBSD: initscr.c,v 1.34 2020/03/11 21:33:38 roy Exp $"); #endif #endif /* not lint */ +#include #include #include "curses.h" @@ -66,7 +67,7 @@ initscr(void) /* LINTED const castaway; newterm does not modify sp! */ if ((_cursesi_screen = newterm((char *) sp, stdout, stdin)) == NULL) - return NULL; + errx(EXIT_FAILURE, "initscr"); /* POSIX says exit on failure */ set_term(_cursesi_screen); wrefresh(curscr);
CVS commit: src/lib/libcurses
Module Name:src Committed By: blymn Date: Wed Apr 24 07:09:44 UTC 2019 Modified Files: src/lib/libcurses: add_wch.c refresh.c touchwin.c Log Message: Add/improve debug output for some routines. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/lib/libcurses/add_wch.c cvs rdiff -u -r1.107 -r1.108 src/lib/libcurses/refresh.c cvs rdiff -u -r1.30 -r1.31 src/lib/libcurses/touchwin.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/add_wch.c diff -u src/lib/libcurses/add_wch.c:1.6 src/lib/libcurses/add_wch.c:1.7 --- src/lib/libcurses/add_wch.c:1.6 Thu Nov 22 22:16:45 2018 +++ src/lib/libcurses/add_wch.c Wed Apr 24 07:09:44 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: add_wch.c,v 1.6 2018/11/22 22:16:45 uwe Exp $ */ +/* $NetBSD: add_wch.c,v 1.7 2019/04/24 07:09:44 blymn Exp $ */ /* * Copyright (c) 2005 The NetBSD Foundation Inc. @@ -36,7 +36,7 @@ #include #ifndef lint -__RCSID("$NetBSD: add_wch.c,v 1.6 2018/11/22 22:16:45 uwe Exp $"); +__RCSID("$NetBSD: add_wch.c,v 1.7 2019/04/24 07:09:44 blymn Exp $"); #endif /* not lint */ #include @@ -101,7 +101,8 @@ wadd_wch(WINDOW *win, const cchar_t *wch for (i = 0; i < win->maxy; i++) { assert(win->alines[i]->sentinel == SENTINEL_VALUE); } - __CTRACE(__CTRACE_INPUT, "wadd_wch: win(%p)\n", win); + __CTRACE(__CTRACE_INPUT, "wadd_wch: win(%p), x: %d, y: %d\n", + win, x, y); #endif lnp = win->alines[y]; return _cursesi_addwchar(win, &lnp, &y, &x, wch, 1); Index: src/lib/libcurses/refresh.c diff -u src/lib/libcurses/refresh.c:1.107 src/lib/libcurses/refresh.c:1.108 --- src/lib/libcurses/refresh.c:1.107 Fri Mar 29 18:32:45 2019 +++ src/lib/libcurses/refresh.c Wed Apr 24 07:09:44 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: refresh.c,v 1.107 2019/03/29 18:32:45 roy Exp $ */ +/* $NetBSD: refresh.c,v 1.108 2019/04/24 07:09:44 blymn Exp $ */ /* * Copyright (c) 1981, 1993, 1994 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)refresh.c 8.7 (Berkeley) 8/13/94"; #else -__RCSID("$NetBSD: refresh.c,v 1.107 2019/03/29 18:32:45 roy Exp $"); +__RCSID("$NetBSD: refresh.c,v 1.108 2019/04/24 07:09:44 blymn Exp $"); #endif #endif/* not lint */ @@ -251,14 +251,19 @@ _wnoutrefresh(WINDOW *win, int begy, int "_wnoutrefresh: wy %d\tf %d\tl %d\tflags %x\n", wy, *wlp->firstchp, *wlp->lastchp, wlp->flags); - if ((dwin->flags & __ISDERWIN) != 0) { - __CTRACE(__CTRACE_REFRESH, - "_wnoutrefresh: derwin wy %d\tf %d\tl %d\tflags %x\n", - dy_off, *dwlp->firstchp, *dwlp->lastchp, dwlp->flags); - __CTRACE(__CTRACE_REFRESH, - "_wnoutrefresh: derwin maxx %d\tch_off %d\n", - dwin->maxx, dwin->ch_off); - } + char *_wintype; + + if ((dwin->flags & __ISDERWIN) != 0) + _wintype = "derwin"; + else + _wintype = "dwin"; + + __CTRACE(__CTRACE_REFRESH, + "_wnoutrefresh: %s wy %d\tf %d\tl %d\tflags %x\n", + _wintype, dy_off, *dwlp->firstchp, *dwlp->lastchp, dwlp->flags); + __CTRACE(__CTRACE_REFRESH, + "_wnoutrefresh: %s maxx %d\tch_off %d\n", + _wintype, dwin->maxx, dwin->ch_off); #endif if (((wlp->flags & (__ISDIRTY | __ISFORCED)) == 0) && ((dwlp->flags & (__ISDIRTY | __ISFORCED)) == 0)) Index: src/lib/libcurses/touchwin.c diff -u src/lib/libcurses/touchwin.c:1.30 src/lib/libcurses/touchwin.c:1.31 --- src/lib/libcurses/touchwin.c:1.30 Fri Jan 6 13:53:18 2017 +++ src/lib/libcurses/touchwin.c Wed Apr 24 07:09:44 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: touchwin.c,v 1.30 2017/01/06 13:53:18 roy Exp $ */ +/* $NetBSD: touchwin.c,v 1.31 2019/04/24 07:09:44 blymn Exp $ */ /* * Copyright (c) 1981, 1993, 1994 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)touchwin.c 8.2 (Berkeley) 5/4/94"; #else -__RCSID("$NetBSD: touchwin.c,v 1.30 2017/01/06 13:53:18 roy Exp $"); +__RCSID("$NetBSD: touchwin.c,v 1.31 2019/04/24 07:09:44 blymn Exp $"); #endif #endif/* not lint */ @@ -67,6 +67,10 @@ is_linetouched(WINDOW *win, int line) if (line > win->maxy) return FALSE; +#ifdef DEBUG + __CTRACE(__CTRACE_LINE, "is_linetouched: (%p, line %d, dirty %d)\n", + win, line, (win->alines[line]->flags & __ISDIRTY)); +#endif return (win->alines[line]->flags & __ISDIRTY) != 0; } @@ -106,6 +110,10 @@ is_wintouched(WINDOW *win) { int y, maxy; +#ifdef DEBUG + __CTRACE(__CTRACE_LINE, "is_wintouched: (%p, maxy %d)\n", win, + win->maxy); +#endif maxy = win->maxy; for (y = 0; y < maxy; y++) { if (is_linetouched(win, y) == TRUE)
CVS commit: src/lib/libcurses
Module Name:src Committed By: roy Date: Mon Apr 1 11:39:15 UTC 2019 Modified Files: src/lib/libcurses: curses_private.h delwin.c newwin.c printw.c Log Message: printw: rework vw_printw so it uses open_memstream rather than funopen2 This makes it more portable as open_memstream is POSIX and fixes a potential issue with wide characters not fully being printed due to any buffer overflow. To generate a diff of this commit: cvs rdiff -u -r1.68 -r1.69 src/lib/libcurses/curses_private.h cvs rdiff -u -r1.20 -r1.21 src/lib/libcurses/delwin.c cvs rdiff -u -r1.54 -r1.55 src/lib/libcurses/newwin.c cvs rdiff -u -r1.26 -r1.27 src/lib/libcurses/printw.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/curses_private.h diff -u src/lib/libcurses/curses_private.h:1.68 src/lib/libcurses/curses_private.h:1.69 --- src/lib/libcurses/curses_private.h:1.68 Fri Nov 16 10:12:00 2018 +++ src/lib/libcurses/curses_private.h Mon Apr 1 11:39:15 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: curses_private.h,v 1.68 2018/11/16 10:12:00 blymn Exp $ */ +/* $NetBSD: curses_private.h,v 1.69 2019/04/01 11:39:15 roy Exp $ */ /*- * Copyright (c) 1998-2000 Brett Lymn @@ -151,6 +151,8 @@ struct __window { /* Window structure. nschar_t *bnsp; /* Background non-spacing char list */ #endif /* HAVE_WCHAR */ FILE *fp; /* for window formatted printf */ + char *buf; /* buffer for window formatted printf */ + size_t buflen; /* length of above buffer */ }; /* Set of attributes unset by 'me' - 'mb', 'md', 'mh', 'mk', 'mp' and 'mr'. */ Index: src/lib/libcurses/delwin.c diff -u src/lib/libcurses/delwin.c:1.20 src/lib/libcurses/delwin.c:1.21 --- src/lib/libcurses/delwin.c:1.20 Fri Jan 6 13:53:18 2017 +++ src/lib/libcurses/delwin.c Mon Apr 1 11:39:15 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: delwin.c,v 1.20 2017/01/06 13:53:18 roy Exp $ */ +/* $NetBSD: delwin.c,v 1.21 2019/04/01 11:39:15 roy Exp $ */ /* * Copyright (c) 1981, 1993, 1994 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)delwin.c 8.2 (Berkeley) 5/4/94"; #else -__RCSID("$NetBSD: delwin.c,v 1.20 2017/01/06 13:53:18 roy Exp $"); +__RCSID("$NetBSD: delwin.c,v 1.21 2019/04/01 11:39:15 roy Exp $"); #endif #endif/* not lint */ @@ -114,6 +114,7 @@ delwin(WINDOW *win) _cursesi_screen->__virtscr = NULL; if (win->fp) fclose(win->fp); + free(win->buf); free(win); return OK; } Index: src/lib/libcurses/newwin.c diff -u src/lib/libcurses/newwin.c:1.54 src/lib/libcurses/newwin.c:1.55 --- src/lib/libcurses/newwin.c:1.54 Wed Oct 10 09:40:11 2018 +++ src/lib/libcurses/newwin.c Mon Apr 1 11:39:15 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: newwin.c,v 1.54 2018/10/10 09:40:11 roy Exp $ */ +/* $NetBSD: newwin.c,v 1.55 2019/04/01 11:39:15 roy Exp $ */ /* * Copyright (c) 1981, 1993, 1994 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)newwin.c 8.3 (Berkeley) 7/27/94"; #else -__RCSID("$NetBSD: newwin.c,v 1.54 2018/10/10 09:40:11 roy Exp $"); +__RCSID("$NetBSD: newwin.c,v 1.55 2019/04/01 11:39:15 roy Exp $"); #endif #endif/* not lint */ @@ -303,6 +303,8 @@ __makenew(SCREEN *screen, int nlines, in __CTRACE(__CTRACE_WINDOW, "makenew: win = %p\n", win); #endif win->fp = NULL; + win->buf = NULL; + win->buflen = 0; /* Set up line pointer array and line space. */ if ((win->alines = malloc(nlines * sizeof(__LINE *))) == NULL) { Index: src/lib/libcurses/printw.c diff -u src/lib/libcurses/printw.c:1.26 src/lib/libcurses/printw.c:1.27 --- src/lib/libcurses/printw.c:1.26 Thu Mar 28 23:24:22 2019 +++ src/lib/libcurses/printw.c Mon Apr 1 11:39:15 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: printw.c,v 1.26 2019/03/28 23:24:22 uwe Exp $ */ +/* $NetBSD: printw.c,v 1.27 2019/04/01 11:39:15 roy 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.26 2019/03/28 23:24:22 uwe Exp $"); +__RCSID("$NetBSD: printw.c,v 1.27 2019/04/01 11:39:15 roy Exp $"); #endif #endif/* not lint */ @@ -110,22 +110,7 @@ mvwprintw(WINDOW * win, int y, int x, co va_end(ap); return ret; } -/* - * Internal write-buffer-to-window function. - */ -static ssize_t -winwrite(void *cookie, const void *vbuf, size_t n) -{ - WINDOW *win = cookie; - const char *buf = vbuf; - int status; - - status = waddnstr(win, buf, n); - if (status == ERR) - return -1; - return (ssize_t)n; -} /* * vw_printw -- * This routine actually executes the printf and adds it to the window. @@ -133,14 +118,23 @@ winwrite(void *cookie, const void *vbuf, int vw_printw(WINDOW *win, const char *fmt, va_list ap) { + int n; + if (win->fp == NULL) { - win->fp = funopen2(win, NULL, winwrite, NULL, NULL, NULL); - if (win->fp == NULL) + win->fp = open_memstream(&win->buf, &win->buflen); + if (__predict_false(win->fp == NULL)) return ERR; - } - vfprintf(win->fp, fmt, ap);
CVS commit: src/lib/libcurses
Module Name:src Committed By: roy Date: Fri Mar 29 18:32:45 UTC 2019 Modified Files: src/lib/libcurses: refresh.c Log Message: Minor adjustment to prior to match putch To generate a diff of this commit: cvs rdiff -u -r1.106 -r1.107 src/lib/libcurses/refresh.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/refresh.c diff -u src/lib/libcurses/refresh.c:1.106 src/lib/libcurses/refresh.c:1.107 --- src/lib/libcurses/refresh.c:1.106 Fri Mar 29 16:56:58 2019 +++ src/lib/libcurses/refresh.c Fri Mar 29 18:32:45 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: refresh.c,v 1.106 2019/03/29 16:56:58 roy Exp $ */ +/* $NetBSD: refresh.c,v 1.107 2019/03/29 18:32:45 roy Exp $ */ /* * Copyright (c) 1981, 1993, 1994 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)refresh.c 8.7 (Berkeley) 8/13/94"; #else -__RCSID("$NetBSD: refresh.c,v 1.106 2019/03/29 16:56:58 roy Exp $"); +__RCSID("$NetBSD: refresh.c,v 1.107 2019/03/29 18:32:45 roy Exp $"); #endif #endif/* not lint */ @@ -1317,7 +1317,7 @@ makech(int wy) #ifdef HAVE_WCHAR chw = WCOL(*nsp); if (chw < 0) -chw = 1; +chw = 0; /* match putch() */ #else chw = 1; #endif /* HAVE_WCHAR */
CVS commit: src/lib/libcurses
Module Name:src Committed By: roy Date: Fri Mar 29 16:56:58 UTC 2019 Modified Files: src/lib/libcurses: refresh.c Log Message: Use WCOL rather than wcwidth(3) as we should already know the width during refresh. Ensure the character width is not negative when advancing during refresh (unlikely) and we actually have something to insert in the lower right corner depending on terminal caps. Fixes PR lib/54085 To generate a diff of this commit: cvs rdiff -u -r1.105 -r1.106 src/lib/libcurses/refresh.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/refresh.c diff -u src/lib/libcurses/refresh.c:1.105 src/lib/libcurses/refresh.c:1.106 --- src/lib/libcurses/refresh.c:1.105 Sun Jan 6 04:27:53 2019 +++ src/lib/libcurses/refresh.c Fri Mar 29 16:56:58 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: refresh.c,v 1.105 2019/01/06 04:27:53 uwe Exp $ */ +/* $NetBSD: refresh.c,v 1.106 2019/03/29 16:56:58 roy Exp $ */ /* * Copyright (c) 1981, 1993, 1994 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)refresh.c 8.7 (Berkeley) 8/13/94"; #else -__RCSID("$NetBSD: refresh.c,v 1.105 2019/01/06 04:27:53 uwe Exp $"); +__RCSID("$NetBSD: refresh.c,v 1.106 2019/03/29 16:56:58 roy Exp $"); #endif #endif/* not lint */ @@ -1042,16 +1042,14 @@ putchbr(__LDATA *nsp, __LDATA *csp, __LD return error; } - /* We need to insert characters. - * To do this, work out their widths. - * XXX This does not work when the bottom right corner is an ACS. */ + /* We need to insert characters. */ #ifdef HAVE_WCHAR - cw = wcwidth(nsp->ch); - pcw = psp == NULL ? 0 : wcwidth(psp->ch); - if (pcw < 1) + cw = WCOL(*nsp); + pcw = WCOL(*psp); + if (cw < 1 || pcw < 1) return ERR; /* Nothing to insert */ - /* When wide characters we need something other than + /* When inserting a wide character, we need something other than * insert_character. */ if (pcw > 1 && !(parm_ich != NULL || @@ -1317,7 +1315,9 @@ makech(int wy) } #ifdef HAVE_WCHAR - chw = wcwidth(nsp->ch); + chw = WCOL(*nsp); + if (chw < 0) +chw = 1; #else chw = 1; #endif /* HAVE_WCHAR */
CVS commit: src/lib/libcurses
Module Name:src Committed By: uwe Date: Thu Mar 28 23:24:22 UTC 2019 Modified Files: src/lib/libcurses: printw.c Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.26 src/lib/libcurses/printw.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/printw.c diff -u src/lib/libcurses/printw.c:1.25 src/lib/libcurses/printw.c:1.26 --- src/lib/libcurses/printw.c:1.25 Thu Mar 21 21:28:55 2019 +++ src/lib/libcurses/printw.c Thu Mar 28 23:24:22 2019 @@ -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 @@ winwrite(void *cookie, const void *vbuf, { WINDOW *win = cookie; const char *buf = vbuf; - size_t c; + int status; + + status = waddnstr(win, buf, n); + if (status == ERR) + return -1; - 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; - } return (ssize_t)n; } /*
CVS commit: src/lib/libcurses
Module Name:src Committed By: uwe Date: Thu Mar 21 21:28:55 UTC 2019 Modified Files: src/lib/libcurses: printw.c Log Message: winwrite - deobfuscate a bit. To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/lib/libcurses/printw.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/printw.c diff -u src/lib/libcurses/printw.c:1.24 src/lib/libcurses/printw.c:1.25 --- src/lib/libcurses/printw.c:1.24 Fri Jan 6 13:53:18 2017 +++ src/lib/libcurses/printw.c Thu Mar 21 21:28:55 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: printw.c,v 1.24 2017/01/06 13:53:18 roy Exp $ */ +/* $NetBSD: printw.c,v 1.25 2019/03/21 21:28:55 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.24 2017/01/06 13:53:18 roy Exp $"); +__RCSID("$NetBSD: printw.c,v 1.25 2019/03/21 21:28:55 uwe Exp $"); #endif #endif/* not lint */ @@ -114,13 +114,13 @@ mvwprintw(WINDOW * win, int y, int x, co * Internal write-buffer-to-window function. */ static ssize_t -winwrite(void *cookie, const void *vbuf, size_t n) +winwrite(void *cookie, const void *vbuf, size_t n) { - WINDOW *win; - size_t c; + WINDOW *win = cookie; const char *buf = vbuf; + size_t c; - for (c = 0, win = cookie; c < n; c++) { + for (c = 0; c < n; c++) { #ifdef DEBUG __CTRACE(__CTRACE_MISC, "__winwrite: %c\n", *buf); #endif
CVS commit: src/lib/libcurses
Module Name:src Committed By: rin Date: Thu Mar 14 00:36:06 UTC 2019 Modified Files: src/lib/libcurses: get_wch.c getch.c Log Message: Rename global variable "state" to "_cursesi_state". Until now, if application happens to have a global variable of the same name, it was overridden by curses routines. This is the scenario in which aspell crashes when linked to our curses, reported in pkg/44005. We need to wipe out global/static variables like "_cursesi_state" or "wstate" for thread safety. But it would be a future task... XXX pullup to netbsd-8 and netbsd-7 To generate a diff of this commit: cvs rdiff -u -r1.20 -r1.21 src/lib/libcurses/get_wch.c cvs rdiff -u -r1.70 -r1.71 src/lib/libcurses/getch.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/get_wch.c diff -u src/lib/libcurses/get_wch.c:1.20 src/lib/libcurses/get_wch.c:1.21 --- src/lib/libcurses/get_wch.c:1.20 Thu Nov 22 22:16:45 2018 +++ src/lib/libcurses/get_wch.c Thu Mar 14 00:36:06 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: get_wch.c,v 1.20 2018/11/22 22:16:45 uwe Exp $ */ +/* $NetBSD: get_wch.c,v 1.21 2019/03/14 00:36:06 rin Exp $ */ /* * Copyright (c) 2005 The NetBSD Foundation Inc. @@ -36,7 +36,7 @@ #include #ifndef lint -__RCSID("$NetBSD: get_wch.c,v 1.20 2018/11/22 22:16:45 uwe Exp $"); +__RCSID("$NetBSD: get_wch.c,v 1.21 2019/03/14 00:36:06 rin Exp $"); #endif /* not lint */ #include @@ -48,8 +48,8 @@ __RCSID("$NetBSD: get_wch.c,v 1.20 2018/ #include "curses_private.h" #include "keymap.h" -static short wstate; /* state of the wcinkey function */ -extern short state; /* storage declared in getch.c */ +static short wstate; /* state of the wcinkey function */ +extern short _cursesi_state; /* storage declared in getch.c */ /* prototypes for private functions */ static int inkey(wchar_t *wc, int to, int delay); @@ -216,7 +216,7 @@ inkey(wchar_t *wc, int to, int delay) *wc = inbuf[*start]; *working = *start = (*start +1) % MAX_CBUF_SIZE; if (*start == *end) { - state = wstate = INKEY_NORM; + _cursesi_state = wstate = INKEY_NORM; #ifdef DEBUG __CTRACE(__CTRACE_INPUT, "inkey: WCASSEMBLING=>NORM, " @@ -224,7 +224,7 @@ inkey(wchar_t *wc, int to, int delay) *start, *working, *end); #endif /* DEBUG */ } else { - state = wstate = INKEY_BACKOUT; + _cursesi_state = wstate = INKEY_BACKOUT; #ifdef DEBUG __CTRACE(__CTRACE_INPUT, "inkey: WCASSEMBLING=>BACKOUT, " @@ -283,7 +283,7 @@ inkey(wchar_t *wc, int to, int delay) if (*start == *end) { /* only one char processed */ - state = wstate = INKEY_NORM; + _cursesi_state = wstate = INKEY_NORM; #ifdef DEBUG __CTRACE(__CTRACE_INPUT, "inkey: WCASSEMBLING=>NORM, " @@ -293,7 +293,7 @@ inkey(wchar_t *wc, int to, int delay) } else { /* otherwise we must have more than * one char to backout */ - state = wstate = INKEY_BACKOUT; + _cursesi_state = wstate = INKEY_BACKOUT; #ifdef DEBUG __CTRACE(__CTRACE_INPUT, "inkey: WCASSEMBLING=>BACKOUT, " @@ -381,7 +381,7 @@ inkey(wchar_t *wc, int to, int delay) } if (*start == *end) { /* only one char processed */ -state = wstate = INKEY_NORM; +_cursesi_state = wstate = INKEY_NORM; #ifdef DEBUG __CTRACE(__CTRACE_INPUT, "inkey: Empty cbuf=>NORM, " @@ -391,7 +391,7 @@ inkey(wchar_t *wc, int to, int delay) } else { /* otherwise we must have more than one * char to backout */ -state = wstate = INKEY_BACKOUT; +_cursesi_state = wstate = INKEY_BACKOUT; #ifdef DEBUG __CTRACE(__CTRACE_INPUT, "inkey: Non-empty cbuf=>BACKOUT, " @@ -416,7 +416,7 @@ inkey(wchar_t *wc, int to, int delay) #endif /* DEBUG */ if (*start == *end) { /* if it is go back to normal */ - state = wstate = INKEY_NORM; + _cursesi_state = wstate = INKEY_NORM; #ifdef DEBUG __CTRACE(__CTRACE_INPUT, "[inkey]=>NORM, start(%d), " @@ -425,7 +425,7 @@ inkey(wchar_t *wc, int to, int delay) #endif /* DEBUG */ } else { /* otherwise go to backout state */ - state = wstate = INKEY_BACKOUT; + _cursesi_state = wstate = INKEY_BACKOUT; #ifdef DEBUG __CTRACE(__CTRACE_INPUT, "[inkey]=>BACKOUT, start(%d), " Index: src/lib/libcurses/getch.c diff -u src/lib/libcurses/getch.c:1.70 src/lib/libcurses/getch.c:1.71 --- src/lib/libcurses/getch.c:1.70 Fri Sep 28 15:03:48 2018 +++ src/lib/libcurses/getch.c Thu Mar 14 00:36:06 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: getch.c,v 1.70 2018/09/28 15:03:48 roy Exp $ */ +/* $NetBSD: getch.c,v 1.71 2019/03/14 00:36:06 rin Exp $ */ /* * Copyright (c) 1981, 1993, 1994 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)getch.c 8.2 (Berkeley) 5/4/94"; #else -__RCSID("$NetBSD: getch.c,v 1.70 2018/09/28 15:03:48 roy Exp $"); +__RCSID("$NetBSD: getch.c,v
CVS commit: src/lib/libcurses
Module Name:src Committed By: roy Date: Sun Feb 24 20:20:18 UTC 2019 Modified Files: src/lib/libcurses: get_wstr.c getstr.c in_wchstr.c inchstr.c instr.c inwstr.c Log Message: Fix warn macro usage. Thanks to rofl0r. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/lib/libcurses/get_wstr.c \ src/lib/libcurses/in_wchstr.c src/lib/libcurses/inwstr.c cvs rdiff -u -r1.24 -r1.25 src/lib/libcurses/getstr.c cvs rdiff -u -r1.7 -r1.8 src/lib/libcurses/inchstr.c cvs rdiff -u -r1.4 -r1.5 src/lib/libcurses/instr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/get_wstr.c diff -u src/lib/libcurses/get_wstr.c:1.5 src/lib/libcurses/get_wstr.c:1.6 --- src/lib/libcurses/get_wstr.c:1.5 Thu Nov 22 22:16:45 2018 +++ src/lib/libcurses/get_wstr.c Sun Feb 24 20:20:18 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: get_wstr.c,v 1.5 2018/11/22 22:16:45 uwe Exp $ */ +/* $NetBSD: get_wstr.c,v 1.6 2019/02/24 20:20:18 roy Exp $ */ /* * Copyright (c) 2005 The NetBSD Foundation Inc. @@ -36,7 +36,7 @@ #include #ifndef lint -__RCSID("$NetBSD: get_wstr.c,v 1.5 2018/11/22 22:16:45 uwe Exp $"); +__RCSID("$NetBSD: get_wstr.c,v 1.6 2019/02/24 20:20:18 roy Exp $"); #endif /* not lint */ #include "curses.h" @@ -61,7 +61,7 @@ getn_wstr(wchar_t *wstr, int n) * Get a string from stdscr starting at (cury, curx). */ __warn_references(get_wstr, - "warning: this program uses get_wstr(), which is unsafe.") + "warning: this program uses get_wstr(), which is unsafe."); int get_wstr(wchar_t *wstr) { @@ -83,7 +83,7 @@ mvgetn_wstr(int y, int x, wchar_t *wstr, * Get a string from stdscr starting at (y, x). */ __warn_references(mvget_wstr, - "warning: this program uses mvget_wstr(), which is unsafe.") + "warning: this program uses mvget_wstr(), which is unsafe."); int mvget_wstr(int y, int x, wchar_t *wstr) { @@ -109,7 +109,7 @@ mvwgetn_wstr(WINDOW *win, int y, int x, * Get a string from the given window starting at (y, x). */ __warn_references(mvget_wstr, - "warning: this program uses mvget_wstr(), which is unsafe.") + "warning: this program uses mvget_wstr(), which is unsafe."); int mvwget_wstr(WINDOW *win, int y, int x, wchar_t *wstr) { @@ -124,7 +124,7 @@ mvwget_wstr(WINDOW *win, int y, int x, w * Get a string starting at (cury, curx). */ __warn_references(wget_wstr, - "warning: this program uses wget_wstr(), which is unsafe.") + "warning: this program uses wget_wstr(), which is unsafe."); int wget_wstr(WINDOW *win, wchar_t *wstr) { Index: src/lib/libcurses/in_wchstr.c diff -u src/lib/libcurses/in_wchstr.c:1.5 src/lib/libcurses/in_wchstr.c:1.6 --- src/lib/libcurses/in_wchstr.c:1.5 Thu Nov 22 22:16:45 2018 +++ src/lib/libcurses/in_wchstr.c Sun Feb 24 20:20:18 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: in_wchstr.c,v 1.5 2018/11/22 22:16:45 uwe Exp $ */ +/* $NetBSD: in_wchstr.c,v 1.6 2019/02/24 20:20:18 roy Exp $ */ /* * Copyright (c) 2005 The NetBSD Foundation Inc. @@ -36,7 +36,7 @@ #include #ifndef lint -__RCSID("$NetBSD: in_wchstr.c,v 1.5 2018/11/22 22:16:45 uwe Exp $"); +__RCSID("$NetBSD: in_wchstr.c,v 1.6 2019/02/24 20:20:18 roy Exp $"); #endif /* not lint */ #include "curses.h" @@ -47,7 +47,7 @@ __RCSID("$NetBSD: in_wchstr.c,v 1.5 2018 * Return an array of wide characters at cursor position from stdscr. */ __warn_references(in_wchstr, - "warning: this program uses in_wchstr(), which is unsafe.") + "warning: this program uses in_wchstr(), which is unsafe."); int in_wchstr(cchar_t *wchstr) { @@ -65,7 +65,7 @@ in_wchnstr(cchar_t *wchstr, int n) * Return an array of wide characters at position (y, x) from stdscr. */ __warn_references(mvin_wchstr, - "warning: this program uses mvin_wchstr(), which is unsafe.") + "warning: this program uses mvin_wchstr(), which is unsafe."); int mvin_wchstr(int y, int x, cchar_t *wchstr) { @@ -83,7 +83,7 @@ mvin_wchnstr(int y, int x, cchar_t *wchs * Return an array wide characters at position (y, x) from the given window. */ __warn_references(mvwin_wchstr, - "warning: this program uses mvwin_wchstr(), which is unsafe.") + "warning: this program uses mvwin_wchstr(), which is unsafe."); int mvwin_wchstr(WINDOW *win, int y, int x, cchar_t *wchstr) { @@ -107,7 +107,7 @@ mvwin_wchnstr(WINDOW *win, int y, int x, * Return an array of characters at cursor position. */ __warn_references(win_wchstr, - "warning: this program uses win_wchstr(), which is unsafe.") + "warning: this program uses win_wchstr(), which is unsafe."); int win_wchstr(WINDOW *win, cchar_t *wchstr) { Index: src/lib/libcurses/inwstr.c diff -u src/lib/libcurses/inwstr.c:1.5 src/lib/libcurses/inwstr.c:1.6 --- src/lib/libcurses/inwstr.c:1.5 Thu Nov 22 22:16:45 2018 +++ src/lib/libcurses/inwstr.c Sun Feb 24 20:20:18 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: inwstr.c,v 1.5 2018/11/22 22:16:45 uwe Exp $ */ +/* $NetBS
CVS commit: src/lib/libcurses
Module Name:src Committed By: dholland Date: Fri Jan 11 06:14:39 UTC 2019 Modified Files: src/lib/libcurses: curses_clear.3 Log Message: At some point we lost the text that explains the difference between clear() and erase(). Or possibly we never had any. Put some back. Bump date. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/lib/libcurses/curses_clear.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/curses_clear.3 diff -u src/lib/libcurses/curses_clear.3:1.3 src/lib/libcurses/curses_clear.3:1.4 --- src/lib/libcurses/curses_clear.3:1.3 Wed Apr 16 13:35:00 2003 +++ src/lib/libcurses/curses_clear.3 Fri Jan 11 06:14:39 2019 @@ -1,4 +1,4 @@ -.\" $NetBSD: curses_clear.3,v 1.3 2003/04/16 13:35:00 wiz Exp $ +.\" $NetBSD: curses_clear.3,v 1.4 2019/01/11 06:14:39 dholland Exp $ .\" .\" Copyright (c) 2002 .\" Brett Lymn (bl...@netbsd.org, brett_l...@yahoo.com.au) @@ -30,7 +30,7 @@ .\" SUCH DAMAGE. .\" .\" -.Dd August 12, 2002 +.Dd January 11, 2019 .Dt CURSES_CLEAR 3 .Os .Sh NAME @@ -78,6 +78,13 @@ and .Fn erase functions erase all characters on .Dv stdscr . +These differ in that +.Fn clear +uses +.Fn clearok +to force a complete redraw on the next refresh, and +.Fn erase +does not. .Fn wclear and .Fn werase
CVS commit: src/lib/libcurses
Module Name:src Committed By: uwe Date: Sun Jan 6 04:27:53 UTC 2019 Modified Files: src/lib/libcurses: refresh.c Log Message: _wnoutrefresh - extend current position checks. Also verify that dwin->cury >= begy (ditto for x), i.e. for pads make sure that the current position is after the beginning of the displayed portion. While here refactor the checks for better readability. We should probably combine the y and x checks b/c if one of them is not in the range, the current position as a whole is not in the range and it doesn't make sense to pick and set just the y or just the x part of it. To generate a diff of this commit: cvs rdiff -u -r1.104 -r1.105 src/lib/libcurses/refresh.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/refresh.c diff -u src/lib/libcurses/refresh.c:1.104 src/lib/libcurses/refresh.c:1.105 --- src/lib/libcurses/refresh.c:1.104 Sun Jan 6 03:59:17 2019 +++ src/lib/libcurses/refresh.c Sun Jan 6 04:27:53 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: refresh.c,v 1.104 2019/01/06 03:59:17 uwe Exp $ */ +/* $NetBSD: refresh.c,v 1.105 2019/01/06 04:27:53 uwe Exp $ */ /* * Copyright (c) 1981, 1993, 1994 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)refresh.c 8.7 (Berkeley) 8/13/94"; #else -__RCSID("$NetBSD: refresh.c,v 1.104 2019/01/06 03:59:17 uwe Exp $"); +__RCSID("$NetBSD: refresh.c,v 1.105 2019/01/06 04:27:53 uwe Exp $"); #endif #endif/* not lint */ @@ -165,6 +165,7 @@ _wnoutrefresh(WINDOW *win, int begy, int { SCREEN *screen = win->screen; short sy, wy, wx, y_off, x_off, mx, dy_off, dx_off, endy; + int newy, newx; __LINE *wlp, *vlp, *dwlp; WINDOW *sub_win, *orig, *swin, *dwin; @@ -217,12 +218,14 @@ _wnoutrefresh(WINDOW *win, int begy, int } /* Check that cursor position on "win" is valid for "__virtscr" */ - if (dwin->cury + wbegy - begy < screen->__virtscr->maxy && - dwin->cury + wbegy - begy >= 0 && dwin->cury < maxy) - screen->__virtscr->cury = dwin->cury + wbegy - begy; - if (dwin->curx + wbegx - begx < screen->__virtscr->maxx && - dwin->curx + wbegx - begx >= 0 && dwin->curx < maxx) - screen->__virtscr->curx = dwin->curx + wbegx - begx; + newy = wbegy + dwin->cury - begy; + newx = wbegx + dwin->curx - begx; + if (begy <= dwin->cury && dwin->cury < maxy + && 0 <= newy && newy < screen->__virtscr->maxy) + screen->__virtscr->cury = newy; + if (begx <= dwin->curx && dwin->curx < maxx + && 0 <= newx && newx < screen->__virtscr->maxx) + screen->__virtscr->curx = newx; /* Copy the window flags from "win" to "__virtscr" */ if (dwin->flags & __CLEAROK) {
CVS commit: src/lib/libcurses
Module Name:src Committed By: uwe Date: Sun Jan 6 03:59:17 UTC 2019 Modified Files: src/lib/libcurses: refresh.c Log Message: _wnoutrefresh - fix current position checks for pads maxy is an absolute value and should not be adjusted for begy when we check also absolute cury. Note that this change does not affect calculations for normal windows as for them we always pass zero for begy. Ditto for x. To generate a diff of this commit: cvs rdiff -u -r1.103 -r1.104 src/lib/libcurses/refresh.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/refresh.c diff -u src/lib/libcurses/refresh.c:1.103 src/lib/libcurses/refresh.c:1.104 --- src/lib/libcurses/refresh.c:1.103 Sun Jan 6 03:46:11 2019 +++ src/lib/libcurses/refresh.c Sun Jan 6 03:59:17 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: refresh.c,v 1.103 2019/01/06 03:46:11 uwe Exp $ */ +/* $NetBSD: refresh.c,v 1.104 2019/01/06 03:59:17 uwe Exp $ */ /* * Copyright (c) 1981, 1993, 1994 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)refresh.c 8.7 (Berkeley) 8/13/94"; #else -__RCSID("$NetBSD: refresh.c,v 1.103 2019/01/06 03:46:11 uwe Exp $"); +__RCSID("$NetBSD: refresh.c,v 1.104 2019/01/06 03:59:17 uwe Exp $"); #endif #endif/* not lint */ @@ -218,10 +218,10 @@ _wnoutrefresh(WINDOW *win, int begy, int /* Check that cursor position on "win" is valid for "__virtscr" */ if (dwin->cury + wbegy - begy < screen->__virtscr->maxy && - dwin->cury + wbegy - begy >= 0 && dwin->cury < maxy - begy) + dwin->cury + wbegy - begy >= 0 && dwin->cury < maxy) screen->__virtscr->cury = dwin->cury + wbegy - begy; if (dwin->curx + wbegx - begx < screen->__virtscr->maxx && - dwin->curx + wbegx - begx >= 0 && dwin->curx < maxx - begx) + dwin->curx + wbegx - begx >= 0 && dwin->curx < maxx) screen->__virtscr->curx = dwin->curx + wbegx - begx; /* Copy the window flags from "win" to "__virtscr" */
CVS commit: src/lib/libcurses
Module Name:src Committed By: uwe Date: Sun Jan 6 03:46:11 UTC 2019 Modified Files: src/lib/libcurses: refresh.c Log Message: prefresh - fix current position calculations The code was copy-pasted from wrefresh(), but for pads we need to adjust for (pbegy, pbegx). PR lib/53801 To generate a diff of this commit: cvs rdiff -u -r1.102 -r1.103 src/lib/libcurses/refresh.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/refresh.c diff -u src/lib/libcurses/refresh.c:1.102 src/lib/libcurses/refresh.c:1.103 --- src/lib/libcurses/refresh.c:1.102 Fri Nov 30 04:38:14 2018 +++ src/lib/libcurses/refresh.c Sun Jan 6 03:46:11 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: refresh.c,v 1.102 2018/11/30 04:38:14 roy Exp $ */ +/* $NetBSD: refresh.c,v 1.103 2019/01/06 03:46:11 uwe Exp $ */ /* * Copyright (c) 1981, 1993, 1994 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)refresh.c 8.7 (Berkeley) 8/13/94"; #else -__RCSID("$NetBSD: refresh.c,v 1.102 2018/11/30 04:38:14 roy Exp $"); +__RCSID("$NetBSD: refresh.c,v 1.103 2019/01/06 03:46:11 uwe Exp $"); #endif #endif/* not lint */ @@ -498,8 +498,8 @@ prefresh(WINDOW *pad, int pbegy, int pbe if (retval == OK) { retval = doupdate(); if (!(pad->flags & __LEAVEOK)) { - pad->cury = max(0, curscr->cury - pad->begy); - pad->curx = max(0, curscr->curx - pad->begx); + pad->cury = max(0, pbegy + (curscr->cury - sbegy)); + pad->curx = max(0, pbegx + (curscr->curx - sbegx)); } } return retval;
CVS commit: src/lib/libcurses
Module Name:src Committed By: roy Date: Fri Nov 30 04:38:14 UTC 2018 Modified Files: src/lib/libcurses: refresh.c Log Message: curses: Fix inverted logic when drawing LR corner with auto margins Thanks to M. Levinson. To generate a diff of this commit: cvs rdiff -u -r1.101 -r1.102 src/lib/libcurses/refresh.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/refresh.c diff -u src/lib/libcurses/refresh.c:1.101 src/lib/libcurses/refresh.c:1.102 --- src/lib/libcurses/refresh.c:1.101 Sun Nov 18 02:46:24 2018 +++ src/lib/libcurses/refresh.c Fri Nov 30 04:38:14 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: refresh.c,v 1.101 2018/11/18 02:46:24 uwe Exp $ */ +/* $NetBSD: refresh.c,v 1.102 2018/11/30 04:38:14 roy Exp $ */ /* * Copyright (c) 1981, 1993, 1994 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)refresh.c 8.7 (Berkeley) 8/13/94"; #else -__RCSID("$NetBSD: refresh.c,v 1.101 2018/11/18 02:46:24 uwe Exp $"); +__RCSID("$NetBSD: refresh.c,v 1.102 2018/11/30 04:38:14 roy Exp $"); #endif #endif/* not lint */ @@ -1033,9 +1033,9 @@ putchbr(__LDATA *nsp, __LDATA *csp, __LD /* Disable auto margins temporarily. */ if (enter_am_mode && exit_am_mode) { - tputs(enter_am_mode, 0, __cputchar); - error = putch(nsp, csp, wy, wx); tputs(exit_am_mode, 0, __cputchar); + error = putch(nsp, csp, wy, wx); + tputs(enter_am_mode, 0, __cputchar); return error; }
CVS commit: src/lib/libcurses
Module Name:src Committed By: wiz Date: Sat Nov 24 11:04:39 UTC 2018 Modified Files: src/lib/libcurses: curses_cchar.3 Log Message: Grammar improvements. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/lib/libcurses/curses_cchar.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/curses_cchar.3 diff -u src/lib/libcurses/curses_cchar.3:1.1 src/lib/libcurses/curses_cchar.3:1.2 --- src/lib/libcurses/curses_cchar.3:1.1 Mon Nov 19 01:08:22 2018 +++ src/lib/libcurses/curses_cchar.3 Sat Nov 24 11:04:39 2018 @@ -1,4 +1,4 @@ -.\" $NetBSD: curses_cchar.3,v 1.1 2018/11/19 01:08:22 uwe Exp $ +.\" $NetBSD: curses_cchar.3,v 1.2 2018/11/24 11:04:39 wiz Exp $ .\" .\" Copyright (c) 2018 Valery Ushakov .\" All rights reserved. @@ -55,12 +55,12 @@ .Fa "const void *opts" .Fc .Sh DESCRIPTION -Curses uses opaque type +Curses uses the opaque type .Vt cchar_t to represent a string of wide characters up to an implementation-dependent length along with a color pair and zero or more attributes. -A null +A null .Vt cchar_t object is an object that references an empty wide-character string. Arrays of @@ -71,19 +71,19 @@ object. .Pp Objects of type .Vt cchar_t -can be manipulated using +can be manipulated using the .Nm getcchar and .Nm setcchar functions. -Both these functions take as their last paramter the +Both these functions take as their last parameter the .Fa opts argument which is reserved for future extensions. Currently, the application must provide a null pointer as .Fa opts . .\" .Pp -When +When the .Nm getcchar function is called with non-null .Fa wch @@ -96,7 +96,7 @@ is copied to the .Fa wch array. The attributes are stored in -.Fa attrs , +.Fa attrs and the color pair is stored in .Fa color_pair . In this case it returns
CVS commit: src/lib/libcurses
Module Name:src Committed By: uwe Date: Sat Nov 24 01:04:18 UTC 2018 Modified Files: src/lib/libcurses: attributes.c Log Message: attron(), attroff() - don't take a shortcut. To generate a diff of this commit: cvs rdiff -u -r1.29 -r1.30 src/lib/libcurses/attributes.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/attributes.c diff -u src/lib/libcurses/attributes.c:1.29 src/lib/libcurses/attributes.c:1.30 --- src/lib/libcurses/attributes.c:1.29 Fri Nov 23 11:16:59 2018 +++ src/lib/libcurses/attributes.c Sat Nov 24 01:04:18 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: attributes.c,v 1.29 2018/11/23 11:16:59 uwe Exp $ */ +/* $NetBSD: attributes.c,v 1.30 2018/11/24 01:04:18 uwe Exp $ */ /*- * Copyright (c) 1999 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include #ifndef lint -__RCSID("$NetBSD: attributes.c,v 1.29 2018/11/23 11:16:59 uwe Exp $"); +__RCSID("$NetBSD: attributes.c,v 1.30 2018/11/24 01:04:18 uwe Exp $"); #endif/* not lint */ #include "curses.h" @@ -105,7 +105,7 @@ color_set(short pair, void *opts) int attron(int attr) { - return __wattr_on(stdscr, (attr_t) attr); + return wattron(stdscr, attr); } /* @@ -115,7 +115,7 @@ attron(int attr) int attroff(int attr) { - return __wattr_off(stdscr, (attr_t) attr); + return wattroff(stdscr, attr); } /*
CVS commit: src/lib/libcurses
Module Name:src Committed By: uwe Date: Fri Nov 23 11:16:59 UTC 2018 Modified Files: src/lib/libcurses: attributes.c Log Message: wattr_set - turn off all wide attributes (fix unedited copy/paste). To generate a diff of this commit: cvs rdiff -u -r1.28 -r1.29 src/lib/libcurses/attributes.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/attributes.c diff -u src/lib/libcurses/attributes.c:1.28 src/lib/libcurses/attributes.c:1.29 --- src/lib/libcurses/attributes.c:1.28 Fri Nov 23 11:15:14 2018 +++ src/lib/libcurses/attributes.c Fri Nov 23 11:16:59 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: attributes.c,v 1.28 2018/11/23 11:15:14 uwe Exp $ */ +/* $NetBSD: attributes.c,v 1.29 2018/11/23 11:16:59 uwe Exp $ */ /*- * Copyright (c) 1999 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include #ifndef lint -__RCSID("$NetBSD: attributes.c,v 1.28 2018/11/23 11:15:14 uwe Exp $"); +__RCSID("$NetBSD: attributes.c,v 1.29 2018/11/23 11:16:59 uwe Exp $"); #endif/* not lint */ #include "curses.h" @@ -204,7 +204,7 @@ wattr_set(WINDOW *win, attr_t attr, shor */ attr = (attr & ~__COLOR) | COLOR_PAIR(pair); - __wattr_off(win, __ATTRIBUTES); + __wattr_off(win, WA_ATTRIBUTES); __wattr_on(win, attr); return OK; }
CVS commit: src/lib/libcurses
Module Name:src Committed By: uwe Date: Fri Nov 23 11:15:14 UTC 2018 Modified Files: src/lib/libcurses: attributes.c Log Message: Rename the reserved argument from "opt" to "opts" to match SUS text. To generate a diff of this commit: cvs rdiff -u -r1.27 -r1.28 src/lib/libcurses/attributes.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/attributes.c diff -u src/lib/libcurses/attributes.c:1.27 src/lib/libcurses/attributes.c:1.28 --- src/lib/libcurses/attributes.c:1.27 Fri Nov 23 11:11:59 2018 +++ src/lib/libcurses/attributes.c Fri Nov 23 11:15:14 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: attributes.c,v 1.27 2018/11/23 11:11:59 uwe Exp $ */ +/* $NetBSD: attributes.c,v 1.28 2018/11/23 11:15:14 uwe Exp $ */ /*- * Copyright (c) 1999 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include #ifndef lint -__RCSID("$NetBSD: attributes.c,v 1.27 2018/11/23 11:11:59 uwe Exp $"); +__RCSID("$NetBSD: attributes.c,v 1.28 2018/11/23 11:15:14 uwe Exp $"); #endif/* not lint */ #include "curses.h" @@ -49,9 +49,9 @@ static void __wcolor_set(WINDOW *, attr_ */ /* ARGSUSED */ int -attr_get(attr_t *attr, short *pair, void *opt) +attr_get(attr_t *attr, short *pair, void *opts) { - return wattr_get(stdscr, attr, pair, opt); + return wattr_get(stdscr, attr, pair, opts); } /* @@ -60,9 +60,9 @@ attr_get(attr_t *attr, short *pair, void */ /* ARGSUSED */ int -attr_on(attr_t attr, void *opt) +attr_on(attr_t attr, void *opts) { - return wattr_on(stdscr, attr, opt); + return wattr_on(stdscr, attr, opts); } /* @@ -71,9 +71,9 @@ attr_on(attr_t attr, void *opt) */ /* ARGSUSED */ int -attr_off(attr_t attr, void *opt) +attr_off(attr_t attr, void *opts) { - return wattr_off(stdscr, attr, opt); + return wattr_off(stdscr, attr, opts); } /* @@ -82,9 +82,9 @@ attr_off(attr_t attr, void *opt) */ /* ARGSUSED */ int -attr_set(attr_t attr, short pair, void *opt) +attr_set(attr_t attr, short pair, void *opts) { - return wattr_set(stdscr, attr, pair, opt); + return wattr_set(stdscr, attr, pair, opts); } /* @@ -93,9 +93,9 @@ attr_set(attr_t attr, short pair, void * */ /* ARGSUSED */ int -color_set(short pair, void *opt) +color_set(short pair, void *opts) { - return wcolor_set(stdscr, pair, opt); + return wcolor_set(stdscr, pair, opts); } /* @@ -137,7 +137,7 @@ attrset(int attr) */ /* ARGSUSED */ int -wattr_get(WINDOW *win, attr_t *attr, short *pair, void *opt) +wattr_get(WINDOW *win, attr_t *attr, short *pair, void *opts) { #ifdef DEBUG __CTRACE(__CTRACE_ATTR, "wattr_get: win %p\n", win); @@ -159,9 +159,9 @@ wattr_get(WINDOW *win, attr_t *attr, sho * Test and set wide attributes on window */ int -wattr_on(WINDOW *win, attr_t attr, void *opt) +wattr_on(WINDOW *win, attr_t attr, void *opts) { - if (__predict_false(opt != NULL)) + if (__predict_false(opts != NULL)) return ERR; return __wattr_on(win, attr); @@ -175,9 +175,9 @@ wattr_on(WINDOW *win, attr_t attr, void * which attributes should really be set in refresh.c:makech(). */ int -wattr_off(WINDOW *win, attr_t attr, void *opt) +wattr_off(WINDOW *win, attr_t attr, void *opts) { - if (__predict_false(opt != NULL)) + if (__predict_false(opts != NULL)) return ERR; return __wattr_off(win, attr); @@ -189,13 +189,13 @@ wattr_off(WINDOW *win, attr_t attr, void * Set wide attributes and color pair on window */ int -wattr_set(WINDOW *win, attr_t attr, short pair, void *opt) +wattr_set(WINDOW *win, attr_t attr, short pair, void *opts) { #ifdef DEBUG __CTRACE(__CTRACE_ATTR, "wattr_set: win %p, attr %08x, pair %d\n", win, attr, pair); #endif - if (__predict_false(opt != NULL)) + if (__predict_false(opts != NULL)) return ERR; /* @@ -215,7 +215,7 @@ wattr_set(WINDOW *win, attr_t attr, shor */ /* ARGSUSED */ int -wcolor_set(WINDOW *win, short pair, void *opt) +wcolor_set(WINDOW *win, short pair, void *opts) { #ifdef DEBUG __CTRACE(__CTRACE_COLOR, "wolor_set: win %p, pair %d\n", win, pair);
CVS commit: src/lib/libcurses
Module Name:src Committed By: uwe Date: Fri Nov 23 11:11:59 UTC 2018 Modified Files: src/lib/libcurses: attributes.c Log Message: Refactor. Move code to turn attributes on/off into separate functions. Express both old and new functions to manipulate attributes using those functions. Check that the the new API's opts argument (reserved by the standard for future use) is NULL and error out if not (like getcchar/setcchar). No functional change intended. To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 src/lib/libcurses/attributes.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/attributes.c diff -u src/lib/libcurses/attributes.c:1.26 src/lib/libcurses/attributes.c:1.27 --- src/lib/libcurses/attributes.c:1.26 Thu Nov 22 23:37:31 2018 +++ src/lib/libcurses/attributes.c Fri Nov 23 11:11:59 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: attributes.c,v 1.26 2018/11/22 23:37:31 uwe Exp $ */ +/* $NetBSD: attributes.c,v 1.27 2018/11/23 11:11:59 uwe Exp $ */ /*- * Copyright (c) 1999 The NetBSD Foundation, Inc. @@ -31,14 +31,17 @@ #include #ifndef lint -__RCSID("$NetBSD: attributes.c,v 1.26 2018/11/22 23:37:31 uwe Exp $"); +__RCSID("$NetBSD: attributes.c,v 1.27 2018/11/23 11:11:59 uwe Exp $"); #endif/* not lint */ #include "curses.h" #include "curses_private.h" +static int __wattr_off(WINDOW *, attr_t); +static int __wattr_on(WINDOW *, attr_t); static void __wcolor_set(WINDOW *, attr_t); + #ifndef _CURSES_USE_MACROS /* * attr_get -- @@ -102,7 +105,7 @@ color_set(short pair, void *opt) int attron(int attr) { - return wattr_on(stdscr, (attr_t) attr, NULL); + return __wattr_on(stdscr, (attr_t) attr); } /* @@ -112,7 +115,7 @@ attron(int attr) int attroff(int attr) { - return wattr_off(stdscr, (attr_t) attr, NULL); + return __wattr_off(stdscr, (attr_t) attr); } /* @@ -155,53 +158,13 @@ wattr_get(WINDOW *win, attr_t *attr, sho * wattr_on -- * Test and set wide attributes on window */ -/* ARGSUSED */ int wattr_on(WINDOW *win, attr_t attr, void *opt) { - const TERMINAL *t = win->screen->term; + if (__predict_false(opt != NULL)) + return ERR; -#ifdef DEBUG - __CTRACE(__CTRACE_ATTR, "wattr_on: win %p, attr %08x\n", win, attr); -#endif - /* If can enter modes, set the relevent attribute bits. */ - if (t_exit_attribute_mode(t) != NULL) { - if (attr & __BLINK && t_enter_blink_mode(t) != NULL) - win->wattr |= __BLINK; - if (attr & __BOLD && t_enter_bold_mode(t) != NULL) - win->wattr |= __BOLD; - if (attr & __DIM && t_enter_dim_mode(t) != NULL) - win->wattr |= __DIM; - if (attr & __BLANK && t_enter_secure_mode(t) != NULL) - win->wattr |= __BLANK; - if (attr & __PROTECT && t_enter_protected_mode(t) != NULL) - win->wattr |= __PROTECT; - if (attr & __REVERSE && t_enter_reverse_mode(t) != NULL) - win->wattr |= __REVERSE; -#ifdef HAVE_WCHAR - if (attr & WA_LOW && t_enter_low_hl_mode(t) != NULL) - win->wattr |= WA_LOW; - if (attr & WA_TOP && t_enter_top_hl_mode(t) != NULL) - win->wattr |= WA_TOP; - if (attr & WA_LEFT && t_enter_left_hl_mode(t) != NULL) - win->wattr |= WA_LEFT; - if (attr & WA_RIGHT && t_enter_right_hl_mode(t) != NULL) - win->wattr |= WA_RIGHT; - if (attr & WA_HORIZONTAL && t_enter_horizontal_hl_mode(t) != NULL) - win->wattr |= WA_HORIZONTAL; - if (attr & WA_VERTICAL && t_enter_vertical_hl_mode(t) != NULL) - win->wattr |= WA_VERTICAL; -#endif /* HAVE_WCHAR */ - } - if (attr & __STANDOUT && t_enter_standout_mode(t) != NULL && - t_exit_standout_mode(t) != NULL) - wstandout(win); - if (attr & __UNDERSCORE && t_enter_underline_mode(t) != NULL && - t_exit_underline_mode(t) != NULL) - wunderscore(win); - if (attr & __COLOR) - __wcolor_set(win, attr); - return OK; + return __wattr_on(win, attr); } /* @@ -211,55 +174,16 @@ wattr_on(WINDOW *win, attr_t attr, void * Note that the 'me' sequence unsets all attributes. We handle * which attributes should really be set in refresh.c:makech(). */ -/* ARGSUSED */ int wattr_off(WINDOW *win, attr_t attr, void *opt) { - const TERMINAL *t = win->screen->term; + if (__predict_false(opt != NULL)) + return ERR; -#ifdef DEBUG - __CTRACE(__CTRACE_ATTR, "wattr_off: win %p, attr %08x\n", win, attr); -#endif - /* If can do exit modes, unset the relevent attribute bits. */ - if (t_exit_attribute_mode(t) != NULL) { - if (attr & __BLINK) - win->wattr &= ~__BLINK; - if (attr & __BOLD) - win->wattr &= ~__BOLD; - if (attr & __DIM) - win->wattr &= ~__DIM; - if (attr & __BLANK) - win->wattr &= ~__BLANK; - if (attr & __PROTECT) - win->wattr &= ~__PROTECT; - if (attr & __REVERSE) - win->wattr &= ~__REVERSE; -#ifdef HAVE_WCHAR - if (attr & WA_LOW) - win->wattr &= ~WA_LOW; - if (attr & WA_TOP) - win->wattr &= ~WA_TOP; - if (attr & WA_LEFT) - win->wattr &= ~WA_LEFT; - if (attr & WA_RIGHT) - win->wattr &= ~WA_RIGHT; - if (attr & WA
CVS commit: src/lib/libcurses
Module Name:src Committed By: uwe Date: Thu Nov 22 23:37:31 UTC 2018 Modified Files: src/lib/libcurses: attributes.c Log Message: Drop a few redundant casts of a variable to its own type. To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.26 src/lib/libcurses/attributes.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/attributes.c diff -u src/lib/libcurses/attributes.c:1.25 src/lib/libcurses/attributes.c:1.26 --- src/lib/libcurses/attributes.c:1.25 Thu Nov 22 23:29:09 2018 +++ src/lib/libcurses/attributes.c Thu Nov 22 23:37:31 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: attributes.c,v 1.25 2018/11/22 23:29:09 uwe Exp $ */ +/* $NetBSD: attributes.c,v 1.26 2018/11/22 23:37:31 uwe Exp $ */ /*- * Copyright (c) 1999 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include #ifndef lint -__RCSID("$NetBSD: attributes.c,v 1.25 2018/11/22 23:29:09 uwe Exp $"); +__RCSID("$NetBSD: attributes.c,v 1.26 2018/11/22 23:37:31 uwe Exp $"); #endif/* not lint */ #include "curses.h" @@ -199,8 +199,8 @@ wattr_on(WINDOW *win, attr_t attr, void if (attr & __UNDERSCORE && t_enter_underline_mode(t) != NULL && t_exit_underline_mode(t) != NULL) wunderscore(win); - if ((attr_t) attr & __COLOR) - __wcolor_set(win, (attr_t) attr); + if (attr & __COLOR) + __wcolor_set(win, attr); return OK; } @@ -253,7 +253,7 @@ wattr_off(WINDOW *win, attr_t attr, void wstandend(win); if (attr & __UNDERSCORE) wunderend(win); - if ((attr_t) attr & __COLOR) { + if (attr & __COLOR) { if (max_colors != 0) win->wattr &= ~__COLOR; }
CVS commit: src/lib/libcurses
Module Name:src Committed By: uwe Date: Thu Nov 22 23:29:09 UTC 2018 Modified Files: src/lib/libcurses: attributes.c Log Message: Move getattrs() and wcolor_set() so that they are with their peers and so that wide and non-wide functions are in the same order. While here, make __wcolor_set() static. No functional change intended. To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/lib/libcurses/attributes.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/attributes.c diff -u src/lib/libcurses/attributes.c:1.24 src/lib/libcurses/attributes.c:1.25 --- src/lib/libcurses/attributes.c:1.24 Mon Oct 29 01:27:39 2018 +++ src/lib/libcurses/attributes.c Thu Nov 22 23:29:09 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: attributes.c,v 1.24 2018/10/29 01:27:39 uwe Exp $ */ +/* $NetBSD: attributes.c,v 1.25 2018/11/22 23:29:09 uwe Exp $ */ /*- * Copyright (c) 1999 The NetBSD Foundation, Inc. @@ -31,13 +31,13 @@ #include #ifndef lint -__RCSID("$NetBSD: attributes.c,v 1.24 2018/10/29 01:27:39 uwe Exp $"); +__RCSID("$NetBSD: attributes.c,v 1.25 2018/11/22 23:29:09 uwe Exp $"); #endif/* not lint */ #include "curses.h" #include "curses_private.h" -void __wcolor_set(WINDOW *, attr_t); +static void __wcolor_set(WINDOW *, attr_t); #ifndef _CURSES_USE_MACROS /* @@ -282,6 +282,34 @@ wattr_set(WINDOW *win, attr_t attr, shor } /* + * wcolor_set -- + * Set color pair on window + */ +/* ARGSUSED */ +int +wcolor_set(WINDOW *win, short pair, void *opt) +{ +#ifdef DEBUG + __CTRACE(__CTRACE_COLOR, "wolor_set: win %p, pair %d\n", win, pair); +#endif + __wcolor_set(win, (attr_t) COLOR_PAIR(pair)); + return OK; +} + +/* + * getattrs -- + * Get window attributes. + */ +chtype +getattrs(WINDOW *win) +{ +#ifdef DEBUG + __CTRACE(__CTRACE_ATTR, "getattrs: win %p\n", win); +#endif + return((chtype) win->wattr); +} + +/* * wattron -- * Test and set attributes. */ @@ -324,34 +352,6 @@ wattrset(WINDOW *win, int attr) } /* - * wcolor_set -- - * Set color pair on window - */ -/* ARGSUSED */ -int -wcolor_set(WINDOW *win, short pair, void *opt) -{ -#ifdef DEBUG - __CTRACE(__CTRACE_COLOR, "wolor_set: win %p, pair %d\n", win, pair); -#endif - __wcolor_set(win, (attr_t) COLOR_PAIR(pair)); - return OK; -} - -/* - * getattrs -- - * Get window attributes. - */ -chtype -getattrs(WINDOW *win) -{ -#ifdef DEBUG - __CTRACE(__CTRACE_ATTR, "getattrs: win %p\n", win); -#endif - return((chtype) win->wattr); -} - -/* * termattrs -- * Get terminal attributes */ @@ -444,7 +444,7 @@ term_attrs(void) * __wcolor_set -- * Set color attribute on window */ -void +static void __wcolor_set(WINDOW *win, attr_t attr) { const TERMINAL *t = win->screen->term;
CVS commit: src/lib/libcurses
Module Name:src Committed By: uwe Date: Thu Nov 22 22:16:45 UTC 2018 Modified Files: src/lib/libcurses: add_wch.c add_wchstr.c addwstr.c cchar.c echo_wchar.c get_wch.c get_wstr.c in_wch.c in_wchstr.c ins_wch.c ins_wstr.c inwstr.c Log Message: Drop HAVE_WCHAR ifdefs from code that is not even compiled with !HAVE_WCHAR. We still try to mainain the ability to build our curses with !HAVE_WCHAR, but it doesn't make sense to provide stubs for new wide API functions that just error out when !HAVE_WCHAR. Any code that only uses old API (and can work with !HAVE_WCHAR curses) doesn't use those new functions. The code that uses new API obviosly cannot work when all the new API is stubbed out. So the plan is to drop the stubs. This commit does that for files that are not even compiled with !HAVE_WCHAR (not only those stubs are useless, they were not even there to begin with). Same object code is generated for the normal HAVE_WCHAR case. Nothing is even recompiled for !HAVE_WCHAR. Ok by blymn@ jdc@ roy@ To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/lib/libcurses/add_wch.c \ src/lib/libcurses/add_wchstr.c cvs rdiff -u -r1.3 -r1.4 src/lib/libcurses/addwstr.c cvs rdiff -u -r1.10 -r1.11 src/lib/libcurses/cchar.c cvs rdiff -u -r1.2 -r1.3 src/lib/libcurses/echo_wchar.c cvs rdiff -u -r1.19 -r1.20 src/lib/libcurses/get_wch.c cvs rdiff -u -r1.4 -r1.5 src/lib/libcurses/get_wstr.c \ src/lib/libcurses/in_wch.c src/lib/libcurses/in_wchstr.c \ src/lib/libcurses/inwstr.c cvs rdiff -u -r1.11 -r1.12 src/lib/libcurses/ins_wch.c \ src/lib/libcurses/ins_wstr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/add_wch.c diff -u src/lib/libcurses/add_wch.c:1.5 src/lib/libcurses/add_wch.c:1.6 --- src/lib/libcurses/add_wch.c:1.5 Thu Jan 7 07:36:35 2016 +++ src/lib/libcurses/add_wch.c Thu Nov 22 22:16:45 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: add_wch.c,v 1.5 2016/01/07 07:36:35 jdc Exp $ */ +/* $NetBSD: add_wch.c,v 1.6 2018/11/22 22:16:45 uwe Exp $ */ /* * Copyright (c) 2005 The NetBSD Foundation Inc. @@ -36,7 +36,7 @@ #include #ifndef lint -__RCSID("$NetBSD: add_wch.c,v 1.5 2016/01/07 07:36:35 jdc Exp $"); +__RCSID("$NetBSD: add_wch.c,v 1.6 2018/11/22 22:16:45 uwe Exp $"); #endif /* not lint */ #include @@ -54,11 +54,7 @@ __RCSID("$NetBSD: add_wch.c,v 1.5 2016/0 int add_wch(const cchar_t *wch) { -#ifndef HAVE_WCHAR - return ERR; -#else return wadd_wch(stdscr, wch); -#endif /* HAVE_WCHAR */ } @@ -69,11 +65,7 @@ add_wch(const cchar_t *wch) int mvadd_wch(int y, int x, const cchar_t *wch) { -#ifndef HAVE_WCHAR - return ERR; -#else return mvwadd_wch(stdscr, y, x, wch); -#endif /* HAVE_WCHAR */ } @@ -84,14 +76,10 @@ mvadd_wch(int y, int x, const cchar_t *w int mvwadd_wch(WINDOW *win, int y, int x, const cchar_t *wch) { -#ifndef HAVE_WCHAR - return ERR; -#else if (wmove(win, y, x) == ERR) return ERR; return wadd_wch(win, wch); -#endif /* HAVE_WCHAR */ } @@ -104,9 +92,6 @@ mvwadd_wch(WINDOW *win, int y, int x, co int wadd_wch(WINDOW *win, const cchar_t *wch) { -#ifndef HAVE_WCHAR - return ERR; -#else int x = win->curx, y = win->cury; __LINE *lnp = NULL; @@ -120,5 +105,4 @@ wadd_wch(WINDOW *win, const cchar_t *wch #endif lnp = win->alines[y]; return _cursesi_addwchar(win, &lnp, &y, &x, wch, 1); -#endif /* HAVE_WCHAR */ } Index: src/lib/libcurses/add_wchstr.c diff -u src/lib/libcurses/add_wchstr.c:1.5 src/lib/libcurses/add_wchstr.c:1.6 --- src/lib/libcurses/add_wchstr.c:1.5 Sat Oct 22 21:55:06 2016 +++ src/lib/libcurses/add_wchstr.c Thu Nov 22 22:16:45 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: add_wchstr.c,v 1.5 2016/10/22 21:55:06 christos Exp $ */ +/* $NetBSD: add_wchstr.c,v 1.6 2018/11/22 22:16:45 uwe Exp $ */ /* * Copyright (c) 2005 The NetBSD Foundation Inc. @@ -36,7 +36,7 @@ #include #ifndef lint -__RCSID("$NetBSD: add_wchstr.c,v 1.5 2016/10/22 21:55:06 christos Exp $"); +__RCSID("$NetBSD: add_wchstr.c,v 1.6 2018/11/22 22:16:45 uwe Exp $"); #endif/* not lint */ #include @@ -51,11 +51,7 @@ __RCSID("$NetBSD: add_wchstr.c,v 1.5 201 int add_wchstr(const cchar_t *wchstr) { -#ifndef HAVE_WCHAR - return ERR; -#else return wadd_wchnstr(stdscr, wchstr, -1); -#endif } @@ -66,11 +62,7 @@ add_wchstr(const cchar_t *wchstr) int wadd_wchstr(WINDOW *win, const cchar_t *wchstr) { -#ifndef HAVE_WCHAR - return ERR; -#else return wadd_wchnstr(win, wchstr, -1); -#endif } @@ -82,11 +74,7 @@ wadd_wchstr(WINDOW *win, const cchar_t * int add_wchnstr(const cchar_t *wchstr, int n) { -#ifndef HAVE_WCHAR - return ERR; -#else return wadd_wchnstr(stdscr, wchstr, n); -#endif } @@ -97,11 +85,7 @@ add_wchnstr(const cchar_t *wchstr, int n int mvadd_wchstr(int y, int x, const cchar_t *wchstr) { -#ifndef HAVE_WCHAR - return ERR; -#else return mvwadd_wchnstr(stdscr, y, x, w
CVS commit: src/lib/libcurses
Module Name:src Committed By: uwe Date: Thu Nov 22 22:00:49 UTC 2018 Modified Files: src/lib/libcurses: Makefile Log Message: We need insstr.c for !HAVE_WCHAR too. To generate a diff of this commit: cvs rdiff -u -r1.89 -r1.90 src/lib/libcurses/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/Makefile diff -u src/lib/libcurses/Makefile:1.89 src/lib/libcurses/Makefile:1.90 --- src/lib/libcurses/Makefile:1.89 Mon Nov 19 01:08:22 2018 +++ src/lib/libcurses/Makefile Thu Nov 22 22:00:49 2018 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.89 2018/11/19 01:08:22 uwe Exp $ +# $NetBSD: Makefile,v 1.90 2018/11/22 22:00:49 uwe Exp $ # @(#)Makefile 8.2 (Berkeley) 1/2/94 .include @@ -20,7 +20,8 @@ SRCS= acs.c addbytes.c addch.c addchnstr curses.c delch.c deleteln.c delwin.c echochar.c erase.c fileio.c \ flushok.c fullname.c getch.c getstr.c getyx.c id_subwins.c idlok.c \ idcok.c immedok.c inch.c inchstr.c initscr.c insch.c insdelln.c \ - insertln.c instr.c keypad.c keyname.c leaveok.c line.c meta.c move.c \ + insertln.c insstr.c instr.c keypad.c keyname.c leaveok.c line.c \ + meta.c move.c \ mvwin.c newwin.c nodelay.c notimeout.c overlay.c overwrite.c pause.c \ printw.c putchar.c refresh.c resize.c ripoffline.c scanw.c screen.c \ scroll.c scrollok.c setterm.c slk.c standout.c syncok.c timeout.c \ @@ -45,7 +46,7 @@ LIBDPLIBS+= terminfo ${.CURDIR}/../libte .if !defined(DISABLE_WCHAR) CPPFLAGS+=-DHAVE_WCHAR SRCS+= cchar.c add_wch.c add_wchstr.c addwstr.c echo_wchar.c ins_wch.c \ - insstr.c ins_wstr.c get_wch.c get_wstr.c in_wch.c in_wchstr.c \ + ins_wstr.c get_wch.c get_wstr.c in_wch.c in_wchstr.c \ inwstr.c .else CPPFLAGS+=-DDISABLE_WCHAR
CVS commit: src/lib/libcurses
Module Name:src Committed By: uwe Date: Tue Nov 20 22:02:31 UTC 2018 Modified Files: src/lib/libcurses: cchar.c Log Message: Compare pointers to NULL, not to zero. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/lib/libcurses/cchar.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/cchar.c diff -u src/lib/libcurses/cchar.c:1.9 src/lib/libcurses/cchar.c:1.10 --- src/lib/libcurses/cchar.c:1.9 Tue Nov 20 21:42:52 2018 +++ src/lib/libcurses/cchar.c Tue Nov 20 22:02:31 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: cchar.c,v 1.9 2018/11/20 21:42:52 uwe Exp $ */ +/* $NetBSD: cchar.c,v 1.10 2018/11/20 22:02:31 uwe Exp $ */ /* * Copyright (c) 2005 The NetBSD Foundation Inc. @@ -36,7 +36,7 @@ #include #ifndef lint -__RCSID("$NetBSD: cchar.c,v 1.9 2018/11/20 21:42:52 uwe Exp $"); +__RCSID("$NetBSD: cchar.c,v 1.10 2018/11/20 22:02:31 uwe Exp $"); #endif /* not lint */ #include @@ -66,8 +66,10 @@ getcchar(const cchar_t *wcval, wchar_t * if (wch == NULL) return (int)len; - if (attrs == 0 || color_pair == 0) + + if (attrs == NULL || color_pair == NULL) return ERR; + if (len > 0) { *attrs = wcval->attributes; if (__using_color)
CVS commit: src/lib/libcurses
Module Name:src Committed By: uwe Date: Tue Nov 20 21:42:52 UTC 2018 Modified Files: src/lib/libcurses: cchar.c Log Message: Drop bogus cast. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/lib/libcurses/cchar.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/cchar.c diff -u src/lib/libcurses/cchar.c:1.8 src/lib/libcurses/cchar.c:1.9 --- src/lib/libcurses/cchar.c:1.8 Tue Nov 20 21:41:31 2018 +++ src/lib/libcurses/cchar.c Tue Nov 20 21:42:52 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: cchar.c,v 1.8 2018/11/20 21:41:31 uwe Exp $ */ +/* $NetBSD: cchar.c,v 1.9 2018/11/20 21:42:52 uwe Exp $ */ /* * Copyright (c) 2005 The NetBSD Foundation Inc. @@ -36,7 +36,7 @@ #include #ifndef lint -__RCSID("$NetBSD: cchar.c,v 1.8 2018/11/20 21:41:31 uwe Exp $"); +__RCSID("$NetBSD: cchar.c,v 1.9 2018/11/20 21:42:52 uwe Exp $"); #endif /* not lint */ #include @@ -74,7 +74,7 @@ getcchar(const cchar_t *wcval, wchar_t * *color_pair = PAIR_NUMBER(wcval->attributes); else *color_pair = 0; - wmemcpy(wch, wcval->vals, (unsigned)len); + wmemcpy(wch, wcval->vals, len); wch[len] = L'\0'; } return OK;
CVS commit: src/lib/libcurses
Module Name:src Committed By: uwe Date: Tue Nov 20 21:41:31 UTC 2018 Modified Files: src/lib/libcurses: cchar.c Log Message: Don't hide assignments inside tests. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/lib/libcurses/cchar.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/cchar.c diff -u src/lib/libcurses/cchar.c:1.7 src/lib/libcurses/cchar.c:1.8 --- src/lib/libcurses/cchar.c:1.7 Tue Nov 20 17:48:19 2018 +++ src/lib/libcurses/cchar.c Tue Nov 20 21:41:31 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: cchar.c,v 1.7 2018/11/20 17:48:19 uwe Exp $ */ +/* $NetBSD: cchar.c,v 1.8 2018/11/20 21:41:31 uwe Exp $ */ /* * Copyright (c) 2005 The NetBSD Foundation Inc. @@ -36,7 +36,7 @@ #include #ifndef lint -__RCSID("$NetBSD: cchar.c,v 1.7 2018/11/20 17:48:19 uwe Exp $"); +__RCSID("$NetBSD: cchar.c,v 1.8 2018/11/20 21:41:31 uwe Exp $"); #endif /* not lint */ #include @@ -58,11 +58,11 @@ getcchar(const cchar_t *wcval, wchar_t * wchar_t *wp; size_t len; - if (opts) + if (__predict_false(opts != NULL)) return ERR; - len = (wp = wmemchr(wcval->vals, L'\0', CCHARW_MAX)) - ? wp - wcval->vals : CCHARW_MAX; + wp = wmemchr(wcval->vals, L'\0', CCHARW_MAX); + len = wp ? wp - wcval->vals : CCHARW_MAX; if (wch == NULL) return (int)len; @@ -95,10 +95,12 @@ setcchar(cchar_t *wcval, const wchar_t * int i; size_t len; - if (opts || (len = wcslen(wch)) > CCHARW_MAX - || (len > 1 && wcwidth(wch[0]) < 0)) { + if (__predict_false(opts != NULL)) + return ERR; + + len = wcslen(wch); + if (len > CCHARW_MAX || (len > 1 && wcwidth(wch[0]) < 0)) return ERR; - } /* * If we have a following spacing-character, stop at that point. We
CVS commit: src/lib/libcurses
Module Name:src Committed By: uwe Date: Tue Nov 20 17:48:19 UTC 2018 Modified Files: src/lib/libcurses: cchar.c Log Message: Fix color pair handling. color_pair argument is a pair number. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/lib/libcurses/cchar.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/cchar.c diff -u src/lib/libcurses/cchar.c:1.6 src/lib/libcurses/cchar.c:1.7 --- src/lib/libcurses/cchar.c:1.6 Fri Jan 6 13:53:18 2017 +++ src/lib/libcurses/cchar.c Tue Nov 20 17:48:19 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: cchar.c,v 1.6 2017/01/06 13:53:18 roy Exp $ */ +/* $NetBSD: cchar.c,v 1.7 2018/11/20 17:48:19 uwe Exp $ */ /* * Copyright (c) 2005 The NetBSD Foundation Inc. @@ -36,7 +36,7 @@ #include #ifndef lint -__RCSID("$NetBSD: cchar.c,v 1.6 2017/01/06 13:53:18 roy Exp $"); +__RCSID("$NetBSD: cchar.c,v 1.7 2018/11/20 17:48:19 uwe Exp $"); #endif /* not lint */ #include @@ -70,7 +70,10 @@ getcchar(const cchar_t *wcval, wchar_t * return ERR; if (len > 0) { *attrs = wcval->attributes; - *color_pair = COLOR_PAIR(wcval ->attributes); + if (__using_color) + *color_pair = PAIR_NUMBER(wcval->attributes); + else + *color_pair = 0; wmemcpy(wch, wcval->vals, (unsigned)len); wch[len] = L'\0'; } @@ -110,7 +113,9 @@ setcchar(cchar_t *wcval, const wchar_t * memset(wcval, 0, sizeof(*wcval)); if (len != 0) { - wcval->attributes = attrs | color_pair; + wcval->attributes = attrs & ~__COLOR; + if (__using_color && color_pair) + wcval->attributes |= COLOR_PAIR(color_pair); wcval->elements = 1; memcpy(&wcval->vals, wch, len * sizeof(wchar_t)); }
CVS commit: src/lib/libcurses
Module Name:src Committed By: uwe Date: Mon Nov 19 20:37:04 UTC 2018 Modified Files: src/lib/libcurses: background.c Log Message: wbkgd - when updating window rendition for the new background character, it's the old background characters that need to be updated, not spaces. While here, simplify and also fix the bug introduced in 1.20 (that lost the default color) - actually use the results of wbkgdset(). To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/lib/libcurses/background.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/background.c diff -u src/lib/libcurses/background.c:1.24 src/lib/libcurses/background.c:1.25 --- src/lib/libcurses/background.c:1.24 Sun Nov 18 22:53:22 2018 +++ src/lib/libcurses/background.c Mon Nov 19 20:37:04 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: background.c,v 1.24 2018/11/18 22:53:22 uwe Exp $ */ +/* $NetBSD: background.c,v 1.25 2018/11/19 20:37:04 uwe Exp $ */ /*- * Copyright (c) 2000 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include #ifndef lint -__RCSID("$NetBSD: background.c,v 1.24 2018/11/18 22:53:22 uwe Exp $"); +__RCSID("$NetBSD: background.c,v 1.25 2018/11/19 20:37:04 uwe Exp $"); #endif/* not lint */ #include @@ -89,32 +89,33 @@ wbkgdset(WINDOW *win, chtype ch) int wbkgd(WINDOW *win, chtype ch) { - int y, x; + chtype obch; + int y, x; #ifdef DEBUG __CTRACE(__CTRACE_ATTR, "wbkgd: (%p), '%s', %08x\n", win, unctrl(ch & __CHARTEXT), ch & __ATTRIBUTES); #endif + obch = win->bch; wbkgdset(win, ch); - for (y = 0; y < win->maxy; y++) + for (y = 0; y < win->maxy; y++) { for (x = 0; x < win->maxx; x++) { - /* Copy character if space */ - if (ch & __CHARTEXT && win->alines[y]->line[x].ch == ' ') -win->alines[y]->line[x].ch = ch & __CHARTEXT; - /* Merge attributes */ - if (win->alines[y]->line[x].attr & __ALTCHARSET) -win->alines[y]->line[x].attr = -(ch & __ATTRIBUTES) | __ALTCHARSET; - else -win->alines[y]->line[x].attr = -ch & __ATTRIBUTES; + __LDATA *cp = &win->alines[y]->line[x]; + + /* Update/switch background characters */ + if (cp->ch == obch) +cp->ch = win->bch; + + /* Update/merge attributes */ + cp->attr = win->battr | (cp->attr & __ALTCHARSET); #ifdef HAVE_WCHAR - SET_WCOL(win->alines[y]->line[x], 1); + SET_WCOL(*cp, 1); #endif } + } __touchwin(win); - return(OK); + return OK; } /*
CVS commit: src/lib/libcurses
Module Name:src Committed By: uwe Date: Sun Nov 18 22:53:22 UTC 2018 Modified Files: src/lib/libcurses: background.c Log Message: wbkgrnd - do not duplicate code that's already in wbkgrndset() To generate a diff of this commit: cvs rdiff -u -r1.23 -r1.24 src/lib/libcurses/background.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/background.c diff -u src/lib/libcurses/background.c:1.23 src/lib/libcurses/background.c:1.24 --- src/lib/libcurses/background.c:1.23 Sun Nov 18 22:34:32 2018 +++ src/lib/libcurses/background.c Sun Nov 18 22:53:22 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: background.c,v 1.23 2018/11/18 22:34:32 uwe Exp $ */ +/* $NetBSD: background.c,v 1.24 2018/11/18 22:53:22 uwe Exp $ */ /*- * Copyright (c) 2000 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include #ifndef lint -__RCSID("$NetBSD: background.c,v 1.23 2018/11/18 22:34:32 uwe Exp $"); +__RCSID("$NetBSD: background.c,v 1.24 2018/11/18 22:53:22 uwe Exp $"); #endif/* not lint */ #include @@ -227,8 +227,6 @@ wbkgrndset(WINDOW *win, const cchar_t *w int wbkgrnd(WINDOW *win, const cchar_t *wch) { - attr_t battr; - #ifdef DEBUG __CTRACE(__CTRACE_ATTR, "wbkgrnd: (%p), '%s', %x\n", win, (const char *) wunctrl(wch), wch->attributes); @@ -238,12 +236,6 @@ wbkgrnd(WINDOW *win, const cchar_t *wch) if (!wch->elements || wcwidth( wch->vals[ 0 ]) > 1) return ERR; - /* Background attributes (check colour). */ - battr = wch->attributes & WA_ATTRIBUTES; - if (__using_color && !( battr & __COLOR)) - battr |= __default_color; - - win->battr = battr; wbkgrndset(win, wch); __touchwin(win); return OK;
CVS commit: src/lib/libcurses
Module Name:src Committed By: uwe Date: Sun Nov 18 22:34:32 UTC 2018 Modified Files: src/lib/libcurses: background.c inch.c Log Message: When we remove default color from attributes, just clear all __COLOR. It's both a nono-optmization and matches the test used in counterpart code that adds default color when none is set. To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/lib/libcurses/background.c cvs rdiff -u -r1.11 -r1.12 src/lib/libcurses/inch.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/background.c diff -u src/lib/libcurses/background.c:1.22 src/lib/libcurses/background.c:1.23 --- src/lib/libcurses/background.c:1.22 Sun Nov 18 22:18:02 2018 +++ src/lib/libcurses/background.c Sun Nov 18 22:34:32 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: background.c,v 1.22 2018/11/18 22:18:02 uwe Exp $ */ +/* $NetBSD: background.c,v 1.23 2018/11/18 22:34:32 uwe Exp $ */ /*- * Copyright (c) 2000 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include #ifndef lint -__RCSID("$NetBSD: background.c,v 1.22 2018/11/18 22:18:02 uwe Exp $"); +__RCSID("$NetBSD: background.c,v 1.23 2018/11/18 22:34:32 uwe Exp $"); #endif/* not lint */ #include @@ -129,7 +129,7 @@ getbkgd(WINDOW *win) /* Background attributes (check colour). */ battr = win->battr & A_ATTRIBUTES; if (__using_color && ((battr & __COLOR) == __default_color)) - battr &= ~__default_color; + battr &= ~__COLOR; return ((chtype) ((win->bch & A_CHARTEXT) | battr)); } @@ -257,9 +257,8 @@ wgetbkgrnd(WINDOW *win, cchar_t *wch) /* Background attributes (check colour). */ wch->attributes = win->battr & WA_ATTRIBUTES; - if (__using_color && ((wch->attributes & __COLOR) - == __default_color)) - wch->attributes &= ~__default_color; + if (__using_color && ((wch->attributes & __COLOR) == __default_color)) + wch->attributes &= ~__COLOR; wch->vals[0] = win->bch; wch->elements = 1; np = win->bnsp; Index: src/lib/libcurses/inch.c diff -u src/lib/libcurses/inch.c:1.11 src/lib/libcurses/inch.c:1.12 --- src/lib/libcurses/inch.c:1.11 Fri Jan 6 13:53:18 2017 +++ src/lib/libcurses/inch.c Sun Nov 18 22:34:32 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: inch.c,v 1.11 2017/01/06 13:53:18 roy Exp $ */ +/* $NetBSD: inch.c,v 1.12 2018/11/18 22:34:32 uwe Exp $ */ /*- * Copyright (c) 1999 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include #ifndef lint -__RCSID("$NetBSD: inch.c,v 1.11 2017/01/06 13:53:18 roy Exp $"); +__RCSID("$NetBSD: inch.c,v 1.12 2018/11/18 22:34:32 uwe Exp $"); #endif/* not lint */ #include "curses.h" @@ -92,6 +92,6 @@ winch(WINDOW *win) attr = (attr_t) ((win)->alines[(win)->cury]->line[(win)->curx].attr & __ATTRIBUTES); if (__using_color && ((attr & __COLOR) == __default_color)) - attr &= ~__default_color; + attr &= ~__COLOR; return (ch | attr); }
CVS commit: src/lib/libcurses
Module Name:src Committed By: uwe Date: Sun Nov 18 22:18:02 UTC 2018 Modified Files: src/lib/libcurses: background.c Log Message: Reorder "bkgrnd" functions to match the order of old "bkgd" functions. To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/lib/libcurses/background.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/background.c diff -u src/lib/libcurses/background.c:1.21 src/lib/libcurses/background.c:1.22 --- src/lib/libcurses/background.c:1.21 Sun Nov 18 22:11:38 2018 +++ src/lib/libcurses/background.c Sun Nov 18 22:18:02 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: background.c,v 1.21 2018/11/18 22:11:38 uwe Exp $ */ +/* $NetBSD: background.c,v 1.22 2018/11/18 22:18:02 uwe Exp $ */ /*- * Copyright (c) 2000 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include #ifndef lint -__RCSID("$NetBSD: background.c,v 1.21 2018/11/18 22:11:38 uwe Exp $"); +__RCSID("$NetBSD: background.c,v 1.22 2018/11/18 22:18:02 uwe Exp $"); #endif/* not lint */ #include @@ -137,50 +137,24 @@ getbkgd(WINDOW *win) #ifdef HAVE_WCHAR -int -bkgrnd(const cchar_t *wch) -{ - return wbkgrnd( stdscr, wch ); -} - - void bkgrndset(const cchar_t *wch) { - wbkgrndset( stdscr, wch ); + wbkgrndset(stdscr, wch); } int -getbkgrnd(cchar_t *wch) +bkgrnd(const cchar_t *wch) { - return wgetbkgrnd( stdscr, wch ); + return wbkgrnd(stdscr, wch); } int -wbkgrnd(WINDOW *win, const cchar_t *wch) +getbkgrnd(cchar_t *wch) { - attr_t battr; - -#ifdef DEBUG - __CTRACE(__CTRACE_ATTR, "wbkgrnd: (%p), '%s', %x\n", - win, (const char *) wunctrl(wch), wch->attributes); -#endif - - /* ignore multi-column characters */ - if (!wch->elements || wcwidth( wch->vals[ 0 ]) > 1) - return ERR; - - /* Background attributes (check colour). */ - battr = wch->attributes & WA_ATTRIBUTES; - if (__using_color && !( battr & __COLOR)) - battr |= __default_color; - - win->battr = battr; - wbkgrndset(win, wch); - __touchwin(win); - return OK; + return wgetbkgrnd(stdscr, wch); } @@ -251,6 +225,32 @@ wbkgrndset(WINDOW *win, const cchar_t *w int +wbkgrnd(WINDOW *win, const cchar_t *wch) +{ + attr_t battr; + +#ifdef DEBUG + __CTRACE(__CTRACE_ATTR, "wbkgrnd: (%p), '%s', %x\n", + win, (const char *) wunctrl(wch), wch->attributes); +#endif + + /* ignore multi-column characters */ + if (!wch->elements || wcwidth( wch->vals[ 0 ]) > 1) + return ERR; + + /* Background attributes (check colour). */ + battr = wch->attributes & WA_ATTRIBUTES; + if (__using_color && !( battr & __COLOR)) + battr |= __default_color; + + win->battr = battr; + wbkgrndset(win, wch); + __touchwin(win); + return OK; +} + + +int wgetbkgrnd(WINDOW *win, cchar_t *wch) { nschar_t *np; @@ -275,13 +275,6 @@ wgetbkgrnd(WINDOW *win, cchar_t *wch) #else /* !HAVE_WCHAR */ -int -bkgrnd(const cchar_t *wch) -{ - return ERR; -} - - void bkgrndset(const cchar_t *wch) { @@ -289,14 +282,14 @@ bkgrndset(const cchar_t *wch) } int -getbkgrnd(cchar_t *wch) +bkgrnd(const cchar_t *wch) { return ERR; } int -wbkgrnd(WINDOW *win, const cchar_t *wch) +getbkgrnd(cchar_t *wch) { return ERR; } @@ -310,6 +303,13 @@ wbkgrndset(WINDOW *win, const cchar_t *w int +wbkgrnd(WINDOW *win, const cchar_t *wch) +{ + return ERR; +} + + +int wgetbkgrnd(WINDOW *win, cchar_t *wch) { return ERR;
CVS commit: src/lib/libcurses
Module Name:src Committed By: uwe Date: Sun Nov 18 22:11:39 UTC 2018 Modified Files: src/lib/libcurses: background.c Log Message: Don't fuse HAVE_WCHAR and (trivial) !HAVE_WCHAR bodies into single function definition. Instead provide two sets of definitions under single #ifdef. Same object code is generated for both HAVE_WCHAR and !HAVE_WCHAR. To generate a diff of this commit: cvs rdiff -u -r1.20 -r1.21 src/lib/libcurses/background.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/background.c diff -u src/lib/libcurses/background.c:1.20 src/lib/libcurses/background.c:1.21 --- src/lib/libcurses/background.c:1.20 Sun Nov 18 21:01:16 2018 +++ src/lib/libcurses/background.c Sun Nov 18 22:11:38 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: background.c,v 1.20 2018/11/18 21:01:16 uwe Exp $ */ +/* $NetBSD: background.c,v 1.21 2018/11/18 22:11:38 uwe Exp $ */ /*- * Copyright (c) 2000 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include #ifndef lint -__RCSID("$NetBSD: background.c,v 1.20 2018/11/18 21:01:16 uwe Exp $"); +__RCSID("$NetBSD: background.c,v 1.21 2018/11/18 22:11:38 uwe Exp $"); #endif/* not lint */ #include @@ -134,39 +134,34 @@ getbkgd(WINDOW *win) return ((chtype) ((win->bch & A_CHARTEXT) | battr)); } -int bkgrnd(const cchar_t *wch) + +#ifdef HAVE_WCHAR + +int +bkgrnd(const cchar_t *wch) { -#ifndef HAVE_WCHAR - return ERR; -#else return wbkgrnd( stdscr, wch ); -#endif /* HAVE_WCHAR */ } -void bkgrndset(const cchar_t *wch) + +void +bkgrndset(const cchar_t *wch) { -#ifdef HAVE_WCHAR wbkgrndset( stdscr, wch ); -#endif /* HAVE_WCHAR */ } -int getbkgrnd(cchar_t *wch) + +int +getbkgrnd(cchar_t *wch) { -#ifndef HAVE_WCHAR - return ERR; -#else return wgetbkgrnd( stdscr, wch ); -#endif /* HAVE_WCHAR */ } -int wbkgrnd(WINDOW *win, const cchar_t *wch) + +int +wbkgrnd(WINDOW *win, const cchar_t *wch) { -#ifndef HAVE_WCHAR - return ERR; -#else -/* int y, x, i; */ attr_t battr; -/* nschar_t *np, *tnp, *pnp; */ #ifdef DEBUG __CTRACE(__CTRACE_ATTR, "wbkgrnd: (%p), '%s', %x\n", @@ -186,12 +181,12 @@ int wbkgrnd(WINDOW *win, const cchar_t * wbkgrndset(win, wch); __touchwin(win); return OK; -#endif /* HAVE_WCHAR */ } -void wbkgrndset(WINDOW *win, const cchar_t *wch) + +void +wbkgrndset(WINDOW *win, const cchar_t *wch) { -#ifdef HAVE_WCHAR attr_t battr; nschar_t *np, *tnp; int i; @@ -252,14 +247,12 @@ void wbkgrndset(WINDOW *win, const cchar battr |= __default_color; win->battr = battr; SET_BGWCOL((*win), 1); -#endif /* HAVE_WCHAR */ } -int wgetbkgrnd(WINDOW *win, cchar_t *wch) + +int +wgetbkgrnd(WINDOW *win, cchar_t *wch) { -#ifndef HAVE_WCHAR - return ERR; -#else nschar_t *np; /* Background attributes (check colour). */ @@ -278,5 +271,48 @@ int wgetbkgrnd(WINDOW *win, cchar_t *wch } return OK; -#endif /* HAVE_WCHAR */ } + +#else /* !HAVE_WCHAR */ + +int +bkgrnd(const cchar_t *wch) +{ + return ERR; +} + + +void +bkgrndset(const cchar_t *wch) +{ + return; +} + +int +getbkgrnd(cchar_t *wch) +{ + return ERR; +} + + +int +wbkgrnd(WINDOW *win, const cchar_t *wch) +{ + return ERR; +} + + +void +wbkgrndset(WINDOW *win, const cchar_t *wch) +{ + return; +} + + +int +wgetbkgrnd(WINDOW *win, cchar_t *wch) +{ + return ERR; +} + +#endif /* !HAVE_WCHAR */
CVS commit: src/lib/libcurses
Module Name:src Committed By: uwe Date: Sun Nov 18 21:01:17 UTC 2018 Modified Files: src/lib/libcurses: background.c Log Message: wbkgd - do not duplicate the code that's already in wbkgdset() that we do call anyway. To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/lib/libcurses/background.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/background.c diff -u src/lib/libcurses/background.c:1.19 src/lib/libcurses/background.c:1.20 --- src/lib/libcurses/background.c:1.19 Sun Nov 18 20:26:29 2018 +++ src/lib/libcurses/background.c Sun Nov 18 21:01:16 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: background.c,v 1.19 2018/11/18 20:26:29 uwe Exp $ */ +/* $NetBSD: background.c,v 1.20 2018/11/18 21:01:16 uwe Exp $ */ /*- * Copyright (c) 2000 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include #ifndef lint -__RCSID("$NetBSD: background.c,v 1.19 2018/11/18 20:26:29 uwe Exp $"); +__RCSID("$NetBSD: background.c,v 1.20 2018/11/18 21:01:16 uwe Exp $"); #endif/* not lint */ #include @@ -95,13 +95,8 @@ wbkgd(WINDOW *win, chtype ch) __CTRACE(__CTRACE_ATTR, "wbkgd: (%p), '%s', %08x\n", win, unctrl(ch & __CHARTEXT), ch & __ATTRIBUTES); #endif - - /* Background attributes (check colour). */ - if (__using_color && !(ch & __COLOR)) - ch |= __default_color; - - win->battr = (attr_t) ch & __ATTRIBUTES; wbkgdset(win, ch); + for (y = 0; y < win->maxy; y++) for (x = 0; x < win->maxx; x++) { /* Copy character if space */
CVS commit: src/lib/libcurses
Module Name:src Committed By: uwe Date: Sun Nov 18 20:26:29 UTC 2018 Modified Files: src/lib/libcurses: background.c Log Message: Fix comments on bkgdset() and friends to match reality. To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/lib/libcurses/background.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/background.c diff -u src/lib/libcurses/background.c:1.18 src/lib/libcurses/background.c:1.19 --- src/lib/libcurses/background.c:1.18 Sun Nov 18 18:52:29 2018 +++ src/lib/libcurses/background.c Sun Nov 18 20:26:29 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: background.c,v 1.18 2018/11/18 18:52:29 uwe Exp $ */ +/* $NetBSD: background.c,v 1.19 2018/11/18 20:26:29 uwe Exp $ */ /*- * Copyright (c) 2000 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include #ifndef lint -__RCSID("$NetBSD: background.c,v 1.18 2018/11/18 18:52:29 uwe Exp $"); +__RCSID("$NetBSD: background.c,v 1.19 2018/11/18 20:26:29 uwe Exp $"); #endif/* not lint */ #include @@ -50,7 +50,8 @@ bkgdset(chtype ch) /* * bkgd -- - * Set new background and new background attributes on stdscr. + * Set new background attributes on stdscr and apply them to its + * contents. */ int bkgd(chtype ch) @@ -60,7 +61,7 @@ bkgd(chtype ch) /* * wbkgdset - * Set new background attributes. + * Set new background attributes on the specified window. */ void wbkgdset(WINDOW *win, chtype ch) @@ -82,7 +83,8 @@ wbkgdset(WINDOW *win, chtype ch) /* * wbkgd -- - * Set new background and new background attributes. + * Set new background attributes on the specified window and + * apply them to its contents. */ int wbkgd(WINDOW *win, chtype ch)
CVS commit: src/lib/libcurses
Module Name:src Committed By: uwe Date: Sun Nov 18 18:52:29 UTC 2018 Modified Files: src/lib/libcurses: background.c Log Message: Don't mix private and public names for the same thing in one statement. While here, fix harmless edito in a debug call. To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/lib/libcurses/background.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/background.c diff -u src/lib/libcurses/background.c:1.17 src/lib/libcurses/background.c:1.18 --- src/lib/libcurses/background.c:1.17 Fri Jan 6 13:53:18 2017 +++ src/lib/libcurses/background.c Sun Nov 18 18:52:29 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: background.c,v 1.17 2017/01/06 13:53:18 roy Exp $ */ +/* $NetBSD: background.c,v 1.18 2018/11/18 18:52:29 uwe Exp $ */ /*- * Copyright (c) 2000 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include #ifndef lint -__RCSID("$NetBSD: background.c,v 1.17 2017/01/06 13:53:18 roy Exp $"); +__RCSID("$NetBSD: background.c,v 1.18 2018/11/18 18:52:29 uwe Exp $"); #endif/* not lint */ #include @@ -67,7 +67,7 @@ wbkgdset(WINDOW *win, chtype ch) { #ifdef DEBUG __CTRACE(__CTRACE_ATTR, "wbkgdset: (%p), '%s', %08x\n", - win, unctrl(ch & +__CHARTEXT), ch & __ATTRIBUTES); + win, unctrl(ch & __CHARTEXT), ch & __ATTRIBUTES); #endif /* Background character. */ @@ -91,7 +91,7 @@ wbkgd(WINDOW *win, chtype ch) #ifdef DEBUG __CTRACE(__CTRACE_ATTR, "wbkgd: (%p), '%s', %08x\n", - win, unctrl(ch & +__CHARTEXT), ch & __ATTRIBUTES); + win, unctrl(ch & __CHARTEXT), ch & __ATTRIBUTES); #endif /* Background attributes (check colour). */ @@ -103,7 +103,7 @@ wbkgd(WINDOW *win, chtype ch) for (y = 0; y < win->maxy; y++) for (x = 0; x < win->maxx; x++) { /* Copy character if space */ - if (ch & A_CHARTEXT && win->alines[y]->line[x].ch == ' ') + if (ch & __CHARTEXT && win->alines[y]->line[x].ch == ' ') win->alines[y]->line[x].ch = ch & __CHARTEXT; /* Merge attributes */ if (win->alines[y]->line[x].attr & __ALTCHARSET)
CVS commit: src/lib/libcurses
Module Name:src Committed By: uwe Date: Sun Nov 18 02:46:24 UTC 2018 Modified Files: src/lib/libcurses: refresh.c Log Message: Reindent a few lineeq() calls now that we can w/out exceeding 80 columns limit. Whitespace change only. To generate a diff of this commit: cvs rdiff -u -r1.100 -r1.101 src/lib/libcurses/refresh.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/refresh.c diff -u src/lib/libcurses/refresh.c:1.100 src/lib/libcurses/refresh.c:1.101 --- src/lib/libcurses/refresh.c:1.100 Sun Nov 18 02:39:44 2018 +++ src/lib/libcurses/refresh.c Sun Nov 18 02:46:24 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: refresh.c,v 1.100 2018/11/18 02:39:44 uwe Exp $ */ +/* $NetBSD: refresh.c,v 1.101 2018/11/18 02:46:24 uwe Exp $ */ /* * Copyright (c) 1981, 1993, 1994 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)refresh.c 8.7 (Berkeley) 8/13/94"; #else -__RCSID("$NetBSD: refresh.c,v 1.100 2018/11/18 02:39:44 uwe Exp $"); +__RCSID("$NetBSD: refresh.c,v 1.101 2018/11/18 02:46:24 uwe Exp $"); #endif #endif/* not lint */ @@ -1469,9 +1469,9 @@ quickch(void) for (top = 0; top < __virtscr->maxy; top++) { if (__virtscr->alines[top]->flags & __ISDIRTY && (__virtscr->alines[top]->hash != curscr->alines[top]->hash || - !lineeq(__virtscr->alines[top]->line, - curscr->alines[top]->line, - (size_t) __virtscr->maxx))) + !lineeq(__virtscr->alines[top]->line, + curscr->alines[top]->line, + (size_t) __virtscr->maxx))) break; else __virtscr->alines[top]->flags &= ~__ISDIRTY; @@ -1482,9 +1482,9 @@ quickch(void) for (bot = __virtscr->maxy - 1; bot >= 0; bot--) { if (__virtscr->alines[bot]->flags & __ISDIRTY && (__virtscr->alines[bot]->hash != curscr->alines[bot]->hash || - !lineeq(__virtscr->alines[bot]->line, - curscr->alines[bot]->line, - (size_t) __virtscr->maxx))) + !lineeq(__virtscr->alines[bot]->line, + curscr->alines[bot]->line, + (size_t) __virtscr->maxx))) break; else __virtscr->alines[bot]->flags &= ~__ISDIRTY; @@ -1546,8 +1546,8 @@ quickch(void) for (curw = startw, curs = starts; curs < starts + bsize; curw++, curs++) if (!lineeq(__virtscr->alines[curw]->line, - curscr->alines[curs]->line, - (size_t) __virtscr->maxx)) + curscr->alines[curs]->line, + (size_t) __virtscr->maxx)) break; if (curs == starts + bsize) goto done;
CVS commit: src/lib/libcurses
Module Name:src Committed By: uwe Date: Sun Nov 18 02:39:44 UTC 2018 Modified Files: src/lib/libcurses: refresh.c Log Message: Further tweak previous. Change the check order to be more logical. No functional change intentded. While here fix indentation. To generate a diff of this commit: cvs rdiff -u -r1.99 -r1.100 src/lib/libcurses/refresh.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/refresh.c diff -u src/lib/libcurses/refresh.c:1.99 src/lib/libcurses/refresh.c:1.100 --- src/lib/libcurses/refresh.c:1.99 Sun Nov 18 02:34:39 2018 +++ src/lib/libcurses/refresh.c Sun Nov 18 02:39:44 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: refresh.c,v 1.99 2018/11/18 02:34:39 uwe Exp $ */ +/* $NetBSD: refresh.c,v 1.100 2018/11/18 02:39:44 uwe Exp $ */ /* * Copyright (c) 1981, 1993, 1994 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)refresh.c 8.7 (Berkeley) 8/13/94"; #else -__RCSID("$NetBSD: refresh.c,v 1.99 2018/11/18 02:34:39 uwe Exp $"); +__RCSID("$NetBSD: refresh.c,v 1.100 2018/11/18 02:39:44 uwe Exp $"); #endif #endif/* not lint */ @@ -1250,16 +1250,15 @@ makech(int wy) _cursesi_screen->ly = wy; _cursesi_screen->lx = wx; while (wx <= lch && - (!celleq(nsp, csp) - || (wlp->flags & __ISFORCED))) + ((wlp->flags & __ISFORCED) || !celleq(nsp, csp))) { #ifndef HAVE_WCHAR if (ce != NULL && wx >= nlsp && nsp->ch == ' ' && nsp->attr == lspc) #else if (ce != NULL && wx >= nlsp - && nsp->ch == (wchar_t)btowc((int)' ') /* XXX */ - && (nsp->attr & WA_ATTRIBUTES) == lspc) + && nsp->ch == (wchar_t)btowc((int)' ') /* XXX */ + && (nsp->attr & WA_ATTRIBUTES) == lspc) #endif { /* Check for clear to end-of-line. */
CVS commit: src/lib/libcurses
Module Name:src Committed By: uwe Date: Sun Nov 18 02:34:39 UTC 2018 Modified Files: src/lib/libcurses: refresh.c Log Message: Merge one more #ifdef with mostly identical code in both branches. The same object code is generated modulo gratuitously different order of checks. To generate a diff of this commit: cvs rdiff -u -r1.98 -r1.99 src/lib/libcurses/refresh.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/refresh.c diff -u src/lib/libcurses/refresh.c:1.98 src/lib/libcurses/refresh.c:1.99 --- src/lib/libcurses/refresh.c:1.98 Sun Nov 18 02:17:24 2018 +++ src/lib/libcurses/refresh.c Sun Nov 18 02:34:39 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: refresh.c,v 1.98 2018/11/18 02:17:24 uwe Exp $ */ +/* $NetBSD: refresh.c,v 1.99 2018/11/18 02:34:39 uwe Exp $ */ /* * Copyright (c) 1981, 1993, 1994 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)refresh.c 8.7 (Berkeley) 8/13/94"; #else -__RCSID("$NetBSD: refresh.c,v 1.98 2018/11/18 02:17:24 uwe Exp $"); +__RCSID("$NetBSD: refresh.c,v 1.99 2018/11/18 02:34:39 uwe Exp $"); #endif #endif/* not lint */ @@ -1249,24 +1249,19 @@ makech(int wy) #endif _cursesi_screen->ly = wy; _cursesi_screen->lx = wx; -#ifndef HAVE_WCHAR while (wx <= lch && (!celleq(nsp, csp) || (wlp->flags & __ISFORCED))) { - if (ce != NULL && - wx >= nlsp && nsp->ch == ' ' && nsp->attr == lspc) - { +#ifndef HAVE_WCHAR + if (ce != NULL && wx >= nlsp + && nsp->ch == ' ' && nsp->attr == lspc) #else - while ((!celleq(nsp, csp) || (wlp->flags & __ISFORCED)) && - wx <= lch) - { if (ce != NULL && wx >= nlsp && nsp->ch == (wchar_t)btowc((int)' ') /* XXX */ && (nsp->attr & WA_ATTRIBUTES) == lspc) - { - #endif + { /* Check for clear to end-of-line. */ cep = &curscr->alines[wy]->line[win->maxx - 1]; #ifndef HAVE_WCHAR
CVS commit: src/lib/libcurses
Module Name:src Committed By: uwe Date: Sun Nov 18 02:17:24 UTC 2018 Modified Files: src/lib/libcurses: refresh.c Log Message: Merge another #ifdefs that now has identical code in both branches modulo swapped arguments to celleq() call. Same object code is generated otherwise for both HAVE_WCHAR and !HAVE_WCHAR To generate a diff of this commit: cvs rdiff -u -r1.97 -r1.98 src/lib/libcurses/refresh.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/refresh.c diff -u src/lib/libcurses/refresh.c:1.97 src/lib/libcurses/refresh.c:1.98 --- src/lib/libcurses/refresh.c:1.97 Sun Nov 18 01:54:30 2018 +++ src/lib/libcurses/refresh.c Sun Nov 18 02:17:24 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: refresh.c,v 1.97 2018/11/18 01:54:30 uwe Exp $ */ +/* $NetBSD: refresh.c,v 1.98 2018/11/18 02:17:24 uwe Exp $ */ /* * Copyright (c) 1981, 1993, 1994 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)refresh.c 8.7 (Berkeley) 8/13/94"; #else -__RCSID("$NetBSD: refresh.c,v 1.97 2018/11/18 01:54:30 uwe Exp $"); +__RCSID("$NetBSD: refresh.c,v 1.98 2018/11/18 02:17:24 uwe Exp $"); #endif #endif/* not lint */ @@ -1213,36 +1213,23 @@ makech(int wy) while (wx <= lch) { #ifdef DEBUG - __CTRACE(__CTRACE_REFRESH, "makech: wx=%d,lch=%d\n", wx, lch); -#endif /* DEBUG */ #ifndef HAVE_WCHAR - if (!(wlp->flags & __ISFORCED) && celleq(nsp, csp)) - { - if (wx <= lch) { -while (wx <= lch && celleq(nsp, csp)) -{ - nsp++; - if (!_cursesi_screen->curwin) - ++csp; - ++wx; -} -continue; - } - break; - } + __CTRACE(__CTRACE_REFRESH, "makech: wx=%d,lch=%d\n", wx, lch); #else -#ifdef DEBUG __CTRACE(__CTRACE_REFRESH, "makech: nsp=(%x,%x,%x,%x,%p)\n", nsp->ch, nsp->attr, win->bch, win->battr, nsp->nsp); __CTRACE(__CTRACE_REFRESH, "makech: csp=(%x,%x,%x,%x,%p)\n", csp->ch, csp->attr, win->bch, win->battr, csp->nsp); +#endif #endif /* DEBUG */ if (!(wlp->flags & __ISFORCED) && - (((nsp->attr & __WCWIDTH) != __WCWIDTH) && - celleq(nsp, csp))) +#ifdef HAVE_WCHAR + ((nsp->attr & __WCWIDTH) != __WCWIDTH) && +#endif + celleq(nsp, csp)) { if (wx <= lch) { -while (wx <= lch && celleq( csp, nsp )) { +while (wx <= lch && celleq(nsp, csp)) { nsp++; if (!_cursesi_screen->curwin) ++csp; @@ -1252,7 +1239,7 @@ makech(int wy) } break; } -#endif /* HAVE_WCHAR */ + domvcur(win, _cursesi_screen->ly, _cursesi_screen->lx, wy, wx); #ifdef DEBUG
CVS commit: src/lib/libcurses
Module Name:src Committed By: uwe Date: Sun Nov 18 01:54:30 UTC 2018 Modified Files: src/lib/libcurses: refresh.c Log Message: Merge few #ifdefs that now have identical code in both branches. Same object code is generated for both HAVE_WCHAR and !HAVE_WCHAR. To generate a diff of this commit: cvs rdiff -u -r1.96 -r1.97 src/lib/libcurses/refresh.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/refresh.c diff -u src/lib/libcurses/refresh.c:1.96 src/lib/libcurses/refresh.c:1.97 --- src/lib/libcurses/refresh.c:1.96 Sun Nov 18 01:39:55 2018 +++ src/lib/libcurses/refresh.c Sun Nov 18 01:54:30 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: refresh.c,v 1.96 2018/11/18 01:39:55 uwe Exp $ */ +/* $NetBSD: refresh.c,v 1.97 2018/11/18 01:54:30 uwe Exp $ */ /* * Copyright (c) 1981, 1993, 1994 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)refresh.c 8.7 (Berkeley) 8/13/94"; #else -__RCSID("$NetBSD: refresh.c,v 1.96 2018/11/18 01:39:55 uwe Exp $"); +__RCSID("$NetBSD: refresh.c,v 1.97 2018/11/18 01:54:30 uwe Exp $"); #endif #endif/* not lint */ @@ -1486,21 +1486,12 @@ quickch(void) * Find how many lines from the top of the screen are unchanged. */ for (top = 0; top < __virtscr->maxy; top++) { -#ifndef HAVE_WCHAR if (__virtscr->alines[top]->flags & __ISDIRTY && (__virtscr->alines[top]->hash != curscr->alines[top]->hash || !lineeq(__virtscr->alines[top]->line, curscr->alines[top]->line, (size_t) __virtscr->maxx))) break; -#else - if (__virtscr->alines[top]->flags & __ISDIRTY && - (__virtscr->alines[top]->hash != curscr->alines[top]->hash || - !lineeq(__virtscr->alines[top]->line, - curscr->alines[top]->line, - (size_t) __virtscr->maxx ))) - break; -#endif /* HAVE_WCHAR */ else __virtscr->alines[top]->flags &= ~__ISDIRTY; } @@ -1508,21 +1499,12 @@ quickch(void) * Find how many lines from bottom of screen are unchanged. */ for (bot = __virtscr->maxy - 1; bot >= 0; bot--) { -#ifndef HAVE_WCHAR if (__virtscr->alines[bot]->flags & __ISDIRTY && (__virtscr->alines[bot]->hash != curscr->alines[bot]->hash || !lineeq(__virtscr->alines[bot]->line, curscr->alines[bot]->line, (size_t) __virtscr->maxx))) break; -#else - if (__virtscr->alines[bot]->flags & __ISDIRTY && - (__virtscr->alines[bot]->hash != curscr->alines[bot]->hash || - !lineeq(__virtscr->alines[bot]->line, - curscr->alines[bot]->line, - (size_t) __virtscr->maxx ))) - break; -#endif /* HAVE_WCHAR */ else __virtscr->alines[bot]->flags &= ~__ISDIRTY; } @@ -1582,17 +1564,10 @@ quickch(void) continue; for (curw = startw, curs = starts; curs < starts + bsize; curw++, curs++) -#ifndef HAVE_WCHAR if (!lineeq(__virtscr->alines[curw]->line, curscr->alines[curs]->line, (size_t) __virtscr->maxx)) break; -#else - if (!lineeq(__virtscr->alines[curw]->line, - curscr->alines[curs]->line, - (size_t) __virtscr->maxx)) - break; -#endif /* HAVE_WCHAR */ if (curs == starts + bsize) goto done; } @@ -1741,19 +1716,11 @@ done: if ((n > 0 && target >= top && target < top + n) || (n < 0 && target <= bot && target > bot + n)) { -#ifndef HAVE_WCHAR if (clp->hash != blank_hash || !lineeq(clp->line, clp->line + 1, -(__virtscr->maxx - 1)) || + (__virtscr->maxx - 1)) || !celleq(clp->line, buf)) { -#else -if (clp->hash != blank_hash -|| !lineeq(clp->line, clp->line + 1, -(unsigned int) (__virtscr->maxx - 1)) -|| !celleq(clp->line, buf)) -{ -#endif /* HAVE_WCHAR */ for (i = __virtscr->maxx; i > BLANKSIZE; i -= BLANKSIZE) {
CVS commit: src/lib/libcurses
Module Name:src Committed By: uwe Date: Sun Nov 18 01:39:55 UTC 2018 Modified Files: src/lib/libcurses: refresh.c Log Message: Define celleq() and lineeq() for !HAVE_WCHAR too and use them instead of explicit memcmp() calls. Same object code is generated for both HAVE_WCHAR and !HAVE_WCHAR, but we can now try to merge some of the #ifdefs To generate a diff of this commit: cvs rdiff -u -r1.95 -r1.96 src/lib/libcurses/refresh.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/refresh.c diff -u src/lib/libcurses/refresh.c:1.95 src/lib/libcurses/refresh.c:1.96 --- src/lib/libcurses/refresh.c:1.95 Sun Nov 18 01:19:29 2018 +++ src/lib/libcurses/refresh.c Sun Nov 18 01:39:55 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: refresh.c,v 1.95 2018/11/18 01:19:29 uwe Exp $ */ +/* $NetBSD: refresh.c,v 1.96 2018/11/18 01:39:55 uwe Exp $ */ /* * Copyright (c) 1981, 1993, 1994 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)refresh.c 8.7 (Berkeley) 8/13/94"; #else -__RCSID("$NetBSD: refresh.c,v 1.95 2018/11/18 01:19:29 uwe Exp $"); +__RCSID("$NetBSD: refresh.c,v 1.96 2018/11/18 01:39:55 uwe Exp $"); #endif #endif/* not lint */ @@ -59,6 +59,18 @@ static int _wnoutrefresh(WINDOW *, int, #ifdef HAVE_WCHAR static int celleq(__LDATA *, __LDATA *); static int lineeq(__LDATA *, __LDATA *, size_t); +#else /* !HAVE_WCHAR */ +static inline int +celleq(__LDATA *x, __LDATA *y) +{ + return memcmp(x, y, sizeof(__LDATA)) == 0; +} + +static int +lineeq(__LDATA *xl, __LDATA *yl, size_t len) +{ + return memcmp(xl, yl, len * __LDATASIZE) == 0; +} #endif /* HAVE_WCHAR */ #define CHECK_INTERVAL 5 /* Change N lines before checking typeahead */ @@ -1204,12 +1216,10 @@ makech(int wy) __CTRACE(__CTRACE_REFRESH, "makech: wx=%d,lch=%d\n", wx, lch); #endif /* DEBUG */ #ifndef HAVE_WCHAR - if (!(wlp->flags & __ISFORCED) && - (memcmp(nsp, csp, sizeof(__LDATA)) == 0)) + if (!(wlp->flags & __ISFORCED) && celleq(nsp, csp)) { if (wx <= lch) { -while (wx <= lch && -memcmp(nsp, csp, sizeof(__LDATA)) == 0) +while (wx <= lch && celleq(nsp, csp)) { nsp++; if (!_cursesi_screen->curwin) @@ -1254,7 +1264,7 @@ makech(int wy) _cursesi_screen->lx = wx; #ifndef HAVE_WCHAR while (wx <= lch && - ((memcmp(nsp, csp, sizeof(__LDATA)) != 0) + (!celleq(nsp, csp) || (wlp->flags & __ISFORCED))) { if (ce != NULL && @@ -1479,10 +1489,9 @@ quickch(void) #ifndef HAVE_WCHAR if (__virtscr->alines[top]->flags & __ISDIRTY && (__virtscr->alines[top]->hash != curscr->alines[top]->hash || - memcmp(__virtscr->alines[top]->line, + !lineeq(__virtscr->alines[top]->line, curscr->alines[top]->line, - (size_t) __virtscr->maxx * __LDATASIZE) - != 0)) + (size_t) __virtscr->maxx))) break; #else if (__virtscr->alines[top]->flags & __ISDIRTY && @@ -1502,10 +1511,9 @@ quickch(void) #ifndef HAVE_WCHAR if (__virtscr->alines[bot]->flags & __ISDIRTY && (__virtscr->alines[bot]->hash != curscr->alines[bot]->hash || - memcmp(__virtscr->alines[bot]->line, + !lineeq(__virtscr->alines[bot]->line, curscr->alines[bot]->line, - (size_t) __virtscr->maxx * __LDATASIZE) - != 0)) + (size_t) __virtscr->maxx))) break; #else if (__virtscr->alines[bot]->flags & __ISDIRTY && @@ -1575,10 +1583,9 @@ quickch(void) for (curw = startw, curs = starts; curs < starts + bsize; curw++, curs++) #ifndef HAVE_WCHAR - if (memcmp(__virtscr->alines[curw]->line, + if (!lineeq(__virtscr->alines[curw]->line, curscr->alines[curs]->line, - (size_t) __virtscr->maxx * - __LDATASIZE) != 0) + (size_t) __virtscr->maxx)) break; #else if (!lineeq(__virtscr->alines[curw]->line, @@ -1736,10 +1743,9 @@ done: { #ifndef HAVE_WCHAR if (clp->hash != blank_hash || -memcmp(clp->line, clp->line + 1, -(__virtscr->maxx - 1) -* __LDATASIZE) || -memcmp(clp->line, buf, __LDATASIZE)) +!lineeq(clp->line, clp->line + 1, +(__virtscr->maxx - 1)) || +!celleq(clp->line, buf)) { #else if (clp->hash != blank_hash
CVS commit: src/lib/libcurses
Module Name:src Committed By: uwe Date: Sun Nov 18 01:23:57 UTC 2018 Modified Files: src/lib/libcurses: Makefile Log Message: Oops, revert previous. Wrong tree. To generate a diff of this commit: cvs rdiff -u -r1.87 -r1.88 src/lib/libcurses/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/Makefile diff -u src/lib/libcurses/Makefile:1.87 src/lib/libcurses/Makefile:1.88 --- src/lib/libcurses/Makefile:1.87 Sun Nov 18 01:22:49 2018 +++ src/lib/libcurses/Makefile Sun Nov 18 01:23:57 2018 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.87 2018/11/18 01:22:49 uwe Exp $ +# $NetBSD: Makefile,v 1.88 2018/11/18 01:23:57 uwe Exp $ # @(#)Makefile 8.2 (Berkeley) 1/2/94 .include @@ -39,7 +39,7 @@ MAN= curses.3 curses_addch.3 curses_addc INCS= curses.h unctrl.h INCSDIR=/usr/include -# LIBDPLIBS+= terminfo ${.CURDIR}/../libterminfo +LIBDPLIBS+= terminfo ${.CURDIR}/../libterminfo .if !defined(DISABLE_WCHAR) CPPFLAGS+=-DHAVE_WCHAR
CVS commit: src/lib/libcurses
Module Name:src Committed By: uwe Date: Sun Nov 18 01:22:49 UTC 2018 Modified Files: src/lib/libcurses: Makefile Log Message: Comment out LIBDPLIBS so that this can be built outside of the tree. To generate a diff of this commit: cvs rdiff -u -r1.86 -r1.87 src/lib/libcurses/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/Makefile diff -u src/lib/libcurses/Makefile:1.86 src/lib/libcurses/Makefile:1.87 --- src/lib/libcurses/Makefile:1.86 Thu Oct 25 10:36:56 2018 +++ src/lib/libcurses/Makefile Sun Nov 18 01:22:49 2018 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.86 2018/10/25 10:36:56 uwe Exp $ +# $NetBSD: Makefile,v 1.87 2018/11/18 01:22:49 uwe Exp $ # @(#)Makefile 8.2 (Berkeley) 1/2/94 .include @@ -39,7 +39,7 @@ MAN= curses.3 curses_addch.3 curses_addc INCS= curses.h unctrl.h INCSDIR=/usr/include -LIBDPLIBS+= terminfo ${.CURDIR}/../libterminfo +# LIBDPLIBS+= terminfo ${.CURDIR}/../libterminfo .if !defined(DISABLE_WCHAR) CPPFLAGS+=-DHAVE_WCHAR
CVS commit: src/lib/libcurses
Module Name:src Committed By: uwe Date: Sun Nov 18 01:19:29 UTC 2018 Modified Files: src/lib/libcurses: refresh.c Log Message: Rename cellcmp() and linecmp() to celleq() and lineeq() respectively and make them static. To generate a diff of this commit: cvs rdiff -u -r1.94 -r1.95 src/lib/libcurses/refresh.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/refresh.c diff -u src/lib/libcurses/refresh.c:1.94 src/lib/libcurses/refresh.c:1.95 --- src/lib/libcurses/refresh.c:1.94 Sun Nov 18 01:05:30 2018 +++ src/lib/libcurses/refresh.c Sun Nov 18 01:19:29 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: refresh.c,v 1.94 2018/11/18 01:05:30 uwe Exp $ */ +/* $NetBSD: refresh.c,v 1.95 2018/11/18 01:19:29 uwe Exp $ */ /* * Copyright (c) 1981, 1993, 1994 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)refresh.c 8.7 (Berkeley) 8/13/94"; #else -__RCSID("$NetBSD: refresh.c,v 1.94 2018/11/18 01:05:30 uwe Exp $"); +__RCSID("$NetBSD: refresh.c,v 1.95 2018/11/18 01:19:29 uwe Exp $"); #endif #endif/* not lint */ @@ -57,8 +57,8 @@ static void scrolln(int, int, int, int, static int _wnoutrefresh(WINDOW *, int, int, int, int, int, int); #ifdef HAVE_WCHAR -int cellcmp( __LDATA *, __LDATA * ); -int linecmp( __LDATA *, __LDATA *, size_t ); +static int celleq(__LDATA *, __LDATA *); +static int lineeq(__LDATA *, __LDATA *, size_t); #endif /* HAVE_WCHAR */ #define CHECK_INTERVAL 5 /* Change N lines before checking typeahead */ @@ -1229,10 +1229,10 @@ makech(int wy) #endif /* DEBUG */ if (!(wlp->flags & __ISFORCED) && (((nsp->attr & __WCWIDTH) != __WCWIDTH) && - cellcmp(nsp, csp))) + celleq(nsp, csp))) { if (wx <= lch) { -while (wx <= lch && cellcmp( csp, nsp )) { +while (wx <= lch && celleq( csp, nsp )) { nsp++; if (!_cursesi_screen->curwin) ++csp; @@ -1261,7 +1261,7 @@ makech(int wy) wx >= nlsp && nsp->ch == ' ' && nsp->attr == lspc) { #else - while ((!cellcmp(nsp, csp) || (wlp->flags & __ISFORCED)) && + while ((!celleq(nsp, csp) || (wlp->flags & __ISFORCED)) && wx <= lch) { if (ce != NULL && wx >= nlsp @@ -1487,7 +1487,7 @@ quickch(void) #else if (__virtscr->alines[top]->flags & __ISDIRTY && (__virtscr->alines[top]->hash != curscr->alines[top]->hash || - !linecmp(__virtscr->alines[top]->line, + !lineeq(__virtscr->alines[top]->line, curscr->alines[top]->line, (size_t) __virtscr->maxx ))) break; @@ -1510,7 +1510,7 @@ quickch(void) #else if (__virtscr->alines[bot]->flags & __ISDIRTY && (__virtscr->alines[bot]->hash != curscr->alines[bot]->hash || - !linecmp(__virtscr->alines[bot]->line, + !lineeq(__virtscr->alines[bot]->line, curscr->alines[bot]->line, (size_t) __virtscr->maxx ))) break; @@ -1581,7 +1581,7 @@ quickch(void) __LDATASIZE) != 0) break; #else - if (!linecmp(__virtscr->alines[curw]->line, + if (!lineeq(__virtscr->alines[curw]->line, curscr->alines[curs]->line, (size_t) __virtscr->maxx)) break; @@ -1743,9 +1743,9 @@ done: { #else if (clp->hash != blank_hash -|| !linecmp(clp->line, clp->line + 1, +|| !lineeq(clp->line, clp->line + 1, (unsigned int) (__virtscr->maxx - 1)) -|| !cellcmp(clp->line, buf)) +|| !celleq(clp->line, buf)) { #endif /* HAVE_WCHAR */ for (i = __virtscr->maxx; @@ -2035,8 +2035,8 @@ __unsetattr(int checkms) #ifdef HAVE_WCHAR /* compare two cells on screen, must have the same forground/background, * and the same sequence of non-spacing characters */ -int -cellcmp( __LDATA *x, __LDATA *y ) +static int +celleq(__LDATA *x, __LDATA *y) { nschar_t *xnp = x->nsp, *ynp = y->nsp; int ret = ( x->ch == y->ch ) && ( x->attr == y->attr ); @@ -2058,14 +2058,14 @@ cellcmp( __LDATA *x, __LDATA *y ) } /* compare two line segments */ -int -linecmp( __LDATA *xl, __LDATA *yl, size_t len ) +static int +lineeq(__LDATA *xl, __LDATA *yl, size_t len) { int i = 0; __LDATA *xp = xl, *yp = yl; for (i = 0; i < len; i++, xp++, yp++) { - if (!cellcmp(xp, yp)) + if (!celleq(xp, yp)) return 0; } return 1;
CVS commit: src/lib/libcurses
Module Name:src Committed By: uwe Date: Sun Nov 18 01:05:30 UTC 2018 Modified Files: src/lib/libcurses: refresh.c Log Message: quickch - fix inverted checks. I have to admit I have no idea what's going on here, but HAVE_WCHAR code here inverted the sense of linecmp and cellcmp checks w.r.t the !HAVE_WCHAR variant just above it. Cf. also all other similar #ifdefs in this file. Found through source code inspection, not really tested. To generate a diff of this commit: cvs rdiff -u -r1.93 -r1.94 src/lib/libcurses/refresh.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/refresh.c diff -u src/lib/libcurses/refresh.c:1.93 src/lib/libcurses/refresh.c:1.94 --- src/lib/libcurses/refresh.c:1.93 Sun Nov 18 00:45:44 2018 +++ src/lib/libcurses/refresh.c Sun Nov 18 01:05:30 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: refresh.c,v 1.93 2018/11/18 00:45:44 uwe Exp $ */ +/* $NetBSD: refresh.c,v 1.94 2018/11/18 01:05:30 uwe Exp $ */ /* * Copyright (c) 1981, 1993, 1994 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)refresh.c 8.7 (Berkeley) 8/13/94"; #else -__RCSID("$NetBSD: refresh.c,v 1.93 2018/11/18 00:45:44 uwe Exp $"); +__RCSID("$NetBSD: refresh.c,v 1.94 2018/11/18 01:05:30 uwe Exp $"); #endif #endif/* not lint */ @@ -1743,9 +1743,9 @@ done: { #else if (clp->hash != blank_hash -|| linecmp(clp->line, clp->line + 1, +|| !linecmp(clp->line, clp->line + 1, (unsigned int) (__virtscr->maxx - 1)) -|| cellcmp(clp->line, buf)) +|| !cellcmp(clp->line, buf)) { #endif /* HAVE_WCHAR */ for (i = __virtscr->maxx;
CVS commit: src/lib/libcurses
Module Name:src Committed By: uwe Date: Sun Nov 18 00:45:44 UTC 2018 Modified Files: src/lib/libcurses: refresh.c Log Message: cellcmp - use logical && not bitwise & To generate a diff of this commit: cvs rdiff -u -r1.92 -r1.93 src/lib/libcurses/refresh.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/refresh.c diff -u src/lib/libcurses/refresh.c:1.92 src/lib/libcurses/refresh.c:1.93 --- src/lib/libcurses/refresh.c:1.92 Mon Oct 29 01:02:16 2018 +++ src/lib/libcurses/refresh.c Sun Nov 18 00:45:44 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: refresh.c,v 1.92 2018/10/29 01:02:16 uwe Exp $ */ +/* $NetBSD: refresh.c,v 1.93 2018/11/18 00:45:44 uwe Exp $ */ /* * Copyright (c) 1981, 1993, 1994 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)refresh.c 8.7 (Berkeley) 8/13/94"; #else -__RCSID("$NetBSD: refresh.c,v 1.92 2018/10/29 01:02:16 uwe Exp $"); +__RCSID("$NetBSD: refresh.c,v 1.93 2018/11/18 00:45:44 uwe Exp $"); #endif #endif/* not lint */ @@ -2039,7 +2039,7 @@ int cellcmp( __LDATA *x, __LDATA *y ) { nschar_t *xnp = x->nsp, *ynp = y->nsp; - int ret = ( x->ch == y->ch ) & ( x->attr == y->attr ); + int ret = ( x->ch == y->ch ) && ( x->attr == y->attr ); if (!ret) return 0;
CVS commit: src/lib/libcurses
Module Name:src Committed By: blymn Date: Fri Nov 16 10:12:00 UTC 2018 Modified Files: src/lib/libcurses: curses_private.h fileio.h screen.c shlib_version tty.c Log Message: Fix for PR lib/52063 Many thanks to Onno van der Linden (o.vd.lin...@quicknet.nl) for providing the bulk of the patch that fixes the issue. To generate a diff of this commit: cvs rdiff -u -r1.67 -r1.68 src/lib/libcurses/curses_private.h cvs rdiff -u -r1.4 -r1.5 src/lib/libcurses/fileio.h cvs rdiff -u -r1.34 -r1.35 src/lib/libcurses/screen.c cvs rdiff -u -r1.42 -r1.43 src/lib/libcurses/shlib_version cvs rdiff -u -r1.47 -r1.48 src/lib/libcurses/tty.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/curses_private.h diff -u src/lib/libcurses/curses_private.h:1.67 src/lib/libcurses/curses_private.h:1.68 --- src/lib/libcurses/curses_private.h:1.67 Mon Oct 29 00:25:20 2018 +++ src/lib/libcurses/curses_private.h Fri Nov 16 10:12:00 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: curses_private.h,v 1.67 2018/10/29 00:25:20 uwe Exp $ */ +/* $NetBSD: curses_private.h,v 1.68 2018/11/16 10:12:00 blymn Exp $ */ /*- * Copyright (c) 1998-2000 Brett Lymn @@ -133,6 +133,7 @@ struct __window { /* Window structure. #define __ISDERWIN 0x0010 /* "window" is derived from parent */ #define __IMMEDOK 0x0020 /* refreshed when changed */ #define __SYNCOK 0x0040 /* sync when changed */ +#define __HALFDELAY 0x0080 /* In half delay mode */ unsigned int flags; int delay; /* delay for getch() */ attr_t wattr; /* Character attributes */ @@ -278,7 +279,6 @@ struct __screen { char padchar; int endwin; int notty; - int half_delay; int resized; wchar_t *unget_list; int unget_len, unget_pos; Index: src/lib/libcurses/fileio.h diff -u src/lib/libcurses/fileio.h:1.4 src/lib/libcurses/fileio.h:1.5 --- src/lib/libcurses/fileio.h:1.4 Mon Jan 2 12:38:16 2017 +++ src/lib/libcurses/fileio.h Fri Nov 16 10:12:00 2018 @@ -1,8 +1,8 @@ /* * Do not edit! Automatically generated file: - * from: NetBSD: shlib_version,v 1.41 2015/11/22 04:56:00 kamil Exp + * from: NetBSD: shlib_version,v 1.42 2017/01/02 12:38:16 roy Exp * by : NetBSD: genfileioh.awk,v 1.2 2008/05/02 11:13:02 martin Exp */ #define CURSES_LIB_MAJOR 7 -#define CURSES_LIB_MINOR 1 +#define CURSES_LIB_MINOR 2 Index: src/lib/libcurses/screen.c diff -u src/lib/libcurses/screen.c:1.34 src/lib/libcurses/screen.c:1.35 --- src/lib/libcurses/screen.c:1.34 Tue Oct 2 17:35:44 2018 +++ src/lib/libcurses/screen.c Fri Nov 16 10:12:00 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: screen.c,v 1.34 2018/10/02 17:35:44 roy Exp $ */ +/* $NetBSD: screen.c,v 1.35 2018/11/16 10:12:00 blymn Exp $ */ /* * Copyright (c) 1981, 1993, 1994 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)screen.c 8.2 (blymn) 11/27/2001"; #else -__RCSID("$NetBSD: screen.c,v 1.34 2018/10/02 17:35:44 roy Exp $"); +__RCSID("$NetBSD: screen.c,v 1.35 2018/11/16 10:12:00 blymn Exp $"); #endif #endif /* not lint */ @@ -167,7 +167,6 @@ newterm(char *type, FILE *outfd, FILE *i new_screen->__virtscr = NULL; new_screen->curwin = 0; new_screen->notty = FALSE; - new_screen->half_delay = FALSE; new_screen->resized = 0; new_screen->unget_len = 32; Index: src/lib/libcurses/shlib_version diff -u src/lib/libcurses/shlib_version:1.42 src/lib/libcurses/shlib_version:1.43 --- src/lib/libcurses/shlib_version:1.42 Mon Jan 2 12:38:16 2017 +++ src/lib/libcurses/shlib_version Fri Nov 16 10:12:00 2018 @@ -1,8 +1,8 @@ -# $NetBSD: shlib_version,v 1.42 2017/01/02 12:38:16 roy Exp $ +# $NetBSD: shlib_version,v 1.43 2018/11/16 10:12:00 blymn Exp $ # Remember to update distrib/sets/lists/base/shl.* when changing # Remember to run `make fileio.h` when changing # Remember to increment the major numbers of libform, libmenu and # libpanel when the libcurses major number increments. # major=7 -minor=1 +minor=2 Index: src/lib/libcurses/tty.c diff -u src/lib/libcurses/tty.c:1.47 src/lib/libcurses/tty.c:1.48 --- src/lib/libcurses/tty.c:1.47 Thu Oct 18 07:53:13 2018 +++ src/lib/libcurses/tty.c Fri Nov 16 10:12:00 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: tty.c,v 1.47 2018/10/18 07:53:13 roy Exp $ */ +/* $NetBSD: tty.c,v 1.48 2018/11/16 10:12:00 blymn Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)tty.c 8.6 (Berkeley) 1/10/95"; #else -__RCSID("$NetBSD: tty.c,v 1.47 2018/10/18 07:53:13 roy Exp $"); +__RCSID("$NetBSD: tty.c,v 1.48 2018/11/16 10:12:00 blymn Exp $"); #endif #endif/* not lint */ @@ -250,11 +250,11 @@ nocbreak(void) if (_cursesi_screen->notty == TRUE) return OK; /* if we were in halfdelay mode then nuke the timeout */ - if ((_cursesi_screen->half_delay == TRUE) && + if ((stdscr->flags & __HALFDELAY) && (__notimeout() == ERR)) return ERR; - _cursesi_screen->half_delay = FALSE; + stdscr->flags &= ~_
CVS commit: src/lib/libcurses
Module Name:src Committed By: uwe Date: Thu Nov 15 03:17:51 UTC 2018 Modified Files: src/lib/libcurses: addbytes.c Log Message: _cursesi_addbyte - fix function comment after what looks like an editing accident. To generate a diff of this commit: cvs rdiff -u -r1.48 -r1.49 src/lib/libcurses/addbytes.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/addbytes.c diff -u src/lib/libcurses/addbytes.c:1.48 src/lib/libcurses/addbytes.c:1.49 --- src/lib/libcurses/addbytes.c:1.48 Wed Aug 8 02:26:08 2018 +++ src/lib/libcurses/addbytes.c Thu Nov 15 03:17:51 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: addbytes.c,v 1.48 2018/08/08 02:26:08 simonb Exp $ */ +/* $NetBSD: addbytes.c,v 1.49 2018/11/15 03:17:51 uwe Exp $ */ /* * Copyright (c) 1987, 1993, 1994 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)addbytes.c 8.4 (Berkeley) 5/4/94"; #else -__RCSID("$NetBSD: addbytes.c,v 1.48 2018/08/08 02:26:08 simonb Exp $"); +__RCSID("$NetBSD: addbytes.c,v 1.49 2018/11/15 03:17:51 uwe Exp $"); #endif #endif/* not lint */ @@ -204,9 +204,9 @@ _cursesi_waddbytes(WINDOW *win, const ch /* * _cursesi_addbyte - * Internal function to add a byte and update the row and column - * positions as appropriate. This function is only used in the narrow - * character version of curses. If update_cursor is non-zero then character - * interpretation. + * positions as appropriate. If char_interp is non-zero then + * character interpretation is done on the byte. This function is + * only used in the narrow character version of curses. */ int _cursesi_addbyte(WINDOW *win, __LINE **lp, int *y, int *x, int c,
CVS commit: src/lib/libcurses
Module Name:src Committed By: blymn Date: Fri Nov 2 04:17:39 UTC 2018 Modified Files: src/lib/libcurses: resize.c Log Message: Remove obsolete clauses from copyright block. Original copyright was mine so should be ok to do. To generate a diff of this commit: cvs rdiff -u -r1.29 -r1.30 src/lib/libcurses/resize.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/resize.c diff -u src/lib/libcurses/resize.c:1.29 src/lib/libcurses/resize.c:1.30 --- src/lib/libcurses/resize.c:1.29 Wed Oct 3 13:22:29 2018 +++ src/lib/libcurses/resize.c Fri Nov 2 04:17:39 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: resize.c,v 1.29 2018/10/03 13:22:29 roy Exp $ */ +/* $NetBSD: resize.c,v 1.30 2018/11/02 04:17:39 blymn Exp $ */ /* * Copyright (c) 2001 @@ -14,13 +14,6 @@ * 2. Redistributions in binary form must reproduce the above copyright *notice, this list of conditions and the following disclaimer in the *documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - *must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - *may be used to endorse or promote products derived from this software - *without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE @@ -40,7 +33,7 @@ #if 0 static char sccsid[] = "@(#)resize.c blymn 2001/08/26"; #else -__RCSID("$NetBSD: resize.c,v 1.29 2018/10/03 13:22:29 roy Exp $"); +__RCSID("$NetBSD: resize.c,v 1.30 2018/11/02 04:17:39 blymn Exp $"); #endif #endif/* not lint */
CVS commit: src/lib/libcurses
Module Name:src Committed By: wiz Date: Mon Oct 29 21:06:14 UTC 2018 Modified Files: src/lib/libcurses: curses_inch.3 Log Message: Add comma in enumeration. To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/lib/libcurses/curses_inch.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/curses_inch.3 diff -u src/lib/libcurses/curses_inch.3:1.13 src/lib/libcurses/curses_inch.3:1.14 --- src/lib/libcurses/curses_inch.3:1.13 Thu Oct 25 10:36:56 2018 +++ src/lib/libcurses/curses_inch.3 Mon Oct 29 21:06:13 2018 @@ -1,4 +1,4 @@ -.\" $NetBSD: curses_inch.3,v 1.13 2018/10/25 10:36:56 uwe Exp $ +.\" $NetBSD: curses_inch.3,v 1.14 2018/10/29 21:06:13 wiz Exp $ .\" .\" Copyright (c) 2002 .\" Brett Lymn (bl...@netbsd.org, brett_l...@yahoo.com.au) @@ -50,7 +50,7 @@ .Nm mvinnstr , .Nm mvwinnstr , .Nm instr , -.Nm winstr +.Nm winstr , .Nm mvinstr , .Nm mvwinstr .Nd curses read screen contents routines
CVS commit: src/lib/libcurses
Module Name:src Committed By: uwe Date: Mon Oct 29 01:27:40 UTC 2018 Modified Files: src/lib/libcurses: attributes.c Log Message: Fix indentation. To generate a diff of this commit: cvs rdiff -u -r1.23 -r1.24 src/lib/libcurses/attributes.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/attributes.c diff -u src/lib/libcurses/attributes.c:1.23 src/lib/libcurses/attributes.c:1.24 --- src/lib/libcurses/attributes.c:1.23 Tue Jan 10 21:56:50 2017 +++ src/lib/libcurses/attributes.c Mon Oct 29 01:27:39 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: attributes.c,v 1.23 2017/01/10 21:56:50 roy Exp $ */ +/* $NetBSD: attributes.c,v 1.24 2018/10/29 01:27:39 uwe Exp $ */ /*- * Copyright (c) 1999 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include #ifndef lint -__RCSID("$NetBSD: attributes.c,v 1.23 2017/01/10 21:56:50 roy Exp $"); +__RCSID("$NetBSD: attributes.c,v 1.24 2018/10/29 01:27:39 uwe Exp $"); #endif/* not lint */ #include "curses.h" @@ -245,7 +245,7 @@ wattr_off(WINDOW *win, attr_t attr, void win->wattr &= ~WA_RIGHT; if (attr & WA_HORIZONTAL) win->wattr &= ~WA_HORIZONTAL; - if (attr & WA_VERTICAL) + if (attr & WA_VERTICAL) win->wattr &= ~WA_VERTICAL; #endif /* HAVE_WCHAR */ }
CVS commit: src/lib/libcurses
Module Name:src Committed By: uwe Date: Mon Oct 29 01:19:54 UTC 2018 Modified Files: src/lib/libcurses: addch.c Log Message: waddch - instead of enclosing every statement in #ifdef HAVE_WCHAR just provide two separate definitions. Same object code is generated for all four combinations of debug/wchar. To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/lib/libcurses/addch.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/addch.c diff -u src/lib/libcurses/addch.c:1.18 src/lib/libcurses/addch.c:1.19 --- src/lib/libcurses/addch.c:1.18 Fri Jan 6 14:06:00 2017 +++ src/lib/libcurses/addch.c Mon Oct 29 01:19:54 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: addch.c,v 1.18 2017/01/06 14:06:00 roy Exp $ */ +/* $NetBSD: addch.c,v 1.19 2018/10/29 01:19:54 uwe Exp $ */ /* * Copyright (c) 1981, 1993, 1994 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)addch.c 8.2 (Berkeley) 5/4/94"; #else -__RCSID("$NetBSD: addch.c,v 1.18 2017/01/06 14:06:00 roy Exp $"); +__RCSID("$NetBSD: addch.c,v 1.19 2018/10/29 01:19:54 uwe Exp $"); #endif #endif/* not lint */ @@ -82,43 +82,45 @@ mvwaddch(WINDOW *win, int y, int x, chty #endif +#ifdef HAVE_WCHAR /* * waddch -- * Add the character to the current position in the given window. - * */ int waddch(WINDOW *win, chtype ch) { -#ifdef HAVE_WCHAR cchar_t cc; -#else - __LDATA buf; -#endif -#ifdef HAVE_WCHAR __cursesi_chtype_to_cchar(ch, &cc); -#else - buf.ch = (wchar_t)ch & __CHARTEXT; - buf.attr = (attr_t)ch & __ATTRIBUTES; -#endif - #ifdef DEBUG -#ifdef HAVE_WCHAR __CTRACE(__CTRACE_INPUT, "addch: %d : 0x%x (adding char as wide char)\n", cc.vals[0], cc.attributes); -#else - __CTRACE(__CTRACE_INPUT, "addch: %d : 0x%x\n", buf.ch, buf.attr); -#endif #endif -#ifdef HAVE_WCHAR return wadd_wch(win, &cc); -#else - return __waddch(win, &buf); +} + +#else /* !HAVE_WCHAR */ + +/* + * waddch -- + * Add the character to the current position in the given window. + */ +int +waddch(WINDOW *win, chtype ch) +{ + __LDATA buf; + + buf.ch = (wchar_t)ch & __CHARTEXT; + buf.attr = (attr_t)ch & __ATTRIBUTES; +#ifdef DEBUG + __CTRACE(__CTRACE_INPUT, "addch: %d : 0x%x\n", buf.ch, buf.attr); #endif + return __waddch(win, &buf); } +#endif /* !HAVE_WCHAR */ int __waddch(WINDOW *win, __LDATA *dp)
CVS commit: src/lib/libcurses
Module Name:src Committed By: uwe Date: Mon Oct 29 01:02:16 UTC 2018 Modified Files: src/lib/libcurses: refresh.c Log Message: Fix operator precedence for !HAVE_WCHAR To generate a diff of this commit: cvs rdiff -u -r1.91 -r1.92 src/lib/libcurses/refresh.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/refresh.c diff -u src/lib/libcurses/refresh.c:1.91 src/lib/libcurses/refresh.c:1.92 --- src/lib/libcurses/refresh.c:1.91 Sun Oct 21 12:47:33 2018 +++ src/lib/libcurses/refresh.c Mon Oct 29 01:02:16 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: refresh.c,v 1.91 2018/10/21 12:47:33 roy Exp $ */ +/* $NetBSD: refresh.c,v 1.92 2018/10/29 01:02:16 uwe Exp $ */ /* * Copyright (c) 1981, 1993, 1994 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)refresh.c 8.7 (Berkeley) 8/13/94"; #else -__RCSID("$NetBSD: refresh.c,v 1.91 2018/10/21 12:47:33 roy Exp $"); +__RCSID("$NetBSD: refresh.c,v 1.92 2018/10/29 01:02:16 uwe Exp $"); #endif #endif/* not lint */ @@ -1253,8 +1253,9 @@ makech(int wy) _cursesi_screen->ly = wy; _cursesi_screen->lx = wx; #ifndef HAVE_WCHAR - while (wx <= lch && (memcmp(nsp, csp, sizeof(__LDATA)) != 0) || - (wlp->flags & __ISFORCED)) + while (wx <= lch && + ((memcmp(nsp, csp, sizeof(__LDATA)) != 0) + || (wlp->flags & __ISFORCED))) { if (ce != NULL && wx >= nlsp && nsp->ch == ' ' && nsp->attr == lspc)
CVS commit: src/lib/libcurses
Module Name:src Committed By: uwe Date: Mon Oct 29 00:31:57 UTC 2018 Modified Files: src/lib/libcurses: ctrace.c Log Message: __CTRACE - don't call gettimeofday() twice. To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/lib/libcurses/ctrace.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/ctrace.c diff -u src/lib/libcurses/ctrace.c:1.22 src/lib/libcurses/ctrace.c:1.23 --- src/lib/libcurses/ctrace.c:1.22 Mon Oct 29 00:25:20 2018 +++ src/lib/libcurses/ctrace.c Mon Oct 29 00:31:57 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: ctrace.c,v 1.22 2018/10/29 00:25:20 uwe Exp $ */ +/* $NetBSD: ctrace.c,v 1.23 2018/10/29 00:31:57 uwe Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)ctrace.c 8.2 (Berkeley) 10/5/93"; #else -__RCSID("$NetBSD: ctrace.c,v 1.22 2018/10/29 00:25:20 uwe Exp $"); +__RCSID("$NetBSD: ctrace.c,v 1.23 2018/10/29 00:31:57 uwe Exp $"); #endif #endif/* not lint */ @@ -85,7 +85,6 @@ __CTRACE_init(void) void __CTRACE(int area, const char *fmt,...) { - struct timeval tv; static int seencr = 1; va_list ap; @@ -93,8 +92,9 @@ __CTRACE(int area, const char *fmt,...) __CTRACE_init(); if (tracefp == NULL || !(tracemask & area)) return; - gettimeofday(&tv, NULL); + if (seencr && (tracemask & __CTRACE_TSTAMP)) { + struct timeval tv; gettimeofday(&tv, NULL); (void)fprintf(tracefp, "%llu.%06lu: ", (long long)tv.tv_sec, (long)tv.tv_usec);
CVS commit: src/lib/libcurses
Module Name:src Committed By: uwe Date: Mon Oct 29 00:25:20 UTC 2018 Modified Files: src/lib/libcurses: ctrace.c curses_private.h Log Message: Make __CTRACE_init() static and ANSIfy its definition. To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/lib/libcurses/ctrace.c cvs rdiff -u -r1.66 -r1.67 src/lib/libcurses/curses_private.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcurses/ctrace.c diff -u src/lib/libcurses/ctrace.c:1.21 src/lib/libcurses/ctrace.c:1.22 --- src/lib/libcurses/ctrace.c:1.21 Fri Jan 6 13:53:18 2017 +++ src/lib/libcurses/ctrace.c Mon Oct 29 00:25:20 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: ctrace.c,v 1.21 2017/01/06 13:53:18 roy Exp $ */ +/* $NetBSD: ctrace.c,v 1.22 2018/10/29 00:25:20 uwe Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)ctrace.c 8.2 (Berkeley) 10/5/93"; #else -__RCSID("$NetBSD: ctrace.c,v 1.21 2017/01/06 13:53:18 roy Exp $"); +__RCSID("$NetBSD: ctrace.c,v 1.22 2018/10/29 00:25:20 uwe Exp $"); #endif #endif/* not lint */ @@ -55,8 +55,8 @@ static int tracemask; /* Areas of trace static int init_done = 0; -void -__CTRACE_init() +static void +__CTRACE_init(void) { char *tf, *tm; Index: src/lib/libcurses/curses_private.h diff -u src/lib/libcurses/curses_private.h:1.66 src/lib/libcurses/curses_private.h:1.67 --- src/lib/libcurses/curses_private.h:1.66 Thu Oct 4 18:40:41 2018 +++ src/lib/libcurses/curses_private.h Mon Oct 29 00:25:20 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: curses_private.h,v 1.66 2018/10/04 18:40:41 roy Exp $ */ +/* $NetBSD: curses_private.h,v 1.67 2018/10/29 00:25:20 uwe Exp $ */ /*- * Copyright (c) 1998-2000 Brett Lymn @@ -332,7 +332,6 @@ extern SCREEN *_cursesi_screen; #define __CTRACE_ERASE 0x0800 #define __CTRACE_FILEIO 0x1000 #define __CTRACE_ALL 0x7fff -void __CTRACE_init(void); void __CTRACE(int, const char *, ...) __attribute__((__format__(__printf__, 2, 3))); #endif