Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libcurses Fix obvious bugs in init_pair().



details:   https://anonhg.NetBSD.org/src/rev/3c5bf354de64
branches:  trunk
changeset: 485404:3c5bf354de64
user:      mycroft <mycroft%NetBSD.org@localhost>
date:      Thu Apr 27 05:03:22 2000 +0000

description:
Fix obvious bugs in init_pair().

diffstat:

 lib/libcurses/color.c |  30 +++++++++++++-----------------
 1 files changed, 13 insertions(+), 17 deletions(-)

diffs (63 lines):

diff -r 6b02932118d2 -r 3c5bf354de64 lib/libcurses/color.c
--- a/lib/libcurses/color.c     Thu Apr 27 00:57:48 2000 +0000
+++ b/lib/libcurses/color.c     Thu Apr 27 05:03:22 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: color.c,v 1.9 2000/04/27 00:26:57 jdc Exp $    */
+/*     $NetBSD: color.c,v 1.10 2000/04/27 05:03:22 mycroft Exp $       */
 
 /*
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: color.c,v 1.9 2000/04/27 00:26:57 jdc Exp $");
+__RCSID("$NetBSD: color.c,v 1.10 2000/04/27 05:03:22 mycroft Exp $");
 #endif                         /* not lint */
 
 #include "curses.h"
@@ -257,8 +257,13 @@
 #ifdef DEBUG
        __CTRACE("init_pair: %d, %d, %d\n", pair, fore, back);
 #endif
+
        if (pair < 0 || pair >= COLOR_PAIRS)
-               return(ERR);
+               return (ERR);
+       if (fore < 0 || fore >= COLORS)
+               return (ERR);
+       if (back < 0 || back >= COLORS)
+               return (ERR);
 
        if ((pairs[pair].flags & __USED) && (fore != pairs[pair].fore ||
            back != pairs[pair].back))
@@ -266,24 +271,15 @@
        else
                changed = 0;
 
-       if (fore >= 0 && fore < COLORS)
-               pairs[pair].fore = fore;
-       else
-               return(ERR);
-
-       if (back >= 0 && back < COLOR_PAIRS)
-               pairs[pair].back = back;
-       else
-               return(ERR);
-
        pairs[pair].flags |= __USED;
+       pairs[pair].fore = fore;
+       pairs[pair].back = back;
 
        /* XXX: need to initialise HP style (iP) */
 
-       if (changed) {
-               __change_pair (pair);
-       }
-       return(OK);
+       if (changed)
+               __change_pair(pair);
+       return (OK);
 }
 
 /*



Home | Main Index | Thread Index | Old Index