Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libcurses Don't wrap added string



details:   https://anonhg.NetBSD.org/src/rev/367ae9f943a9
branches:  trunk
changeset: 781763:367ae9f943a9
user:      blymn <blymn%NetBSD.org@localhost>
date:      Fri Sep 28 06:07:05 2012 +0000

description:
Don't wrap added string

diffstat:

 lib/libcurses/addnstr.c |  13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)

diffs (37 lines):

diff -r 1d27575ceb5d -r 367ae9f943a9 lib/libcurses/addnstr.c
--- a/lib/libcurses/addnstr.c   Fri Sep 28 06:05:19 2012 +0000
+++ b/lib/libcurses/addnstr.c   Fri Sep 28 06:07:05 2012 +0000
@@ -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 @@
         * 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));
 }



Home | Main Index | Thread Index | Old Index