diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 1997-12-03 05:21:47 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 1997-12-03 05:21:47 +0000 |
commit | 211326e37501ac01a66994a221020b75ab5f63f0 (patch) | |
tree | 6d6c7182f1034b1b04c98386a1c3ba44e8accd5f /lib/libcurses/lib_instr.c | |
parent | 7c742f381e7808d0b12c17b534305751f3ebb0cb (diff) |
Merge of ncurses-4.1-971129
Diffstat (limited to 'lib/libcurses/lib_instr.c')
-rw-r--r-- | lib/libcurses/lib_instr.c | 37 |
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); } + |