]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - include/curses.h.in
ncurses 5.9 - patch 20111015
[ncurses.git] / include / curses.h.in
index 2ad68f1fee78aa47218645fd8f21d54a039409e1..c49422b188092c65c87f8c695df6fac80f93cc8d 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2009,2010 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2010,2011 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            *
@@ -32,7 +32,7 @@
  *     and: Thomas E. Dickey                        1996-on                 *
  ****************************************************************************/
 
-/* $Id: curses.h.in,v 1.215 2010/04/29 09:46:38 tom Exp $ */
+/* $Id: curses.h.in,v 1.225 2011/08/20 16:09:38 tom Exp $ */
 
 #ifndef __NCURSES_H
 #define __NCURSES_H
@@ -1097,7 +1097,7 @@ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(use_legacy_coding) (SCREEN*, int);     /*
 
 /* It seems older SYSV curses versions define these */
 #if !NCURSES_OPAQUE
-#define getattrs(win)          ((win) ? (win)->_attrs : A_NORMAL)
+#define getattrs(win)          NCURSES_CAST(int, (win) ? (win)->_attrs : A_NORMAL)
 #define getcurx(win)           ((win) ? (win)->_curx : ERR)
 #define getcury(win)           ((win) ? (win)->_cury : ERR)
 #define getbegx(win)           ((win) ? (win)->_begx : ERR)
@@ -1118,12 +1118,12 @@ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(use_legacy_coding) (SCREEN*, int);   /*
 #if defined(NCURSES_WIDECHAR) && @NCURSES_EXT_COLORS@
 #define wattrset(win,at)       ((win) \
                                  ? ((win)->_color = PAIR_NUMBER(at), \
-                                     (win)->_attrs = (at), \
+                                     (win)->_attrs = NCURSES_CAST(attr_t, at), \
                                      OK) \
                                  : ERR)
 #else
 #define wattrset(win,at)        ((win) \
-                                 ? ((win)->_attrs = (at), \
+                                 ? ((win)->_attrs = NCURSES_CAST(attr_t, at), \
                                     OK) \
                                  : ERR)
 #endif
@@ -1145,7 +1145,7 @@ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(use_legacy_coding) (SCREEN*, int);     /*
 #define winsstr(w, s)          winsnstr(w, s, -1)
 
 #if !NCURSES_OPAQUE
-#define redrawwin(win)         wredrawln(win, 0, (win)->_maxy+1)
+#define redrawwin(win)         wredrawln(win, 0, ((win) ? (win)->_maxy+1 : -1))
 #endif /* NCURSES_OPAQUE */
 
 #define waddstr(win,str)       waddnstr(win,str,-1)
@@ -1155,7 +1155,7 @@ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(use_legacy_coding) (SCREEN*, int);     /*
  * These apply to the first 256 color pairs.
  */
 #define COLOR_PAIR(n)  NCURSES_BITS(n, 0)
-#define PAIR_NUMBER(a) (NCURSES_CAST(int,(((a) & A_COLOR) >> NCURSES_ATTR_SHIFT)))
+#define PAIR_NUMBER(a) (NCURSES_CAST(int,((NCURSES_CAST(unsigned long,a) & A_COLOR) >> NCURSES_ATTR_SHIFT)))
 
 /*
  * pseudo functions for standard screen
@@ -1256,7 +1256,7 @@ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(use_legacy_coding) (SCREEN*, int);     /*
  * Some wide-character functions can be implemented without the extensions.
  */
 #if !NCURSES_OPAQUE
-#define getbkgd(win)                    ((win)->_bkgd)
+#define getbkgd(win)                    ((win) ? ((win)->_bkgd) : 0)
 #endif /* NCURSES_OPAQUE */
 
 #define slk_attr_off(a,v)              ((v) ? ERR : slk_attroff(a))
@@ -1264,16 +1264,21 @@ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(use_legacy_coding) (SCREEN*, int);   /*
 
 #if !NCURSES_OPAQUE
 #if defined(NCURSES_WIDECHAR) && @NCURSES_EXT_COLORS@
-#define wattr_set(win,a,p,opts)                ((win)->_attrs = ((a) & ~A_COLOR), \
-                                        (win)->_color = (p), \
+#define wattr_set(win,a,p,opts)                (((win) \
+                                         ? ((win)->_attrs = ((a) & ~A_COLOR), \
+                                            (win)->_color = (p)) \
+                                         : OK), \
                                         OK)
-#define wattr_get(win,a,p,opts)                ((void)((a) != (void *)0 && (*(a) = (win)->_attrs)), \
-                                        (void)((p) != (void *)0 && (*(p) = (win)->_color)), \
+#define wattr_get(win,a,p,opts)                ((void)(((a) != (void *)0) ? (*(a) = (win) ? (win)->_attrs : 0) : OK), \
+                                        (void)(((p) != (void *)0) ? (*(p) = (win) ? (short)(win)->_color : 0) : OK), \
                                         OK)
 #else
-#define wattr_set(win,a,p,opts)                ((win)->_attrs = (((a) & ~A_COLOR) | COLOR_PAIR(p)), OK)
-#define wattr_get(win,a,p,opts)                ((void)((a) != (void *)0 && (*(a) = (win)->_attrs)), \
-                                        (void)((p) != (void *)0 && (*(p) = PAIR_NUMBER((win)->_attrs))), \
+#define wattr_set(win,a,p,opts)                (((win) \
+                                         ? ((win)->_attrs = (((a) & ~A_COLOR) | (attr_t)COLOR_PAIR(p))) \
+                                         : OK), \
+                                        OK)
+#define wattr_get(win,a,p,opts)                ((void)(((a) != (void *)0) ? (*(a) = (win) ? (win)->_attrs : 0) : OK), \
+                                        (void)(((p) != (void *)0) ? (*(p) = (win) ? (short)PAIR_NUMBER((win)->_attrs) : 0) : OK), \
                                         OK)
 #endif
 #endif /* NCURSES_OPAQUE */