X-Git-Url: https://ncurses.scripts.mit.edu/?a=blobdiff_plain;f=ncurses%2Fbase%2Fnew_pair.c;h=8597fc4db20b53cc0bb4a1edbfe56b63634bf956;hb=af3d0ee323cbb22d2a7596d564bf68f7307f5076;hp=271d494d8f884f3ad21102643b377541bfa5364b;hpb=90d42867e1296bc79021006a92032c76e59068b6;p=ncurses.git diff --git a/ncurses/base/new_pair.c b/ncurses/base/new_pair.c index 271d494d..8597fc4d 100644 --- a/ncurses/base/new_pair.c +++ b/ncurses/base/new_pair.c @@ -60,7 +60,7 @@ #endif -MODULE_ID("$Id: new_pair.c,v 1.8 2017/03/10 09:22:50 tom Exp $") +MODULE_ID("$Id: new_pair.c,v 1.11 2017/06/17 18:43:16 tom Exp $") #if USE_NEW_PAIR @@ -118,7 +118,7 @@ dumpit(SCREEN *sp, int pair, const char *tag) if (next_len(sp, 0) != prev_len(sp, 0)) { endwin(); - exit(1); + ExitProgram(EXIT_FAILURE); } } #else @@ -144,7 +144,8 @@ _nc_find_color_pair(SCREEN *sp, int fg, int bg) find.fg = fg; find.bg = bg; - if ((pp = tfind(&find, &sp->_ordered_pairs, compare_data)) != 0) { + if (sp != 0 && + (pp = tfind(&find, &sp->_ordered_pairs, compare_data)) != 0) { colorpair_t *temp = *(colorpair_t **) pp; result = (int) (temp - sp->_color_pairs); } else { @@ -221,7 +222,9 @@ NCURSES_SP_NAME(alloc_pair) (NCURSES_SP_DCLx int fg, int bg) int pair; T((T_CALLED("alloc_pair(%d,%d)"), fg, bg)); - if ((pair = _nc_find_color_pair(SP_PARM, fg, bg)) < 0) { + if (SP_PARM == 0) { + pair = -1; + } else if ((pair = _nc_find_color_pair(SP_PARM, fg, bg)) < 0) { /* * Check if all of the slots have been used. If not, find one and * use that. @@ -261,11 +264,8 @@ NCURSES_SP_NAME(alloc_pair) (NCURSES_SP_DCLx int fg, int bg) T(("reusing %d", pair)); } - if (pair > 0 && pair <= MAX_XCURSES_PAIR) { - IGNORE_RC(init_pair((short)pair, (short)fg, (short)bg)); - } else { + if (_nc_init_pair(SP_PARM, pair, fg, bg) == ERR) pair = ERR; - } } returnCode(pair); } @@ -336,5 +336,5 @@ void _nc_new_pair(void); void _nc_new_pair(void) { -}; +} #endif /* USE_NEW_PAIR */