Module Name:    src
Committed By:   blymn
Date:           Fri Sep 28 06:07:05 UTC 2012

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

Log Message:
Don't wrap added string


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/lib/libcurses/addnstr.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.12 src/lib/libcurses/addnstr.c:1.13
--- src/lib/libcurses/addnstr.c:1.12	Mon May 28 15:01:54 2007
+++ src/lib/libcurses/addnstr.c	Fri Sep 28 06:07:05 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: addnstr.c,v 1.12 2007/05/28 15:01:54 blymn Exp $	*/
+/*	$NetBSD: addnstr.c,v 1.13 2012/09/28 06:07:05 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.12 2007/05/28 15:01:54 blymn Exp $");
+__RCSID("$NetBSD: addnstr.c,v 1.13 2012/09/28 06:07:05 blymn Exp $");
 #endif
 #endif				/* not lint */
 
@@ -146,10 +146,17 @@ waddnstr(WINDOW *win, const char *s, int
 	 * BSD curses: if (n > 0) then "at most n", else "len = strlen(s)"
 	 * ncurses: if (n >= 0) then "at most n", else "len = strlen(s)"
 	 * XCURSES: if (n != -1) then "at most n", else "len = strlen(s)"
+	 * 
+	 * Also SUSv2 says these functions do not wrap nor change the
+	 * cursor position.
 	 */
 	if (n >= 0)
 		for (p = s, len = 0; n-- && *p++; ++len);
 	else
 		len = strlen(s);
-	return (waddbytes(win, s, (int) len));
+	
+	if (len > (win->maxx - win->curx))
+		len = win->maxx - win->curx;
+
+	return(waddbytes(win, s, (int) len));
 }

Reply via email to