[Python-bugs-list] [ python-Bugs-641808 ] Portability of Modules/_cursesmodule.c

noreply@sourceforge.net noreply@sourceforge.net
Thu, 21 Nov 2002 07:05:23 -0800


Bugs item #641808, was opened at 2002-11-21 12:18
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=641808&group_id=5470

Category: Extension Modules
Group: Python 2.2.2
>Status: Closed
>Resolution: Accepted
Priority: 5
Submitted By: Nick Maclaren (nmm1)
>Assigned to: Michael Hudson (mwh)
Summary: Portability of Modules/_cursesmodule.c

Initial Comment:
tparm is not a varargs function under at least Solaris,
IRIX and AIX (though there is a kludge in the last).
The following fix should work, but this is not an area
that I actually use:

*** Modules/_cursesmodule.c.org Mon Sep 30 17:16:13
2002
--- Modules/_cursesmodule.c     Thu Nov 21 11:58:40
2002
***************
*** 2321,2351 ****
  #else
        switch (PyTuple_GET_SIZE(args)) {
        case 1:
!               result = tparm(fmt);
                break;
        case 2:
!               result = tparm(fmt,i1);
                break;
        case 3:
!               result = tparm(fmt,i1,i2);
                break;
        case 4:
!               result = tparm(fmt,i1,i2,i3);
                break;
        case 5:
!               result = tparm(fmt,i1,i2,i3,i4);
                break;
        case 6:
!               result = tparm(fmt,i1,i2,i3,i4,i5);
                break;
        case 7:
!               result = tparm(fmt,i1,i2,i3,i4,i5,i6);
                break;
        case 8:
!               result =
tparm(fmt,i1,i2,i3,i4,i5,i6,i7);
                break;
        case 9:
!               result =
tparm(fmt,i1,i2,i3,i4,i5,i6,i7,i8);
                break;
        case 10:
                result =
tparm(fmt,i1,i2,i3,i4,i5,i6,i7,i8,i9);
--- 2321,2351 ----
  #else
        switch (PyTuple_GET_SIZE(args)) {
        case 1:
!               result = tparm(fmt,0,0,0,0,0,0,0,0,0);
                break;
        case 2:
!               result = tparm(fmt,i1,0,0,0,0,0,0,0,0);
                break;
        case 3:
!               result =
tparm(fmt,i1,i2,0,0,0,0,0,0,0);
                break;
        case 4:
!               result =
tparm(fmt,i1,i2,i3,0,0,0,0,0,0);
                break;
        case 5:
!               result =
tparm(fmt,i1,i2,i3,i4,0,0,0,0,0);
                break;
        case 6:
!               result =
tparm(fmt,i1,i2,i3,i4,i5,0,0,0,0);
                break;
        case 7:
!               result =
tparm(fmt,i1,i2,i3,i4,i5,i6,0,0,0);
                break;
        case 8:
!               result =
tparm(fmt,i1,i2,i3,i4,i5,i6,i7,0,0);
                break;
        case 9:
!               result =
tparm(fmt,i1,i2,i3,i4,i5,i6,i7,i8,0);
                break;
        case 10:
                result =
tparm(fmt,i1,i2,i3,i4,i5,i6,i7,i8,i9);


----------------------------------------------------------------------

Comment By: Michael Hudson (mwh)
Date: 2002-11-21 14:18

Message:
Logged In: YES 
user_id=6656

Hmm.  I've changed the function to:

PyCurses_tparm(PyObject *self, PyObject *args)
{
        char* fmt;
        char* result = NULL;
        int i1=0,i2=0,i3=0,i4=0,i5=0,i6=0,i7=0,i8=0,i9=0;

        PyCursesSetupTermCalled;

        if (!PyArg_ParseTuple(args, "s|iiiiiiiii:tparm", 
                              &fmt, &i1, &i2, &i3, &i4, 
                              &i5, &i6, &i7, &i8, &i9)) {
                return NULL;
        }

        result = tparm(fmt,i1,i2,i3,i4,i5,i6,i7,i8,i9);

        return PyString_FromString(result);
}

(which sf will now mangle).    This would have the same
effect, surely?

Thanks for the prod!

Checked in as revision 2.71 of Modules/_cursesmodule.c.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=641808&group_id=5470