summaryrefslogtreecommitdiffstats
path: root/lib/libcurses/lib_inchstr.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libcurses/lib_inchstr.c')
-rw-r--r--lib/libcurses/lib_inchstr.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/libcurses/lib_inchstr.c b/lib/libcurses/lib_inchstr.c
index 8ed9a8725cb..7c40224f9c4 100644
--- a/lib/libcurses/lib_inchstr.c
+++ b/lib/libcurses/lib_inchstr.c
@@ -1,3 +1,5 @@
+/* $OpenBSD: lib_inchstr.c,v 1.3 1997/12/03 05:21:19 millert Exp $ */
+
/***************************************************************************
* COPYRIGHT NOTICE *
@@ -29,16 +31,21 @@
#include <curses.priv.h>
-MODULE_ID("Id: lib_inchstr.c,v 1.5 1997/02/02 01:06:03 tom Exp $")
+MODULE_ID("Id: lib_inchstr.c,v 1.6 1997/09/20 15:02:34 juergen Exp $")
int winchnstr(WINDOW *win, chtype *str, int n)
{
- int i;
+ int i = 0;
T((T_CALLED("winchnstr(%p,%p,%d)"), win, str, n));
- for (i = 0; (n < 0 || (i < n)) && (win->_curx + i <= win->_maxx); i++)
+ if (!str)
+ returnCode(0);
+
+ if (win) {
+ for (; (n < 0 || (i < n)) && (win->_curx + i <= win->_maxx); i++)
str[i] = win->_line[win->_cury].text[win->_curx + i];
+ }
str[i] = (chtype)0;
returnCode(i);