- * Copyright (c) 2017 Free Software Foundation, Inc. *
+ * Copyright 2018-2019,2020 Thomas E. Dickey *
+ * Copyright 2017 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 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
- sprintf(p, " %d%c(%d,%d)",
- n, n == pair ? '@' : ':', list[n].next, list[n].prev);
+ if ((size_t) (p - bigbuf) + 50 > have)
+ break;
+ _nc_SPRINTF(p, _nc_SLIMIT(have - (p - bigbuf))
+ " %d%c(%d,%d)",
+ n, n == pair ? '@' : ':', list[n].next, list[n].prev);
- 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 {
- result = -1;
+ if (sp != 0) {
+ if ((pp = tfind(&find, &sp->_ordered_pairs, compare_data)) != 0) {
+ colorpair_t *temp = *(colorpair_t **) pp;
+ result = (int) (temp - sp->_color_pairs);
+ }
delink_color_pair(sp, pair);
if (last->mode > cpFREE &&
(last->fg != next->fg || last->bg != next->bg)) {
/* remove the old entry from fast index */
tdelete(last, &sp->_ordered_pairs, compare_data);
delink_color_pair(sp, pair);
if (last->mode > cpFREE &&
(last->fg != next->fg || last->bg != next->bg)) {
/* remove the old entry from fast index */
tdelete(last, &sp->_ordered_pairs, compare_data);
/* create a new entry in fast index */
*last = *next;
tsearch(last, &sp->_ordered_pairs, compare_data);
/* create a new entry in fast index */
*last = *next;
tsearch(last, &sp->_ordered_pairs, compare_data);