CVS commit: src/lib/libcurses

2024-05-27 Thread Valery Ushakov
Module Name:src
Committed By:   uwe
Date:   Mon May 27 14:30:43 UTC 2024

Modified Files:
src/lib/libcurses: screen.c

Log Message:
curses: init old_mode to 1 (normal visible cursor)

PR bin/58090: Ctrl-Z, fg makes blinking cursor in vi
ok blymn@


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/lib/libcurses/screen.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/screen.c
diff -u src/lib/libcurses/screen.c:1.38 src/lib/libcurses/screen.c:1.39
--- src/lib/libcurses/screen.c:1.38	Fri May 17 23:32:50 2024
+++ src/lib/libcurses/screen.c	Mon May 27 14:30:43 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: screen.c,v 1.38 2024/05/17 23:32:50 uwe Exp $	*/
+/*	$NetBSD: screen.c,v 1.39 2024/05/27 14:30:43 uwe 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.38 2024/05/17 23:32:50 uwe Exp $");
+__RCSID("$NetBSD: screen.c,v 1.39 2024/05/27 14:30:43 uwe Exp $");
 #endif
 #endif	/* not lint */
 
@@ -156,7 +156,7 @@ newterm(const char *type, FILE *outfd, F
 	new_screen->nca = A_NORMAL;
 	new_screen->color_type = COLOR_NONE;
 	new_screen->COLOR_PAIRS = 0;
-	new_screen->old_mode = 2;
+	new_screen->old_mode = 1;
 	new_screen->stdbuf = NULL;
 	new_screen->stdscr = NULL;
 	new_screen->curscr = NULL;



CVS commit: src/lib/libcurses

2024-05-27 Thread Valery Ushakov
Module Name:src
Committed By:   uwe
Date:   Mon May 27 14:30:43 UTC 2024

Modified Files:
src/lib/libcurses: screen.c

Log Message:
curses: init old_mode to 1 (normal visible cursor)

PR bin/58090: Ctrl-Z, fg makes blinking cursor in vi
ok blymn@


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/lib/libcurses/screen.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libcurses

2024-05-17 Thread Valery Ushakov
Module Name:src
Committed By:   uwe
Date:   Fri May 17 23:32:51 UTC 2024

Modified Files:
src/lib/libcurses: curses.h curses_private.h curses_screen.3 screen.c
setterm.c

Log Message:
curses: constify newterm() and setterm() arguments

newterm() argument is const in the spec, so this fixes our
conformance.

setterm() is not in the spec, but it's natural and in ncurses its
argument is const too, so follow suit.

Doesn't change the ABI, so no bump required.

ok blymn@


To generate a diff of this commit:
cvs rdiff -u -r1.131 -r1.132 src/lib/libcurses/curses.h
cvs rdiff -u -r1.80 -r1.81 src/lib/libcurses/curses_private.h
cvs rdiff -u -r1.28 -r1.29 src/lib/libcurses/curses_screen.3
cvs rdiff -u -r1.37 -r1.38 src/lib/libcurses/screen.c
cvs rdiff -u -r1.71 -r1.72 src/lib/libcurses/setterm.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libcurses

2024-05-17 Thread Valery Ushakov
Module Name:src
Committed By:   uwe
Date:   Fri May 17 23:32:51 UTC 2024

Modified Files:
src/lib/libcurses: curses.h curses_private.h curses_screen.3 screen.c
setterm.c

Log Message:
curses: constify newterm() and setterm() arguments

newterm() argument is const in the spec, so this fixes our
conformance.

setterm() is not in the spec, but it's natural and in ncurses its
argument is const too, so follow suit.

Doesn't change the ABI, so no bump required.

ok blymn@


To generate a diff of this commit:
cvs rdiff -u -r1.131 -r1.132 src/lib/libcurses/curses.h
cvs rdiff -u -r1.80 -r1.81 src/lib/libcurses/curses_private.h
cvs rdiff -u -r1.28 -r1.29 src/lib/libcurses/curses_screen.3
cvs rdiff -u -r1.37 -r1.38 src/lib/libcurses/screen.c
cvs rdiff -u -r1.71 -r1.72 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/curses.h
diff -u src/lib/libcurses/curses.h:1.131 src/lib/libcurses/curses.h:1.132
--- src/lib/libcurses/curses.h:1.131	Tue May 14 10:22:48 2024
+++ src/lib/libcurses/curses.h	Fri May 17 23:32:50 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: curses.h,v 1.131 2024/05/14 10:22:48 uwe Exp $	*/
+/*	$NetBSD: curses.h,v 1.132 2024/05/17 23:32:50 uwe Exp $	*/
 
 /*
  * Copyright (c) 1981, 1993, 1994
@@ -719,7 +719,7 @@ int	 mvwprintw(WINDOW *, int, int, const
 int	 mvwscanw(WINDOW *, int, int, const char *, ...) __scanflike(4, 5);
 int	 napms(int);
 WINDOW	*newpad(int, int);
-SCREEN  *newterm(char *, FILE *, FILE *);
+SCREEN  *newterm(const char *, FILE *, FILE *);
 WINDOW	*newwin(int, int, int, int);
 int	 nl(void);
 attr_t	 no_color_attributes(void);
@@ -751,7 +751,7 @@ int	 savetty(void);
 int	 scanw(const char *, ...) __scanflike(1, 2);
 int	 scroll(WINDOW *);
 int	 scrollok(WINDOW *, bool);
-int	 setterm(char *);
+int	 setterm(const char *);
 int	 set_escdelay(int);
 int	 set_tabsize(int);
 SCREEN  *set_term(SCREEN *);

Index: src/lib/libcurses/curses_private.h
diff -u src/lib/libcurses/curses_private.h:1.80 src/lib/libcurses/curses_private.h:1.81
--- src/lib/libcurses/curses_private.h:1.80	Tue May  3 07:25:34 2022
+++ src/lib/libcurses/curses_private.h	Fri May 17 23:32:50 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: curses_private.h,v 1.80 2022/05/03 07:25:34 blymn Exp $	*/
+/*	$NetBSD: curses_private.h,v 1.81 2024/05/17 23:32:50 uwe Exp $	*/
 
 /*-
  * Copyright (c) 1998-2000 Brett Lymn
@@ -355,7 +355,7 @@ int	_cursesi_waddbytes(WINDOW *, const c
 void _cursesi_reset_wacs(SCREEN *);
 #endif /* HAVE_WCHAR */
 void _cursesi_resetterm(SCREEN *);
-int  _cursesi_setterm(char *, SCREEN *);
+int  _cursesi_setterm(const char *, SCREEN *);
 int	 __delay(void);
 unsigned int	 __hash_more(const void *, size_t, unsigned int);
 unsigned int	 __hash_line(const __LDATA *, int);

Index: src/lib/libcurses/curses_screen.3
diff -u src/lib/libcurses/curses_screen.3:1.28 src/lib/libcurses/curses_screen.3:1.29
--- src/lib/libcurses/curses_screen.3:1.28	Sun Feb  7 23:00:57 2021
+++ src/lib/libcurses/curses_screen.3	Fri May 17 23:32:50 2024
@@ -1,4 +1,4 @@
-.\"	$NetBSD: curses_screen.3,v 1.28 2021/02/07 23:00:57 rillig Exp $
+.\"	$NetBSD: curses_screen.3,v 1.29 2024/05/17 23:32:50 uwe Exp $
 .\"
 .\" Copyright (c) 2002
 .\"	Brett Lymn (bl...@netbsd.org, brett_l...@yahoo.com.au)
@@ -30,7 +30,7 @@
 .\" SUCH DAMAGE.
 .\"
 .\"
-.Dd March 12, 2020
+.Dd May 16, 2024
 .Dt CURSES_SCREEN 3
 .Os
 .Sh NAME
@@ -61,7 +61,7 @@
 .Ft void
 .Fn use_env "bool value"
 .Ft SCREEN *
-.Fn newterm "char *type" "FILE *outfd" "FILE *infd"
+.Fn newterm "const char *type" "FILE *outfd" "FILE *infd"
 .Ft SCREEN *
 .Fn set_term "SCREEN *screen"
 .Ft void
@@ -79,7 +79,7 @@
 .Ft int
 .Fn resizeterm "int lines" "int cols"
 .Ft int
-.Fn setterm "char *name"
+.Fn setterm "const char *name"
 .Ft int
 .Fn set_tabsize "int value"
 .Pp
@@ -99,7 +99,9 @@ argument points to a
 .Xr terminfo 5
 entry, or it may be
 .Dv NULL
-in which case the TERM environment variable is used.
+in which case the
+.Ev TERM
+environment variable is used.
 The
 .Fa outfd
 and

Index: src/lib/libcurses/screen.c
diff -u src/lib/libcurses/screen.c:1.37 src/lib/libcurses/screen.c:1.38
--- src/lib/libcurses/screen.c:1.37	Fri Apr  8 10:17:52 2022
+++ src/lib/libcurses/screen.c	Fri May 17 23:32:50 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: screen.c,v 1.37 2022/04/08 10:17:52 andvar Exp $	*/
+/*	$NetBSD: screen.c,v 1.38 2024/05/17 23:32:50 uwe 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.37 2022/04/08 10:17:52 andvar Exp $");
+__RCSID("$NetBSD: screen.c,v 1.38 2024/05/17 23:32:50 uwe Exp $");
 #endif
 #endif	/* not lint */
 
@@ -124,10 +124,10 @@ set_term(SCREEN *new)
  *
  */
 SCREEN *
-newterm(char *type, FILE *outfd, FILE *infd)
+newterm(const char *type, FILE *outfd, FILE *infd)
 {
 	SCREEN *new_screen;
-	char 

CVS commit: src/lib/libcurses

2024-05-14 Thread Valery Ushakov
Module Name:src
Committed By:   uwe
Date:   Tue May 14 10:40:41 UTC 2024

Modified Files:
src/lib/libcurses: curses_input.3

Log Message:
curses_input(3): bump date for define_key() change


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/lib/libcurses/curses_input.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_input.3
diff -u src/lib/libcurses/curses_input.3:1.31 src/lib/libcurses/curses_input.3:1.32
--- src/lib/libcurses/curses_input.3:1.31	Tue May 14 10:22:48 2024
+++ src/lib/libcurses/curses_input.3	Tue May 14 10:40:41 2024
@@ -1,4 +1,4 @@
-.\"	$NetBSD: curses_input.3,v 1.31 2024/05/14 10:22:48 uwe Exp $
+.\"	$NetBSD: curses_input.3,v 1.32 2024/05/14 10:40:41 uwe Exp $
 .\"
 .\" Copyright (c) 2002
 .\"	Brett Lymn (bl...@netbsd.org, brett_l...@yahoo.com.au)
@@ -30,7 +30,7 @@
 .\" SUCH DAMAGE.
 .\"
 .\"
-.Dd May 16, 2022
+.Dd May 14, 2024
 .Dt CURSES_INPUT 3
 .Os
 .Sh NAME



CVS commit: src/lib/libcurses

2024-05-14 Thread Valery Ushakov
Module Name:src
Committed By:   uwe
Date:   Tue May 14 10:40:41 UTC 2024

Modified Files:
src/lib/libcurses: curses_input.3

Log Message:
curses_input(3): bump date for define_key() change


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/lib/libcurses/curses_input.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libcurses

2024-05-14 Thread Valery Ushakov
Module Name:src
Committed By:   uwe
Date:   Tue May 14 10:38:16 UTC 2024

Modified Files:
src/lib/libcurses: curses_termcap.3

Log Message:
curses_termcap(3): fullname() termbuf argument is const


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/lib/libcurses/curses_termcap.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_termcap.3
diff -u src/lib/libcurses/curses_termcap.3:1.6 src/lib/libcurses/curses_termcap.3:1.7
--- src/lib/libcurses/curses_termcap.3:1.6	Sat Apr 21 12:27:28 2012
+++ src/lib/libcurses/curses_termcap.3	Tue May 14 10:38:16 2024
@@ -1,4 +1,4 @@
-.\"	$NetBSD: curses_termcap.3,v 1.6 2012/04/21 12:27:28 roy Exp $
+.\"	$NetBSD: curses_termcap.3,v 1.7 2024/05/14 10:38:16 uwe Exp $
 .\"
 .\" Copyright (c) 2002
 .\"	Brett Lymn (bl...@netbsd.org, brett_l...@yahoo.com.au)
@@ -30,7 +30,7 @@
 .\" SUCH DAMAGE.
 .\"
 .\"
-.Dd October 4, 2011
+.Dd May 14, 2024
 .Dt CURSES_TERMCAP 3
 .Os
 .Sh NAME
@@ -42,7 +42,7 @@
 .Sh SYNOPSIS
 .In curses.h
 .Ft char *
-.Fn fullname "char *termbuf" "char *name"
+.Fn fullname "const char *termbuf" "char *name"
 .Sh DESCRIPTION
 The
 .Fn fullname



CVS commit: src/lib/libcurses

2024-05-14 Thread Valery Ushakov
Module Name:src
Committed By:   uwe
Date:   Tue May 14 10:38:16 UTC 2024

Modified Files:
src/lib/libcurses: curses_termcap.3

Log Message:
curses_termcap(3): fullname() termbuf argument is const


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/lib/libcurses/curses_termcap.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libcurses

2024-05-14 Thread Valery Ushakov
Module Name:src
Committed By:   uwe
Date:   Tue May 14 10:22:48 UTC 2024

Modified Files:
src/lib/libcurses: curses.h curses_input.3 getch.c

Log Message:
curse: constify define_key() argument

define_key() is ncurses extension and ncurses defines its first
argument as "const char *".  Follow suit.

PR lib/58254


To generate a diff of this commit:
cvs rdiff -u -r1.130 -r1.131 src/lib/libcurses/curses.h
cvs rdiff -u -r1.30 -r1.31 src/lib/libcurses/curses_input.3
cvs rdiff -u -r1.78 -r1.79 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/curses.h
diff -u src/lib/libcurses/curses.h:1.130 src/lib/libcurses/curses.h:1.131
--- src/lib/libcurses/curses.h:1.130	Sat Feb 13 10:37:00 2021
+++ src/lib/libcurses/curses.h	Tue May 14 10:22:48 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: curses.h,v 1.130 2021/02/13 10:37:00 rillig Exp $	*/
+/*	$NetBSD: curses.h,v 1.131 2024/05/14 10:22:48 uwe Exp $	*/
 
 /*
  * Copyright (c) 1981, 1993, 1994
@@ -652,7 +652,7 @@ int	 copywin(const WINDOW *, WINDOW *, i
 int	 curs_set(int);
 int	 def_prog_mode(void);
 int	 def_shell_mode(void);
-int  define_key(char *, int);
+int  define_key(const char *, int);
 int	 delay_output(int);
 void delscreen(SCREEN *);
 int	 delwin(WINDOW *);

Index: src/lib/libcurses/curses_input.3
diff -u src/lib/libcurses/curses_input.3:1.30 src/lib/libcurses/curses_input.3:1.31
--- src/lib/libcurses/curses_input.3:1.30	Sat May 21 12:34:44 2022
+++ src/lib/libcurses/curses_input.3	Tue May 14 10:22:48 2024
@@ -1,4 +1,4 @@
-.\"	$NetBSD: curses_input.3,v 1.30 2022/05/21 12:34:44 uwe Exp $
+.\"	$NetBSD: curses_input.3,v 1.31 2024/05/14 10:22:48 uwe Exp $
 .\"
 .\" Copyright (c) 2002
 .\"	Brett Lymn (bl...@netbsd.org, brett_l...@yahoo.com.au)
@@ -76,7 +76,7 @@
 .Ft int
 .Fn has_key "int key_symbol"
 .Ft int
-.Fn define_key "char *sequence" "int key_symbol"
+.Fn define_key "const char *sequence" "int key_symbol"
 .Ft int
 .Fn getnstr "char *str" "int limit"
 .Ft int

Index: src/lib/libcurses/getch.c
diff -u src/lib/libcurses/getch.c:1.78 src/lib/libcurses/getch.c:1.79
--- src/lib/libcurses/getch.c:1.78	Tue Oct 19 06:37:29 2021
+++ src/lib/libcurses/getch.c	Tue May 14 10:22:48 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: getch.c,v 1.78 2021/10/19 06:37:29 blymn Exp $	*/
+/*	$NetBSD: getch.c,v 1.79 2024/05/14 10:22:48 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.78 2021/10/19 06:37:29 blymn Exp $");
+__RCSID("$NetBSD: getch.c,v 1.79 2024/05/14 10:22:48 uwe Exp $");
 #endif
 #endif	/* not lint */
 
@@ -211,7 +211,7 @@ static wchar_t	inbuf[INBUF_SZ];
 static int	start, end, working; /* pointers for manipulating inbuf data */
 
 /* prototypes for private functions */
-static void add_key_sequence(SCREEN *screen, char *sequence, int key_type);
+static void add_key_sequence(SCREEN *screen, const char *sequence, int key_type);
 static key_entry_t *add_new_key(keymap_t *current, char ch, int key_type,
 int symbol);
 static void delete_key_sequence(keymap_t *current, int key_type);
@@ -370,7 +370,7 @@ delete_key_sequence(keymap_t *current, i
  * for the given key symbol.
  */
 static void
-add_key_sequence(SCREEN *screen, char *sequence, int key_type)
+add_key_sequence(SCREEN *screen, const char *sequence, int key_type)
 {
 	key_entry_t *tmp_key;
 	keymap_t *current;
@@ -762,7 +762,7 @@ do_keyok(keymap_t *current, int key_type
  *
  */
 int
-define_key(char *sequence, int symbol)
+define_key(const char *sequence, int symbol)
 {
 
 	if (symbol <= 0 || _cursesi_screen == NULL)



CVS commit: src/lib/libcurses

2024-05-14 Thread Valery Ushakov
Module Name:src
Committed By:   uwe
Date:   Tue May 14 10:22:48 UTC 2024

Modified Files:
src/lib/libcurses: curses.h curses_input.3 getch.c

Log Message:
curse: constify define_key() argument

define_key() is ncurses extension and ncurses defines its first
argument as "const char *".  Follow suit.

PR lib/58254


To generate a diff of this commit:
cvs rdiff -u -r1.130 -r1.131 src/lib/libcurses/curses.h
cvs rdiff -u -r1.30 -r1.31 src/lib/libcurses/curses_input.3
cvs rdiff -u -r1.78 -r1.79 src/lib/libcurses/getch.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libcurses

2023-10-09 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Mon Oct  9 21:14:29 UTC 2023

Modified Files:
src/lib/libcurses: tty.c

Log Message:
Correct the fd closed check so we actually check the outfd as per
the comment.  Thanks for j...@netbsd.org for catching this one.


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 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/tty.c
diff -u src/lib/libcurses/tty.c:1.49 src/lib/libcurses/tty.c:1.50
--- src/lib/libcurses/tty.c:1.49	Mon Sep  6 07:03:50 2021
+++ src/lib/libcurses/tty.c	Mon Oct  9 21:14:29 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: tty.c,v 1.49 2021/09/06 07:03:50 rin Exp $	*/
+/*	$NetBSD: tty.c,v 1.50 2023/10/09 21:14:29 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.49 2021/09/06 07:03:50 rin Exp $");
+__RCSID("$NetBSD: tty.c,v 1.50 2023/10/09 21:14:29 blymn Exp $");
 #endif
 #endif/* not lint */
 
@@ -113,7 +113,7 @@ _cursesi_gettmode(SCREEN *screen)
 
 	if (tcgetattr(fileno(screen->infd), >orig_termios)) {
 		/* if the input fd is not a tty try the output */
-		if (tcgetattr(fileno(screen->infd), >orig_termios)) {
+		if (tcgetattr(fileno(screen->outfd), >orig_termios)) {
 			/* not a tty ... we will disable tty related stuff */
 			screen->notty = TRUE;
 			__GT = 0;



CVS commit: src/lib/libcurses

2023-10-09 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Mon Oct  9 21:14:29 UTC 2023

Modified Files:
src/lib/libcurses: tty.c

Log Message:
Correct the fd closed check so we actually check the outfd as per
the comment.  Thanks for j...@netbsd.org for catching this one.


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/lib/libcurses/tty.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libcurses

2023-10-05 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Thu Oct  5 06:15:04 UTC 2023

Modified Files:
src/lib/libcurses: addbytes.c

Log Message:
Fix for install/56467

Set x to 0 before calling scroll based on a  proposed fix by RVP (thanks!)


To generate a diff of this commit:
cvs rdiff -u -r1.68 -r1.69 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.68 src/lib/libcurses/addbytes.c:1.69
--- src/lib/libcurses/addbytes.c:1.68	Tue Dec 20 04:57:01 2022
+++ src/lib/libcurses/addbytes.c	Thu Oct  5 06:15:03 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: addbytes.c,v 1.68 2022/12/20 04:57:01 blymn Exp $	*/
+/*	$NetBSD: addbytes.c,v 1.69 2023/10/05 06:15:03 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.68 2022/12/20 04:57:01 blymn Exp $");
+__RCSID("$NetBSD: addbytes.c,v 1.69 2023/10/05 06:15:03 blymn Exp $");
 #endif
 #endif/* not lint */
 
@@ -584,6 +584,8 @@ _cursesi_addwchar(WINDOW *win, __LINE **
 return ERR;
 			__CTRACE(__CTRACE_INPUT,
 			"_cursesi_addwchar: do a scroll\n");
+			if (!__NONL)
+*x = 0;
 			scroll(win);
 		}
 		newx = win->maxx - 1 + win->ch_off;



CVS commit: src/lib/libcurses

2023-10-05 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Thu Oct  5 06:15:04 UTC 2023

Modified Files:
src/lib/libcurses: addbytes.c

Log Message:
Fix for install/56467

Set x to 0 before calling scroll based on a  proposed fix by RVP (thanks!)


To generate a diff of this commit:
cvs rdiff -u -r1.68 -r1.69 src/lib/libcurses/addbytes.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libcurses

2023-04-28 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Fri Apr 28 07:12:39 UTC 2023

Modified Files:
src/lib/libcurses: refresh.c

Log Message:
Don't set the clear_to_eol variable in doupdate to NULL, this was a
leftover from previous code that makes no sense and makes worms(6)
crash randomly.  Thanks to kre@ for reporting this.


To generate a diff of this commit:
cvs rdiff -u -r1.126 -r1.127 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.126 src/lib/libcurses/refresh.c:1.127
--- src/lib/libcurses/refresh.c:1.126	Mon Dec  5 21:14:25 2022
+++ src/lib/libcurses/refresh.c	Fri Apr 28 07:12:39 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: refresh.c,v 1.126 2022/12/05 21:14:25 blymn Exp $	*/
+/*	$NetBSD: refresh.c,v 1.127 2023/04/28 07:12:39 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.126 2022/12/05 21:14:25 blymn Exp $");
+__RCSID("$NetBSD: refresh.c,v 1.127 2023/04/28 07:12:39 blymn Exp $");
 #endif
 #endif/* not lint */
 
@@ -1382,7 +1382,6 @@ makech(int wy)
 	}
 	return OK;
 }
-ce = NULL;
 			}
 
 #ifdef HAVE_WCHAR



CVS commit: src/lib/libcurses

2023-04-28 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Fri Apr 28 07:12:39 UTC 2023

Modified Files:
src/lib/libcurses: refresh.c

Log Message:
Don't set the clear_to_eol variable in doupdate to NULL, this was a
leftover from previous code that makes no sense and makes worms(6)
crash randomly.  Thanks to kre@ for reporting this.


To generate a diff of this commit:
cvs rdiff -u -r1.126 -r1.127 src/lib/libcurses/refresh.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libcurses/PSD.doc

2023-02-19 Thread David H. Gutteridge
Module Name:src
Committed By:   gutteridge
Date:   Mon Feb 20 02:05:47 UTC 2023

Modified Files:
src/lib/libcurses/PSD.doc: intro.5

Log Message:
intro.5: fix typo and grammar and simplify a phrase


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/lib/libcurses/PSD.doc/intro.5

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/PSD.doc/intro.5
diff -u src/lib/libcurses/PSD.doc/intro.5:1.9 src/lib/libcurses/PSD.doc/intro.5:1.10
--- src/lib/libcurses/PSD.doc/intro.5:1.9	Mon Feb 13 23:02:27 2023
+++ src/lib/libcurses/PSD.doc/intro.5	Mon Feb 20 02:05:47 2023
@@ -1,4 +1,4 @@
-.\"	$NetBSD: intro.5,v 1.9 2023/02/13 23:02:27 andvar Exp $
+.\"	$NetBSD: intro.5,v 1.10 2023/02/20 02:05:47 gutteridge Exp $
 .\"
 .\" Copyright (c) 1980, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -44,10 +44,10 @@ the position on the next line when the n
 line) is output.
 .pp
 Likewise, if scrolling is enabled, a scroll will be invoked only when the
-first character on he first line past the bottom line of the window is
+first character on the first line past the bottom line of the window is
 output.
-If scrolling is not enabled the characters will to be output to the
-bottom right corner of the window which is the cursor location.
+If scrolling is not enabled the characters will be output to the
+cursor location at the bottom right corner of the window.
 .pp
 This policy allows consistent behavior of the cursor at the boundary
 conditions.



CVS commit: src/lib/libcurses/PSD.doc

2023-02-19 Thread David H. Gutteridge
Module Name:src
Committed By:   gutteridge
Date:   Mon Feb 20 02:05:47 UTC 2023

Modified Files:
src/lib/libcurses/PSD.doc: intro.5

Log Message:
intro.5: fix typo and grammar and simplify a phrase


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/lib/libcurses/PSD.doc/intro.5

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libcurses

2022-12-20 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Wed Dec 21 06:18:01 UTC 2022

Modified Files:
src/lib/libcurses: addnstr.c printw.c

Log Message:
Add more debug so a call to waddbytes can be traced to the caller.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/lib/libcurses/addnstr.c
cvs rdiff -u -r1.29 -r1.30 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/addnstr.c
diff -u src/lib/libcurses/addnstr.c:1.20 src/lib/libcurses/addnstr.c:1.21
--- src/lib/libcurses/addnstr.c:1.20	Tue Oct 19 06:41:03 2021
+++ src/lib/libcurses/addnstr.c	Wed Dec 21 06:18:01 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: addnstr.c,v 1.20 2021/10/19 06:41:03 blymn Exp $	*/
+/*	$NetBSD: addnstr.c,v 1.21 2022/12/21 06:18:01 blymn Exp $	*/
 
 /*
  * Copyright (c) 1993, 1994
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)addnstr.c	8.2 (Berkeley) 5/4/94";
 #else
-__RCSID("$NetBSD: addnstr.c,v 1.20 2021/10/19 06:41:03 blymn Exp $");
+__RCSID("$NetBSD: addnstr.c,v 1.21 2022/12/21 06:18:01 blymn Exp $");
 #endif
 #endif/* not lint */
 
@@ -52,6 +52,8 @@ __RCSID("$NetBSD: addnstr.c,v 1.20 2021/
 int
 addstr(const char *s)
 {
+	__CTRACE(__CTRACE_INPUT, "addstr: %s\n", s);
+
 	return waddnstr(stdscr, s, -1);
 }
 
@@ -62,6 +64,8 @@ addstr(const char *s)
 int
 waddstr(WINDOW *win, const char *s)
 {
+	__CTRACE(__CTRACE_INPUT, "addstr: win %p, sttring: %s\n", win, s);
+
 	return waddnstr(win, s, -1);
 }
 
@@ -73,6 +77,8 @@ waddstr(WINDOW *win, const char *s)
 int
 addnstr(const char *str, int n)
 {
+	__CTRACE(__CTRACE_INPUT, "addnstr: n: %d, string: %s\n", n, str);
+
 	return waddnstr(stdscr, str, n);
 }
 
@@ -83,6 +89,9 @@ addnstr(const char *str, int n)
 int
 mvaddstr(int y, int x, const char *str)
 {
+	__CTRACE(__CTRACE_INPUT, "mvaddnstr: y: %d, x: %d, string: %s\n", y,
+	x, str);
+
 	return mvwaddnstr(stdscr, y, x, str, -1);
 }
 
@@ -93,6 +102,9 @@ mvaddstr(int y, int x, const char *str)
 int
 mvwaddstr(WINDOW *win, int y, int x, const char *str)
 {
+	__CTRACE(__CTRACE_INPUT, "mvwaddnstr: win: %p, y: %d, x: %d, string: %s\n",
+	win, y, x, str);
+
 	return mvwaddnstr(win, y, x, str, -1);
 }
 
@@ -104,6 +116,9 @@ mvwaddstr(WINDOW *win, int y, int x, con
 int
 mvaddnstr(int y, int x, const char *str, int count)
 {
+	__CTRACE(__CTRACE_INPUT, "mvaddnstr: n: %d, y: %d, x: %d, string: %s\n",
+	count, y, x, str);
+
 	return mvwaddnstr(stdscr, y, x, str, count);
 }
 
@@ -115,6 +130,9 @@ mvaddnstr(int y, int x, const char *str,
 int
 mvwaddnstr(WINDOW *win, int y, int x, const char *str, int count)
 {
+	__CTRACE(__CTRACE_INPUT, "mvwaddnstr: win: %p, n: %d, y: %d, x: %d, string: %s\n",
+	win, count, y, x, str);
+
 	if (wmove(win, y, x) == ERR)
 		return ERR;
 

Index: src/lib/libcurses/printw.c
diff -u src/lib/libcurses/printw.c:1.29 src/lib/libcurses/printw.c:1.30
--- src/lib/libcurses/printw.c:1.29	Sun Jun  9 07:40:14 2019
+++ src/lib/libcurses/printw.c	Wed Dec 21 06:18:01 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: printw.c,v 1.29 2019/06/09 07:40:14 blymn Exp $	*/
+/*	$NetBSD: printw.c,v 1.30 2022/12/21 06:18:01 blymn 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.29 2019/06/09 07:40:14 blymn Exp $");
+__RCSID("$NetBSD: printw.c,v 1.30 2022/12/21 06:18:01 blymn Exp $");
 #endif
 #endif/* not lint */
 
@@ -120,6 +120,8 @@ vw_printw(WINDOW *win, const char *fmt, 
 {
 	int n;
 
+	__CTRACE(__CTRACE_INPUT, "vw_printw: win %p\n", win);
+
 	if (win->fp == NULL) {
 		win->fp = open_memstream(>buf, >buflen);
 		if (__predict_false(win->fp == NULL))



CVS commit: src/lib/libcurses

2022-12-20 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Wed Dec 21 06:18:01 UTC 2022

Modified Files:
src/lib/libcurses: addnstr.c printw.c

Log Message:
Add more debug so a call to waddbytes can be traced to the caller.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/lib/libcurses/addnstr.c
cvs rdiff -u -r1.29 -r1.30 src/lib/libcurses/printw.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libcurses

2022-12-19 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Tue Dec 20 04:57:01 UTC 2022

Modified Files:
src/lib/libcurses: addbytes.c slk.c

Log Message:
Backout change to addnstr that broke other applications as n should be
the number of bytes to add - for multibyte characters n will be > 1.

Fix __slk_draw to pass in the actual length of the label instead of
the default label length because wide characters may make the
actual string length longer than the slk display length.


To generate a diff of this commit:
cvs rdiff -u -r1.67 -r1.68 src/lib/libcurses/addbytes.c
cvs rdiff -u -r1.20 -r1.21 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/addbytes.c
diff -u src/lib/libcurses/addbytes.c:1.67 src/lib/libcurses/addbytes.c:1.68
--- src/lib/libcurses/addbytes.c:1.67	Mon Dec 12 21:14:15 2022
+++ src/lib/libcurses/addbytes.c	Tue Dec 20 04:57:01 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: addbytes.c,v 1.67 2022/12/12 21:14:15 blymn Exp $	*/
+/*	$NetBSD: addbytes.c,v 1.68 2022/12/20 04:57:01 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.67 2022/12/12 21:14:15 blymn Exp $");
+__RCSID("$NetBSD: addbytes.c,v 1.68 2022/12/20 04:57:01 blymn Exp $");
 #endif
 #endif/* not lint */
 
@@ -118,7 +118,7 @@ _cursesi_waddbytes(WINDOW *win, const ch
 	int		*py = >cury, *px = >curx, err;
 	__LINE		*lp;
 #ifdef HAVE_WCHAR
-	int		n, width;
+	int		n;
 	cchar_t		cc;
 	wchar_t		wc;
 	mbstate_t	st;
@@ -170,18 +170,14 @@ _cursesi_waddbytes(WINDOW *win, const ch
 		}
 
 		__CTRACE(__CTRACE_INPUT,
-		"ADDBYTES WIDE(0x%x [%s], %x) at (%d, %d), ate %d bytes\n",
+		"ADDBYTES WIDE(0x%04x [%s], %x) at (%d, %d), ate %d bytes\n",
 		(unsigned)wc, unctrl((unsigned)wc), attr, *py, *px, n);
 		cc.vals[0] = wc;
 		cc.elements = 1;
 		cc.attributes = attr;
 		err = _cursesi_addwchar(win, , py, px, , char_interp);
 		bytes += n;
-
-		width = wcwidth(wc);
-		if (width < 0)
-			width = 1;
-		count -= width;
+		count -= n;
 #endif
 	}
 

Index: src/lib/libcurses/slk.c
diff -u src/lib/libcurses/slk.c:1.20 src/lib/libcurses/slk.c:1.21
--- src/lib/libcurses/slk.c:1.20	Tue Apr 12 07:03:04 2022
+++ src/lib/libcurses/slk.c	Tue Dec 20 04:57:01 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: slk.c,v 1.20 2022/04/12 07:03:04 blymn Exp $	*/
+/*	$NetBSD: slk.c,v 1.21 2022/12/20 04:57:01 blymn Exp $	*/
 
 /*-
  * Copyright (c) 2017 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #include 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: slk.c,v 1.20 2022/04/12 07:03:04 blymn Exp $");
+__RCSID("$NetBSD: slk.c,v 1.21 2022/12/20 04:57:01 blymn Exp $");
 #endif/* not lint */
 
 #include 
@@ -819,6 +819,9 @@ __slk_draw(SCREEN *screen, int labnum)
 	wchar_t wc[2];
 #endif
 
+	__CTRACE(__CTRACE_INPUT, "__slk_draw: screen %p, label %d\n", screen,
+	labnum);
+
 	if (screen->slk_hidden)
 		return OK;
 
@@ -834,7 +837,7 @@ __slk_draw(SCREEN *screen, int labnum)
 		(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);
+			l->label, strlen(l->label));
 		} else {
 			lcnt = 0;
 			tx = 0;



CVS commit: src/lib/libcurses

2022-12-19 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Tue Dec 20 04:57:01 UTC 2022

Modified Files:
src/lib/libcurses: addbytes.c slk.c

Log Message:
Backout change to addnstr that broke other applications as n should be
the number of bytes to add - for multibyte characters n will be > 1.

Fix __slk_draw to pass in the actual length of the label instead of
the default label length because wide characters may make the
actual string length longer than the slk display length.


To generate a diff of this commit:
cvs rdiff -u -r1.67 -r1.68 src/lib/libcurses/addbytes.c
cvs rdiff -u -r1.20 -r1.21 src/lib/libcurses/slk.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libcurses

2022-12-12 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Mon Dec 12 21:14:15 UTC 2022

Modified Files:
src/lib/libcurses: addbytes.c

Log Message:
Default the character width to 1 if wcwidth fails.


To generate a diff of this commit:
cvs rdiff -u -r1.66 -r1.67 src/lib/libcurses/addbytes.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libcurses

2022-12-12 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Mon Dec 12 21:14:15 UTC 2022

Modified Files:
src/lib/libcurses: addbytes.c

Log Message:
Default the character width to 1 if wcwidth fails.


To generate a diff of this commit:
cvs rdiff -u -r1.66 -r1.67 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.66 src/lib/libcurses/addbytes.c:1.67
--- src/lib/libcurses/addbytes.c:1.66	Mon Nov  7 21:18:49 2022
+++ src/lib/libcurses/addbytes.c	Mon Dec 12 21:14:15 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: addbytes.c,v 1.66 2022/11/07 21:18:49 blymn Exp $	*/
+/*	$NetBSD: addbytes.c,v 1.67 2022/12/12 21:14:15 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.66 2022/11/07 21:18:49 blymn Exp $");
+__RCSID("$NetBSD: addbytes.c,v 1.67 2022/12/12 21:14:15 blymn Exp $");
 #endif
 #endif/* not lint */
 
@@ -118,7 +118,7 @@ _cursesi_waddbytes(WINDOW *win, const ch
 	int		*py = >cury, *px = >curx, err;
 	__LINE		*lp;
 #ifdef HAVE_WCHAR
-	int		n;
+	int		n, width;
 	cchar_t		cc;
 	wchar_t		wc;
 	mbstate_t	st;
@@ -177,7 +177,11 @@ _cursesi_waddbytes(WINDOW *win, const ch
 		cc.attributes = attr;
 		err = _cursesi_addwchar(win, , py, px, , char_interp);
 		bytes += n;
-		count -= wcwidth(wc);
+
+		width = wcwidth(wc);
+		if (width < 0)
+			width = 1;
+		count -= width;
 #endif
 	}
 



CVS commit: src/lib/libcurses

2022-12-05 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Mon Dec  5 21:14:25 UTC 2022

Modified Files:
src/lib/libcurses: refresh.c

Log Message:
Revert previous change, it is not correct.


To generate a diff of this commit:
cvs rdiff -u -r1.125 -r1.126 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.125 src/lib/libcurses/refresh.c:1.126
--- src/lib/libcurses/refresh.c:1.125	Wed Nov 30 06:19:15 2022
+++ src/lib/libcurses/refresh.c	Mon Dec  5 21:14:25 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: refresh.c,v 1.125 2022/11/30 06:19:15 blymn Exp $	*/
+/*	$NetBSD: refresh.c,v 1.126 2022/12/05 21:14:25 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.125 2022/11/30 06:19:15 blymn Exp $");
+__RCSID("$NetBSD: refresh.c,v 1.126 2022/12/05 21:14:25 blymn Exp $");
 #endif
 #endif/* not lint */
 
@@ -1852,13 +1852,6 @@ scrolln(int starts, int startw, int curs
 	ox = curscr->curx;
 	n = starts - startw;
 
-	if (!lineeq(__virtscr->alines[startw]->line,
-	curscr->alines[starts]->line, (size_t) __virtscr->maxx))
-		n--;
-
-	if (n == 0)
-		return;
-
 	/*
 	 * XXX
 	 * The initial tests that set __noqch don't let us reach here unless



CVS commit: src/lib/libcurses

2022-12-05 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Mon Dec  5 21:14:25 UTC 2022

Modified Files:
src/lib/libcurses: refresh.c

Log Message:
Revert previous change, it is not correct.


To generate a diff of this commit:
cvs rdiff -u -r1.125 -r1.126 src/lib/libcurses/refresh.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



Re: CVS commit: src/lib/libcurses

2022-11-30 Thread Ryo ONODERA
Hi,

r1.125 of refresh.c breaks /usr/bin/vi for me.
When scrolling down long file with 'j' key and reaches the bottom
line, screen is not scrolled up and new lines are displayed
over the previous bottom line.

Could you take a look at my problem?

Thank you very much.

"Brett Lymn"  writes:

> Module Name:  src
> Committed By: blymn
> Date: Wed Nov 30 06:19:16 UTC 2022
>
> Modified Files:
>   src/lib/libcurses: refresh.c
>
> Log Message:
> When performing a scroll, check the last line of the region is the same
> on virtscr and curscr because the indexes past are supposed to be
> one *past* the last matching line (they may actually match if the line is
> at the bottom of the screen).  Iff they don't match reduce the scroll
> region size by one so we don't scroll non-matching lines, also check
> if the region is then 0 after the decrement and just return if it was.
>
>
> To generate a diff of this commit:
> cvs rdiff -u -r1.124 -r1.125 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.124 src/lib/libcurses/refresh.c:1.125
> --- src/lib/libcurses/refresh.c:1.124 Wed Oct 19 06:09:27 2022
> +++ src/lib/libcurses/refresh.c   Wed Nov 30 06:19:15 2022
> @@ -1,4 +1,4 @@
> -/*   $NetBSD: refresh.c,v 1.124 2022/10/19 06:09:27 blymn Exp $  */
> +/*   $NetBSD: refresh.c,v 1.125 2022/11/30 06:19:15 blymn Exp $  */
>  
>  /*
>   * Copyright (c) 1981, 1993, 1994
> @@ -34,7 +34,7 @@
>  #if 0
>  static char sccsid[] = "@(#)refresh.c8.7 (Berkeley) 8/13/94";
>  #else
> -__RCSID("$NetBSD: refresh.c,v 1.124 2022/10/19 06:09:27 blymn Exp $");
> +__RCSID("$NetBSD: refresh.c,v 1.125 2022/11/30 06:19:15 blymn Exp $");
>  #endif
>  #endif   /* not lint */
>  
> @@ -1852,6 +1852,13 @@ scrolln(int starts, int startw, int curs
>   ox = curscr->curx;
>   n = starts - startw;
>  
> + if (!lineeq(__virtscr->alines[startw]->line,
> + curscr->alines[starts]->line, (size_t) __virtscr->maxx))
> + n--;
> +
> + if (n == 0)
> + return;
> +
>   /*
>* XXX
>* The initial tests that set __noqch don't let us reach here unless
>

-- 
Ryo ONODERA // r...@tetera.org
PGP fingerprint = 82A2 DC91 76E0 A10A 8ABB  FD1B F404 27FA C7D1 15F3


CVS commit: src/lib/libcurses

2022-11-29 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Wed Nov 30 06:19:16 UTC 2022

Modified Files:
src/lib/libcurses: refresh.c

Log Message:
When performing a scroll, check the last line of the region is the same
on virtscr and curscr because the indexes past are supposed to be
one *past* the last matching line (they may actually match if the line is
at the bottom of the screen).  Iff they don't match reduce the scroll
region size by one so we don't scroll non-matching lines, also check
if the region is then 0 after the decrement and just return if it was.


To generate a diff of this commit:
cvs rdiff -u -r1.124 -r1.125 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.124 src/lib/libcurses/refresh.c:1.125
--- src/lib/libcurses/refresh.c:1.124	Wed Oct 19 06:09:27 2022
+++ src/lib/libcurses/refresh.c	Wed Nov 30 06:19:15 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: refresh.c,v 1.124 2022/10/19 06:09:27 blymn Exp $	*/
+/*	$NetBSD: refresh.c,v 1.125 2022/11/30 06:19:15 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.124 2022/10/19 06:09:27 blymn Exp $");
+__RCSID("$NetBSD: refresh.c,v 1.125 2022/11/30 06:19:15 blymn Exp $");
 #endif
 #endif/* not lint */
 
@@ -1852,6 +1852,13 @@ scrolln(int starts, int startw, int curs
 	ox = curscr->curx;
 	n = starts - startw;
 
+	if (!lineeq(__virtscr->alines[startw]->line,
+	curscr->alines[starts]->line, (size_t) __virtscr->maxx))
+		n--;
+
+	if (n == 0)
+		return;
+
 	/*
 	 * XXX
 	 * The initial tests that set __noqch don't let us reach here unless



CVS commit: src/lib/libcurses

2022-11-29 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Wed Nov 30 06:19:16 UTC 2022

Modified Files:
src/lib/libcurses: refresh.c

Log Message:
When performing a scroll, check the last line of the region is the same
on virtscr and curscr because the indexes past are supposed to be
one *past* the last matching line (they may actually match if the line is
at the bottom of the screen).  Iff they don't match reduce the scroll
region size by one so we don't scroll non-matching lines, also check
if the region is then 0 after the decrement and just return if it was.


To generate a diff of this commit:
cvs rdiff -u -r1.124 -r1.125 src/lib/libcurses/refresh.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libcurses

2022-11-07 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Mon Nov  7 21:18:49 UTC 2022

Modified Files:
src/lib/libcurses: addbytes.c

Log Message:
Count character widths not number of bytes when calculating number
of characters to add.  Fixes an error detected by slk tests where
a label containing wide characters was not correctly printed.


To generate a diff of this commit:
cvs rdiff -u -r1.65 -r1.66 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.65 src/lib/libcurses/addbytes.c:1.66
--- src/lib/libcurses/addbytes.c:1.65	Wed Oct 19 06:09:27 2022
+++ src/lib/libcurses/addbytes.c	Mon Nov  7 21:18:49 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: addbytes.c,v 1.65 2022/10/19 06:09:27 blymn Exp $	*/
+/*	$NetBSD: addbytes.c,v 1.66 2022/11/07 21:18:49 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.65 2022/10/19 06:09:27 blymn Exp $");
+__RCSID("$NetBSD: addbytes.c,v 1.66 2022/11/07 21:18:49 blymn Exp $");
 #endif
 #endif/* not lint */
 
@@ -177,7 +177,7 @@ _cursesi_waddbytes(WINDOW *win, const ch
 		cc.attributes = attr;
 		err = _cursesi_addwchar(win, , py, px, , char_interp);
 		bytes += n;
-		count -= n;
+		count -= wcwidth(wc);
 #endif
 	}
 



CVS commit: src/lib/libcurses

2022-11-07 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Mon Nov  7 21:18:49 UTC 2022

Modified Files:
src/lib/libcurses: addbytes.c

Log Message:
Count character widths not number of bytes when calculating number
of characters to add.  Fixes an error detected by slk tests where
a label containing wide characters was not correctly printed.


To generate a diff of this commit:
cvs rdiff -u -r1.65 -r1.66 src/lib/libcurses/addbytes.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libcurses

2022-11-04 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Fri Nov  4 06:12:23 UTC 2022

Modified Files:
src/lib/libcurses: move.c

Log Message:
PR bin/57072

This fixes observed behviour in the PR.  Allow the cursor to be
moved one past the EOL, if postitioned here then set ISPASTEOL.
also protect out of range access if win->cury is past maxy.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/lib/libcurses/move.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/move.c
diff -u src/lib/libcurses/move.c:1.24 src/lib/libcurses/move.c:1.25
--- src/lib/libcurses/move.c:1.24	Wed Apr 27 22:04:04 2022
+++ src/lib/libcurses/move.c	Fri Nov  4 06:12:22 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: move.c,v 1.24 2022/04/27 22:04:04 blymn Exp $	*/
+/*	$NetBSD: move.c,v 1.25 2022/11/04 06:12:22 blymn Exp $	*/
 
 /*
  * Copyright (c) 1981, 1993, 1994
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)move.c	8.2 (Berkeley) 5/4/94";
 #else
-__RCSID("$NetBSD: move.c,v 1.24 2022/04/27 22:04:04 blymn Exp $");
+__RCSID("$NetBSD: move.c,v 1.25 2022/11/04 06:12:22 blymn Exp $");
 #endif
 #endif/* not lint */
 
@@ -65,13 +65,17 @@ wmove(WINDOW *win, int y, int x)
 	__CTRACE(__CTRACE_MISC, "wmove: win %p, (%d, %d)\n", win, y, x);
 	if (x < 0 || y < 0)
 		return ERR;
-	if (x >= win->maxx || y >= win->maxy)
+	if (x > win->maxx || y >= win->maxy)
 		return ERR;
 
 	/* clear the EOL flags for both where we were and where we are going */
-	win->alines[win->cury]->flags &= ~ __ISPASTEOL;
+	if (win->cury < win->maxy)
+		win->alines[win->cury]->flags &= ~ __ISPASTEOL;
 	win->alines[y]->flags &= ~ __ISPASTEOL;
 
+	if (x == win->maxx)
+		win->alines[y]->flags |= __ISPASTEOL;
+
 	win->curx = x;
 	win->cury = y;
 



CVS commit: src/lib/libcurses

2022-11-04 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Fri Nov  4 06:12:23 UTC 2022

Modified Files:
src/lib/libcurses: move.c

Log Message:
PR bin/57072

This fixes observed behviour in the PR.  Allow the cursor to be
moved one past the EOL, if postitioned here then set ISPASTEOL.
also protect out of range access if win->cury is past maxy.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/lib/libcurses/move.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libcurses

2022-10-25 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Tue Oct 25 06:20:01 UTC 2022

Modified Files:
src/lib/libcurses: attributes.c

Log Message:
Fix for lib/57050
Perform a sanity check on the window parameter being passed and return
ERR if it is null.  This prevents buggy code crashing.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 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.34 src/lib/libcurses/attributes.c:1.35
--- src/lib/libcurses/attributes.c:1.34	Tue Apr 12 07:03:04 2022
+++ src/lib/libcurses/attributes.c	Tue Oct 25 06:20:01 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: attributes.c,v 1.34 2022/04/12 07:03:04 blymn Exp $	*/
+/*	$NetBSD: attributes.c,v 1.35 2022/10/25 06:20:01 blymn Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: attributes.c,v 1.34 2022/04/12 07:03:04 blymn Exp $");
+__RCSID("$NetBSD: attributes.c,v 1.35 2022/10/25 06:20:01 blymn Exp $");
 #endif/* not lint */
 
 #include "curses.h"
@@ -143,6 +143,9 @@ attrset(int attr)
 int
 wattr_get(WINDOW *win, attr_t *attr, short *pair, void *opts)
 {
+	if (__predict_false(win == NULL))
+		return ERR;
+
 	__CTRACE(__CTRACE_ATTR, "wattr_get: win %p\n", win);
 	if (attr != NULL) {
 		*attr = win->wattr;
@@ -231,6 +234,9 @@ wcolor_set(WINDOW *win, short pair, void
 chtype
 getattrs(WINDOW *win)
 {
+	if (__predict_false(win == NULL))
+		return ERR;
+
 	__CTRACE(__CTRACE_ATTR, "getattrs: win %p\n", win);
 	return((chtype) win->wattr);
 }
@@ -361,7 +367,12 @@ term_attrs(void)
 static int
 __wattr_on(WINDOW *win, attr_t attr)
 {
-	const TERMINAL *t = win->screen->term;
+	const TERMINAL *t;
+
+	if (__predict_false(win == NULL))
+		return ERR;
+
+	t = win->screen->term;
 
 	__CTRACE(__CTRACE_ATTR, "wattr_on: win %p, attr %08x\n", win, attr);
 	/* If can enter modes, set the relevant attribute bits. */
@@ -408,7 +419,12 @@ __wattr_on(WINDOW *win, attr_t attr)
 static int
 __wattr_off(WINDOW *win, attr_t attr)
 {
-	const TERMINAL *t = win->screen->term;
+	const TERMINAL *t;
+
+	if (__predict_false(win == NULL))
+		return ERR;
+
+	t = win->screen->term;
 
 	__CTRACE(__CTRACE_ATTR, "wattr_off: win %p, attr %08x\n", win, attr);
 	/* If can do exit modes, unset the relevant attribute bits. */
@@ -455,7 +471,12 @@ __wattr_off(WINDOW *win, attr_t attr)
 static void
 __wcolor_set(WINDOW *win, attr_t attr)
 {
-	const TERMINAL *t = win->screen->term;
+	const TERMINAL *t;
+
+	if (__predict_false(win == NULL))
+		return;
+
+	t = win->screen->term;
 
 	/* If another color pair is set, turn that off first. */
 	win->wattr &= ~__COLOR;



CVS commit: src/lib/libcurses

2022-10-25 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Tue Oct 25 06:20:01 UTC 2022

Modified Files:
src/lib/libcurses: attributes.c

Log Message:
Fix for lib/57050
Perform a sanity check on the window parameter being passed and return
ERR if it is null.  This prevents buggy code crashing.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/lib/libcurses/attributes.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libcurses

2022-10-19 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Wed Oct 19 06:09:27 UTC 2022

Modified Files:
src/lib/libcurses: add_wchstr.c addbytes.c background.c chgat.c
clrtobot.c color.c cr_put.c curses.c delch.c erase.c ins_wch.c
ins_wstr.c insch.c insdelln.c insstr.c refresh.c resize.c

Log Message:
Fixes for lib/56926 amongst other things:
 - plod now correctly accounts for wide characters when plodding
 - use erase line when in color mode if the terminal has the capability
 - ensure that the CA_CONTINUATION flag is applied consistently to the
   subsequent characters in a wide character.
 - fix a bunch of refresh bugs that caused inconsistent placement of
   wide characters.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/lib/libcurses/add_wchstr.c
cvs rdiff -u -r1.64 -r1.65 src/lib/libcurses/addbytes.c
cvs rdiff -u -r1.32 -r1.33 src/lib/libcurses/background.c
cvs rdiff -u -r1.8 -r1.9 src/lib/libcurses/chgat.c
cvs rdiff -u -r1.30 -r1.31 src/lib/libcurses/clrtobot.c \
src/lib/libcurses/curses.c
cvs rdiff -u -r1.46 -r1.47 src/lib/libcurses/color.c
cvs rdiff -u -r1.39 -r1.40 src/lib/libcurses/cr_put.c
cvs rdiff -u -r1.29 -r1.30 src/lib/libcurses/delch.c
cvs rdiff -u -r1.36 -r1.37 src/lib/libcurses/erase.c
cvs rdiff -u -r1.19 -r1.20 src/lib/libcurses/ins_wch.c
cvs rdiff -u -r1.23 -r1.24 src/lib/libcurses/ins_wstr.c
cvs rdiff -u -r1.27 -r1.28 src/lib/libcurses/insch.c
cvs rdiff -u -r1.22 -r1.23 src/lib/libcurses/insdelln.c
cvs rdiff -u -r1.10 -r1.11 src/lib/libcurses/insstr.c
cvs rdiff -u -r1.123 -r1.124 src/lib/libcurses/refresh.c
cvs rdiff -u -r1.35 -r1.36 src/lib/libcurses/resize.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libcurses

2022-10-19 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Wed Oct 19 06:09:27 UTC 2022

Modified Files:
src/lib/libcurses: add_wchstr.c addbytes.c background.c chgat.c
clrtobot.c color.c cr_put.c curses.c delch.c erase.c ins_wch.c
ins_wstr.c insch.c insdelln.c insstr.c refresh.c resize.c

Log Message:
Fixes for lib/56926 amongst other things:
 - plod now correctly accounts for wide characters when plodding
 - use erase line when in color mode if the terminal has the capability
 - ensure that the CA_CONTINUATION flag is applied consistently to the
   subsequent characters in a wide character.
 - fix a bunch of refresh bugs that caused inconsistent placement of
   wide characters.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/lib/libcurses/add_wchstr.c
cvs rdiff -u -r1.64 -r1.65 src/lib/libcurses/addbytes.c
cvs rdiff -u -r1.32 -r1.33 src/lib/libcurses/background.c
cvs rdiff -u -r1.8 -r1.9 src/lib/libcurses/chgat.c
cvs rdiff -u -r1.30 -r1.31 src/lib/libcurses/clrtobot.c \
src/lib/libcurses/curses.c
cvs rdiff -u -r1.46 -r1.47 src/lib/libcurses/color.c
cvs rdiff -u -r1.39 -r1.40 src/lib/libcurses/cr_put.c
cvs rdiff -u -r1.29 -r1.30 src/lib/libcurses/delch.c
cvs rdiff -u -r1.36 -r1.37 src/lib/libcurses/erase.c
cvs rdiff -u -r1.19 -r1.20 src/lib/libcurses/ins_wch.c
cvs rdiff -u -r1.23 -r1.24 src/lib/libcurses/ins_wstr.c
cvs rdiff -u -r1.27 -r1.28 src/lib/libcurses/insch.c
cvs rdiff -u -r1.22 -r1.23 src/lib/libcurses/insdelln.c
cvs rdiff -u -r1.10 -r1.11 src/lib/libcurses/insstr.c
cvs rdiff -u -r1.123 -r1.124 src/lib/libcurses/refresh.c
cvs rdiff -u -r1.35 -r1.36 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/add_wchstr.c
diff -u src/lib/libcurses/add_wchstr.c:1.13 src/lib/libcurses/add_wchstr.c:1.14
--- src/lib/libcurses/add_wchstr.c:1.13	Tue May  3 07:25:34 2022
+++ src/lib/libcurses/add_wchstr.c	Wed Oct 19 06:09:27 2022
@@ -1,4 +1,4 @@
-/*   $NetBSD: add_wchstr.c,v 1.13 2022/05/03 07:25:34 blymn Exp $ */
+/*   $NetBSD: add_wchstr.c,v 1.14 2022/10/19 06:09:27 blymn Exp $ */
 
 /*
  * Copyright (c) 2005 The NetBSD Foundation Inc.
@@ -36,7 +36,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: add_wchstr.c,v 1.13 2022/05/03 07:25:34 blymn Exp $");
+__RCSID("$NetBSD: add_wchstr.c,v 1.14 2022/10/19 06:09:27 blymn Exp $");
 #endif/* not lint */
 
 #include 
@@ -174,7 +174,8 @@ wadd_wchnstr(WINDOW *win, const cchar_t 
 if (_cursesi_copy_nsp(win->bnsp, tp) == ERR)
 	return ERR;
 tp->attr = win->battr;
-(*tp).wcols = 1;
+tp->wcols = 1;
+tp->cflags = CA_BACKGROUND;
 np = tp->nsp;
 			}
 		} else {
@@ -186,7 +187,7 @@ wadd_wchnstr(WINDOW *win, const cchar_t 
 	}
 	lnp->flags |= __ISDIRTY;
 	newx = sx + win->ch_off;
-	if (newx < *lnp->firstchp)
+	if (newx < *lnp->firstchp) 
 		*lnp->firstchp = newx;
 
 	/* add characters in the string */
@@ -210,7 +211,7 @@ wadd_wchnstr(WINDOW *win, const cchar_t 
 	== ERR)
 		return ERR;
 	lp->attr = win->battr;
-	lp->cflags |= CA_BACKGROUND;
+	lp->cflags = CA_BACKGROUND;
 	(*lp).wcols = 1;
 	lp++, ex++;
 }
@@ -259,6 +260,8 @@ wadd_wchnstr(WINDOW *win, const cchar_t 
 }
 lp->ch = chp->vals[0];
 lp->attr = chp->attributes & WA_ATTRIBUTES;
+lp->cflags &= ~CA_BACKGROUND;
+lp->cflags |= CA_CONTINUATION;
 (*lp).wcols = x - ex;
 lp++, ex++;
 			}

Index: src/lib/libcurses/addbytes.c
diff -u src/lib/libcurses/addbytes.c:1.64 src/lib/libcurses/addbytes.c:1.65
--- src/lib/libcurses/addbytes.c:1.64	Thu May 19 07:41:26 2022
+++ src/lib/libcurses/addbytes.c	Wed Oct 19 06:09:27 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: addbytes.c,v 1.64 2022/05/19 07:41:26 blymn Exp $	*/
+/*	$NetBSD: addbytes.c,v 1.65 2022/10/19 06:09:27 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.64 2022/05/19 07:41:26 blymn Exp $");
+__RCSID("$NetBSD: addbytes.c,v 1.65 2022/10/19 06:09:27 blymn Exp $");
 #endif
 #endif/* not lint */
 
@@ -293,6 +293,7 @@ _cursesi_addbyte(WINDOW *win, __LINE **l
 	 */
 	if (newx < *(*lp)->firstchp)
 		*(*lp)->firstchp = newx;
+
 	if (newx > *(*lp)->lastchp)
 		*(*lp)->lastchp = newx;
 	__CTRACE(__CTRACE_INPUT, "ADDBYTES: change gives f/l: %d/%d [%d/%d]\n",
@@ -311,7 +312,7 @@ _cursesi_addbyte(WINDOW *win, __LINE **l
 #endif
 	}
 
-	(*lp)->line[*x].cflags &= ~ CA_BACKGROUND;
+	(*lp)->line[*x].cflags &= ~ (CA_BACKGROUND | CA_CONTINUATION);
 
 	if (attributes & __COLOR)
 		(*lp)->line[*x].attr =
@@ -421,6 +422,7 @@ _cursesi_addwchar(WINDOW *win, __LINE **
 		newx = *x + win->ch_off;
 		if (newx < *(*lnp)->firstchp)
 			*(*lnp)->firstchp = newx;
+
 		if (newx > *(*lnp)->lastchp)
 			*(*lnp)->lastchp = newx;
 		__touchline(win, *y, *x, *x);
@@ -451,7 +453,7 @@ _cursesi_addwchar(WINDOW 

CVS commit: src/lib/libcurses

2022-05-21 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Sat May 21 12:34:45 UTC 2022

Modified Files:
src/lib/libcurses: curses_input.3

Log Message:
curses_input.3: wtimeout() returns void too


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/lib/libcurses/curses_input.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_input.3
diff -u src/lib/libcurses/curses_input.3:1.29 src/lib/libcurses/curses_input.3:1.30
--- src/lib/libcurses/curses_input.3:1.29	Sat May 21 06:22:49 2022
+++ src/lib/libcurses/curses_input.3	Sat May 21 12:34:44 2022
@@ -1,4 +1,4 @@
-.\"	$NetBSD: curses_input.3,v 1.29 2022/05/21 06:22:49 charlotte Exp $
+.\"	$NetBSD: curses_input.3,v 1.30 2022/05/21 12:34:44 uwe Exp $
 .\"
 .\" Copyright (c) 2002
 .\"	Brett Lymn (bl...@netbsd.org, brett_l...@yahoo.com.au)
@@ -101,7 +101,7 @@
 .Fn notimeout "WINDOW *win" "bool flag"
 .Ft void
 .Fn timeout "int delay"
-.Ft int
+.Ft void
 .Fn wtimeout "WINDOW *win" "int delay"
 .Ft int
 .Fn nodelay "WINDOW *win" "bool flag"



CVS commit: src/lib/libcurses

2022-05-21 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Sat May 21 12:34:45 UTC 2022

Modified Files:
src/lib/libcurses: curses_input.3

Log Message:
curses_input.3: wtimeout() returns void too


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/lib/libcurses/curses_input.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libcurses

2022-05-21 Thread Charlotte Koch
Module Name:src
Committed By:   charlotte
Date:   Sat May 21 06:22:49 UTC 2022

Modified Files:
src/lib/libcurses: curses_input.3

Log Message:
curses_input.3: timeout() actually returns void


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/lib/libcurses/curses_input.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libcurses

2022-05-21 Thread Charlotte Koch
Module Name:src
Committed By:   charlotte
Date:   Sat May 21 06:22:49 UTC 2022

Modified Files:
src/lib/libcurses: curses_input.3

Log Message:
curses_input.3: timeout() actually returns void


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/lib/libcurses/curses_input.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_input.3
diff -u src/lib/libcurses/curses_input.3:1.28 src/lib/libcurses/curses_input.3:1.29
--- src/lib/libcurses/curses_input.3:1.28	Mon May 16 20:09:13 2022
+++ src/lib/libcurses/curses_input.3	Sat May 21 06:22:49 2022
@@ -1,4 +1,4 @@
-.\"	$NetBSD: curses_input.3,v 1.28 2022/05/16 20:09:13 rillig Exp $
+.\"	$NetBSD: curses_input.3,v 1.29 2022/05/21 06:22:49 charlotte Exp $
 .\"
 .\" Copyright (c) 2002
 .\"	Brett Lymn (bl...@netbsd.org, brett_l...@yahoo.com.au)
@@ -99,7 +99,7 @@
 .Fn is_keypad "const WINDOW *win"
 .Ft int
 .Fn notimeout "WINDOW *win" "bool flag"
-.Ft int
+.Ft void
 .Fn timeout "int delay"
 .Ft int
 .Fn wtimeout "WINDOW *win" "int delay"



CVS commit: src/lib/libcurses

2022-05-19 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Thu May 19 07:41:26 UTC 2022

Modified Files:
src/lib/libcurses: addbytes.c

Log Message:
Set the last change pointer after adding a character at the bottom right
of a window.  This fixes the character missing in the LR of a window.
Thanks to uwe@ for pointing this out.


To generate a diff of this commit:
cvs rdiff -u -r1.63 -r1.64 src/lib/libcurses/addbytes.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libcurses

2022-05-19 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Thu May 19 07:41:26 UTC 2022

Modified Files:
src/lib/libcurses: addbytes.c

Log Message:
Set the last change pointer after adding a character at the bottom right
of a window.  This fixes the character missing in the LR of a window.
Thanks to uwe@ for pointing this out.


To generate a diff of this commit:
cvs rdiff -u -r1.63 -r1.64 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.63 src/lib/libcurses/addbytes.c:1.64
--- src/lib/libcurses/addbytes.c:1.63	Tue May  3 07:25:34 2022
+++ src/lib/libcurses/addbytes.c	Thu May 19 07:41:26 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: addbytes.c,v 1.63 2022/05/03 07:25:34 blymn Exp $	*/
+/*	$NetBSD: addbytes.c,v 1.64 2022/05/19 07:41:26 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.63 2022/05/03 07:25:34 blymn Exp $");
+__RCSID("$NetBSD: addbytes.c,v 1.64 2022/05/19 07:41:26 blymn Exp $");
 #endif
 #endif/* not lint */
 
@@ -588,6 +588,7 @@ _cursesi_addwchar(WINDOW *win, __LINE **
 		}
 		lp = >alines[*y]->line[0];
 		(*lnp) = win->alines[*y];
+		*(*lnp)->lastchp = win->ch_off + win->maxx - 1;
 	} else {
 
 		/* clear the remaining of the current character */



CVS commit: src/lib/libcurses

2022-05-16 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon May 16 20:09:13 UTC 2022

Modified Files:
src/lib/libcurses: curses_input.3

Log Message:
curses_input.3: fix argument type for keypad, notimeout, nodelay

There is no type named 'boolf', there's only 'bool'.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/lib/libcurses/curses_input.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libcurses

2022-05-16 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon May 16 20:09:13 UTC 2022

Modified Files:
src/lib/libcurses: curses_input.3

Log Message:
curses_input.3: fix argument type for keypad, notimeout, nodelay

There is no type named 'boolf', there's only 'bool'.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/lib/libcurses/curses_input.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_input.3
diff -u src/lib/libcurses/curses_input.3:1.27 src/lib/libcurses/curses_input.3:1.28
--- src/lib/libcurses/curses_input.3:1.27	Mon Jul  3 21:32:50 2017
+++ src/lib/libcurses/curses_input.3	Mon May 16 20:09:13 2022
@@ -1,4 +1,4 @@
-.\"	$NetBSD: curses_input.3,v 1.27 2017/07/03 21:32:50 wiz Exp $
+.\"	$NetBSD: curses_input.3,v 1.28 2022/05/16 20:09:13 rillig Exp $
 .\"
 .\" Copyright (c) 2002
 .\"	Brett Lymn (bl...@netbsd.org, brett_l...@yahoo.com.au)
@@ -30,7 +30,7 @@
 .\" SUCH DAMAGE.
 .\"
 .\"
-.Dd January 5, 2017
+.Dd May 16, 2022
 .Dt CURSES_INPUT 3
 .Os
 .Sh NAME
@@ -94,17 +94,17 @@
 .Ft int
 .Fn mvwgetstr "WINDOW *win" "int y" "int x" "char *str"
 .Ft int
-.Fn keypad "WINDOW *win" "boolf flag"
+.Fn keypad "WINDOW *win" "bool flag"
 .Ft bool
 .Fn is_keypad "const WINDOW *win"
 .Ft int
-.Fn notimeout "WINDOW *win" "boolf flag"
+.Fn notimeout "WINDOW *win" "bool flag"
 .Ft int
 .Fn timeout "int delay"
 .Ft int
 .Fn wtimeout "WINDOW *win" "int delay"
 .Ft int
-.Fn nodelay "WINDOW *win" "boolf flag"
+.Fn nodelay "WINDOW *win" "bool flag"
 .Ft int
 .Fn ungetch "int c"
 .Ft int



CVS commit: src/lib/libcurses

2022-05-12 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Thu May 12 22:25:38 UTC 2022

Modified Files:
src/lib/libcurses: clrtoeol.c

Log Message:
Make clrtoeol match the ncurses behaviour where it seems to make the
rest of line foreground.  This fixes a display oddity in mutt.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/lib/libcurses/clrtoeol.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/clrtoeol.c
diff -u src/lib/libcurses/clrtoeol.c:1.34 src/lib/libcurses/clrtoeol.c:1.35
--- src/lib/libcurses/clrtoeol.c:1.34	Tue Apr 12 07:03:04 2022
+++ src/lib/libcurses/clrtoeol.c	Thu May 12 22:25:38 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: clrtoeol.c,v 1.34 2022/04/12 07:03:04 blymn Exp $	*/
+/*	$NetBSD: clrtoeol.c,v 1.35 2022/05/12 22:25:38 blymn 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.34 2022/04/12 07:03:04 blymn Exp $");
+__RCSID("$NetBSD: clrtoeol.c,v 1.35 2022/05/12 22:25:38 blymn Exp $");
 #endif
 #endif/* not lint */
 
@@ -91,6 +91,12 @@ wclrtoeol(WINDOW *win)
 	maxx = >alines[y]->line[x];
 
 	for (sp = maxx; sp < end; sp++) {
+		/*
+		 * It looks like ncurses makes the rest of line foreground
+		 * when it is cleared - this doesn't seem right but it
+		 * makes applicatins look right.
+		 */
+		sp->cflags &= ~CA_BACKGROUND;
 		if (!(__NEED_ERASE(sp, bch, battr)))
 			continue;
 



CVS commit: src/lib/libcurses

2022-05-12 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Thu May 12 22:25:38 UTC 2022

Modified Files:
src/lib/libcurses: clrtoeol.c

Log Message:
Make clrtoeol match the ncurses behaviour where it seems to make the
rest of line foreground.  This fixes a display oddity in mutt.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/lib/libcurses/clrtoeol.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libcurses

2022-05-05 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Thu May  5 22:02:17 UTC 2022

Modified Files:
src/lib/libcurses: background.c

Log Message:
Don't force the refresh, it doesn't really need it.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/lib/libcurses/background.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libcurses

2022-05-05 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Thu May  5 22:02:17 UTC 2022

Modified Files:
src/lib/libcurses: background.c

Log Message:
Don't force the refresh, it doesn't really need it.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 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.31 src/lib/libcurses/background.c:1.32
--- src/lib/libcurses/background.c:1.31	Tue May  3 07:25:34 2022
+++ src/lib/libcurses/background.c	Thu May  5 22:02:17 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: background.c,v 1.31 2022/05/03 07:25:34 blymn Exp $	*/
+/*	$NetBSD: background.c,v 1.32 2022/05/05 22:02:17 blymn Exp $	*/
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: background.c,v 1.31 2022/05/03 07:25:34 blymn Exp $");
+__RCSID("$NetBSD: background.c,v 1.32 2022/05/05 22:02:17 blymn Exp $");
 #endif/* not lint */
 
 #include 
@@ -245,7 +245,7 @@ wbkgrndset(WINDOW *win, const cchar_t *w
 			}
 		}
 	}
-	__touchwin(win, 1);
+	__touchwin(win, 0);
 
 }
 



CVS commit: src/lib/libcurses

2022-05-03 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Tue May  3 07:25:34 UTC 2022

Modified Files:
src/lib/libcurses: add_wchstr.c addbytes.c background.c border.c
clrtobot.c curses.c curses_private.h delch.c erase.c newwin.c
refresh.c

Log Message:
 * Don't redraw the background if the new background character is the
   same as the old one.  This prevents excessive redraws in some
   applications.

 * Fix bug introduced when wbkgrndset was fixed, we cannot blindly
   replace any instance of the old background character with the new one
   because some of those characters were put there by the application
   leading to display corruption.  So flag characters as background when
   they are erased and only update the flagged characters when setting
   the background.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/lib/libcurses/add_wchstr.c
cvs rdiff -u -r1.62 -r1.63 src/lib/libcurses/addbytes.c
cvs rdiff -u -r1.30 -r1.31 src/lib/libcurses/background.c
cvs rdiff -u -r1.23 -r1.24 src/lib/libcurses/border.c
cvs rdiff -u -r1.29 -r1.30 src/lib/libcurses/clrtobot.c \
src/lib/libcurses/curses.c
cvs rdiff -u -r1.79 -r1.80 src/lib/libcurses/curses_private.h
cvs rdiff -u -r1.28 -r1.29 src/lib/libcurses/delch.c
cvs rdiff -u -r1.35 -r1.36 src/lib/libcurses/erase.c
cvs rdiff -u -r1.66 -r1.67 src/lib/libcurses/newwin.c
cvs rdiff -u -r1.122 -r1.123 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/add_wchstr.c
diff -u src/lib/libcurses/add_wchstr.c:1.12 src/lib/libcurses/add_wchstr.c:1.13
--- src/lib/libcurses/add_wchstr.c:1.12	Tue Apr 12 07:03:04 2022
+++ src/lib/libcurses/add_wchstr.c	Tue May  3 07:25:34 2022
@@ -1,4 +1,4 @@
-/*   $NetBSD: add_wchstr.c,v 1.12 2022/04/12 07:03:04 blymn Exp $ */
+/*   $NetBSD: add_wchstr.c,v 1.13 2022/05/03 07:25:34 blymn Exp $ */
 
 /*
  * Copyright (c) 2005 The NetBSD Foundation Inc.
@@ -36,7 +36,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: add_wchstr.c,v 1.12 2022/04/12 07:03:04 blymn Exp $");
+__RCSID("$NetBSD: add_wchstr.c,v 1.13 2022/05/03 07:25:34 blymn Exp $");
 #endif/* not lint */
 
 #include 
@@ -210,6 +210,7 @@ wadd_wchnstr(WINDOW *win, const cchar_t 
 	== ERR)
 		return ERR;
 	lp->attr = win->battr;
+	lp->cflags |= CA_BACKGROUND;
 	(*lp).wcols = 1;
 	lp++, ex++;
 }
@@ -229,6 +230,7 @@ wadd_wchnstr(WINDOW *win, const cchar_t 
 			}
 			lp->ch = chp->vals[0];
 			lp->attr = chp->attributes & WA_ATTRIBUTES;
+			lp->cflags &= ~CA_BACKGROUND;
 			(*lp).wcols = cw;
 			if (chp->elements > 1) {
 for (i = 1; i < chp->elements; i++) {

Index: src/lib/libcurses/addbytes.c
diff -u src/lib/libcurses/addbytes.c:1.62 src/lib/libcurses/addbytes.c:1.63
--- src/lib/libcurses/addbytes.c:1.62	Tue Apr 12 07:03:04 2022
+++ src/lib/libcurses/addbytes.c	Tue May  3 07:25:34 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: addbytes.c,v 1.62 2022/04/12 07:03:04 blymn Exp $	*/
+/*	$NetBSD: addbytes.c,v 1.63 2022/05/03 07:25:34 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.62 2022/04/12 07:03:04 blymn Exp $");
+__RCSID("$NetBSD: addbytes.c,v 1.63 2022/05/03 07:25:34 blymn Exp $");
 #endif
 #endif/* not lint */
 
@@ -311,6 +311,8 @@ _cursesi_addbyte(WINDOW *win, __LINE **l
 #endif
 	}
 
+	(*lp)->line[*x].cflags &= ~ CA_BACKGROUND;
+
 	if (attributes & __COLOR)
 		(*lp)->line[*x].attr =
 			attributes | (win->battr & ~__COLOR);
@@ -449,6 +451,7 @@ _cursesi_addwchar(WINDOW *win, __LINE **
 			*y, sx);
 			tp = >alines[*y]->line[sx];
 			tp->ch = win->bch;
+			tp->cflags |= CA_BACKGROUND;
 			if (_cursesi_copy_nsp(win->bnsp, tp) == ERR)
 return ERR;
 
@@ -513,6 +516,7 @@ _cursesi_addwchar(WINDOW *win, __LINE **
 	}
 
 	lp->ch = wch->vals[0];
+	lp->cflags &= ~CA_BACKGROUND;
 
 	attributes = (win->wattr | wch->attributes)
 		& (WA_ATTRIBUTES & ~__COLOR);
@@ -559,7 +563,7 @@ _cursesi_addwchar(WINDOW *win, __LINE **
 		tp->ch = wch->vals[0];
 		tp->attr = lp->attr & WA_ATTRIBUTES;
 		/* Mark as "continuation" cell */
-		tp->wflags |= WCA_CONTINUATION;
+		tp->cflags |= CA_CONTINUATION;
 	}
 
 
@@ -596,6 +600,7 @@ _cursesi_addwchar(WINDOW *win, __LINE **
 "remaining of current char (%d,%d)nn",
 *y, ex);
 tp->ch = win->bch;
+tp->cflags |= CA_BACKGROUND;
 if (_cursesi_copy_nsp(win->bnsp, tp) == ERR)
 	return ERR;
 tp->attr = win->battr;

Index: src/lib/libcurses/background.c
diff -u src/lib/libcurses/background.c:1.30 src/lib/libcurses/background.c:1.31
--- src/lib/libcurses/background.c:1.30	Tue Apr 19 22:26:57 2022
+++ src/lib/libcurses/background.c	Tue May  3 07:25:34 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: background.c,v 1.30 2022/04/19 22:26:57 blymn Exp $	*/
+/*	$NetBSD: background.c,v 1.31 2022/05/03 

CVS commit: src/lib/libcurses

2022-05-03 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Tue May  3 07:25:34 UTC 2022

Modified Files:
src/lib/libcurses: add_wchstr.c addbytes.c background.c border.c
clrtobot.c curses.c curses_private.h delch.c erase.c newwin.c
refresh.c

Log Message:
 * Don't redraw the background if the new background character is the
   same as the old one.  This prevents excessive redraws in some
   applications.

 * Fix bug introduced when wbkgrndset was fixed, we cannot blindly
   replace any instance of the old background character with the new one
   because some of those characters were put there by the application
   leading to display corruption.  So flag characters as background when
   they are erased and only update the flagged characters when setting
   the background.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/lib/libcurses/add_wchstr.c
cvs rdiff -u -r1.62 -r1.63 src/lib/libcurses/addbytes.c
cvs rdiff -u -r1.30 -r1.31 src/lib/libcurses/background.c
cvs rdiff -u -r1.23 -r1.24 src/lib/libcurses/border.c
cvs rdiff -u -r1.29 -r1.30 src/lib/libcurses/clrtobot.c \
src/lib/libcurses/curses.c
cvs rdiff -u -r1.79 -r1.80 src/lib/libcurses/curses_private.h
cvs rdiff -u -r1.28 -r1.29 src/lib/libcurses/delch.c
cvs rdiff -u -r1.35 -r1.36 src/lib/libcurses/erase.c
cvs rdiff -u -r1.66 -r1.67 src/lib/libcurses/newwin.c
cvs rdiff -u -r1.122 -r1.123 src/lib/libcurses/refresh.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libcurses

2022-04-27 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Wed Apr 27 22:04:04 UTC 2022

Modified Files:
src/lib/libcurses: move.c

Log Message:
Fix for PR 56243
clear the past EOL flags when moving the cursor - they are no longer
valid as move cannot put the cursor past the EOL.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/lib/libcurses/move.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/move.c
diff -u src/lib/libcurses/move.c:1.23 src/lib/libcurses/move.c:1.24
--- src/lib/libcurses/move.c:1.23	Tue Oct 19 06:41:03 2021
+++ src/lib/libcurses/move.c	Wed Apr 27 22:04:04 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: move.c,v 1.23 2021/10/19 06:41:03 blymn Exp $	*/
+/*	$NetBSD: move.c,v 1.24 2022/04/27 22:04:04 blymn Exp $	*/
 
 /*
  * Copyright (c) 1981, 1993, 1994
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)move.c	8.2 (Berkeley) 5/4/94";
 #else
-__RCSID("$NetBSD: move.c,v 1.23 2021/10/19 06:41:03 blymn Exp $");
+__RCSID("$NetBSD: move.c,v 1.24 2022/04/27 22:04:04 blymn Exp $");
 #endif
 #endif/* not lint */
 
@@ -68,6 +68,10 @@ wmove(WINDOW *win, int y, int x)
 	if (x >= win->maxx || y >= win->maxy)
 		return ERR;
 
+	/* clear the EOL flags for both where we were and where we are going */
+	win->alines[win->cury]->flags &= ~ __ISPASTEOL;
+	win->alines[y]->flags &= ~ __ISPASTEOL;
+
 	win->curx = x;
 	win->cury = y;
 



CVS commit: src/lib/libcurses

2022-04-27 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Wed Apr 27 22:04:04 UTC 2022

Modified Files:
src/lib/libcurses: move.c

Log Message:
Fix for PR 56243
clear the past EOL flags when moving the cursor - they are no longer
valid as move cannot put the cursor past the EOL.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/lib/libcurses/move.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libcurses

2022-04-26 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Tue Apr 26 22:40:32 UTC 2022

Modified Files:
src/lib/libcurses: resize.c

Log Message:
Fix for PR 55517.
Actually us x values to recalculate subwin columns.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 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.34 src/lib/libcurses/resize.c:1.35
--- src/lib/libcurses/resize.c:1.34	Tue Jan 25 03:05:06 2022
+++ src/lib/libcurses/resize.c	Tue Apr 26 22:40:32 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: resize.c,v 1.34 2022/01/25 03:05:06 blymn Exp $	*/
+/*	$NetBSD: resize.c,v 1.35 2022/04/26 22:40:32 blymn 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.34 2022/01/25 03:05:06 blymn Exp $");
+__RCSID("$NetBSD: resize.c,v 1.35 2022/04/26 22:40:32 blymn Exp $");
 #endif
 #endif/* not lint */
 
@@ -390,7 +390,7 @@ __resizewin(WINDOW *win, int nlines, int
 			if (swin->begx + x > win->begx + win->maxx)
 x = 0;
 			if (x <= 0)
-x += win->begy + win->maxx - swin->begx;
+x += win->begx + win->maxx - swin->begx;
 			if (x < 1)
 x = 1;
 			__resizewin(swin, y, x);



CVS commit: src/lib/libcurses

2022-04-26 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Tue Apr 26 22:40:32 UTC 2022

Modified Files:
src/lib/libcurses: resize.c

Log Message:
Fix for PR 55517.
Actually us x values to recalculate subwin columns.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/lib/libcurses/resize.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libcurses

2022-04-19 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Tue Apr 19 22:26:57 UTC 2022

Modified Files:
src/lib/libcurses: background.c curses.c curses_private.h refresh.c

Log Message:
fix for PR 55496

 * Fix bkgrndset so that it actually sets the background character in
   in line with the SUSv2 specification.

 * Add an internal function to copy a complex character

 * Make the previously static celleq function into a libcurses private
   function so that it can be called in other files.


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/lib/libcurses/background.c
cvs rdiff -u -r1.28 -r1.29 src/lib/libcurses/curses.c
cvs rdiff -u -r1.78 -r1.79 src/lib/libcurses/curses_private.h
cvs rdiff -u -r1.121 -r1.122 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/background.c
diff -u src/lib/libcurses/background.c:1.29 src/lib/libcurses/background.c:1.30
--- src/lib/libcurses/background.c:1.29	Tue Apr 12 07:03:04 2022
+++ src/lib/libcurses/background.c	Tue Apr 19 22:26:57 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: background.c,v 1.29 2022/04/12 07:03:04 blymn Exp $	*/
+/*	$NetBSD: background.c,v 1.30 2022/04/19 22:26:57 blymn Exp $	*/
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: background.c,v 1.29 2022/04/12 07:03:04 blymn Exp $");
+__RCSID("$NetBSD: background.c,v 1.30 2022/04/19 22:26:57 blymn Exp $");
 #endif/* not lint */
 
 #include 
@@ -160,7 +160,9 @@ wbkgrndset(WINDOW *win, const cchar_t *w
 {
 	attr_t battr;
 	nschar_t *np, *tnp;
-	int i;
+	int i, wy, wx;
+	__LDATA obkgrnd, nbkgrnd;
+	__LINE *wlp;
 
 	__CTRACE(__CTRACE_ATTR, "wbkgrndset: (%p), '%s', %x\n",
 	win, (const char *)wunctrl(wch), wch->attributes);
@@ -169,6 +171,14 @@ wbkgrndset(WINDOW *win, const cchar_t *w
 	if (!wch->elements || wcwidth(wch->vals[0]) > 1)
 		return;
 
+	/* get a copy of the old background, we will need it. */
+	obkgrnd.ch = win->bch;
+	obkgrnd.attr = win->battr;
+	obkgrnd.wflags = 0;
+	obkgrnd.wcols = win->wcols;
+	obkgrnd.nsp = NULL;
+	_cursesi_copy_nsp(win->bnsp, );
+
 	/* Background character. */
 	tnp = np = win->bnsp;
 	if (wcwidth( wch->vals[0]))
@@ -204,11 +214,7 @@ wbkgrndset(WINDOW *win, const cchar_t *w
 		}
 	}
 	/* clear the old non-spacing characters */
-	while (np) {
-		tnp = np->next;
-		free(np);
-		np = tnp;
-	}
+	__cursesi_free_nsp(np);
 
 	/* Background attributes (check colour). */
 	battr = wch->attributes & WA_ATTRIBUTES;
@@ -216,6 +222,29 @@ wbkgrndset(WINDOW *win, const cchar_t *w
 		battr |= __default_color;
 	win->battr = battr;
 	win->wcols = 1;
+
+	/*
+	 * Now do the dirty work of updating all the locations
+	 * that have the old background character with the new.
+	 */
+
+	nbkgrnd.ch = win->bch;
+	nbkgrnd.attr = win->battr;
+	nbkgrnd.wflags = 0;
+	nbkgrnd.wcols = win->wcols;
+	nbkgrnd.nsp = NULL;
+	_cursesi_copy_nsp(win->bnsp, );
+
+	for (wy = 0; wy < win->maxy; wy++) {
+		wlp = win->alines[wy];
+		for (wx = 0; wx < win->maxx; wx++) {
+			if (_cursesi_celleq(, >line[wx])) {
+_cursesi_copy_wchar(, >line[wx]);
+			}
+		}
+	}
+	__touchwin(win, 1);
+
 }
 
 

Index: src/lib/libcurses/curses.c
diff -u src/lib/libcurses/curses.c:1.28 src/lib/libcurses/curses.c:1.29
--- src/lib/libcurses/curses.c:1.28	Tue Jan 31 09:17:53 2017
+++ src/lib/libcurses/curses.c	Tue Apr 19 22:26:57 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: curses.c,v 1.28 2017/01/31 09:17:53 roy Exp $	*/
+/*	$NetBSD: curses.c,v 1.29 2022/04/19 22:26:57 blymn Exp $	*/
 
 /*
  * Copyright (c) 1981, 1993, 1994
@@ -35,7 +35,7 @@
 #if 0
 static char sccsid[] = "@(#)curses.c	8.3 (Berkeley) 5/4/94";
 #else
-__RCSID("$NetBSD: curses.c,v 1.28 2017/01/31 09:17:53 roy Exp $");
+__RCSID("$NetBSD: curses.c,v 1.29 2022/04/19 22:26:57 blymn Exp $");
 #endif
 #endif/* not lint */
 
@@ -77,7 +77,55 @@ char	 __GT;/* Gtty indicates tabs. *
 char	 __NONL;			/* Term can't hack LF doing a CR. */
 char	 __UPPERCASE;			/* Terminal is uppercase only. */
 
+/* compare two cells on screen, must have the same foreground/background,
+ * and for wide characters the same sequence of non-spacing characters
+ */
+int
+_cursesi_celleq(__LDATA *x, __LDATA *y)
+{
 #ifdef HAVE_WCHAR
+	nschar_t *xnp = x->nsp, *ynp = y->nsp;
+#endif /* HAVE_WCHAR */
+	int ret = ( x->ch == y->ch ) && ( x->attr == y->attr );
+
+#ifdef HAVE_WCHAR
+	if (!ret)
+		return 0;
+
+	if (!xnp && !ynp)
+		return 1;
+
+	if ((xnp && !ynp) || (!xnp && ynp))
+		return 0;
+
+	while (xnp && ynp) {
+		if (xnp->ch != ynp->ch)
+			return 0;
+		xnp = xnp->next;
+		ynp = ynp->next;
+	}
+
+	return !xnp && !ynp;
+#else
+	return ret;
+#endif /* HAVE_WCHAR */
+}
+
+#ifdef HAVE_WCHAR
+/*
+ * Copy a complex character from source to destination.
+ *
+ */
+void
+_cursesi_copy_wchar(__LDATA *src, __LDATA *dest)
+{
+	dest->ch = src->ch;
+	dest->attr = src->attr;
+	dest->wflags = src->wflags;

CVS commit: src/lib/libcurses

2022-04-19 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Tue Apr 19 22:26:57 UTC 2022

Modified Files:
src/lib/libcurses: background.c curses.c curses_private.h refresh.c

Log Message:
fix for PR 55496

 * Fix bkgrndset so that it actually sets the background character in
   in line with the SUSv2 specification.

 * Add an internal function to copy a complex character

 * Make the previously static celleq function into a libcurses private
   function so that it can be called in other files.


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/lib/libcurses/background.c
cvs rdiff -u -r1.28 -r1.29 src/lib/libcurses/curses.c
cvs rdiff -u -r1.78 -r1.79 src/lib/libcurses/curses_private.h
cvs rdiff -u -r1.121 -r1.122 src/lib/libcurses/refresh.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libcurses

2022-04-13 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Wed Apr 13 19:17:09 UTC 2022

Modified Files:
src/lib/libcurses: refresh.c

Log Message:
Fix build (enabled only for MKDEBUG?)


To generate a diff of this commit:
cvs rdiff -u -r1.120 -r1.121 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.120 src/lib/libcurses/refresh.c:1.121
--- src/lib/libcurses/refresh.c:1.120	Tue Apr 12 21:54:16 2022
+++ src/lib/libcurses/refresh.c	Wed Apr 13 19:17:09 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: refresh.c,v 1.120 2022/04/12 21:54:16 blymn Exp $	*/
+/*	$NetBSD: refresh.c,v 1.121 2022/04/13 19:17:09 pgoyette 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.120 2022/04/12 21:54:16 blymn Exp $");
+__RCSID("$NetBSD: refresh.c,v 1.121 2022/04/13 19:17:09 pgoyette Exp $");
 #endif
 #endif/* not lint */
 
@@ -1256,7 +1256,7 @@ makech(int wy)
 else
 	clsp = 0;
 __CTRACE(__CTRACE_REFRESH,
-"makech: clsp = %zu, nlsp = %zu, strlen(ce) = %ld\n",
+"makech: clsp = %zu, nlsp = %zu, strlen(ce) = %zu\n",
 clsp, nlsp, strlen(ce));
 __CTRACE(__CTRACE_REFRESH,
 "makech: line = %p, cep = %p, begx = %u\n",



CVS commit: src/lib/libcurses

2022-04-13 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Wed Apr 13 19:17:09 UTC 2022

Modified Files:
src/lib/libcurses: refresh.c

Log Message:
Fix build (enabled only for MKDEBUG?)


To generate a diff of this commit:
cvs rdiff -u -r1.120 -r1.121 src/lib/libcurses/refresh.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libcurses

2022-04-12 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Tue Apr 12 21:54:16 UTC 2022

Modified Files:
src/lib/libcurses: insdelln.c refresh.c

Log Message:
Fix compile breakage when wide char support is disabled.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/lib/libcurses/insdelln.c
cvs rdiff -u -r1.119 -r1.120 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/insdelln.c
diff -u src/lib/libcurses/insdelln.c:1.21 src/lib/libcurses/insdelln.c:1.22
--- src/lib/libcurses/insdelln.c:1.21	Tue Apr 12 07:03:04 2022
+++ src/lib/libcurses/insdelln.c	Tue Apr 12 21:54:16 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: insdelln.c,v 1.21 2022/04/12 07:03:04 blymn Exp $	*/
+/*	$NetBSD: insdelln.c,v 1.22 2022/04/12 21:54:16 blymn Exp $	*/
 
 /*
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: insdelln.c,v 1.21 2022/04/12 07:03:04 blymn Exp $");
+__RCSID("$NetBSD: insdelln.c,v 1.22 2022/04/12 21:54:16 blymn Exp $");
 #endif/* not lint */
 
 /*
@@ -158,7 +158,7 @@ winsdelln(WINDOW *win, int nlines)
 win->alines[y]->line[i].ch = win->bch;
 win->alines[y]->line[i].attr = attr;
 win->alines[y]->line[i].ch = win->bch;
-#ifndef HAVE_WCHAR
+#ifdef HAVE_WCHAR
 lp = >alines[y]->line[i];
 lp->wcols = 1;
 if (_cursesi_copy_nsp(win->bnsp, lp) == ERR)

Index: src/lib/libcurses/refresh.c
diff -u src/lib/libcurses/refresh.c:1.119 src/lib/libcurses/refresh.c:1.120
--- src/lib/libcurses/refresh.c:1.119	Tue Apr 12 07:03:04 2022
+++ src/lib/libcurses/refresh.c	Tue Apr 12 21:54:16 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: refresh.c,v 1.119 2022/04/12 07:03:04 blymn Exp $	*/
+/*	$NetBSD: refresh.c,v 1.120 2022/04/12 21:54:16 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.119 2022/04/12 07:03:04 blymn Exp $");
+__RCSID("$NetBSD: refresh.c,v 1.120 2022/04/12 21:54:16 blymn Exp $");
 #endif
 #endif/* not lint */
 
@@ -1297,8 +1297,8 @@ makech(int wy)
 #ifdef HAVE_WCHAR
 		if (_cursesi_copy_nsp(blank.nsp, csp) == ERR)
 			return ERR;
-#endif /* HAVE_WCHAR */
 		csp->wcols = blank.wcols;
+#endif /* HAVE_WCHAR */
 		assert(csp != );
 		csp++;
 	}



CVS commit: src/lib/libcurses

2022-04-12 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Tue Apr 12 21:54:16 UTC 2022

Modified Files:
src/lib/libcurses: insdelln.c refresh.c

Log Message:
Fix compile breakage when wide char support is disabled.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/lib/libcurses/insdelln.c
cvs rdiff -u -r1.119 -r1.120 src/lib/libcurses/refresh.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libcurses

2022-04-12 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Tue Apr 12 07:03:05 UTC 2022

Modified Files:
src/lib/libcurses: add_wchstr.c addbytes.c attributes.c background.c
border.c clrtobot.c clrtoeol.c color.c copywin.c curses_private.h
delch.c erase.c get_wstr.c ins_wch.c ins_wstr.c insdelln.c mvwin.c
newwin.c refresh.c shlib_version slk.c touchwin.c

Log Message:
Make the default colour pair be pair 0 which appears to match other
curses implementations.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/lib/libcurses/add_wchstr.c
cvs rdiff -u -r1.61 -r1.62 src/lib/libcurses/addbytes.c
cvs rdiff -u -r1.33 -r1.34 src/lib/libcurses/attributes.c \
src/lib/libcurses/clrtoeol.c src/lib/libcurses/touchwin.c
cvs rdiff -u -r1.28 -r1.29 src/lib/libcurses/background.c \
src/lib/libcurses/clrtobot.c
cvs rdiff -u -r1.22 -r1.23 src/lib/libcurses/border.c \
src/lib/libcurses/ins_wstr.c
cvs rdiff -u -r1.45 -r1.46 src/lib/libcurses/color.c
cvs rdiff -u -r1.20 -r1.21 src/lib/libcurses/copywin.c \
src/lib/libcurses/insdelln.c
cvs rdiff -u -r1.77 -r1.78 src/lib/libcurses/curses_private.h
cvs rdiff -u -r1.27 -r1.28 src/lib/libcurses/delch.c
cvs rdiff -u -r1.34 -r1.35 src/lib/libcurses/erase.c
cvs rdiff -u -r1.10 -r1.11 src/lib/libcurses/get_wstr.c
cvs rdiff -u -r1.18 -r1.19 src/lib/libcurses/ins_wch.c
cvs rdiff -u -r1.23 -r1.24 src/lib/libcurses/mvwin.c
cvs rdiff -u -r1.65 -r1.66 src/lib/libcurses/newwin.c
cvs rdiff -u -r1.118 -r1.119 src/lib/libcurses/refresh.c
cvs rdiff -u -r1.46 -r1.47 src/lib/libcurses/shlib_version
cvs rdiff -u -r1.19 -r1.20 src/lib/libcurses/slk.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libcurses

2022-04-12 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Tue Apr 12 07:03:05 UTC 2022

Modified Files:
src/lib/libcurses: add_wchstr.c addbytes.c attributes.c background.c
border.c clrtobot.c clrtoeol.c color.c copywin.c curses_private.h
delch.c erase.c get_wstr.c ins_wch.c ins_wstr.c insdelln.c mvwin.c
newwin.c refresh.c shlib_version slk.c touchwin.c

Log Message:
Make the default colour pair be pair 0 which appears to match other
curses implementations.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/lib/libcurses/add_wchstr.c
cvs rdiff -u -r1.61 -r1.62 src/lib/libcurses/addbytes.c
cvs rdiff -u -r1.33 -r1.34 src/lib/libcurses/attributes.c \
src/lib/libcurses/clrtoeol.c src/lib/libcurses/touchwin.c
cvs rdiff -u -r1.28 -r1.29 src/lib/libcurses/background.c \
src/lib/libcurses/clrtobot.c
cvs rdiff -u -r1.22 -r1.23 src/lib/libcurses/border.c \
src/lib/libcurses/ins_wstr.c
cvs rdiff -u -r1.45 -r1.46 src/lib/libcurses/color.c
cvs rdiff -u -r1.20 -r1.21 src/lib/libcurses/copywin.c \
src/lib/libcurses/insdelln.c
cvs rdiff -u -r1.77 -r1.78 src/lib/libcurses/curses_private.h
cvs rdiff -u -r1.27 -r1.28 src/lib/libcurses/delch.c
cvs rdiff -u -r1.34 -r1.35 src/lib/libcurses/erase.c
cvs rdiff -u -r1.10 -r1.11 src/lib/libcurses/get_wstr.c
cvs rdiff -u -r1.18 -r1.19 src/lib/libcurses/ins_wch.c
cvs rdiff -u -r1.23 -r1.24 src/lib/libcurses/mvwin.c
cvs rdiff -u -r1.65 -r1.66 src/lib/libcurses/newwin.c
cvs rdiff -u -r1.118 -r1.119 src/lib/libcurses/refresh.c
cvs rdiff -u -r1.46 -r1.47 src/lib/libcurses/shlib_version
cvs rdiff -u -r1.19 -r1.20 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/add_wchstr.c
diff -u src/lib/libcurses/add_wchstr.c:1.11 src/lib/libcurses/add_wchstr.c:1.12
--- src/lib/libcurses/add_wchstr.c:1.11	Tue Jan 25 03:05:06 2022
+++ src/lib/libcurses/add_wchstr.c	Tue Apr 12 07:03:04 2022
@@ -1,4 +1,4 @@
-/*   $NetBSD: add_wchstr.c,v 1.11 2022/01/25 03:05:06 blymn Exp $ */
+/*   $NetBSD: add_wchstr.c,v 1.12 2022/04/12 07:03:04 blymn Exp $ */
 
 /*
  * Copyright (c) 2005 The NetBSD Foundation Inc.
@@ -36,7 +36,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: add_wchstr.c,v 1.11 2022/01/25 03:05:06 blymn Exp $");
+__RCSID("$NetBSD: add_wchstr.c,v 1.12 2022/04/12 07:03:04 blymn Exp $");
 #endif/* not lint */
 
 #include 
@@ -170,7 +170,7 @@ wadd_wchnstr(WINDOW *win, const cchar_t 
 		if (wcwidth(chp->vals[0])) {
 			/* clear the partial character before cursor */
 			for (tp = lp + cw; tp < lp; tp++) {
-tp->ch = (wchar_t) btowc((int) win->bch);
+tp->ch = win->bch;
 if (_cursesi_copy_nsp(win->bnsp, tp) == ERR)
 	return ERR;
 tp->attr = win->battr;
@@ -205,8 +205,7 @@ wadd_wchnstr(WINDOW *win, const cchar_t 
 			if (cw > win->maxx - ex) {
 /* clear to EOL */
 while (ex < win->maxx) {
-	lp->ch = (wchar_t)
-		btowc((int) win->bch);
+	lp->ch = win->bch;
 	if (_cursesi_copy_nsp(win->bnsp, lp)
 	== ERR)
 		return ERR;

Index: src/lib/libcurses/addbytes.c
diff -u src/lib/libcurses/addbytes.c:1.61 src/lib/libcurses/addbytes.c:1.62
--- src/lib/libcurses/addbytes.c:1.61	Tue Jan 25 03:05:06 2022
+++ src/lib/libcurses/addbytes.c	Tue Apr 12 07:03:04 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: addbytes.c,v 1.61 2022/01/25 03:05:06 blymn Exp $	*/
+/*	$NetBSD: addbytes.c,v 1.62 2022/04/12 07:03:04 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.61 2022/01/25 03:05:06 blymn Exp $");
+__RCSID("$NetBSD: addbytes.c,v 1.62 2022/04/12 07:03:04 blymn Exp $");
 #endif
 #endif/* not lint */
 
@@ -448,7 +448,7 @@ _cursesi_addwchar(WINDOW *win, __LINE **
 			"_cursesi_addwchar: clear current char (%d,%d)\n",
 			*y, sx);
 			tp = >alines[*y]->line[sx];
-			tp->ch = (wchar_t) btowc((int) win->bch);
+			tp->ch = win->bch;
 			if (_cursesi_copy_nsp(win->bnsp, tp) == ERR)
 return ERR;
 
@@ -481,7 +481,7 @@ _cursesi_addwchar(WINDOW *win, __LINE **
 		if (newx < *(*lnp)->firstchp)
 			*(*lnp)->firstchp = newx;
 		for (tp = lp; *x < win->maxx; tp++, (*x)++) {
-			tp->ch = (wchar_t) btowc((int) win->bch);
+			tp->ch = win->bch;
 			if (_cursesi_copy_nsp(win->bnsp, tp) == ERR)
 return ERR;
 			tp->attr = win->battr;
@@ -595,7 +595,7 @@ _cursesi_addwchar(WINDOW *win, __LINE **
 "_cursesi_addwchar: clear "
 "remaining of current char (%d,%d)nn",
 *y, ex);
-tp->ch = (wchar_t) btowc((int) win->bch);
+tp->ch = win->bch;
 if (_cursesi_copy_nsp(win->bnsp, tp) == ERR)
 	return ERR;
 tp->attr = win->battr;

Index: src/lib/libcurses/attributes.c
diff -u src/lib/libcurses/attributes.c:1.33 src/lib/libcurses/attributes.c:1.34
--- src/lib/libcurses/attributes.c:1.33	Wed Dec  8 20:50:01 2021
+++ 

CVS commit: src/lib/libcurses

2022-03-26 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Sat Mar 26 16:03:02 UTC 2022

Modified Files:
src/lib/libcurses: newwin.c

Log Message:
__makenew: use calloc to get zeroed memory for window contents.

PR lib/56767.


To generate a diff of this commit:
cvs rdiff -u -r1.64 -r1.65 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.64 src/lib/libcurses/newwin.c:1.65
--- src/lib/libcurses/newwin.c:1.64	Tue Jan 25 03:05:06 2022
+++ src/lib/libcurses/newwin.c	Sat Mar 26 16:03:02 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: newwin.c,v 1.64 2022/01/25 03:05:06 blymn Exp $	*/
+/*	$NetBSD: newwin.c,v 1.65 2022/03/26 16:03:02 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.64 2022/01/25 03:05:06 blymn Exp $");
+__RCSID("$NetBSD: newwin.c,v 1.65 2022/03/26 16:03:02 uwe Exp $");
 #endif
 #endif/* not lint */
 
@@ -275,7 +275,7 @@ __makenew(SCREEN *screen, int nlines, in
 		free(win);
 		return NULL;
 	}
-	if ((win->lspace = malloc(nlines * sizeof(__LINE))) == NULL) {
+	if ((win->lspace = calloc(nlines, sizeof(__LINE))) == NULL) {
 		free(win->alines);
 		free(win);
 		return NULL;
@@ -288,7 +288,7 @@ __makenew(SCREEN *screen, int nlines, in
 		 * Allocate window space in one chunk.
 		 */
 		if ((win->wspace =
-			malloc(ncols * nlines * sizeof(__LDATA))) == NULL) {
+			calloc(ncols * nlines, sizeof(__LDATA))) == NULL) {
 			free(win->lspace);
 			free(win->alines);
 			free(win);



CVS commit: src/lib/libcurses

2022-03-26 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Sat Mar 26 16:03:02 UTC 2022

Modified Files:
src/lib/libcurses: newwin.c

Log Message:
__makenew: use calloc to get zeroed memory for window contents.

PR lib/56767.


To generate a diff of this commit:
cvs rdiff -u -r1.64 -r1.65 src/lib/libcurses/newwin.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libcurses

2022-01-24 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Tue Jan 25 03:05:06 UTC 2022

Modified Files:
src/lib/libcurses: add_wchstr.c addbytes.c background.c border.c
clrtobot.c clrtoeol.c cr_put.c curses_private.h delch.c erase.c
in_wch.c in_wchstr.c ins_wch.c ins_wstr.c insch.c insdelln.c
insstr.c inwstr.c newwin.c refresh.c resize.c slk.c

Log Message:
Correct (hopefully) the handling of wide characters.

* Remove the WCOL family of macros, these were "stealing" the upper bits
  of a character attribute to store the column width of a character.  No
  warning was given about this in curses.h which meant it was easy to
  accidentally reuse the bits in use by the WCOL macros (we already did).
  Add couple of 16bit ints to the character structure iff HAVE_WCHAR is
  true to hold the display width and wide char related flags (just
  continuation at the moment)
* Convert all instances of WCOL macros to just reference the column width
  in the char structure so it is not obfuscated.
* Fix cursor positioning so placing a cursor in the middle of a wide char
  actually does just that.
* Fix plod so it understands that if the cursor is going to be positioned
  in the middle of a wide char it cannot just reprint the char to get there.
* Fix plodput so it correctly counts the number of output characters for
  wide characters.
* Fix slk routines to properly size the wctomb() buffer.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/lib/libcurses/add_wchstr.c
cvs rdiff -u -r1.60 -r1.61 src/lib/libcurses/addbytes.c
cvs rdiff -u -r1.27 -r1.28 src/lib/libcurses/background.c \
src/lib/libcurses/clrtobot.c
cvs rdiff -u -r1.21 -r1.22 src/lib/libcurses/border.c \
src/lib/libcurses/ins_wstr.c
cvs rdiff -u -r1.32 -r1.33 src/lib/libcurses/clrtoeol.c
cvs rdiff -u -r1.37 -r1.38 src/lib/libcurses/cr_put.c
cvs rdiff -u -r1.76 -r1.77 src/lib/libcurses/curses_private.h
cvs rdiff -u -r1.26 -r1.27 src/lib/libcurses/delch.c \
src/lib/libcurses/insch.c
cvs rdiff -u -r1.33 -r1.34 src/lib/libcurses/erase.c \
src/lib/libcurses/resize.c
cvs rdiff -u -r1.7 -r1.8 src/lib/libcurses/in_wch.c
cvs rdiff -u -r1.9 -r1.10 src/lib/libcurses/in_wchstr.c \
src/lib/libcurses/insstr.c src/lib/libcurses/inwstr.c
cvs rdiff -u -r1.17 -r1.18 src/lib/libcurses/ins_wch.c
cvs rdiff -u -r1.19 -r1.20 src/lib/libcurses/insdelln.c
cvs rdiff -u -r1.63 -r1.64 src/lib/libcurses/newwin.c
cvs rdiff -u -r1.117 -r1.118 src/lib/libcurses/refresh.c
cvs rdiff -u -r1.18 -r1.19 src/lib/libcurses/slk.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libcurses

2022-01-24 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Tue Jan 25 03:05:06 UTC 2022

Modified Files:
src/lib/libcurses: add_wchstr.c addbytes.c background.c border.c
clrtobot.c clrtoeol.c cr_put.c curses_private.h delch.c erase.c
in_wch.c in_wchstr.c ins_wch.c ins_wstr.c insch.c insdelln.c
insstr.c inwstr.c newwin.c refresh.c resize.c slk.c

Log Message:
Correct (hopefully) the handling of wide characters.

* Remove the WCOL family of macros, these were "stealing" the upper bits
  of a character attribute to store the column width of a character.  No
  warning was given about this in curses.h which meant it was easy to
  accidentally reuse the bits in use by the WCOL macros (we already did).
  Add couple of 16bit ints to the character structure iff HAVE_WCHAR is
  true to hold the display width and wide char related flags (just
  continuation at the moment)
* Convert all instances of WCOL macros to just reference the column width
  in the char structure so it is not obfuscated.
* Fix cursor positioning so placing a cursor in the middle of a wide char
  actually does just that.
* Fix plod so it understands that if the cursor is going to be positioned
  in the middle of a wide char it cannot just reprint the char to get there.
* Fix plodput so it correctly counts the number of output characters for
  wide characters.
* Fix slk routines to properly size the wctomb() buffer.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/lib/libcurses/add_wchstr.c
cvs rdiff -u -r1.60 -r1.61 src/lib/libcurses/addbytes.c
cvs rdiff -u -r1.27 -r1.28 src/lib/libcurses/background.c \
src/lib/libcurses/clrtobot.c
cvs rdiff -u -r1.21 -r1.22 src/lib/libcurses/border.c \
src/lib/libcurses/ins_wstr.c
cvs rdiff -u -r1.32 -r1.33 src/lib/libcurses/clrtoeol.c
cvs rdiff -u -r1.37 -r1.38 src/lib/libcurses/cr_put.c
cvs rdiff -u -r1.76 -r1.77 src/lib/libcurses/curses_private.h
cvs rdiff -u -r1.26 -r1.27 src/lib/libcurses/delch.c \
src/lib/libcurses/insch.c
cvs rdiff -u -r1.33 -r1.34 src/lib/libcurses/erase.c \
src/lib/libcurses/resize.c
cvs rdiff -u -r1.7 -r1.8 src/lib/libcurses/in_wch.c
cvs rdiff -u -r1.9 -r1.10 src/lib/libcurses/in_wchstr.c \
src/lib/libcurses/insstr.c src/lib/libcurses/inwstr.c
cvs rdiff -u -r1.17 -r1.18 src/lib/libcurses/ins_wch.c
cvs rdiff -u -r1.19 -r1.20 src/lib/libcurses/insdelln.c
cvs rdiff -u -r1.63 -r1.64 src/lib/libcurses/newwin.c
cvs rdiff -u -r1.117 -r1.118 src/lib/libcurses/refresh.c
cvs rdiff -u -r1.18 -r1.19 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/add_wchstr.c
diff -u src/lib/libcurses/add_wchstr.c:1.10 src/lib/libcurses/add_wchstr.c:1.11
--- src/lib/libcurses/add_wchstr.c:1.10	Mon Sep  6 07:45:48 2021
+++ src/lib/libcurses/add_wchstr.c	Tue Jan 25 03:05:06 2022
@@ -1,4 +1,4 @@
-/*   $NetBSD: add_wchstr.c,v 1.10 2021/09/06 07:45:48 rin Exp $ */
+/*   $NetBSD: add_wchstr.c,v 1.11 2022/01/25 03:05:06 blymn Exp $ */
 
 /*
  * Copyright (c) 2005 The NetBSD Foundation Inc.
@@ -36,7 +36,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: add_wchstr.c,v 1.10 2021/09/06 07:45:48 rin Exp $");
+__RCSID("$NetBSD: add_wchstr.c,v 1.11 2022/01/25 03:05:06 blymn Exp $");
 #endif/* not lint */
 
 #include 
@@ -163,7 +163,7 @@ wadd_wchnstr(WINDOW *win, const cchar_t 
 	lp = >alines[y]->line[x];
 	lnp = win->alines[y];
 
-	cw = WCOL(*lp);
+	cw = (*lp).wcols;
 	if (cw >= 0) {
 		sx = x;
 	} else {
@@ -174,7 +174,7 @@ wadd_wchnstr(WINDOW *win, const cchar_t 
 if (_cursesi_copy_nsp(win->bnsp, tp) == ERR)
 	return ERR;
 tp->attr = win->battr;
-SET_WCOL(*tp, 1);
+(*tp).wcols = 1;
 np = tp->nsp;
 			}
 		} else {
@@ -211,7 +211,7 @@ wadd_wchnstr(WINDOW *win, const cchar_t 
 	== ERR)
 		return ERR;
 	lp->attr = win->battr;
-	SET_WCOL(*lp, 1);
+	(*lp).wcols = 1;
 	lp++, ex++;
 }
 ex = win->maxx - 1;
@@ -230,7 +230,7 @@ wadd_wchnstr(WINDOW *win, const cchar_t 
 			}
 			lp->ch = chp->vals[0];
 			lp->attr = chp->attributes & WA_ATTRIBUTES;
-			SET_WCOL(*lp, cw);
+			(*lp).wcols = cw;
 			if (chp->elements > 1) {
 for (i = 1; i < chp->elements; i++) {
 	np = (nschar_t *)
@@ -258,7 +258,7 @@ wadd_wchnstr(WINDOW *win, const cchar_t 
 }
 lp->ch = chp->vals[0];
 lp->attr = chp->attributes & WA_ATTRIBUTES;
-SET_WCOL(*lp, x - ex);
+(*lp).wcols = x - ex;
 lp++, ex++;
 			}
 		} else {

Index: src/lib/libcurses/addbytes.c
diff -u src/lib/libcurses/addbytes.c:1.60 src/lib/libcurses/addbytes.c:1.61
--- src/lib/libcurses/addbytes.c:1.60	Sun Jan 16 10:30:45 2022
+++ src/lib/libcurses/addbytes.c	Tue Jan 25 03:05:06 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: addbytes.c,v 1.60 2022/01/16 10:30:45 rillig Exp $	*/
+/*	$NetBSD: addbytes.c,v 1.61 2022/01/25 03:05:06 blymn Exp $	*/
 
 /*
  * Copyright (c) 1987, 1993, 1994
@@ -34,7 +34,7 @@
 #if 0
 

Re: CVS commit: src/lib/libcurses

2022-01-16 Thread Martin Husemann
On Sun, Jan 16, 2022 at 01:13:04PM +0100, Roland Illig wrote:
> I'm not sure what the perfect commit message would look like that
> would keep us both unsurprised and how much time we should spend
> discussing about this particular case since the code itself can be
> reviewed in a few seconds.

"Remove two null statements and an unreachable break. NFC."

:-}

Martin


Re: CVS commit: src/lib/libcurses

2022-01-16 Thread Roland Illig


16.01.2022 12:44:02 Valery Ushakov :

> On Sun, Jan 16, 2022 at 10:30:45 +, Roland Illig wrote:
> 
>> Modified Files:
>>     src/lib/libcurses: addbytes.c ins_wstr.c
>> 
>> Log Message:
>> libcurses: remove unreachable statements
> 
> That summary sounds kinda misleading to me.  It's technically true -
> the commit removes unreachable *empty* statements - accidentally
> doubled semicolons in return foo;; and the like - but it makes it
> sound much more ominous by failing to mention that fact.  I would have
> skipped a change summarized, e.g., as "g/c duplicate semicolons" or
> something like that that actually captured the essense of the change
> correctly.  I felt compelled to go and take a look at something
> described as "remove unreachable statements".  Please, can you be more
> careful in wording those?


Actually, I _was_ careful.  I not only removed 2 null statements (as the C 
standard calls them) but also an unreachable break statement.  Due to this 
break statement it would have been misleading (at least to me) to only state 
"remove empty statements" or even "remove duplicate semicolons".

I'm not sure what the perfect commit message would look like that would keep us 
both unsurprised and how much time we should spend discussing about this 
particular case since the code itself can be reviewed in a few seconds.

Roland


Re: CVS commit: src/lib/libcurses

2022-01-16 Thread Valery Ushakov
On Sun, Jan 16, 2022 at 10:30:45 +, Roland Illig wrote:

> Modified Files:
>   src/lib/libcurses: addbytes.c ins_wstr.c
> 
> Log Message:
> libcurses: remove unreachable statements

That summary sounds kinda misleading to me.  It's technically true -
the commit removes unreachable *empty* statements - accidentally
doubled semicolons in return foo;; and the like - but it makes it
sound much more ominous by failing to mention that fact.  I would have
skipped a change summarized, e.g., as "g/c duplicate semicolons" or
something like that that actually captured the essense of the change
correctly.  I felt compelled to go and take a look at something
described as "remove unreachable statements".  Please, can you be more
careful in wording those?

-uwe


CVS commit: src/lib/libcurses

2022-01-16 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jan 16 10:30:45 UTC 2022

Modified Files:
src/lib/libcurses: addbytes.c ins_wstr.c

Log Message:
libcurses: remove unreachable statements

Found by lint.

No binary change.


To generate a diff of this commit:
cvs rdiff -u -r1.59 -r1.60 src/lib/libcurses/addbytes.c
cvs rdiff -u -r1.20 -r1.21 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/addbytes.c
diff -u src/lib/libcurses/addbytes.c:1.59 src/lib/libcurses/addbytes.c:1.60
--- src/lib/libcurses/addbytes.c:1.59	Mon Sep  6 07:45:48 2021
+++ src/lib/libcurses/addbytes.c	Sun Jan 16 10:30:45 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: addbytes.c,v 1.59 2021/09/06 07:45:48 rin Exp $	*/
+/*	$NetBSD: addbytes.c,v 1.60 2022/01/16 10:30:45 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.59 2021/09/06 07:45:48 rin Exp $");
+__RCSID("$NetBSD: addbytes.c,v 1.60 2022/01/16 10:30:45 rillig Exp $");
 #endif
 #endif/* not lint */
 
@@ -398,7 +398,7 @@ _cursesi_addwchar(WINDOW *win, __LINE **
 		}
 		for (i = 0; i < wch->elements; i++) {
 			if (!(np = (nschar_t *) malloc(sizeof(nschar_t
-return ERR;;
+return ERR;
 			np->ch = wch->vals[i];
 			np->next = lp->nsp;
 			lp->nsp = np;
@@ -523,7 +523,7 @@ _cursesi_addwchar(WINDOW *win, __LINE **
 		for (i = 1; i < wch->elements; i++) {
 			np = malloc(sizeof(nschar_t));
 			if (!np)
-return ERR;;
+return ERR;
 			np->ch = wch->vals[i];
 			np->next = lp->nsp;
 			__CTRACE(__CTRACE_INPUT,

Index: src/lib/libcurses/ins_wstr.c
diff -u src/lib/libcurses/ins_wstr.c:1.20 src/lib/libcurses/ins_wstr.c:1.21
--- src/lib/libcurses/ins_wstr.c:1.20	Tue Nov 16 23:23:02 2021
+++ src/lib/libcurses/ins_wstr.c	Sun Jan 16 10:30:45 2022
@@ -1,4 +1,4 @@
-/*   $NetBSD: ins_wstr.c,v 1.20 2021/11/16 23:23:02 kre Exp $ */
+/*   $NetBSD: ins_wstr.c,v 1.21 2022/01/16 10:30:45 rillig Exp $ */
 
 /*
  * Copyright (c) 2005 The NetBSD Foundation Inc.
@@ -36,7 +36,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: ins_wstr.c,v 1.20 2021/11/16 23:23:02 kre Exp $");
+__RCSID("$NetBSD: ins_wstr.c,v 1.21 2022/01/16 10:30:45 rillig Exp $");
 #endif		  /* not lint */
 
 #include 
@@ -174,7 +174,7 @@ wins_nwstr(WINDOW *win, const wchar_t *w
 	cw = 1;
 width -= cw;
 scp++;
-continue;;
+continue;
 
 			case L'\r':
 width = 0;
@@ -242,7 +242,7 @@ wins_nwstr(WINDOW *win, const wchar_t *w
 	scp++;
 	if (lstr != slstr)
 		lstr--;
-	continue;;
+	continue;
 
 case L'\r':
 	width = 0;
@@ -254,7 +254,6 @@ wins_nwstr(WINDOW *win, const wchar_t *w
 
 case L'\n':
 	goto loopdone;
-	break;
 
 case L'\t':
 	cw = wcwidth(ws[0]);



CVS commit: src/lib/libcurses

2022-01-16 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jan 16 10:30:45 UTC 2022

Modified Files:
src/lib/libcurses: addbytes.c ins_wstr.c

Log Message:
libcurses: remove unreachable statements

Found by lint.

No binary change.


To generate a diff of this commit:
cvs rdiff -u -r1.59 -r1.60 src/lib/libcurses/addbytes.c
cvs rdiff -u -r1.20 -r1.21 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.



CVS commit: src/lib/libcurses

2022-01-06 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Thu Jan  6 20:50:19 UTC 2022

Modified Files:
src/lib/libcurses: slk.c

Log Message:
Revert change for array definition, it was incorrect, thanks Uwe.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/lib/libcurses/slk.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libcurses

2022-01-06 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Thu Jan  6 20:50:19 UTC 2022

Modified Files:
src/lib/libcurses: slk.c

Log Message:
Revert change for array definition, it was incorrect, thanks Uwe.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 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.17 src/lib/libcurses/slk.c:1.18
--- src/lib/libcurses/slk.c:1.17	Thu Jan  6 06:18:13 2022
+++ src/lib/libcurses/slk.c	Thu Jan  6 20:50:18 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: slk.c,v 1.17 2022/01/06 06:18:13 blymn Exp $	*/
+/*	$NetBSD: slk.c,v 1.18 2022/01/06 20:50:18 blymn Exp $	*/
 
 /*-
  * Copyright (c) 2017 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: slk.c,v 1.17 2022/01/06 06:18:13 blymn Exp $");
+__RCSID("$NetBSD: slk.c,v 1.18 2022/01/06 20:50:18 blymn Exp $");
 #endif/* not lint */
 
 #include 
@@ -811,7 +811,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];



Re: CVS commit: src/lib/libcurses

2022-01-06 Thread Valery Ushakov
On Thu, Jan 06, 2022 at 06:18:13 +, Brett Lymn wrote:

> Module Name:  src
> Committed By: blymn
> Date: Thu Jan  6 06:18:13 UTC 2022
> 
> Modified Files:
>   src/lib/libcurses: slk.c
> 
> Log Message:
> Properly size and array to hold the larget return from wctomb.

I'm not sure this is correct.  You are introducing a variable length
array here.

POSIX says that 

  The  header shall define the following macro which shall
  expand to a positive integer expression with type size_t:

  {MB_CUR_MAX}
  Maximum number of bytes in a character specified by the current
  locale (category LC_CTYPE).

the important exegetical fact about this passage is that it says
"integer expression", not "integer constant expression".

MB_LEN_MAX is maximum MB_CUR_MAX and "shall be suitable for use in #if
preprocessing directives".

I think this should be reverted.

-uwe


CVS commit: src/lib/libcurses

2022-01-05 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Thu Jan  6 06:18:13 UTC 2022

Modified Files:
src/lib/libcurses: slk.c

Log Message:
Properly size and array to hold the larget return from wctomb.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 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.16 src/lib/libcurses/slk.c:1.17
--- src/lib/libcurses/slk.c:1.16	Mon Sep  6 07:45:48 2021
+++ src/lib/libcurses/slk.c	Thu Jan  6 06:18:13 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: slk.c,v 1.16 2021/09/06 07:45:48 rin Exp $	*/
+/*	$NetBSD: slk.c,v 1.17 2022/01/06 06:18:13 blymn Exp $	*/
 
 /*-
  * Copyright (c) 2017 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: slk.c,v 1.16 2021/09/06 07:45:48 rin Exp $");
+__RCSID("$NetBSD: slk.c,v 1.17 2022/01/06 06:18:13 blymn Exp $");
 #endif/* not lint */
 
 #include 
@@ -811,7 +811,7 @@ __slk_draw(SCREEN *screen, int labnum)
 {
 	const struct __slk_label *l;
 	int retval, inc, lcnt, tx;
-	char ts[MB_LEN_MAX];
+	char ts[MB_CUR_MAX];
 #ifdef HAVE_WCHAR
 	cchar_t cc;
 	wchar_t wc[2];



CVS commit: src/lib/libcurses

2022-01-05 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Thu Jan  6 06:18:13 UTC 2022

Modified Files:
src/lib/libcurses: slk.c

Log Message:
Properly size and array to hold the larget return from wctomb.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/lib/libcurses/slk.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libcurses

2021-12-16 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Fri Dec 17 03:50:18 UTC 2021

Modified Files:
src/lib/libcurses: color.c refresh.c

Log Message:
curses: spell "foreground" correctly in comments


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/lib/libcurses/color.c
cvs rdiff -u -r1.116 -r1.117 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/color.c
diff -u src/lib/libcurses/color.c:1.44 src/lib/libcurses/color.c:1.45
--- src/lib/libcurses/color.c:1.44	Mon Sep  6 07:45:48 2021
+++ src/lib/libcurses/color.c	Fri Dec 17 03:50:18 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: color.c,v 1.44 2021/09/06 07:45:48 rin Exp $	*/
+/*	$NetBSD: color.c,v 1.45 2021/12/17 03:50:18 uwe Exp $	*/
 
 /*
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: color.c,v 1.44 2021/09/06 07:45:48 rin Exp $");
+__RCSID("$NetBSD: color.c,v 1.45 2021/12/17 03:50:18 uwe Exp $");
 #endif/* not lint */
 
 #include "curses.h"
@@ -536,7 +536,7 @@ __set_color( /*ARGSUSED*/ WINDOW *win, a
 	_cursesi_screen->colour_pairs[pair].fore,
 	_cursesi_screen->colour_pairs[pair].back);
 	switch (_cursesi_screen->color_type) {
-	/* Set ANSI forground and background colours */
+	/* Set ANSI foreground and background colours */
 	case COLOR_ANSI:
 		if (_cursesi_screen->colour_pairs[pair].fore < 0 ||
 		_cursesi_screen->colour_pairs[pair].back < 0)
@@ -583,7 +583,7 @@ __unset_color(WINDOW *win)
 {
 	__CTRACE(__CTRACE_COLOR, "__unset_color\n");
 	switch (_cursesi_screen->color_type) {
-	/* Clear ANSI forground and background colours */
+	/* Clear ANSI foreground and background colours */
 	case COLOR_ANSI:
 		if (orig_pair != NULL) {
 			tputs(orig_pair, 0, __cputchar);

Index: src/lib/libcurses/refresh.c
diff -u src/lib/libcurses/refresh.c:1.116 src/lib/libcurses/refresh.c:1.117
--- src/lib/libcurses/refresh.c:1.116	Tue Sep  7 01:23:09 2021
+++ src/lib/libcurses/refresh.c	Fri Dec 17 03:50:18 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: refresh.c,v 1.116 2021/09/07 01:23:09 rin Exp $	*/
+/*	$NetBSD: refresh.c,v 1.117 2021/12/17 03:50:18 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.116 2021/09/07 01:23:09 rin Exp $");
+__RCSID("$NetBSD: refresh.c,v 1.117 2021/12/17 03:50:18 uwe Exp $");
 #endif
 #endif/* not lint */
 
@@ -1916,7 +1916,7 @@ __unsetattr(int checkms)
 }
 
 #ifdef HAVE_WCHAR
-/* compare two cells on screen, must have the same forground/background,
+/* compare two cells on screen, must have the same foreground/background,
  * and the same sequence of non-spacing characters */
 static int
 celleq(__LDATA *x, __LDATA *y)



CVS commit: src/lib/libcurses

2021-12-16 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Fri Dec 17 03:50:18 UTC 2021

Modified Files:
src/lib/libcurses: color.c refresh.c

Log Message:
curses: spell "foreground" correctly in comments


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/lib/libcurses/color.c
cvs rdiff -u -r1.116 -r1.117 src/lib/libcurses/refresh.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libcurses

2021-11-22 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Mon Nov 22 21:25:25 UTC 2021

Modified Files:
src/lib/libcurses: chgat.c

Log Message:
Don't waste time setting the dirty flag multiple times.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/lib/libcurses/chgat.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/chgat.c
diff -u src/lib/libcurses/chgat.c:1.7 src/lib/libcurses/chgat.c:1.8
--- src/lib/libcurses/chgat.c:1.7	Mon Sep  6 07:45:48 2021
+++ src/lib/libcurses/chgat.c	Mon Nov 22 21:25:25 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: chgat.c,v 1.7 2021/09/06 07:45:48 rin Exp $	*/
+/*	$NetBSD: chgat.c,v 1.8 2021/11/22 21:25:25 blymn Exp $	*/
 
 /*
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: chgat.c,v 1.7 2021/09/06 07:45:48 rin Exp $");
+__RCSID("$NetBSD: chgat.c,v 1.8 2021/11/22 21:25:25 blymn Exp $");
 
 #include "curses.h"
 #include "curses_private.h"
@@ -82,8 +82,9 @@ mvwchgat(WINDOW *win , int y, int x, int
 	if (x + win->ch_off + count > *lp->lastchp)
 		*lp->lastchp = x + win->ch_off + count;
 
+	lp->flags |= __ISDIRTY;
+
 	while (count-- > 0) {
-		lp->flags |= __ISDIRTY;
 #ifdef HAVE_WCHAR
 		lc->attr = (lc->attr & ~WA_ATTRIBUTES) | attr;
 #else



CVS commit: src/lib/libcurses

2021-11-22 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Mon Nov 22 21:25:25 UTC 2021

Modified Files:
src/lib/libcurses: chgat.c

Log Message:
Don't waste time setting the dirty flag multiple times.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/lib/libcurses/chgat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libcurses

2021-11-16 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Tue Nov 16 23:23:02 UTC 2021

Modified Files:
src/lib/libcurses: ins_wstr.c

Log Message:
Move 'i' into DEBUG only code (now there be three).
Hopefully unbreaks !DEBUG builds.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 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/ins_wstr.c
diff -u src/lib/libcurses/ins_wstr.c:1.19 src/lib/libcurses/ins_wstr.c:1.20
--- src/lib/libcurses/ins_wstr.c:1.19	Tue Nov 16 21:00:50 2021
+++ src/lib/libcurses/ins_wstr.c	Tue Nov 16 23:23:02 2021
@@ -1,4 +1,4 @@
-/*   $NetBSD: ins_wstr.c,v 1.19 2021/11/16 21:00:50 blymn Exp $ */
+/*   $NetBSD: ins_wstr.c,v 1.20 2021/11/16 23:23:02 kre Exp $ */
 
 /*
  * Copyright (c) 2005 The NetBSD Foundation Inc.
@@ -36,7 +36,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: ins_wstr.c,v 1.19 2021/11/16 21:00:50 blymn Exp $");
+__RCSID("$NetBSD: ins_wstr.c,v 1.20 2021/11/16 23:23:02 kre Exp $");
 #endif		  /* not lint */
 
 #include 
@@ -135,7 +135,7 @@ wins_nwstr(WINDOW *win, const wchar_t *w
 	const wchar_t *scp;
 	cchar_t cc;
 	wchar_t *lstr, *slstr;
-	int i, width, len, lx, sx, x, y, tx, ty, cw, pcw, newx, tn, w;
+	int width, len, lx, sx, x, y, tx, ty, cw, pcw, newx, tn, w;
 	wchar_t ws[] = L"		";
 
 	/* check for leading non-spacing character */
@@ -294,6 +294,8 @@ loopdone:
 			*lnp->firstchp = newx;
 #ifdef DEBUG
 		{
+			int i;
+
 			__CTRACE(__CTRACE_INPUT, "before===\n");
 			for (i = 0; i < win->maxx; i++)
 			__CTRACE(__CTRACE_INPUT,
@@ -334,6 +336,8 @@ loopdone:
 			}
 #ifdef DEBUG
 			{
+int i;
+
 __CTRACE(__CTRACE_INPUT, "=after shift\n");
 for (i = 0; i < win->maxx; i++)
 	__CTRACE(__CTRACE_INPUT,
@@ -363,6 +367,8 @@ loopdone:
 
 #ifdef DEBUG
 		{
+			int i;
+
 			__CTRACE(__CTRACE_INPUT, "lx = %d, x = %x\n", lx, x);
 			__CTRACE(__CTRACE_INPUT, "after===\n");
 			for (i = 0; i < win->maxx; i++)



CVS commit: src/lib/libcurses

2021-11-16 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Tue Nov 16 23:23:02 UTC 2021

Modified Files:
src/lib/libcurses: ins_wstr.c

Log Message:
Move 'i' into DEBUG only code (now there be three).
Hopefully unbreaks !DEBUG builds.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 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.



CVS commit: src/lib/libcurses

2021-11-16 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Tue Nov 16 21:00:50 UTC 2021

Modified Files:
src/lib/libcurses: ins_wstr.c

Log Message:
Fix handling of the tab special character.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 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/ins_wstr.c
diff -u src/lib/libcurses/ins_wstr.c:1.18 src/lib/libcurses/ins_wstr.c:1.19
--- src/lib/libcurses/ins_wstr.c:1.18	Mon Nov 15 06:27:06 2021
+++ src/lib/libcurses/ins_wstr.c	Tue Nov 16 21:00:50 2021
@@ -1,4 +1,4 @@
-/*   $NetBSD: ins_wstr.c,v 1.18 2021/11/15 06:27:06 blymn Exp $ */
+/*   $NetBSD: ins_wstr.c,v 1.19 2021/11/16 21:00:50 blymn Exp $ */
 
 /*
  * Copyright (c) 2005 The NetBSD Foundation Inc.
@@ -36,7 +36,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: ins_wstr.c,v 1.18 2021/11/15 06:27:06 blymn Exp $");
+__RCSID("$NetBSD: ins_wstr.c,v 1.19 2021/11/16 21:00:50 blymn Exp $");
 #endif		  /* not lint */
 
 #include 
@@ -194,9 +194,12 @@ wins_nwstr(WINDOW *win, const wchar_t *w
 continue;
 
 			case L'\t':
-w = min(win->maxx - x, TABSIZE - (x % TABSIZE));
-width += w * wcwidth(ws[0]);
-x += w * wcwidth(ws[0]);
+cw = wcwidth(ws[0]);
+if (cw < 0)
+	cw = 1;
+w = cw * (TABSIZE - (x % TABSIZE));
+width += w;
+x += w;
 scp++;
 continue;
 		}
@@ -254,16 +257,16 @@ wins_nwstr(WINDOW *win, const wchar_t *w
 	break;
 
 case L'\t':
-	w = min(win->maxx - x,
-	TABSIZE - (x % TABSIZE));
-	width += w * wcwidth(ws[0]);
-	x += w * wcwidth(ws[0]);
+	cw = wcwidth(ws[0]);
+	if (cw < 0)
+		cw = 1;
+	w = cw * (TABSIZE - (x % TABSIZE));
+	width += w;
+	x += w;
 	len += w;
 	scp++;
-	for (i = 0; i < w; i++ ) {
-		*lstr = *ws;
-		lstr++;
-	}
+	*lstr = *ws;
+	lstr++;
 	continue;
 			}
 			w = wcwidth(*scp);



CVS commit: src/lib/libcurses

2021-11-16 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Tue Nov 16 21:00:50 UTC 2021

Modified Files:
src/lib/libcurses: ins_wstr.c

Log Message:
Fix handling of the tab special character.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 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.



CVS commit: src/lib/libcurses

2021-11-14 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Mon Nov 15 06:27:06 UTC 2021

Modified Files:
src/lib/libcurses: ins_wstr.c

Log Message:
Fix for PR lib/55433

Correct the behaviour for ins_wstr:
* Properly check the string will fit by processing any special
  characters present when preforming the check.
* Simplify the routine by removing code that duplicates the code in
  _cursesi_addwchar and just call _cursesi_addwchar.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 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/ins_wstr.c
diff -u src/lib/libcurses/ins_wstr.c:1.17 src/lib/libcurses/ins_wstr.c:1.18
--- src/lib/libcurses/ins_wstr.c:1.17	Mon Sep  6 07:45:48 2021
+++ src/lib/libcurses/ins_wstr.c	Mon Nov 15 06:27:06 2021
@@ -1,4 +1,4 @@
-/*   $NetBSD: ins_wstr.c,v 1.17 2021/09/06 07:45:48 rin Exp $ */
+/*   $NetBSD: ins_wstr.c,v 1.18 2021/11/15 06:27:06 blymn Exp $ */
 
 /*
  * Copyright (c) 2005 The NetBSD Foundation Inc.
@@ -36,7 +36,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: ins_wstr.c,v 1.17 2021/09/06 07:45:48 rin Exp $");
+__RCSID("$NetBSD: ins_wstr.c,v 1.18 2021/11/15 06:27:06 blymn Exp $");
 #endif		  /* not lint */
 
 #include 
@@ -133,8 +133,9 @@ wins_nwstr(WINDOW *win, const wchar_t *w
 	__LDATA	 *start, *temp1, *temp2;
 	__LINE	  *lnp;
 	const wchar_t *scp;
-	int width, len, sx, x, y, cw, pcw, newx;
-	nschar_t *np;
+	cchar_t cc;
+	wchar_t *lstr, *slstr;
+	int i, width, len, lx, sx, x, y, tx, ty, cw, pcw, newx, tn, w;
 	wchar_t ws[] = L"		";
 
 	/* check for leading non-spacing character */
@@ -146,171 +147,259 @@ wins_nwstr(WINDOW *win, const wchar_t *w
 	if (!cw)
 		return ERR;
 
+	lstr = malloc(sizeof(wchar_t) * win->maxx);
+	if (lstr == NULL)
+		return ERR;
+
 	scp = wstr + 1;
 	width = cw;
 	len = 1;
 	n--;
+	y = win->cury;
+	x = win->curx;
+	tn = n;
+
+	/*
+	 * Firstly, make sure the string will fit...
+	 */
 	while (*scp) {
-		int w;
-		if (!n)
+		if (!tn)
 			break;
+		switch (*scp) {
+			case L'\b':
+if (--x < 0)
+	x = 0;
+cw = wcwidth(*(scp - 1));
+if (cw < 0)
+	cw = 1;
+width -= cw;
+scp++;
+continue;;
+
+			case L'\r':
+width = 0;
+x = 0;
+scp++;
+continue;
+
+			case L'\n':
+if (y == win->scr_b) {
+	if (!(win->flags & __SCROLLOK)) {
+		free(lstr);
+		return ERR;
+	}
+}
+y++;
+scp++;
+continue;
+
+			case L'\t':
+w = min(win->maxx - x, TABSIZE - (x % TABSIZE));
+width += w * wcwidth(ws[0]);
+x += w * wcwidth(ws[0]);
+scp++;
+continue;
+		}
 		w = wcwidth(*scp);
 		if (w < 0)
 			w = 1;
-		n--, len++, width += w;
+		tn--, width += w;
 		scp++;
 	}
 	__CTRACE(__CTRACE_INPUT, "wins_nwstr: width=%d,len=%d\n", width, len);
 
-	if (cw > win->maxx - win->curx + 1)
+	if (width > win->maxx - win->curx + 1) {
+		free(lstr);
 		return ERR;
-	start = >alines[win->cury]->line[win->curx];
-	sx = win->curx;
-	lnp = win->alines[win->cury];
-	pcw = WCOL(*start);
-	if (pcw < 0) {
-		sx += pcw;
-		start += pcw;
 	}
-	__CTRACE(__CTRACE_INPUT, "wins_nwstr: start@(%d)\n", sx);
-	pcw = WCOL(*start);
-	lnp->flags |= __ISDIRTY;
-	newx = sx + win->ch_off;
-	if (newx < *lnp->firstchp)
-		*lnp->firstchp = newx;
+
+	scp = wstr;
+	x = win->curx;
+	y = win->cury;
+	len = 0;
+	width = 0;
+	slstr = lstr;
+
+	while (*scp && n) {
+		lstr = slstr;
+		lx = x;
+		while (*scp) {
+			if (!n)
+break;
+			switch (*scp) {
+case L'\b':
+	if (--x < 0)
+		x = 0;
+	if (--len < 0)
+		len = 0;
+	cw = wcwidth(*(scp - 1));
+	if (cw < 0)
+		cw = 1;
+	width -= cw;
+	scp++;
+	if (lstr != slstr)
+		lstr--;
+	continue;;
+
+case L'\r':
+	width = 0;
+	len = 0;
+	x = 0;
+	scp++;
+	lstr = slstr;
+	continue;
+
+case L'\n':
+	goto loopdone;
+	break;
+
+case L'\t':
+	w = min(win->maxx - x,
+	TABSIZE - (x % TABSIZE));
+	width += w * wcwidth(ws[0]);
+	x += w * wcwidth(ws[0]);
+	len += w;
+	scp++;
+	for (i = 0; i < w; i++ ) {
+		*lstr = *ws;
+		lstr++;
+	}
+	continue;
+			}
+			w = wcwidth(*scp);
+			if (w < 0)
+w = 1;
+			*lstr = *scp;
+			n--, len++, width += w;
+			scp++, lstr++;
+		}
+
+loopdone:
+		start = >alines[y]->line[x];
+		sx = x;
+		lnp = win->alines[y];
+		pcw = WCOL(*start);
+		if (pcw < 0) {
+			sx += pcw;
+			start += pcw;
+		}
+		__CTRACE(__CTRACE_INPUT, "wins_nwstr: start@(%d)\n", sx);
+		pcw = WCOL(*start);
+		lnp->flags |= __ISDIRTY;
+		newx = sx + win->ch_off;
+		if (newx < *lnp->firstchp)
+			*lnp->firstchp = newx;
 #ifdef DEBUG
-	{
-		__CTRACE(__CTRACE_INPUT, "before===\n");
-		for (x = 0; x < win->maxx; x++)
+		{
+			__CTRACE(__CTRACE_INPUT, "before===\n");
+			for (i = 0; i < win->maxx; i++)
 			__CTRACE(__CTRACE_INPUT,
-			"wins_nwstr: (%d,%d)=(%x,%x,%p)\n",
-			 

CVS commit: src/lib/libcurses

2021-11-14 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Mon Nov 15 06:27:06 UTC 2021

Modified Files:
src/lib/libcurses: ins_wstr.c

Log Message:
Fix for PR lib/55433

Correct the behaviour for ins_wstr:
* Properly check the string will fit by processing any special
  characters present when preforming the check.
* Simplify the routine by removing code that duplicates the code in
  _cursesi_addwchar and just call _cursesi_addwchar.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 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.



CVS commit: src/lib/libcurses

2021-10-19 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Tue Oct 19 06:41:03 UTC 2021

Modified Files:
src/lib/libcurses: addnstr.c border.c move.c newwin.c

Log Message:
Add a bit more debug.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/lib/libcurses/addnstr.c
cvs rdiff -u -r1.20 -r1.21 src/lib/libcurses/border.c
cvs rdiff -u -r1.22 -r1.23 src/lib/libcurses/move.c
cvs rdiff -u -r1.62 -r1.63 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/addnstr.c
diff -u src/lib/libcurses/addnstr.c:1.19 src/lib/libcurses/addnstr.c:1.20
--- src/lib/libcurses/addnstr.c:1.19	Mon Sep  6 07:45:48 2021
+++ src/lib/libcurses/addnstr.c	Tue Oct 19 06:41:03 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: addnstr.c,v 1.19 2021/09/06 07:45:48 rin Exp $	*/
+/*	$NetBSD: addnstr.c,v 1.20 2021/10/19 06:41:03 blymn Exp $	*/
 
 /*
  * Copyright (c) 1993, 1994
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)addnstr.c	8.2 (Berkeley) 5/4/94";
 #else
-__RCSID("$NetBSD: addnstr.c,v 1.19 2021/09/06 07:45:48 rin Exp $");
+__RCSID("$NetBSD: addnstr.c,v 1.20 2021/10/19 06:41:03 blymn Exp $");
 #endif
 #endif/* not lint */
 
@@ -136,6 +136,7 @@ waddnstr(WINDOW *win, const char *s, int
 	const char *p;
 
 	__CTRACE(__CTRACE_INPUT, "ADDNSTR: win %p, length %d\n", win, n);
+	__CTRACE(__CTRACE_INPUT, "ADDNSTR: string %s\n", s);
 	/*
 	 * behavior changed from traditional BSD curses, for better XCURSES
 	 * conformance.

Index: src/lib/libcurses/border.c
diff -u src/lib/libcurses/border.c:1.20 src/lib/libcurses/border.c:1.21
--- src/lib/libcurses/border.c:1.20	Mon Sep  6 07:45:48 2021
+++ src/lib/libcurses/border.c	Tue Oct 19 06:41:03 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: border.c,v 1.20 2021/09/06 07:45:48 rin Exp $	*/
+/*	$NetBSD: border.c,v 1.21 2021/10/19 06:41:03 blymn Exp $	*/
 
 /*
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: border.c,v 1.20 2021/09/06 07:45:48 rin Exp $");
+__RCSID("$NetBSD: border.c,v 1.21 2021/10/19 06:41:03 blymn Exp $");
 #endif/* not lint */
 
 #include 
@@ -87,6 +87,7 @@ wborder(WINDOW *win, chtype left, chtype
 	if (!(botright & __CHARTEXT))
 		botright |= ACS_LRCORNER;
 
+	__CTRACE(__CTRACE_INPUT, "wborder: window 0x%p\n", win);
 	__CTRACE(__CTRACE_INPUT, "wborder: left = %c, 0x%x\n",
 	left & __CHARTEXT, left & __ATTRIBUTES);
 	__CTRACE(__CTRACE_INPUT, "wborder: right = %c, 0x%x\n",
@@ -237,6 +238,7 @@ int wborder_set(WINDOW *win, const cchar
 	else
 		memcpy(, WACS_LRCORNER, sizeof(cchar_t));
 
+	__CTRACE(__CTRACE_INPUT, "wborder_set: window 0x%p\n", win);
 	__CTRACE(__CTRACE_INPUT, "wborder_set: left = %c, 0x%x\n",
 	left.vals[0], left.attributes );
 	__CTRACE(__CTRACE_INPUT, "wborder_set: right = %c, 0x%x\n",

Index: src/lib/libcurses/move.c
diff -u src/lib/libcurses/move.c:1.22 src/lib/libcurses/move.c:1.23
--- src/lib/libcurses/move.c:1.22	Mon Sep  6 07:03:50 2021
+++ src/lib/libcurses/move.c	Tue Oct 19 06:41:03 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: move.c,v 1.22 2021/09/06 07:03:50 rin Exp $	*/
+/*	$NetBSD: move.c,v 1.23 2021/10/19 06:41:03 blymn Exp $	*/
 
 /*
  * Copyright (c) 1981, 1993, 1994
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)move.c	8.2 (Berkeley) 5/4/94";
 #else
-__RCSID("$NetBSD: move.c,v 1.22 2021/09/06 07:03:50 rin Exp $");
+__RCSID("$NetBSD: move.c,v 1.23 2021/10/19 06:41:03 blymn Exp $");
 #endif
 #endif/* not lint */
 
@@ -62,7 +62,7 @@ move(int y, int x)
 int
 wmove(WINDOW *win, int y, int x)
 {
-	__CTRACE(__CTRACE_MISC, "wmove: (%d, %d)\n", y, x);
+	__CTRACE(__CTRACE_MISC, "wmove: win %p, (%d, %d)\n", win, y, x);
 	if (x < 0 || y < 0)
 		return ERR;
 	if (x >= win->maxx || y >= win->maxy)

Index: src/lib/libcurses/newwin.c
diff -u src/lib/libcurses/newwin.c:1.62 src/lib/libcurses/newwin.c:1.63
--- src/lib/libcurses/newwin.c:1.62	Tue Sep  7 01:23:09 2021
+++ src/lib/libcurses/newwin.c	Tue Oct 19 06:41:03 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: newwin.c,v 1.62 2021/09/07 01:23:09 rin Exp $	*/
+/*	$NetBSD: newwin.c,v 1.63 2021/10/19 06:41:03 blymn 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.62 2021/09/07 01:23:09 rin Exp $");
+__RCSID("$NetBSD: newwin.c,v 1.63 2021/10/19 06:41:03 blymn Exp $");
 #endif
 #endif/* not lint */
 
@@ -365,6 +365,8 @@ __makenew(SCREEN *screen, int nlines, in
 		win->smaxx = 0;
 	} else
 		__swflags(win);
+	__CTRACE(__CTRACE_WINDOW, "makenew: sub = %d\n", sub);
+	__CTRACE(__CTRACE_WINDOW, "makenew: ispad = %d\n", ispad);
 	__CTRACE(__CTRACE_WINDOW, "makenew: win->wattr = %08x\n", win->wattr);
 	__CTRACE(__CTRACE_WINDOW, "makenew: win->flags = %#.4x\n", win->flags);
 	__CTRACE(__CTRACE_WINDOW, "makenew: win->maxy = %d\n", win->maxy);



CVS commit: src/lib/libcurses

2021-10-19 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Tue Oct 19 06:41:03 UTC 2021

Modified Files:
src/lib/libcurses: addnstr.c border.c move.c newwin.c

Log Message:
Add a bit more debug.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/lib/libcurses/addnstr.c
cvs rdiff -u -r1.20 -r1.21 src/lib/libcurses/border.c
cvs rdiff -u -r1.22 -r1.23 src/lib/libcurses/move.c
cvs rdiff -u -r1.62 -r1.63 src/lib/libcurses/newwin.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libcurses

2021-10-19 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Tue Oct 19 06:37:29 UTC 2021

Modified Files:
src/lib/libcurses: getch.c

Log Message:
Fix for PR pkg/55931
Don't move the cursor when getch is called if input is not going to
be echoed.  Lynx uses the cursor to mark the current selection in a
pop-up, previously the cursor was being relocated when getch was called
which broke the Lynx item marking.


To generate a diff of this commit:
cvs rdiff -u -r1.77 -r1.78 src/lib/libcurses/getch.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libcurses

2021-10-19 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Tue Oct 19 06:37:29 UTC 2021

Modified Files:
src/lib/libcurses: getch.c

Log Message:
Fix for PR pkg/55931
Don't move the cursor when getch is called if input is not going to
be echoed.  Lynx uses the cursor to mark the current selection in a
pop-up, previously the cursor was being relocated when getch was called
which broke the Lynx item marking.


To generate a diff of this commit:
cvs rdiff -u -r1.77 -r1.78 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.77 src/lib/libcurses/getch.c:1.78
--- src/lib/libcurses/getch.c:1.77	Mon Sep  6 07:45:48 2021
+++ src/lib/libcurses/getch.c	Tue Oct 19 06:37:29 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: getch.c,v 1.77 2021/09/06 07:45:48 rin Exp $	*/
+/*	$NetBSD: getch.c,v 1.78 2021/10/19 06:37:29 blymn 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.77 2021/09/06 07:45:48 rin Exp $");
+__RCSID("$NetBSD: getch.c,v 1.78 2021/10/19 06:37:29 blymn Exp $");
 #endif
 #endif	/* not lint */
 
@@ -800,8 +800,8 @@ wgetch(WINDOW *win)
 	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))) {
+		else if (__echoit && ((_cursesi_screen->curscr->cury != (win->begy + win->cury))
+		 || (_cursesi_screen->curscr->curx != (win->begx + win->curx {
 			__CTRACE(__CTRACE_INPUT,
 			"wgetch: curscr cury %d cury %d "
 			"curscr curx %d curx %d\n",



CVS commit: src/lib/libcurses

2021-09-07 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Tue Sep  7 12:36:57 UTC 2021

Modified Files:
src/lib/libcurses: fileio.c

Log Message:
Do not compile in whole fileio.c for LIBHACK.

Fix build failure when built as libhack, due to missing fileio.h.

IMO, this should be cleaner than generating fileio.h for {get,put}win(3),
that are useless for install media.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/lib/libcurses/fileio.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libcurses

2021-09-07 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Tue Sep  7 12:36:57 UTC 2021

Modified Files:
src/lib/libcurses: fileio.c

Log Message:
Do not compile in whole fileio.c for LIBHACK.

Fix build failure when built as libhack, due to missing fileio.h.

IMO, this should be cleaner than generating fileio.h for {get,put}win(3),
that are useless for install media.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/lib/libcurses/fileio.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/fileio.c
diff -u src/lib/libcurses/fileio.c:1.8 src/lib/libcurses/fileio.c:1.9
--- src/lib/libcurses/fileio.c:1.8	Mon Sep  6 07:03:49 2021
+++ src/lib/libcurses/fileio.c	Tue Sep  7 12:36:57 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: fileio.c,v 1.8 2021/09/06 07:03:49 rin Exp $	*/
+/*	$NetBSD: fileio.c,v 1.9 2021/09/07 12:36:57 rin Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -29,9 +29,10 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#ifndef LIBHACK
 #include 
 #ifndef lint
-__RCSID("$NetBSD: fileio.c,v 1.8 2021/09/06 07:03:49 rin Exp $");
+__RCSID("$NetBSD: fileio.c,v 1.9 2021/09/07 12:36:57 rin Exp $");
 #endif/* not lint */
 
 #include "curses.h"
@@ -241,3 +242,4 @@ error0:
 		free(wtmp);
 	return NULL;
 }
+#endif /* !LIBHACK */



CVS commit: src/lib/libcurses

2021-09-06 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Tue Sep  7 01:23:10 UTC 2021

Modified Files:
src/lib/libcurses: cur_hash.c curses_private.h newwin.c refresh.c
resize.c

Log Message:
PR lib/56388

For __newwin() and __resizewin(), the line hash was calculated as if
HAVE_WCHAR is disabled.

Fix this bug by refactoring __hash_line() function, which calculates
the line hash by an appropriate method.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/lib/libcurses/cur_hash.c
cvs rdiff -u -r1.75 -r1.76 src/lib/libcurses/curses_private.h
cvs rdiff -u -r1.61 -r1.62 src/lib/libcurses/newwin.c
cvs rdiff -u -r1.115 -r1.116 src/lib/libcurses/refresh.c
cvs rdiff -u -r1.32 -r1.33 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/cur_hash.c
diff -u src/lib/libcurses/cur_hash.c:1.13 src/lib/libcurses/cur_hash.c:1.14
--- src/lib/libcurses/cur_hash.c:1.13	Fri Jan  6 09:14:07 2017
+++ src/lib/libcurses/cur_hash.c	Tue Sep  7 01:23:09 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: cur_hash.c,v 1.13 2017/01/06 09:14:07 roy Exp $	*/
+/*	$NetBSD: cur_hash.c,v 1.14 2021/09/07 01:23:09 rin Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)cur_hash.c	8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: cur_hash.c,v 1.13 2017/01/06 09:14:07 roy Exp $");
+__RCSID("$NetBSD: cur_hash.c,v 1.14 2021/09/07 01:23:09 rin Exp $");
 #endif
 #endif/* not lint */
 
@@ -63,3 +63,25 @@ __hash_more(const void  *v_s, size_t len
 	}
 	return h;
 }
+
+unsigned int
+__hash_line(const __LDATA *cp, int ncols)
+{
+#ifdef HAVE_WCHAR
+	unsigned int h;
+	const nschar_t *np;
+	int x;
+
+	h = 0;
+	for (x = 0; x < ncols; x++) {
+		h = __hash_more(>ch, sizeof(cp->ch), h);
+		h = __hash_more(>attr, sizeof(cp->attr), h);
+		for (np = cp->nsp; np != NULL; np = np->next)
+			h = __hash_more(>ch, sizeof(np->ch), h);
+		cp++;
+	}
+	return h;
+#else
+	return __hash(cp, (size_t)(ncols * __LDATASIZE));
+#endif
+}

Index: src/lib/libcurses/curses_private.h
diff -u src/lib/libcurses/curses_private.h:1.75 src/lib/libcurses/curses_private.h:1.76
--- src/lib/libcurses/curses_private.h:1.75	Mon Sep  6 07:03:49 2021
+++ src/lib/libcurses/curses_private.h	Tue Sep  7 01:23:09 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: curses_private.h,v 1.75 2021/09/06 07:03:49 rin Exp $	*/
+/*	$NetBSD: curses_private.h,v 1.76 2021/09/07 01:23:09 rin Exp $	*/
 
 /*-
  * Copyright (c) 1998-2000 Brett Lymn
@@ -373,6 +373,7 @@ void _cursesi_resetterm(SCREEN *);
 int  _cursesi_setterm(char *, SCREEN *);
 int	 __delay(void);
 unsigned int	 __hash_more(const void *, size_t, unsigned int);
+unsigned int	 __hash_line(const __LDATA *, int);
 #define	__hash(s, len)	__hash_more((s), (len), 0u)
 void	 __id_subwins(WINDOW *);
 void	 __init_getch(SCREEN *);

Index: src/lib/libcurses/newwin.c
diff -u src/lib/libcurses/newwin.c:1.61 src/lib/libcurses/newwin.c:1.62
--- src/lib/libcurses/newwin.c:1.61	Mon Sep  6 07:03:50 2021
+++ src/lib/libcurses/newwin.c	Tue Sep  7 01:23:09 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: newwin.c,v 1.61 2021/09/06 07:03:50 rin Exp $	*/
+/*	$NetBSD: newwin.c,v 1.62 2021/09/07 01:23:09 rin 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.61 2021/09/06 07:03:50 rin Exp $");
+__RCSID("$NetBSD: newwin.c,v 1.62 2021/09/07 01:23:09 rin Exp $");
 #endif
 #endif/* not lint */
 
@@ -169,8 +169,7 @@ __newwin(SCREEN *screen, int nlines, int
 			SET_WCOL(*sp, 1);
 #endif /* HAVE_WCHAR */
 		}
-		lp->hash = __hash((char *)(void *)lp->line,
-  (size_t)(maxx * __LDATASIZE));
+		lp->hash = __hash_line(lp->line, maxx);
 	}
 	return (win);
 }
@@ -227,11 +226,6 @@ __set_subwin(WINDOW *orig, WINDOW *win)
 {
 	int i;
 	__LINE *lp, *olp;
-#ifdef HAVE_WCHAR
-	__LDATA *cp;
-	int j;
-	nschar_t *np;
-#endif /* HAVE_WCHAR */
 
 	win->ch_off = win->begx - orig->begx;
 	/* Point line pointers to line space. */
@@ -244,26 +238,7 @@ __set_subwin(WINDOW *orig, WINDOW *win)
 		lp->line = >line[win->ch_off];
 		lp->firstchp = >firstch;
 		lp->lastchp = >lastch;
-#ifndef HAVE_WCHAR
-		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( >ch,
-			sizeof( wchar_t ), lp->hash );
-			lp->hash = __hash_more( >attr,
-			sizeof( wchar_t ), lp->hash );
-			if ( cp->nsp ) {
-np = cp->nsp;
-while ( np ) {
-	lp->hash = __hash_more( >ch,
-	sizeof( wchar_t ), lp->hash );
-	np = np->next;
-}
-			}
-		}
-#endif /* HAVE_WCHAR */
+		lp->hash = __hash_line(lp->line, win->maxx);
 	}
 
 	__CTRACE(__CTRACE_WINDOW, "__set_subwin: win->ch_off = %d\n",

Index: src/lib/libcurses/refresh.c
diff -u 

CVS commit: src/lib/libcurses

2021-09-06 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Tue Sep  7 01:23:10 UTC 2021

Modified Files:
src/lib/libcurses: cur_hash.c curses_private.h newwin.c refresh.c
resize.c

Log Message:
PR lib/56388

For __newwin() and __resizewin(), the line hash was calculated as if
HAVE_WCHAR is disabled.

Fix this bug by refactoring __hash_line() function, which calculates
the line hash by an appropriate method.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/lib/libcurses/cur_hash.c
cvs rdiff -u -r1.75 -r1.76 src/lib/libcurses/curses_private.h
cvs rdiff -u -r1.61 -r1.62 src/lib/libcurses/newwin.c
cvs rdiff -u -r1.115 -r1.116 src/lib/libcurses/refresh.c
cvs rdiff -u -r1.32 -r1.33 src/lib/libcurses/resize.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libcurses

2021-09-06 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Mon Sep  6 15:17:25 UTC 2021

Modified Files:
src/lib/libcurses: Makefile shlib_version
Removed Files:
src/lib/libcurses: fileio.h

Log Message:
Always autogen fileio.h.

Bump CURSES_LIB_MAJOR.CURSES_LIB_MINOR to 9.0 belatedly.


To generate a diff of this commit:
cvs rdiff -u -r1.95 -r1.96 src/lib/libcurses/Makefile
cvs rdiff -u -r1.7 -r0 src/lib/libcurses/fileio.h
cvs rdiff -u -r1.45 -r1.46 src/lib/libcurses/shlib_version

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.95 src/lib/libcurses/Makefile:1.96
--- src/lib/libcurses/Makefile:1.95	Sun Jun 27 16:24:52 2021
+++ src/lib/libcurses/Makefile	Mon Sep  6 15:17:25 2021
@@ -1,11 +1,11 @@
-#	$NetBSD: Makefile,v 1.95 2021/06/27 16:24:52 christos Exp $
+#	$NetBSD: Makefile,v 1.96 2021/09/06 15:17:25 rin Exp $
 #	@(#)Makefile	8.2 (Berkeley) 1/2/94
 
 .include 
 
 WARNS=	2
 
-CPPFLAGS+=-I${.CURDIR} -I${NETBSDSRCDIR}/lib/libterminfo
+CPPFLAGS+=-I${.CURDIR} -I${NETBSDSRCDIR}/lib/libterminfo -I.
 .if defined(DEBUG_CURSES)
 CPPFLAGS+=-g -DDEBUG
 .endif
@@ -215,8 +215,12 @@ MLINKS+= curses_addch.3 addch.3 curses_a
 
 SUBDIR.roff+= PSD.doc
 
+DPSRCS+=	fileio.h
+CLEANFILES+=	fileio.h
+
 fileio.h: shlib_version genfileioh.awk
-	${TOOL_AWK} -f ${.CURDIR}/genfileioh.awk < ${.CURDIR}/shlib_version > ${.CURDIR}/fileio.h
+	${TOOL_AWK} -f ${.CURDIR}/genfileioh.awk < ${.CURDIR}/shlib_version \
+	> ${.TARGET}
 
 .include 
 .include 

Index: src/lib/libcurses/shlib_version
diff -u src/lib/libcurses/shlib_version:1.45 src/lib/libcurses/shlib_version:1.46
--- src/lib/libcurses/shlib_version:1.45	Fri Mar 13 15:19:24 2020
+++ src/lib/libcurses/shlib_version	Mon Sep  6 15:17:25 2021
@@ -1,6 +1,5 @@
-#	$NetBSD: shlib_version,v 1.45 2020/03/13 15:19:24 roy Exp $
+#	$NetBSD: shlib_version,v 1.46 2021/09/06 15:17:25 rin 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.
 #



CVS commit: src/lib/libcurses

2021-09-06 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Mon Sep  6 15:17:25 UTC 2021

Modified Files:
src/lib/libcurses: Makefile shlib_version
Removed Files:
src/lib/libcurses: fileio.h

Log Message:
Always autogen fileio.h.

Bump CURSES_LIB_MAJOR.CURSES_LIB_MINOR to 9.0 belatedly.


To generate a diff of this commit:
cvs rdiff -u -r1.95 -r1.96 src/lib/libcurses/Makefile
cvs rdiff -u -r1.7 -r0 src/lib/libcurses/fileio.h
cvs rdiff -u -r1.45 -r1.46 src/lib/libcurses/shlib_version

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libcurses

2021-09-06 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Mon Sep  6 07:45:48 UTC 2021

Modified Files:
src/lib/libcurses: add_wchstr.c addbytes.c addch.c addnstr.c addwstr.c
background.c border.c chgat.c color.c cr_put.c curs_set.c get_wch.c
getch.c ins_wstr.c mvwin.c refresh.c setterm.c slk.c

Log Message:
Style fixes most for __CTRACE().


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/lib/libcurses/add_wchstr.c
cvs rdiff -u -r1.58 -r1.59 src/lib/libcurses/addbytes.c
cvs rdiff -u -r1.22 -r1.23 src/lib/libcurses/addch.c \
src/lib/libcurses/mvwin.c
cvs rdiff -u -r1.18 -r1.19 src/lib/libcurses/addnstr.c
cvs rdiff -u -r1.7 -r1.8 src/lib/libcurses/addwstr.c
cvs rdiff -u -r1.26 -r1.27 src/lib/libcurses/background.c
cvs rdiff -u -r1.19 -r1.20 src/lib/libcurses/border.c
cvs rdiff -u -r1.6 -r1.7 src/lib/libcurses/chgat.c
cvs rdiff -u -r1.43 -r1.44 src/lib/libcurses/color.c
cvs rdiff -u -r1.36 -r1.37 src/lib/libcurses/cr_put.c
cvs rdiff -u -r1.11 -r1.12 src/lib/libcurses/curs_set.c
cvs rdiff -u -r1.25 -r1.26 src/lib/libcurses/get_wch.c
cvs rdiff -u -r1.76 -r1.77 src/lib/libcurses/getch.c
cvs rdiff -u -r1.16 -r1.17 src/lib/libcurses/ins_wstr.c
cvs rdiff -u -r1.114 -r1.115 src/lib/libcurses/refresh.c
cvs rdiff -u -r1.70 -r1.71 src/lib/libcurses/setterm.c
cvs rdiff -u -r1.15 -r1.16 src/lib/libcurses/slk.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libcurses

2021-09-06 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Mon Sep  6 07:45:48 UTC 2021

Modified Files:
src/lib/libcurses: add_wchstr.c addbytes.c addch.c addnstr.c addwstr.c
background.c border.c chgat.c color.c cr_put.c curs_set.c get_wch.c
getch.c ins_wstr.c mvwin.c refresh.c setterm.c slk.c

Log Message:
Style fixes most for __CTRACE().


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/lib/libcurses/add_wchstr.c
cvs rdiff -u -r1.58 -r1.59 src/lib/libcurses/addbytes.c
cvs rdiff -u -r1.22 -r1.23 src/lib/libcurses/addch.c \
src/lib/libcurses/mvwin.c
cvs rdiff -u -r1.18 -r1.19 src/lib/libcurses/addnstr.c
cvs rdiff -u -r1.7 -r1.8 src/lib/libcurses/addwstr.c
cvs rdiff -u -r1.26 -r1.27 src/lib/libcurses/background.c
cvs rdiff -u -r1.19 -r1.20 src/lib/libcurses/border.c
cvs rdiff -u -r1.6 -r1.7 src/lib/libcurses/chgat.c
cvs rdiff -u -r1.43 -r1.44 src/lib/libcurses/color.c
cvs rdiff -u -r1.36 -r1.37 src/lib/libcurses/cr_put.c
cvs rdiff -u -r1.11 -r1.12 src/lib/libcurses/curs_set.c
cvs rdiff -u -r1.25 -r1.26 src/lib/libcurses/get_wch.c
cvs rdiff -u -r1.76 -r1.77 src/lib/libcurses/getch.c
cvs rdiff -u -r1.16 -r1.17 src/lib/libcurses/ins_wstr.c
cvs rdiff -u -r1.114 -r1.115 src/lib/libcurses/refresh.c
cvs rdiff -u -r1.70 -r1.71 src/lib/libcurses/setterm.c
cvs rdiff -u -r1.15 -r1.16 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/add_wchstr.c
diff -u src/lib/libcurses/add_wchstr.c:1.9 src/lib/libcurses/add_wchstr.c:1.10
--- src/lib/libcurses/add_wchstr.c:1.9	Mon Sep  6 07:03:49 2021
+++ src/lib/libcurses/add_wchstr.c	Mon Sep  6 07:45:48 2021
@@ -1,4 +1,4 @@
-/*   $NetBSD: add_wchstr.c,v 1.9 2021/09/06 07:03:49 rin Exp $ */
+/*   $NetBSD: add_wchstr.c,v 1.10 2021/09/06 07:45:48 rin Exp $ */
 
 /*
  * Copyright (c) 2005 The NetBSD Foundation Inc.
@@ -36,7 +36,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: add_wchstr.c,v 1.9 2021/09/06 07:03:49 rin Exp $");
+__RCSID("$NetBSD: add_wchstr.c,v 1.10 2021/09/06 07:45:48 rin Exp $");
 #endif/* not lint */
 
 #include 
@@ -244,8 +244,8 @@ wadd_wchnstr(WINDOW *win, const cchar_t 
 			}
 			lp++, ex++;
 			__CTRACE(__CTRACE_INPUT,
-"wadd_wchnstr: ex = %d, x = %d, cw = %d\n",
- ex, x, cw);
+			"wadd_wchnstr: ex = %d, x = %d, cw = %d\n",
+			ex, x, cw);
 			while (ex - x <= cw - 1) {
 np = lp->nsp;
 if (np) {
@@ -264,7 +264,7 @@ wadd_wchnstr(WINDOW *win, const cchar_t 
 		} else {
 			/* non-spacing character */
 			__CTRACE(__CTRACE_INPUT,
-"wadd_wchnstr: as non-spacing char");
+			"wadd_wchnstr: as non-spacing char");
 			for (i = 0; i < chp->elements; i++) {
 np = malloc(sizeof(nschar_t));
 if (!np)

Index: src/lib/libcurses/addbytes.c
diff -u src/lib/libcurses/addbytes.c:1.58 src/lib/libcurses/addbytes.c:1.59
--- src/lib/libcurses/addbytes.c:1.58	Mon Sep  6 07:08:25 2021
+++ src/lib/libcurses/addbytes.c	Mon Sep  6 07:45:48 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: addbytes.c,v 1.58 2021/09/06 07:08:25 rin Exp $	*/
+/*	$NetBSD: addbytes.c,v 1.59 2021/09/06 07:45:48 rin 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.58 2021/09/06 07:08:25 rin Exp $");
+__RCSID("$NetBSD: addbytes.c,v 1.59 2021/09/06 07:45:48 rin Exp $");
 #endif
 #endif/* not lint */
 
@@ -253,8 +253,7 @@ _cursesi_addbyte(WINDOW *win, __LINE **l
 		(*lp)->flags &= ~__ISPASTEOL;
 		if (*y == win->scr_b) {
 			__CTRACE(__CTRACE_INPUT,
- "ADDBYTES - on bottom "
- "of scrolling region\n");
+			"ADDBYTES - on bottom of scrolling region\n");
 			if (!(win->flags & __SCROLLOK))
 return ERR;
 			scroll(win);
@@ -267,9 +266,8 @@ _cursesi_addbyte(WINDOW *win, __LINE **l
 	}
 
 	__CTRACE(__CTRACE_INPUT,
-		 "ADDBYTES: 1: y = %d, x = %d, firstch = %d, lastch = %d\n",
-		 *y, *x, *win->alines[*y]->firstchp,
-		 *win->alines[*y]->lastchp);
+	"ADDBYTES: 1: y = %d, x = %d, firstch = %d, lastch = %d\n",
+	*y, *x, *win->alines[*y]->firstchp, *win->alines[*y]->lastchp);
 
 	attributes = (win->wattr | attr) & (__ATTRIBUTES & ~__COLOR);
 	if (attr & __COLOR)
@@ -293,9 +291,9 @@ _cursesi_addbyte(WINDOW *win, __LINE **l
 	if (newx > *(*lp)->lastchp)
 		*(*lp)->lastchp = newx;
 	__CTRACE(__CTRACE_INPUT, "ADDBYTES: change gives f/l: %d/%d [%d/%d]\n",
-		 *(*lp)->firstchp, *(*lp)->lastchp,
-		 *(*lp)->firstchp - win->ch_off,
-		 *(*lp)->lastchp - win->ch_off);
+	*(*lp)->firstchp, *(*lp)->lastchp,
+	*(*lp)->firstchp - win->ch_off,
+	*(*lp)->lastchp - win->ch_off);
 	if (win->bch != ' ' && c == ' ')
 		(*lp)->line[*x].ch = win->bch;
 	else
@@ -313,9 +311,8 @@ _cursesi_addbyte(WINDOW *win, __LINE **l
 		(*x)++;
 
 	__CTRACE(__CTRACE_INPUT,
-		 "ADDBYTES: 2: y = %d, x = %d, firstch = %d, lastch = %d\n",
-		 *y, *x, *win->alines[*y]->firstchp,
-		 

CVS commit: src/lib/libcurses

2021-09-06 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Mon Sep  6 07:08:25 UTC 2021

Modified Files:
src/lib/libcurses: addbytes.c

Log Message:
Unifdef DEBUG for CTRACE().


To generate a diff of this commit:
cvs rdiff -u -r1.57 -r1.58 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.57 src/lib/libcurses/addbytes.c:1.58
--- src/lib/libcurses/addbytes.c:1.57	Tue Jun 22 07:49:09 2021
+++ src/lib/libcurses/addbytes.c	Mon Sep  6 07:08:25 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: addbytes.c,v 1.57 2021/06/22 07:49:09 blymn Exp $	*/
+/*	$NetBSD: addbytes.c,v 1.58 2021/09/06 07:08:25 rin 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.57 2021/06/22 07:49:09 blymn Exp $");
+__RCSID("$NetBSD: addbytes.c,v 1.58 2021/09/06 07:08:25 rin Exp $");
 #endif
 #endif/* not lint */
 
@@ -144,10 +144,8 @@ _cursesi_waddbytes(WINDOW *win, const ch
 	while (count > 0) {
 #ifndef HAVE_WCHAR
 		c = *bytes++;
-#ifdef DEBUG
 		__CTRACE(__CTRACE_INPUT, "ADDBYTES('%c', %x) at (%d, %d)\n",
 		c, attr, *py, *px);
-#endif
 		err = _cursesi_addbyte(win, , py, px, c, attr, char_interp);
 		count--;
 #else
@@ -171,11 +169,9 @@ _cursesi_waddbytes(WINDOW *win, const ch
 			break;
 		}
 
-#ifdef DEBUG
 		__CTRACE(__CTRACE_INPUT,
 		"ADDBYTES WIDE(0x%x [%s], %x) at (%d, %d), ate %d bytes\n",
 		(unsigned)wc, unctrl((unsigned)wc), attr, *py, *px, n);
-#endif
 		cc.vals[0] = wc;
 		cc.elements = 1;
 		cc.attributes = attr;
@@ -250,19 +246,15 @@ _cursesi_addbyte(WINDOW *win, __LINE **l
 		}
 	}
 
-#ifdef DEBUG
 	__CTRACE(__CTRACE_INPUT, "ADDBYTES(%p, %d, %d)\n", win, *y, *x);
-#endif
 
 	if (char_interp && ((*lp)->flags & __ISPASTEOL)) {
 		*x = 0;
 		(*lp)->flags &= ~__ISPASTEOL;
 		if (*y == win->scr_b) {
-#ifdef DEBUG
 			__CTRACE(__CTRACE_INPUT,
  "ADDBYTES - on bottom "
  "of scrolling region\n");
-#endif
 			if (!(win->flags & __SCROLLOK))
 return ERR;
 			scroll(win);
@@ -274,12 +266,10 @@ _cursesi_addbyte(WINDOW *win, __LINE **l
 			return OK;
 	}
 
-#ifdef DEBUG
 	__CTRACE(__CTRACE_INPUT,
 		 "ADDBYTES: 1: y = %d, x = %d, firstch = %d, lastch = %d\n",
 		 *y, *x, *win->alines[*y]->firstchp,
 		 *win->alines[*y]->lastchp);
-#endif
 
 	attributes = (win->wattr | attr) & (__ATTRIBUTES & ~__COLOR);
 	if (attr & __COLOR)
@@ -302,12 +292,10 @@ _cursesi_addbyte(WINDOW *win, __LINE **l
 		*(*lp)->firstchp = newx;
 	if (newx > *(*lp)->lastchp)
 		*(*lp)->lastchp = newx;
-#ifdef DEBUG
 	__CTRACE(__CTRACE_INPUT, "ADDBYTES: change gives f/l: %d/%d [%d/%d]\n",
 		 *(*lp)->firstchp, *(*lp)->lastchp,
 		 *(*lp)->firstchp - win->ch_off,
 		 *(*lp)->lastchp - win->ch_off);
-#endif
 	if (win->bch != ' ' && c == ' ')
 		(*lp)->line[*x].ch = win->bch;
 	else
@@ -324,12 +312,10 @@ _cursesi_addbyte(WINDOW *win, __LINE **l
 	else
 		(*x)++;
 
-#ifdef DEBUG
 	__CTRACE(__CTRACE_INPUT,
 		 "ADDBYTES: 2: y = %d, x = %d, firstch = %d, lastch = %d\n",
 		 *y, *x, *win->alines[*y]->firstchp,
 		 *win->alines[*y]->lastchp);
-#endif
 	__sync(win);
 	return OK;
 }
@@ -405,11 +391,9 @@ _cursesi_addwchar(WINDOW *win, __LINE **
 
 	/* check for non-spacing character */
 	if (!wcwidth(wch->vals[0])) {
-#ifdef DEBUG
 		__CTRACE(__CTRACE_INPUT,
 			 "_cursesi_addwchar: char '%c' is non-spacing\n",
 			 wch->vals[0]);
-#endif /* DEBUG */
 		cw = WCOL(*lp);
 		if (cw < 0) {
 			lp += cw;
@@ -451,11 +435,9 @@ _cursesi_addwchar(WINDOW *win, __LINE **
 		sx = *x;
 	} else {
 		for (sx = *x - 1; sx >= max(*x + cw, 0); sx--) {
-#ifdef DEBUG
 			__CTRACE(__CTRACE_INPUT,
  "_cursesi_addwchar: clear current char (%d,%d)\n",
  *y, sx);
-#endif /* DEBUG */
 			tp = >alines[*y]->line[sx];
 			tp->ch = (wchar_t) btowc((int) win->bch);
 			if (_cursesi_copy_nsp(win->bnsp, tp) == ERR)
@@ -477,11 +459,9 @@ _cursesi_addwchar(WINDOW *win, __LINE **
 		cw = 1;
 
 	if (cw > win->maxx - *x) {
-#ifdef DEBUG
 		__CTRACE(__CTRACE_INPUT,
 			 "_cursesi_addwchar: clear EOL (%d,%d)\n",
 			 *y, *x);
-#endif /* DEBUG */
 		if (*y == win->scr_b) {
 			if (!(win->flags & __SCROLLOK))
 return ERR;
@@ -512,11 +492,9 @@ _cursesi_addwchar(WINDOW *win, __LINE **
 	}
 
 	/* add spacing character */
-#ifdef DEBUG
 	__CTRACE(__CTRACE_INPUT,
 		 "_cursesi_addwchar: add character (%d,%d) 0x%x\n",
 		 *y, *x, wch->vals[0]);
-#endif /* DEBUG */
 	(*lnp)->flags |= __ISDIRTY;
 	newx = *x + win->ch_off;
 	if (newx < *(*lnp)->firstchp)
@@ -541,11 +519,9 @@ _cursesi_addwchar(WINDOW *win, __LINE **
 
 	SET_WCOL(*lp, cw);
 
-#ifdef DEBUG
 	__CTRACE(__CTRACE_INPUT,
 		 "_cursesi_addwchar: add spacing char 0x%x, attr 0x%x\n",
 		 lp->ch, lp->attr);
-#endif /* DEBUG */
 
 	if (wch->elements > 1) {
 		for (i = 1; i < wch->elements; i++) {
@@ -554,20 +530,16 @@ 

  1   2   3   4   5   6   7   >