summaryrefslogtreecommitdiffstats
path: root/lib/libcurses/lib_instr.c
diff options
context:
space:
mode:
authormillert <millert@openbsd.org>1997-12-03 05:20:47 +0000
committermillert <millert@openbsd.org>1997-12-03 05:20:47 +0000
commit6f4099fecac342eeff29dd2bf0512f777a62a591 (patch)
tree30035276ed4d5b07245464d724dd101dc9b5efb4 /lib/libcurses/lib_instr.c
parentmerge of ncurses-4.1-971129 (diff)
downloadwireguard-openbsd-6f4099fecac342eeff29dd2bf0512f777a62a591.tar.xz
wireguard-openbsd-6f4099fecac342eeff29dd2bf0512f777a62a591.zip
Merge of ncurses-4.1-971129
Diffstat (limited to 'lib/libcurses/lib_instr.c')
-rw-r--r--lib/libcurses/lib_instr.c37
1 files changed, 22 insertions, 15 deletions
diff --git a/lib/libcurses/lib_instr.c b/lib/libcurses/lib_instr.c
index d21de453a09..b3f2397179d 100644
--- a/lib/libcurses/lib_instr.c
+++ b/lib/libcurses/lib_instr.c
@@ -1,3 +1,5 @@
+/* $OpenBSD: lib_instr.c,v 1.3 1997/12/03 05:21:21 millert Exp $ */
+
/***************************************************************************
* COPYRIGHT NOTICE *
@@ -29,28 +31,33 @@
#include <curses.priv.h>
-MODULE_ID("Id: lib_instr.c,v 1.6 1997/05/03 10:51:07 juergen Exp $")
+MODULE_ID("Id: lib_instr.c,v 1.7 1997/09/20 15:02:34 juergen Exp $")
int winnstr(WINDOW *win, char *str, int n)
{
- int i, row, col;
+ int i=0, row, col;
T((T_CALLED("winnstr(%p,%p,%d)"), win, str, n));
- getyx(win, row, col);
-
- if (n < 0)
- n = win->_maxx - win->_curx + 1;
-
- for (i = 0; i < n;) {
- str[i++] = TextOf(win->_line[row].text[col]);
- if (++col > win->_maxx) {
- col = 0;
- if (++row > win->_maxy)
- break;
- }
+ if (!str)
+ returnCode(0);
+
+ if (win) {
+ getyx(win, row, col);
+
+ if (n < 0)
+ n = win->_maxx - win->_curx + 1;
+
+ for (; i < n;) {
+ str[i++] = TextOf(win->_line[row].text[col]);
+ if (++col > win->_maxx) {
+ col = 0;
+ if (++row > win->_maxy)
+ break;
+ }
+ }
}
str[i] = '\0'; /* SVr4 does not seem to count the null */
-
returnCode(i);
}
+