X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=ncurses%2Fbase%2Flib_printw.c;h=41bd2f98946e0d5bf1a4fb7cc64e37ad9d5b246e;hp=3064c260f10376d6e9cc6c16f838195ec61d7b86;hb=8890c8f28a1db5995ef17f52a7d8c0b9cf574210;hpb=ba39fbc2e0cee4681395df4079d9e61c27262132 diff --git a/ncurses/base/lib_printw.c b/ncurses/base/lib_printw.c index 3064c260..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,93 +39,91 @@ #include -MODULE_ID("$Id: lib_printw.c,v 1.22 2012/03/10 20:47:33 tom 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; - begin_va_copy(argq, argp); va_start(argq, fmt); T((T_CALLED("printw(%s%s)"), _nc_visbuf(fmt), _nc_varargs(fmt, argq))); - end_va_copy(argq); + va_end(argq); #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; - begin_va_copy(argq, argp); va_start(argq, fmt); T((T_CALLED("wprintw(%p,%s%s)"), (void *) win, _nc_visbuf(fmt), _nc_varargs(fmt, argq))); - end_va_copy(argq); + va_end(argq); #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; - begin_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))); - end_va_copy(argq); + va_end(argq); #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; - begin_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))); - end_va_copy(argq); + va_end(argq); #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); +}