Patch 1114: fix compilation of curses module on 64-bit AIX, and any other LP64 platforms where attr_t isn't a C long
diff --git a/Modules/_cursesmodule.c b/Modules/_cursesmodule.c
index d883680..1f6a426 100644
--- a/Modules/_cursesmodule.c
+++ b/Modules/_cursesmodule.c
@@ -312,9 +312,6 @@
Window_NoArg2TupleReturnFunction(getmaxyx, int, "ii")
Window_NoArg2TupleReturnFunction(getparyx, int, "ii")
-Window_OneArgNoReturnFunction(wattron, attr_t, "l;attr")
-Window_OneArgNoReturnFunction(wattroff, attr_t, "l;attr")
-Window_OneArgNoReturnFunction(wattrset, attr_t, "l;attr")
Window_OneArgNoReturnFunction(clearok, int, "i;True(1) or False(0)")
Window_OneArgNoReturnFunction(idlok, int, "i;True(1) or False(0)")
#if defined(__NetBSD__)
@@ -369,6 +366,7 @@
PyObject *temp;
chtype ch = 0;
attr_t attr = A_NORMAL;
+ long lattr;
switch (PyTuple_Size(args)) {
case 1:
@@ -376,8 +374,9 @@
return NULL;
break;
case 2:
- if (!PyArg_ParseTuple(args, "Ol;ch or int,attr", &temp, &attr))
+ if (!PyArg_ParseTuple(args, "Ol;ch or int,attr", &temp, &lattr))
return NULL;
+ attr = lattr;
break;
case 3:
if (!PyArg_ParseTuple(args,"iiO;y,x,ch or int", &y, &x, &temp))
@@ -386,8 +385,9 @@
break;
case 4:
if (!PyArg_ParseTuple(args,"iiOl;y,x,ch or int, attr",
- &y, &x, &temp, &attr))
+ &y, &x, &temp, &lattr))
return NULL;
+ attr = lattr;
use_xy = TRUE;
break;
default:
@@ -415,6 +415,7 @@
int x, y;
char *str;
attr_t attr = A_NORMAL , attr_old = A_NORMAL;
+ long lattr;
int use_xy = FALSE, use_attr = FALSE;
switch (PyTuple_Size(args)) {
@@ -423,8 +424,9 @@
return NULL;
break;
case 2:
- if (!PyArg_ParseTuple(args,"sl;str,attr", &str, &attr))
+ if (!PyArg_ParseTuple(args,"sl;str,attr", &str, &lattr))
return NULL;
+ attr = lattr;
use_attr = TRUE;
break;
case 3:
@@ -433,8 +435,9 @@
use_xy = TRUE;
break;
case 4:
- if (!PyArg_ParseTuple(args,"iisl;int,int,str,attr", &y, &x, &str, &attr))
+ if (!PyArg_ParseTuple(args,"iisl;int,int,str,attr", &y, &x, &str, &lattr))
return NULL;
+ attr = lattr;
use_xy = use_attr = TRUE;
break;
default:
@@ -461,6 +464,7 @@
int rtn, x, y, n;
char *str;
attr_t attr = A_NORMAL , attr_old = A_NORMAL;
+ long lattr;
int use_xy = FALSE, use_attr = FALSE;
switch (PyTuple_Size(args)) {
@@ -469,8 +473,9 @@
return NULL;
break;
case 3:
- if (!PyArg_ParseTuple(args,"sil;str,n,attr", &str, &n, &attr))
+ if (!PyArg_ParseTuple(args,"sil;str,n,attr", &str, &n, &lattr))
return NULL;
+ attr = lattr;
use_attr = TRUE;
break;
case 4:
@@ -479,8 +484,9 @@
use_xy = TRUE;
break;
case 5:
- if (!PyArg_ParseTuple(args,"iisil;y,x,str,n,attr", &y, &x, &str, &n, &attr))
+ if (!PyArg_ParseTuple(args,"iisil;y,x,str,n,attr", &y, &x, &str, &n, &lattr))
return NULL;
+ attr = lattr;
use_xy = use_attr = TRUE;
break;
default:
@@ -507,6 +513,7 @@
PyObject *temp;
chtype bkgd;
attr_t attr = A_NORMAL;
+ long lattr;
switch (PyTuple_Size(args)) {
case 1:
@@ -514,8 +521,9 @@
return NULL;
break;
case 2:
- if (!PyArg_ParseTuple(args,"Ol;ch or int,attr", &temp, &attr))
+ if (!PyArg_ParseTuple(args,"Ol;ch or int,attr", &temp, &lattr))
return NULL;
+ attr = lattr;
break;
default:
PyErr_SetString(PyExc_TypeError, "bkgd requires 1 or 2 arguments");
@@ -531,11 +539,39 @@
}
static PyObject *
+PyCursesWindow_AttrOff(PyCursesWindowObject *self, PyObject *args)
+{
+ long lattr;
+ if (!PyArg_ParseTuple(args,"l;attr", &lattr))
+ return NULL;
+ return PyCursesCheckERR(wattroff(self->win, (attr_t)lattr), "attroff");
+}
+
+static PyObject *
+PyCursesWindow_AttrOn(PyCursesWindowObject *self, PyObject *args)
+{
+ long lattr;
+ if (!PyArg_ParseTuple(args,"l;attr", &lattr))
+ return NULL;
+ return PyCursesCheckERR(wattron(self->win, (attr_t)lattr), "attron");
+}
+
+static PyObject *
+PyCursesWindow_AttrSet(PyCursesWindowObject *self, PyObject *args)
+{
+ long lattr;
+ if (!PyArg_ParseTuple(args,"l;attr", &lattr))
+ return NULL;
+ return PyCursesCheckERR(wattrset(self->win, (attr_t)lattr), "attrset");
+}
+
+static PyObject *
PyCursesWindow_BkgdSet(PyCursesWindowObject *self, PyObject *args)
{
PyObject *temp;
chtype bkgd;
attr_t attr = A_NORMAL;
+ long lattr;
switch (PyTuple_Size(args)) {
case 1:
@@ -543,8 +579,9 @@
return NULL;
break;
case 2:
- if (!PyArg_ParseTuple(args,"Ol;ch or int,attr", &temp, &attr))
+ if (!PyArg_ParseTuple(args,"Ol;ch or int,attr", &temp, &lattr))
return NULL;
+ attr = lattr;
break;
default:
PyErr_SetString(PyExc_TypeError, "bkgdset requires 1 or 2 arguments");
@@ -682,6 +719,7 @@
PyObject *temp;
chtype ch;
attr_t attr = A_NORMAL;
+ long lattr;
switch (PyTuple_Size(args)) {
case 1:
@@ -689,8 +727,9 @@
return NULL;
break;
case 2:
- if (!PyArg_ParseTuple(args,"Ol;ch or int,attr", &temp, &attr))
+ if (!PyArg_ParseTuple(args,"Ol;ch or int,attr", &temp, &lattr))
return NULL;
+ attr = lattr;
break;
default:
PyErr_SetString(PyExc_TypeError, "echochar requires 1 or 2 arguments");
@@ -856,6 +895,7 @@
chtype ch;
int n, x, y, code = OK;
attr_t attr = A_NORMAL;
+ long lattr;
switch (PyTuple_Size(args)) {
case 2:
@@ -863,8 +903,9 @@
return NULL;
break;
case 3:
- if (!PyArg_ParseTuple(args, "Oil;ch or int,n,attr", &temp, &n, &attr))
+ if (!PyArg_ParseTuple(args, "Oil;ch or int,n,attr", &temp, &n, &lattr))
return NULL;
+ attr = lattr;
break;
case 4:
if (!PyArg_ParseTuple(args, "iiOi;y,x,ch or int,n", &y, &x, &temp, &n))
@@ -873,8 +914,9 @@
break;
case 5:
if (!PyArg_ParseTuple(args, "iiOil; y,x,ch or int,n,attr",
- &y, &x, &temp, &n, &attr))
+ &y, &x, &temp, &n, &lattr))
return NULL;
+ attr = lattr;
code = wmove(self->win, y, x);
break;
default:
@@ -900,6 +942,7 @@
PyObject *temp;
chtype ch = 0;
attr_t attr = A_NORMAL;
+ long lattr;
switch (PyTuple_Size(args)) {
case 1:
@@ -907,8 +950,9 @@
return NULL;
break;
case 2:
- if (!PyArg_ParseTuple(args, "Ol;ch or int,attr", &temp, &attr))
+ if (!PyArg_ParseTuple(args, "Ol;ch or int,attr", &temp, &lattr))
return NULL;
+ attr = lattr;
break;
case 3:
if (!PyArg_ParseTuple(args,"iiO;y,x,ch or int", &y, &x, &temp))
@@ -916,8 +960,9 @@
use_xy = TRUE;
break;
case 4:
- if (!PyArg_ParseTuple(args,"iiOl;y,x,ch or int, attr", &y, &x, &temp, &attr))
+ if (!PyArg_ParseTuple(args,"iiOl;y,x,ch or int, attr", &y, &x, &temp, &lattr))
return NULL;
+ attr = lattr;
use_xy = TRUE;
break;
default:
@@ -1002,6 +1047,7 @@
int x, y;
char *str;
attr_t attr = A_NORMAL , attr_old = A_NORMAL;
+ long lattr;
int use_xy = FALSE, use_attr = FALSE;
switch (PyTuple_Size(args)) {
@@ -1010,8 +1056,9 @@
return NULL;
break;
case 2:
- if (!PyArg_ParseTuple(args,"sl;str,attr", &str, &attr))
+ if (!PyArg_ParseTuple(args,"sl;str,attr", &str, &lattr))
return NULL;
+ attr = lattr;
use_attr = TRUE;
break;
case 3:
@@ -1020,8 +1067,9 @@
use_xy = TRUE;
break;
case 4:
- if (!PyArg_ParseTuple(args,"iisl;y,x,str,attr", &y, &x, &str, &attr))
+ if (!PyArg_ParseTuple(args,"iisl;y,x,str,attr", &y, &x, &str, &lattr))
return NULL;
+ attr = lattr;
use_xy = use_attr = TRUE;
break;
default:
@@ -1048,6 +1096,7 @@
int rtn, x, y, n;
char *str;
attr_t attr = A_NORMAL , attr_old = A_NORMAL;
+ long lattr;
int use_xy = FALSE, use_attr = FALSE;
switch (PyTuple_Size(args)) {
@@ -1056,8 +1105,9 @@
return NULL;
break;
case 3:
- if (!PyArg_ParseTuple(args,"sil;str,n,attr", &str, &n, &attr))
+ if (!PyArg_ParseTuple(args,"sil;str,n,attr", &str, &n, &lattr))
return NULL;
+ attr = lattr;
use_attr = TRUE;
break;
case 4:
@@ -1066,8 +1116,9 @@
use_xy = TRUE;
break;
case 5:
- if (!PyArg_ParseTuple(args,"iisil;y,x,str,n,attr", &y, &x, &str, &n, &attr))
+ if (!PyArg_ParseTuple(args,"iisil;y,x,str,n,attr", &y, &x, &str, &n, &lattr))
return NULL;
+ attr = lattr;
use_xy = use_attr = TRUE;
break;
default:
@@ -1383,6 +1434,7 @@
chtype ch;
int n, x, y, code = OK;
attr_t attr = A_NORMAL;
+ long lattr;
switch (PyTuple_Size(args)) {
case 2:
@@ -1390,8 +1442,9 @@
return NULL;
break;
case 3:
- if (!PyArg_ParseTuple(args, "Oil;ch or int,n,attr", &temp, &n, &attr))
+ if (!PyArg_ParseTuple(args, "Oil;ch or int,n,attr", &temp, &n, &lattr))
return NULL;
+ attr = lattr;
break;
case 4:
if (!PyArg_ParseTuple(args, "iiOi;y,x,ch or int,n", &y, &x, &temp, &n))
@@ -1400,8 +1453,9 @@
break;
case 5:
if (!PyArg_ParseTuple(args, "iiOil; y,x,ch or int,n,attr",
- &y, &x, &temp, &n, &attr))
+ &y, &x, &temp, &n, &lattr))
return NULL;
+ attr = lattr;
code = wmove(self->win, y, x);
break;
default:
@@ -1424,9 +1478,9 @@
{"addch", (PyCFunction)PyCursesWindow_AddCh, METH_VARARGS},
{"addnstr", (PyCFunction)PyCursesWindow_AddNStr, METH_VARARGS},
{"addstr", (PyCFunction)PyCursesWindow_AddStr, METH_VARARGS},
- {"attroff", (PyCFunction)PyCursesWindow_wattroff, METH_VARARGS},
- {"attron", (PyCFunction)PyCursesWindow_wattron, METH_VARARGS},
- {"attrset", (PyCFunction)PyCursesWindow_wattrset, METH_VARARGS},
+ {"attroff", (PyCFunction)PyCursesWindow_AttrOff, METH_VARARGS},
+ {"attron", (PyCFunction)PyCursesWindow_AttrOn, METH_VARARGS},
+ {"attrset", (PyCFunction)PyCursesWindow_AttrSet, METH_VARARGS},
{"bkgd", (PyCFunction)PyCursesWindow_Bkgd, METH_VARARGS},
{"bkgdset", (PyCFunction)PyCursesWindow_BkgdSet, METH_VARARGS},
{"border", (PyCFunction)PyCursesWindow_Border, METH_VARARGS},