Subject: Re: CVS commit: basesrc
To: Jason Thorpe <thorpej@nas.nasa.gov>
From: Simon Burge <simonb@NetBSD.ORG>
List: tech-userlevel
Date: 08/06/1999 09:22:56
[[ xposted to tech-userlevel, with reply-to set to there ]]

On source-changes, there's been a short discussion on the problems of
<curses.h> using strlen(), and the XCURSES spec saying that <curses.h>
including <string.h> isn't the right thing to do.

Jason Thorpe wrote:

> On Thu, 05 Aug 1999 19:18:58 +1000 
>  Simon Burge <simonb@NetBSD.ORG> wrote:
> 
>  > Since (I think) all the calls to strlen are in addstr() type functions,
>  > and a negative string length in addstr() by definition means "the whole
>  > string", maybe it's better to make __waddbytes() handle a negative
>  > length the same way?
> 
> that would probabably work, too :-)

I think the following is better.  waddnstr is never a macro, and it
doesn't change the semantics of __waddbytes().  Look good?  This also
shouldn't require bumping the libcurses minor either, should it?

Simon.
--

Index: curses.h
===================================================================
RCS file: /cvsroot/basesrc/lib/libcurses/curses.h,v
retrieving revision 1.24
diff -p -u -r1.24 curses.h
--- curses.h	1999/06/28 13:32:43	1.24
+++ curses.h	1999/08/05 23:22:31
@@ -307,7 +307,7 @@ extern char	*ttytype;		/* Full name of c
 #define	addbytes(s, n)			__waddbytes(stdscr, s, n, 0)
 #define	addch(ch)			waddch(stdscr, ch)
 #define	addnstr(s, n)			waddnstr(stdscr, s, n)
-#define	addstr(s)			__waddbytes(stdscr, s, strlen(s), 0)
+#define	addstr(s)			waddnstr(stdscr, s, -1);
 #define	clear()				wclear(stdscr)
 #define	clrtobot()			wclrtobot(stdscr)
 #define	clrtoeol()			wclrtoeol(stdscr)
@@ -330,7 +330,7 @@ extern char	*ttytype;		/* Full name of c
 #define	attroff(attr)			wattroff(stdscr, attr)
 #define	attrset(attr)			wattrset(stdscr, attr)
 #define	waddbytes(w, s, n)		__waddbytes(w, s, n, 0)
-#define	waddstr(w, s)			__waddbytes(w, s, strlen(s), 0)
+#define	waddstr(w, s)			waddnstr(win, s, -1);
 
 /* Attributes */
 #define A_NORMAL	__NORMAL
@@ -361,7 +361,7 @@ extern char	*ttytype;		/* Full name of c
 #define	mvwaddnstr(w, y, x, s, n) \
 	(wmove(w, y, x) == ERR ? ERR : waddnstr(w, s, n))
 #define	mvwaddstr(w, y, x, s) \
-	(wmove(w, y, x) == ERR ? ERR : __waddbytes(w, s, strlen(s), 0))
+	(wmove(w, y, x) == ERR ? ERR : waddnstr(w, s, -1))
 #define	mvwdelch(w, y, x) \
 	(wmove(w, y, x) == ERR ? ERR : wdelch(w))
 #define	mvwgetch(w, y, x) \