]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - ncurses/base/lib_touch.c
ncurses 6.2 - patch 20210213
[ncurses.git] / ncurses / base / lib_touch.c
index 8023c705802766c40ebd7090c759de12b97d0c6b..d8d59e138c2ec63c18750256404eb21d2f06eef1 100644 (file)
@@ -1,5 +1,6 @@
 /****************************************************************************
 /****************************************************************************
- * Copyright (c) 1998-2009,2010 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            *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
 
 #include <curses.priv.h>
 
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_touch.c,v 1.11 2010/12/19 01:22:58 tom Exp $")
+MODULE_ID("$Id: lib_touch.c,v 1.16 2020/02/02 23:34:34 tom Exp $")
+
+#undef is_linetouched
 
 NCURSES_EXPORT(bool)
 is_linetouched(WINDOW *win, int line)
 {
     T((T_CALLED("is_linetouched(%p,%d)"), (void *) win, line));
 
 
 NCURSES_EXPORT(bool)
 is_linetouched(WINDOW *win, int 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((bool) 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);
 }
@@ -60,14 +64,15 @@ is_linetouched(WINDOW *win, int line)
 NCURSES_EXPORT(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)"), (void *) win));
 
-    if (win)
+    if (win) {
+       int i;
+
        for (i = 0; i <= win->_maxy; i++)
            if (win->_line[i].firstchar != _NOCHANGE)
                returnCode(TRUE);
        for (i = 0; i <= win->_maxy; i++)
            if (win->_line[i].firstchar != _NOCHANGE)
                returnCode(TRUE);
+    }
     returnCode(FALSE);
 }
 
     returnCode(FALSE);
 }
 
@@ -84,7 +89,7 @@ wtouchln(WINDOW *win, int y, int n, int changed)
     for (i = y; i < y + n; i++) {
        if (i > win->_maxy)
            break;
     for (i = y; i < y + n; i++) {
        if (i > win->_maxy)
            break;
-       win->_line[i].firstchar = changed ? 0 : _NOCHANGE;
+       win->_line[i].firstchar = (NCURSES_SIZE_T) (changed ? 0 : _NOCHANGE);
        win->_line[i].lastchar = (NCURSES_SIZE_T) (changed
                                                   ? win->_maxx
                                                   : _NOCHANGE);
        win->_line[i].lastchar = (NCURSES_SIZE_T) (changed
                                                   ? win->_maxx
                                                   : _NOCHANGE);