Module Name: src Committed By: blymn Date: Sat Dec 25 10:05:08 UTC 2010
Modified Files: src/lib/libcurses: color.c Log Message: Ignore request to change the values of colour pair 0 Explicitly set foreground and/or background colours when -1 is passed to assume_default_colors() To generate a diff of this commit: cvs rdiff -u -r1.35 -r1.36 src/lib/libcurses/color.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/lib/libcurses/color.c diff -u src/lib/libcurses/color.c:1.35 src/lib/libcurses/color.c:1.36 --- src/lib/libcurses/color.c:1.35 Wed Feb 3 15:34:40 2010 +++ src/lib/libcurses/color.c Sat Dec 25 10:05:08 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: color.c,v 1.35 2010/02/03 15:34:40 roy Exp $ */ +/* $NetBSD: color.c,v 1.36 2010/12/25 10:05:08 blymn Exp $ */ /* * Copyright (c) 2000 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: color.c,v 1.35 2010/02/03 15:34:40 roy Exp $"); +__RCSID("$NetBSD: color.c,v 1.36 2010/12/25 10:05:08 blymn Exp $"); #endif /* not lint */ #include "curses.h" @@ -274,6 +274,10 @@ if (pair < 0 || pair >= COLOR_PAIRS) return (ERR); + + if (pair == 0) /* Ignore request for pair 0, it is default. */ + return OK; + if (fore >= COLORS) return (ERR); if (back >= COLORS) @@ -424,7 +428,7 @@ #ifdef DEBUG __CTRACE(__CTRACE_COLOR, "use_default_colors\n"); #endif - + return(assume_default_colors(-1, -1)); } @@ -433,12 +437,24 @@ * Set the default foreground and background colours. */ int -assume_default_colors(short fore, short back) +assume_default_colors(short arg_fore, short arg_back) { + short fore, back; + + fore = arg_fore; + back = arg_back; + #ifdef DEBUG __CTRACE(__CTRACE_COLOR, "assume_default_colors: %d, %d\n", fore, back); + __CTRACE(__CTRACE_COLOR, "assume_default_colors: default_colour = %d, pair_number = %d\n", __default_color, PAIR_NUMBER(__default_color)); #endif + + if (arg_fore == -1) + fore = COLOR_WHITE; + if (arg_back == -1) + back = COLOR_BLACK; + /* Swap red/blue and yellow/cyan */ if (_cursesi_screen->color_type == COLOR_OTHER) { switch (fore) {