X-Git-Url: http://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=ncurses%2Fbase%2Flib_printw.c;h=41bd2f98946e0d5bf1a4fb7cc64e37ad9d5b246e;hp=530e7134307ed5a1fdb1e273acf3738c8ffe86f0;hb=6b99a559185b3b8fad80b56bc2070b08101c33d1;hpb=b0916ab669030bac5c8590c0d66e36e1b9b34e9b diff --git a/ncurses/base/lib_printw.c b/ncurses/base/lib_printw.c index 530e7134..41bd2f98 100644 --- a/ncurses/base/lib_printw.c +++ b/ncurses/base/lib_printw.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2009,2012 Free Software Foundation, Inc. * + * Copyright (c) 1998-2018,2019 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 * @@ -27,7 +27,7 @@ ****************************************************************************/ /**************************************************************************** - * Author: Thomas E. Dickey 1997 * + * Author: Thomas E. Dickey 1997-on * ****************************************************************************/ /* @@ -39,17 +39,16 @@ #include -MODULE_ID("$Id: lib_printw.c,v 1.21 2012/02/29 10:11:53 Werner.Fink Exp $") +MODULE_ID("$Id: lib_printw.c,v 1.27 2019/01/19 15:46:25 tom Exp $") NCURSES_EXPORT(int) -printw(const char *fmt,...) +printw(const char *fmt, ...) { va_list argp; int code; #ifdef TRACE va_list argq; - va_copy(argq, argp); va_start(argq, fmt); T((T_CALLED("printw(%s%s)"), _nc_visbuf(fmt), _nc_varargs(fmt, argq))); @@ -57,21 +56,20 @@ printw(const char *fmt,...) #endif va_start(argp, fmt); - code = vwprintw(stdscr, fmt, argp); + code = vw_printw(stdscr, fmt, argp); va_end(argp); returnCode(code); } NCURSES_EXPORT(int) -wprintw(WINDOW *win, const char *fmt,...) +wprintw(WINDOW *win, const char *fmt, ...) { va_list argp; int code; #ifdef TRACE va_list argq; - va_copy(argq, argp); va_start(argq, fmt); T((T_CALLED("wprintw(%p,%s%s)"), (void *) win, _nc_visbuf(fmt), _nc_varargs(fmt, argq))); @@ -79,21 +77,19 @@ wprintw(WINDOW *win, const char *fmt,...) #endif va_start(argp, fmt); - code = vwprintw(win, fmt, argp); + code = vw_printw(win, fmt, argp); va_end(argp); returnCode(code); } NCURSES_EXPORT(int) -mvprintw(int y, int x, const char *fmt,...) +mvprintw(int y, int x, const char *fmt, ...) { - va_list argp; int code; #ifdef TRACE va_list argq; - va_copy(argq, argp); va_start(argq, fmt); T((T_CALLED("mvprintw(%d,%d,%s%s)"), y, x, _nc_visbuf(fmt), _nc_varargs(fmt, argq))); @@ -101,22 +97,22 @@ mvprintw(int y, int x, const char *fmt,...) #endif if ((code = move(y, x)) != ERR) { + va_list argp; + va_start(argp, fmt); - code = vwprintw(stdscr, fmt, argp); + code = vw_printw(stdscr, fmt, argp); va_end(argp); } returnCode(code); } NCURSES_EXPORT(int) -mvwprintw(WINDOW *win, int y, int x, const char *fmt,...) +mvwprintw(WINDOW *win, int y, int x, const char *fmt, ...) { - va_list argp; int code; #ifdef TRACE va_list argq; - va_copy(argq, argp); va_start(argq, fmt); T((T_CALLED("mvwprintw(%d,%d,%p,%s%s)"), y, x, (void *) win, _nc_visbuf(fmt), _nc_varargs(fmt, argq))); @@ -124,8 +120,10 @@ mvwprintw(WINDOW *win, int y, int x, const char *fmt,...) #endif if ((code = wmove(win, y, x)) != ERR) { + va_list argp; + va_start(argp, fmt); - code = vwprintw(win, fmt, argp); + code = vw_printw(win, fmt, argp); va_end(argp); } returnCode(code); @@ -148,3 +146,21 @@ vwprintw(WINDOW *win, const char *fmt, va_list argp) } returnCode(code); } + +NCURSES_EXPORT(int) +vw_printw(WINDOW *win, const char *fmt, va_list argp) +{ + char *buf; + int code = ERR; +#if NCURSES_SP_FUNCS + SCREEN *sp = _nc_screen_of(win); +#endif + + T((T_CALLED("vw_printw(%p,%s,va_list)"), (void *) win, _nc_visbuf(fmt))); + + buf = NCURSES_SP_NAME(_nc_printf_string) (NCURSES_SP_ARGx fmt, argp); + if (buf != 0) { + code = waddstr(win, buf); + } + returnCode(code); +}