]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - ncurses/base/lib_color.c
ncurses 5.7 - patch 20100522
[ncurses.git] / ncurses / base / lib_color.c
index 42f5ea7fc03b7cba6a1f00ef763399f598aa32ba..a5c181c8b4b140e60e492d00370d9b455fc5237a 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2008,2009 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2009,2010 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            *
@@ -45,7 +45,7 @@
 #define CUR SP_TERMTYPE
 #endif
 
-MODULE_ID("$Id: lib_color.c,v 1.95 2009/08/22 19:04:36 tom Exp $")
+MODULE_ID("$Id: lib_color.c,v 1.98 2010/04/24 22:57:53 tom Exp $")
 
 #ifdef USE_TERM_DRIVER
 #define CanChange      InfoOf(SP_PARM).canchange
@@ -262,6 +262,7 @@ reset_color_pair(NCURSES_SP_DCL0)
 #else
     bool result = FALSE;
 
+    (void) SP_PARM;
     if (orig_pair != 0) {
        TPUTS_TRACE("orig_pair");
        putp(orig_pair);
@@ -281,7 +282,7 @@ NCURSES_SP_NAME(_nc_reset_colors) (NCURSES_SP_DCL0)
 {
     int result = FALSE;
 
-    T((T_CALLED("_nc_reset_colors(%p)"), SP_PARM));
+    T((T_CALLED("_nc_reset_colors(%p)"), (void *) SP_PARM));
     if (SP_PARM->_color_defs > 0)
        SP_PARM->_color_defs = -(SP_PARM->_color_defs);
     if (reset_color_pair(NCURSES_SP_ARG))
@@ -313,7 +314,7 @@ NCURSES_SP_NAME(start_color) (NCURSES_SP_DCL0)
     int result = ERR;
     int maxpairs = 0, maxcolors = 0;
 
-    T((T_CALLED("start_color(%p)"), SP_PARM));
+    T((T_CALLED("start_color(%p)"), (void *) SP_PARM));
 
     if (SP_PARM == 0) {
        result = ERR;
@@ -393,7 +394,7 @@ rgb2hls(short r, short g, short b, short *h, short *l, short *s)
        max = b;
 
     /* calculate lightness */
-    *l = (min + max) / 20;
+    *l = (short) ((min + max) / 20);
 
     if (min == max) {          /* black, white and all shades of gray */
        *h = 0;
@@ -403,17 +404,17 @@ rgb2hls(short r, short g, short b, short *h, short *l, short *s)
 
     /* calculate saturation */
     if (*l < 50)
-       *s = ((max - min) * 100) / (max + min);
+       *s = (short) (((max - min) * 100) / (max + min));
     else
-       *s = ((max - min) * 100) / (2000 - max - min);
+       *s = (short) (((max - min) * 100) / (2000 - max - min));
 
     /* calculate hue */
     if (r == max)
-       t = 120 + ((g - b) * 60) / (max - min);
+       t = (short) (120 + ((g - b) * 60) / (max - min));
     else if (g == max)
-       t = 240 + ((b - r) * 60) / (max - min);
+       t = (short) (240 + ((b - r) * 60) / (max - min));
     else
-       t = 360 + ((r - g) * 60) / (max - min);
+       t = (short) (360 + ((r - g) * 60) / (max - min));
 
     *h = t % 360;
 }
@@ -429,7 +430,7 @@ NCURSES_SP_NAME(init_pair) (NCURSES_SP_DCLx short pair, short f, short b)
     colorpair_t previous;
     int maxcolors;
 
-    T((T_CALLED("init_pair(%p,%d,%d,%d)"), SP_PARM, pair, f, b));
+    T((T_CALLED("init_pair(%p,%d,%d,%d)"), (void *) SP_PARM, pair, f, b));
 
     if (!ValidPair(pair))
        returnCode(ERR);
@@ -572,7 +573,10 @@ NCURSES_SP_NAME(init_color) (NCURSES_SP_DCLx
     int result = ERR;
     int maxcolors;
 
-    T((T_CALLED("init_color(%p,%d,%d,%d,%d)"), SP_PARM, color, r, g, b));
+    T((T_CALLED("init_color(%p,%d,%d,%d,%d)"),
+       (void *) SP_PARM,
+       color,
+       r, g, b));
 
     if (SP_PARM == 0)
        returnCode(result);
@@ -624,7 +628,7 @@ init_color(short color, short r, short g, short b)
 NCURSES_EXPORT(bool)
 NCURSES_SP_NAME(can_change_color) (NCURSES_SP_DCL)
 {
-    T((T_CALLED("can_change_color(%p)"), SP_PARM));
+    T((T_CALLED("can_change_color(%p)"), (void *) SP_PARM));
     returnCode((CanChange != 0) ? TRUE : FALSE);
 }
 
@@ -641,6 +645,7 @@ NCURSES_SP_NAME(has_colors) (NCURSES_SP_DCL0)
 {
     int code;
 
+    (void) SP_PARM;
     T((T_CALLED("has_colors()")));
 #ifdef USE_TERM_DRIVER
     code = HasColor;
@@ -670,7 +675,12 @@ NCURSES_SP_NAME(color_content) (NCURSES_SP_DCLx
     int result = ERR;
     int maxcolors;
 
-    T((T_CALLED("color_content(%p,%d,%p,%p,%p)"), SP_PARM, color, r, g, b));
+    T((T_CALLED("color_content(%p,%d,%p,%p,%p)"),
+       (void *) SP_PARM,
+       color,
+       (void *) r,
+       (void *) g,
+       (void *) b));
 
     if (SP_PARM == 0)
        returnCode(result);
@@ -712,7 +722,11 @@ NCURSES_SP_NAME(pair_content) (NCURSES_SP_DCLx
 {
     int result;
 
-    T((T_CALLED("pair_content(%p,%d,%p,%p)"), SP_PARM, pair, f, b));
+    T((T_CALLED("pair_content(%p,%d,%p,%p)"),
+       (void *) SP_PARM,
+       pair,
+       (void *) f,
+       (void *) b));
 
     if (!ValidPair(pair)) {
        result = ERR;
@@ -732,7 +746,10 @@ NCURSES_SP_NAME(pair_content) (NCURSES_SP_DCLx
        if (b)
            *b = bg;
 
-       TR(TRACE_ATTRS, ("...pair_content(%p,%d,%d,%d)", SP_PARM, pair, fg, bg));
+       TR(TRACE_ATTRS, ("...pair_content(%p,%d,%d,%d)",
+                        (void *) SP_PARM,
+                        pair,
+                        fg, bg));
        result = OK;
     }
     returnCode(result);
@@ -805,9 +822,9 @@ NCURSES_SP_NAME(_nc_do_color) (NCURSES_SP_DCLx
 
 #if NCURSES_EXT_FUNCS
     if (isDefaultColor(fg))
-       fg = default_fg(NCURSES_SP_ARG);
+       fg = (short) default_fg(NCURSES_SP_ARG);
     if (isDefaultColor(bg))
-       bg = default_bg(NCURSES_SP_ARG);
+       bg = (short) default_bg(NCURSES_SP_ARG);
 #endif
 
     if (reverse) {