*innstr() are supposed to return the number of characters read, not just

OK or ERR. (However, *instr() _are_ supposed to return just OK or ERR.)
Reported by Mike Aubury. I chucked the corresponding macros for *instr()
rather than trying to render the functions into one line.
This commit is contained in:
William McBrine
2006-05-02 17:17:27 +00:00
parent d6d325415c
commit bb3c44e218
2 changed files with 13 additions and 19 deletions

View File

@@ -15,7 +15,7 @@
* See the file maintain.er for details of the current maintainer. *
************************************************************************/
/* $Id: curses.h,v 1.169 2006/04/25 21:03:31 wmcbrine Exp $ */
/* $Id: curses.h,v 1.170 2006/05/02 17:17:25 wmcbrine Exp $ */
/*----------------------------------------------------------------------*
* PDCurses *
@@ -1548,7 +1548,6 @@ int PDC_set_line_color(short);
# define insertln() winsertln(stdscr)
# define insnstr(s, n) winsnstr(stdscr, s, n)
# define insstr(s) winsnstr(stdscr, s, -1)
# define instr(str) winnstr(stdscr, str, stdscr->_maxx)
# define isendwin() (SP->alive ? FALSE : TRUE)
# define mvaddch(y, x, c) (move(y, x)==ERR?ERR:addch(c))
# define mvaddchstr(y, x, c) (move(y, x)==ERR?ERR:addchnstr(c, -1))
@@ -1567,8 +1566,6 @@ int PDC_set_line_color(short);
# define mvinsch(y,x,c) (move(y, x)==ERR?ERR:winsch(stdscr, c))
# define mvinsnstr(y, x, s, n) (move(y, x)==ERR?ERR:winsnstr(stdscr, s, n))
# define mvinsstr(y, x, s) (move(y, x)==ERR?ERR:winsnstr(stdscr, s, -1))
# define mvinstr(y, x, str) (move(y, x)==ERR?ERR:winnstr(stdscr,\
str, stdscr->_maxx))
# define mvinnstr(y, x, str, n) (move(y, x)==ERR?ERR:winnstr(stdscr, str, n))
# define mvvline(y, x, c, n) (move(y, x)==ERR?ERR:vline(c, n))
# define mvwaddch(w, y, x, c) (wmove(w, y, x)==ERR?ERR:waddch(w, c))
@@ -1585,8 +1582,6 @@ int PDC_set_line_color(short);
c, (w)->_maxx - (w)->_curx))
# define mvwinchnstr(w,y,x,c,n) (wmove(w, y, x)==ERR?ERR:winchnstr(w, c, n))
# define mvwinsch(w, y, x, c) (wmove(w, y, x)==ERR?ERR:winsch(w, c))
# define mvwinstr(w, y, x, str) (wmove(w, y, x)==ERR?ERR:winnstr(w,\
str, (w)->_maxx))
# define mvwinnstr(w,y,x,str,n) (wmove(w, y, x)==ERR?ERR:winnstr(w, str, n))
# define mvwinsnstr(w,y,x,s,n) (wmove(w, y, x)==ERR?ERR:winsnstr(w, s, n))
# define mvwinsstr(w, y, x, s) (wmove(w, y, x)==ERR?ERR:winsnstr(w, s, -1))
@@ -1611,7 +1606,6 @@ int PDC_set_line_color(short);
# define winch(w) ((w)->_y[(w)->_cury][(w)->_curx])
# define winchstr(w, c) winchnstr(w, c, (w)->_maxx - (w)->_curx)
# define winsstr(w, str) winsnstr(w, str, -1)
# define winstr(w, str) winnstr(w, str, (w)->_maxx)
# define wstandend(w) wattrset(w, A_NORMAL)
# define wstandout(w) wattrset(w, A_STANDOUT)

View File

@@ -37,7 +37,7 @@
# undef mvwinch
#endif
RCSID("$Id: instr.c,v 1.18 2006/03/29 20:06:41 wmcbrine Exp $");
RCSID("$Id: instr.c,v 1.19 2006/05/02 17:17:27 wmcbrine Exp $");
/*man-start**************************************************************
@@ -64,10 +64,10 @@ RCSID("$Id: instr.c,v 1.18 2006/03/29 20:06:41 wmcbrine Exp $");
mvwinstr() and mvwinnstr() are all macros.
X/Open Return Value:
All functions return OK on success and ERR on error.
X/Open Errors:
No errors are defined for this function.
Upon successful completion, innstr(), mvinnstr(), mvwinnstr()
and winnstr() return the number of characters actually read into
the string; instr(), mvinstr(), mvwinstr() and winstr() return
OK. Otherwise, all these functions return ERR.
Portability X/Open BSD SYS V
Dec '88
@@ -86,7 +86,7 @@ int instr(char *str)
{
PDC_LOG(("instr() - called: string=\"%s\"\n", str));
return winnstr(stdscr, str, stdscr->_maxx);
return (ERR == winnstr(stdscr, str, stdscr->_maxx)) ? ERR : OK;
}
int innstr(char *str, int n)
@@ -100,7 +100,7 @@ int winstr(WINDOW *win, char *str)
{
PDC_LOG(("winstr() - called: \n"));
return winnstr(win, str, win->_maxx);
return (ERR == winnstr(win, str, win->_maxx)) ? ERR : OK;
}
int winnstr(WINDOW *win, char *str, int n)
@@ -126,18 +126,18 @@ int winnstr(WINDOW *win, char *str, int n)
if (tmp == (chtype)ERR)
{
str[imax] = '\0';
str[ic] = '\0';
return ERR;
}
str[ic] = tmp & A_CHARTEXT;
}
str[imax] = '\0';
str[ic] = '\0';
win->_curx = oldx;
return OK;
return ic;
}
int mvinstr(int y, int x, char *str)
@@ -147,7 +147,7 @@ int mvinstr(int y, int x, char *str)
if (move(y, x) == ERR)
return ERR;
return winnstr(stdscr, str, stdscr->_maxx);
return (ERR == winnstr(stdscr, str, stdscr->_maxx)) ? ERR : OK;
}
int mvinnstr(int y, int x, char *str, int n)
@@ -167,7 +167,7 @@ int mvwinstr(WINDOW *win, int y, int x, char *str)
if (wmove(win, y, x) == ERR)
return ERR;
return winnstr(win, str, win->_maxx);
return (ERR == winnstr(win, str, win->_maxx)) ? ERR : OK;
}
int mvwinnstr(WINDOW *win, int y, int x, char *str, int n)