diff options
| m--------- | contrib/scinterm | 0 | ||||
| -rw-r--r-- | src/interface-curses/interface.c | 8 |
2 files changed, 6 insertions, 2 deletions
diff --git a/contrib/scinterm b/contrib/scinterm -Subproject 5a89baa751e2655f3f11be90c2130e19244acf0 +Subproject 03310b95bdd5b8500e281ce9066d109ccaaaf25 diff --git a/src/interface-curses/interface.c b/src/interface-curses/interface.c index 6863a3b..45821f9 100644 --- a/src/interface-curses/interface.c +++ b/src/interface-curses/interface.c @@ -264,7 +264,7 @@ teco_color_pair(attr_t *attr, gshort fg, gshort bg) gpointer value = g_hash_table_lookup(teco_interface.pair_table, key); if (G_LIKELY(value != NULL)) return GPOINTER_TO_UINT(value); - if (G_UNLIKELY(next_pair >= MIN(COLOR_PAIRS, G_MAXSHORT+1))) + if (G_UNLIKELY(next_pair >= COLOR_PAIRS || next_pair > G_MAXSHORT)) return 0; init_pair(next_pair, fg, bg); g_hash_table_insert(teco_interface.pair_table, key, GUINT_TO_POINTER(next_pair)); @@ -746,7 +746,11 @@ teco_interface_init_interactive(GError **error) teco_interface.pair_table = g_hash_table_new(g_direct_hash, g_direct_equal); start_color(); - /* Scinterm uses shorts for color pairs, so G_MAXSHORT is the maximum */ + /* + * Scinterm uses shorts for color pairs, so G_MAXSHORT is the maximum. + * Some Curses implementations (NetBSD, PDCurses) may support less, + * but set COLOR_PAIRS accordingly. + */ scintilla_set_color_offsets(0, MIN(COLOR_PAIRS, G_MAXSHORT)/2); /* |
