X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=ncurses%2Fbase%2Flib_touch.c;h=d8d59e138c2ec63c18750256404eb21d2f06eef1;hp=7ce863d06f104ce295a840c9621db836ea51c49f;hb=fae162795e065e5901068152e91f2962b6b247f3;hpb=0eb88fc5281804773e2a0c7a488a4452463535ce diff --git a/ncurses/base/lib_touch.c b/ncurses/base/lib_touch.c index 7ce863d0..d8d59e13 100644 --- a/ncurses/base/lib_touch.c +++ b/ncurses/base/lib_touch.c @@ -1,5 +1,6 @@ /**************************************************************************** - * Copyright (c) 1998 Free Software Foundation, Inc. * + * Copyright 2020 Thomas E. Dickey * + * Copyright 1998-2016,2017 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 * @@ -43,45 +44,55 @@ #include -MODULE_ID("$Id: lib_touch.c,v 1.6 1998/04/11 22:55:02 tom Exp $") +MODULE_ID("$Id: lib_touch.c,v 1.16 2020/02/02 23:34:34 tom Exp $") -bool is_linetouched(WINDOW *win, int line) +#undef is_linetouched + +NCURSES_EXPORT(bool) +is_linetouched(WINDOW *win, int line) { - T((T_CALLED("is_linetouched(%p,%d)"), win, line)); + T((T_CALLED("is_linetouched(%p,%d)"), (void *) win, line)); - /* XSI doesn't define any error */ - if (!win || (line > win->_maxy) || (line < 0)) - returnCode(ERR); + /* XSI doesn't define any error, and gcc ultimately made it impossible */ + if (!win || (line > win->_maxy) || (line < 0)) { + returnCode(FALSE); + } - returnCode(win->_line[line].firstchar != _NOCHANGE ? TRUE : FALSE); + returnCode(win->_line[line].firstchar != _NOCHANGE ? TRUE : FALSE); } -bool is_wintouched(WINDOW *win) +NCURSES_EXPORT(bool) +is_wintouched(WINDOW *win) { -int i; + T((T_CALLED("is_wintouched(%p)"), (void *) win)); - T((T_CALLED("is_wintouched(%p)"), win)); + if (win) { + int i; - if (win) - for (i = 0; i <= win->_maxy; i++) - if (win->_line[i].firstchar != _NOCHANGE) - returnCode(TRUE); - returnCode(FALSE); + for (i = 0; i <= win->_maxy; i++) + if (win->_line[i].firstchar != _NOCHANGE) + returnCode(TRUE); + } + returnCode(FALSE); } -int wtouchln(WINDOW *win, int y, int n, int changed) +NCURSES_EXPORT(int) +wtouchln(WINDOW *win, int y, int n, int changed) { -int i; + int i; - T((T_CALLED("wtouchln(%p,%d,%d,%d)"), win, y, n, changed)); + T((T_CALLED("wtouchln(%p,%d,%d,%d)"), (void *) win, y, n, changed)); - if (!win || (n<0) || (y<0) || (y>win->_maxy)) - returnCode(ERR); + if (!win || (n < 0) || (y < 0) || (y > win->_maxy)) + returnCode(ERR); - for (i = y; i < y+n; i++) { - if (i>win->_maxy) break; - win->_line[i].firstchar = changed ? 0 : _NOCHANGE; - win->_line[i].lastchar = changed ? win->_maxx : _NOCHANGE; - } - returnCode(OK); + for (i = y; i < y + n; i++) { + if (i > win->_maxy) + break; + win->_line[i].firstchar = (NCURSES_SIZE_T) (changed ? 0 : _NOCHANGE); + win->_line[i].lastchar = (NCURSES_SIZE_T) (changed + ? win->_maxx + : _NOCHANGE); + } + returnCode(OK); }