Skip to content

Commit 9de6a48

Browse files
Inline the single-use getcchar() extended-pair condition
_NCURSES_GETCCHAR_EXTENDED_PAIR was referenced in only one place; move the version condition and its comment to that call site. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent cad3106 commit 9de6a48

1 file changed

Lines changed: 3 additions & 11 deletions

File tree

Modules/_cursesmodule.c

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -151,16 +151,6 @@ typedef chtype attr_t; /* No attr_t type is available */
151151
#define _CURSES_PAIR_CONTENT_FUNC pair_content
152152
#endif /* _NCURSES_EXTENDED_COLOR_FUNCS */
153153

154-
/* getcchar() returned ERR for a non-NULL opts before ncurses 6.3 (patch
155-
20210116, https://invisible-island.net/ncurses/), so read a cchar_t's color
156-
pair through the plain short slot rather than the extended-color opts slot on
157-
older libraries. setcchar() is unaffected: it accepts opts on every version. */
158-
#if _NCURSES_EXTENDED_COLOR_FUNCS && NCURSES_VERSION_PATCH+0 >= 20210116
159-
#define _NCURSES_GETCCHAR_EXTENDED_PAIR 1
160-
#else
161-
#define _NCURSES_GETCCHAR_EXTENDED_PAIR 0
162-
#endif
163-
164154
typedef struct {
165155
PyObject *error; // curses exception type
166156
PyTypeObject *window_type; // exposed by PyCursesWindow_Type
@@ -773,7 +763,9 @@ curses_getcchar(const cchar_t *wcval, wchar_t *wstr, attr_t *attrs, int *pair)
773763
/* getcchar() is not guaranteed to write the text of an empty cell, so make
774764
the output an empty string by default. */
775765
wstr[0] = L'\0';
776-
#if _NCURSES_GETCCHAR_EXTENDED_PAIR
766+
/* getcchar()'s opts slot returns the extended color pair, but ncurses
767+
returned ERR for a non-NULL opts until 6.3 (patch 20210116). */
768+
#if _NCURSES_EXTENDED_COLOR_FUNCS && NCURSES_VERSION_PATCH+0 >= 20210116
777769
int rtn = getcchar(wcval, wstr, attrs, &spair, pair);
778770
#else
779771
int rtn = getcchar(wcval, wstr, attrs, &spair, NULL);

0 commit comments

Comments
 (0)