X-Git-Url: http://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=ncurses%2Fbase%2Flib_scanw.c;h=d75a229add1a77b51bd8383ce7d7011050ec39ba;hp=637aa46ece01ab0921bb18216e9428f9999a1eb9;hb=02c4e383be9337e73a0e75844dfd1047745adb28;hpb=74137fec04e130a88ef25618cf730af988a4f51a diff --git a/ncurses/base/lib_scanw.c b/ncurses/base/lib_scanw.c index 637aa46e..d75a229a 100644 --- a/ncurses/base/lib_scanw.c +++ b/ncurses/base/lib_scanw.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2009,2011 Free Software Foundation, Inc. * + * Copyright (c) 1998-2011,2018 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -40,21 +40,25 @@ #include -MODULE_ID("$Id: lib_scanw.c,v 1.13 2011/10/22 16:31:35 tom Exp $") +MODULE_ID("$Id: lib_scanw.c,v 1.15 2018/04/07 21:28:27 tom Exp $") NCURSES_EXPORT(int) -vwscanw(WINDOW *win, NCURSES_CONST char *fmt, va_list argp) +vwscanw(WINDOW *win, const char *fmt, va_list argp) { char buf[BUFSIZ]; + int code = ERR; - if (wgetnstr(win, buf, (int) sizeof(buf) - 1) == ERR) - return (ERR); + if (wgetnstr(win, buf, (int) sizeof(buf) - 1) != ERR) { + if ((code = vsscanf(buf, fmt, argp)) == EOF) { + code = ERR; + } + } - return (vsscanf(buf, fmt, argp)); + return code; } NCURSES_EXPORT(int) -scanw(NCURSES_CONST char *fmt,...) +scanw(const char *fmt,...) { int code; va_list ap; @@ -68,7 +72,7 @@ scanw(NCURSES_CONST char *fmt,...) } NCURSES_EXPORT(int) -wscanw(WINDOW *win, NCURSES_CONST char *fmt,...) +wscanw(WINDOW *win, const char *fmt,...) { int code; va_list ap; @@ -82,7 +86,7 @@ wscanw(WINDOW *win, NCURSES_CONST char *fmt,...) } NCURSES_EXPORT(int) -mvscanw(int y, int x, NCURSES_CONST char *fmt,...) +mvscanw(int y, int x, const char *fmt,...) { int code; va_list ap; @@ -94,7 +98,7 @@ mvscanw(int y, int x, NCURSES_CONST char *fmt,...) } NCURSES_EXPORT(int) -mvwscanw(WINDOW *win, int y, int x, NCURSES_CONST char *fmt,...) +mvwscanw(WINDOW *win, int y, int x, const char *fmt,...) { int code; va_list ap;