Skip to content

Commit acb3f87

Browse files
authored
gh-123961: Add curses prefix to global variables in _cursesmodule.c (#124047)
Use the `const char*` type instead of a `const *` for the encoding name.
1 parent e49d1b4 commit acb3f87

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

Modules/_cursesmodule.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -170,20 +170,20 @@ class _curses.window "PyCursesWindowObject *" "&PyCursesWindow_Type"
170170
static PyObject *PyCursesError;
171171

172172
/* Tells whether setupterm() has been called to initialise terminfo. */
173-
static int initialised_setupterm = FALSE;
173+
static int curses_setupterm_called = FALSE;
174174

175175
/* Tells whether initscr() has been called to initialise curses. */
176-
static int initialised = FALSE;
176+
static int curses_initscr_called = FALSE;
177177

178178
/* Tells whether start_color() has been called to initialise color usage. */
179-
static int initialisedcolors = FALSE;
179+
static int curses_start_color_called = FALSE;
180180

181-
static char *screen_encoding = NULL;
181+
static const char *curses_screen_encoding = NULL;
182182

183183
/* Utility Macros */
184184
#define PyCursesSetupTermCalled \
185185
do { \
186-
if (initialised_setupterm != TRUE) { \
186+
if (curses_setupterm_called != TRUE) { \
187187
PyErr_SetString(PyCursesError, \
188188
"must call (at least) setupterm() first"); \
189189
return 0; \
@@ -192,7 +192,7 @@ static char *screen_encoding = NULL;
192192

193193
#define PyCursesInitialised \
194194
do { \
195-
if (initialised != TRUE) { \
195+
if (curses_initscr_called != TRUE) { \
196196
PyErr_SetString(PyCursesError, \
197197
"must call initscr() first"); \
198198
return 0; \
@@ -201,7 +201,7 @@ static char *screen_encoding = NULL;
201201

202202
#define PyCursesInitialisedColor \
203203
do { \
204-
if (initialisedcolors != TRUE) { \
204+
if (curses_start_color_called != TRUE) { \
205205
PyErr_SetString(PyCursesError, \
206206
"must call start_color() first"); \
207207
return 0; \
@@ -267,7 +267,7 @@ PyCurses_ConvertToChtype(PyCursesWindowObject *win, PyObject *obj, chtype *ch)
267267
if (win)
268268
encoding = win->encoding;
269269
else
270-
encoding = screen_encoding;
270+
encoding = curses_screen_encoding;
271271
bytes = PyUnicode_AsEncodedString(obj, encoding, NULL);
272272
if (bytes == NULL)
273273
return 0;
@@ -3278,7 +3278,7 @@ _curses_initscr_impl(PyObject *module)
32783278
{
32793279
WINDOW *win;
32803280

3281-
if (initialised) {
3281+
if (curses_initscr_called) {
32823282
wrefresh(stdscr);
32833283
return (PyObject *)PyCursesWindow_New(stdscr, NULL);
32843284
}
@@ -3290,7 +3290,7 @@ _curses_initscr_impl(PyObject *module)
32903290
return NULL;
32913291
}
32923292

3293-
initialised = initialised_setupterm = TRUE;
3293+
curses_initscr_called = curses_setupterm_called = TRUE;
32943294

32953295
PyObject *module_dict = PyModule_GetDict(module); // borrowed
32963296
if (module_dict == NULL) {
@@ -3386,7 +3386,7 @@ _curses_initscr_impl(PyObject *module)
33863386
if (winobj == NULL) {
33873387
return NULL;
33883388
}
3389-
screen_encoding = winobj->encoding;
3389+
curses_screen_encoding = winobj->encoding;
33903390
return (PyObject *)winobj;
33913391
}
33923392

@@ -3428,7 +3428,7 @@ _curses_setupterm_impl(PyObject *module, const char *term, int fd)
34283428
}
34293429
}
34303430

3431-
if (!initialised_setupterm && setupterm((char *)term, fd, &err) == ERR) {
3431+
if (!curses_setupterm_called && setupterm((char *)term, fd, &err) == ERR) {
34323432
const char* s = "setupterm: unknown error";
34333433

34343434
if (err == 0) {
@@ -3441,7 +3441,7 @@ _curses_setupterm_impl(PyObject *module, const char *term, int fd)
34413441
return NULL;
34423442
}
34433443

3444-
initialised_setupterm = TRUE;
3444+
curses_setupterm_called = TRUE;
34453445

34463446
Py_RETURN_NONE;
34473447
}
@@ -4245,7 +4245,7 @@ _curses_start_color_impl(PyObject *module)
42454245
return NULL;
42464246
}
42474247

4248-
initialisedcolors = TRUE;
4248+
curses_start_color_called = TRUE;
42494249

42504250
PyObject *module_dict = PyModule_GetDict(module); // borrowed
42514251
if (module_dict == NULL) {

Tools/c-analyzer/cpython/globals-to-fix.tsv

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -409,10 +409,10 @@ Modules/_tkinter.c - trbInCmd -
409409
Include/datetime.h - PyDateTimeAPI -
410410
Modules/_ctypes/cfield.c _ctypes_get_fielddesc initialized -
411411
Modules/_ctypes/malloc_closure.c - _pagesize -
412-
Modules/_cursesmodule.c - initialised -
413-
Modules/_cursesmodule.c - initialised_setupterm -
414-
Modules/_cursesmodule.c - initialisedcolors -
415-
Modules/_cursesmodule.c - screen_encoding -
412+
Modules/_cursesmodule.c - curses_initscr_called -
413+
Modules/_cursesmodule.c - curses_setupterm_called -
414+
Modules/_cursesmodule.c - curses_start_color_called -
415+
Modules/_cursesmodule.c - curses_screen_encoding -
416416
Modules/_elementtree.c - expat_capi -
417417
Modules/readline.c - libedit_append_replace_history_offset -
418418
Modules/readline.c - using_libedit_emulation -

0 commit comments

Comments
 (0)