Annotation of pkgsrc/lang/python35/patches/patch-Modules___cursesmodule.c, revision 1.5

1.5     ! adam        1: $NetBSD: patch-Modules___cursesmodule.c,v 1.4 2017/01/05 23:16:42 roy Exp $
1.1       adam        2: 
1.3       roy         3: Allow py-curses to use NetBSD curses as well as ncurses
1.1       adam        4: http://bugs.python.org/issue21457
1.5     ! adam        5: Use is_pad() when supported (taken from Python 3.7).
1.1       adam        6: 
1.5     ! adam        7: --- Modules/_cursesmodule.c.orig       2018-02-04 23:40:56.000000000 +0000
1.1       adam        8: +++ Modules/_cursesmodule.c
1.5     ! adam        9: @@ -112,13 +112,13 @@ char *PyCursesVersion = "2.2";
1.3       roy        10:  #define CURSES_MODULE
                     11:  #include "py_curses.h"
                     12:  
                     13: -/*  These prototypes are in <term.h>, but including this header
                     14: -    #defines many common symbols (such as "lines") which breaks the
                     15: -    curses module in other ways.  So the code will just specify
                     16: -    explicit prototypes here. */
                     17: -extern int setupterm(char *,int,int *);
                     18: -#ifdef __sgi
1.5     ! adam       19: +#if defined(HAVE_TERM_H) || defined(__sgi)
        !            20: +/* For termname, longname, putp, tigetflag, tigetnum, tigetstr, tparm
        !            21: +   which are not declared in SysV curses and for setupterm. */
1.3       roy        22:  #include <term.h>
1.5     ! adam       23: +/* Including <term.h> #defines many common symbols. */
        !            24: +#undef lines
        !            25: +#undef columns
1.3       roy        26:  #endif
                     27:  
1.5     ! adam       28:  #ifdef HAVE_LANGINFO_H
        !            29: @@ -494,17 +494,9 @@ Window_NoArg2TupleReturnFunction(getpary
1.1       adam       30:  
                     31:  Window_OneArgNoReturnFunction(clearok, int, "i;True(1) or False(0)")
                     32:  Window_OneArgNoReturnFunction(idlok, int, "i;True(1) or False(0)")
                     33: -#if defined(__NetBSD__)
                     34: -Window_OneArgNoReturnVoidFunction(keypad, int, "i;True(1) or False(0)")
                     35: -#else
                     36:  Window_OneArgNoReturnFunction(keypad, int, "i;True(1) or False(0)")
                     37: -#endif
                     38:  Window_OneArgNoReturnFunction(leaveok, int, "i;True(1) or False(0)")
                     39: -#if defined(__NetBSD__)
                     40: -Window_OneArgNoReturnVoidFunction(nodelay, int, "i;True(1) or False(0)")
                     41: -#else
                     42:  Window_OneArgNoReturnFunction(nodelay, int, "i;True(1) or False(0)")
                     43: -#endif
                     44:  Window_OneArgNoReturnFunction(notimeout, int, "i;True(1) or False(0)")
                     45:  Window_OneArgNoReturnFunction(scrollok, int, "i;True(1) or False(0)")
                     46:  Window_OneArgNoReturnFunction(winsdelln, int, "i;nlines")
1.5     ! adam       47: @@ -940,6 +932,12 @@ int py_mvwdelch(WINDOW *w, int y, int x)
        !            48:  }
        !            49:  #endif
        !            50:  
        !            51: +#if defined(HAVE_CURSES_IS_PAD)
        !            52: +#define py_is_pad(win)      is_pad(win)
        !            53: +#elif defined(WINDOW_HAS_FLAGS)
        !            54: +#define py_is_pad(win)      ((win) ? ((win)->_flags & _ISPAD) != 0 : FALSE)
        !            55: +#endif
        !            56: +
        !            57:  /* chgat, added by Fabian Kreutz <fabian.kreutz at gmx.net> */
        !            58:  
        !            59:  static PyObject *
        !            60: @@ -1080,7 +1078,7 @@ PyCursesWindow_EchoChar(PyCursesWindowOb
1.3       roy        61:          return NULL;
                     62:  
                     63:  #ifdef WINDOW_HAS_FLAGS
                     64: -    if (self->win->_flags & _ISPAD)
1.5     ! adam       65: +    if (py_is_pad(self->win))
1.3       roy        66:          return PyCursesCheckERR(pechochar(self->win, ch | attr),
                     67:                                  "echochar");
                     68:      else
1.5     ! adam       69: @@ -1166,11 +1164,7 @@ PyCursesWindow_GetKey(PyCursesWindowObje
1.1       adam       70:          return Py_BuildValue("C", rtn);
                     71:      } else {
                     72:          const char *knp;
                     73: -#if defined(__NetBSD__)
                     74: -        knp = unctrl(rtn);
                     75: -#else
                     76:          knp = keyname(rtn);
                     77: -#endif
                     78:          return PyUnicode_FromString((knp == NULL) ? "" : knp);
                     79:      }
                     80:  }
1.5     ! adam       81: @@ -1619,7 +1613,7 @@ PyCursesWindow_NoOutRefresh(PyCursesWind
1.3       roy        82:  #ifndef WINDOW_HAS_FLAGS
                     83:      if (0)
                     84:  #else
                     85: -        if (self->win->_flags & _ISPAD)
1.5     ! adam       86: +        if (py_is_pad(self->win))
1.3       roy        87:  #endif
                     88:          {
                     89:              switch(PyTuple_Size(args)) {
1.5     ! adam       90: @@ -1794,7 +1788,7 @@ PyCursesWindow_Refresh(PyCursesWindowObj
1.3       roy        91:  #ifndef WINDOW_HAS_FLAGS
                     92:      if (0)
                     93:  #else
                     94: -        if (self->win->_flags & _ISPAD)
1.5     ! adam       95: +        if (py_is_pad(self->win))
1.3       roy        96:  #endif
                     97:          {
                     98:              switch(PyTuple_Size(args)) {
1.5     ! adam       99: @@ -1861,7 +1855,7 @@ PyCursesWindow_SubWin(PyCursesWindowObje
1.3       roy       100:  
                    101:      /* printf("Subwin: %i %i %i %i   \n", nlines, ncols, begin_y, begin_x); */
                    102:  #ifdef WINDOW_HAS_FLAGS
                    103: -    if (self->win->_flags & _ISPAD)
1.5     ! adam      104: +    if (py_is_pad(self->win))
1.3       roy       105:          win = subpad(self->win, nlines, ncols, begin_y, begin_x);
                    106:      else
                    107:  #endif
1.5     ! adam      108: @@ -2621,7 +2615,6 @@ PyCurses_Is_Term_Resized(PyObject *self,
1.1       adam      109:  }
                    110:  #endif /* HAVE_CURSES_IS_TERM_RESIZED */
                    111:  
                    112: -#if !defined(__NetBSD__)
                    113:  static PyObject *
                    114:  PyCurses_KeyName(PyObject *self, PyObject *args)
                    115:  {
1.5     ! adam      116: @@ -2640,7 +2633,6 @@ PyCurses_KeyName(PyObject *self, PyObjec
1.2       wiz       117:  
                    118:      return PyBytes_FromString((knp == NULL) ? "" : knp);
1.1       adam      119:  }
                    120: -#endif
                    121:  
                    122:  static PyObject *
1.2       wiz       123:  PyCurses_KillChar(PyObject *self)
1.5     ! adam      124: @@ -3254,9 +3246,7 @@ static PyMethodDef PyCurses_methods[] = 
1.1       adam      125:  #ifdef HAVE_CURSES_IS_TERM_RESIZED
                    126:      {"is_term_resized",     (PyCFunction)PyCurses_Is_Term_Resized, METH_VARARGS},
                    127:  #endif
                    128: -#if !defined(__NetBSD__)
                    129:      {"keyname",             (PyCFunction)PyCurses_KeyName, METH_VARARGS},
                    130: -#endif
                    131:      {"killchar",            (PyCFunction)PyCurses_KillChar, METH_NOARGS},
                    132:      {"longname",            (PyCFunction)PyCurses_longname, METH_NOARGS},
                    133:      {"meta",                (PyCFunction)PyCurses_Meta, METH_VARARGS},
1.5     ! adam      134: @@ -3385,9 +3375,7 @@ PyInit__curses(void)
1.1       adam      135:      SetDictInt("A_DIM",                 A_DIM);
                    136:      SetDictInt("A_BOLD",                A_BOLD);
                    137:      SetDictInt("A_ALTCHARSET",          A_ALTCHARSET);
                    138: -#if !defined(__NetBSD__)
                    139:      SetDictInt("A_INVIS",           A_INVIS);
                    140: -#endif
                    141:      SetDictInt("A_PROTECT",         A_PROTECT);
                    142:      SetDictInt("A_CHARTEXT",        A_CHARTEXT);
                    143:      SetDictInt("A_COLOR",           A_COLOR);
1.5     ! adam      144: @@ -3459,7 +3447,6 @@ PyInit__curses(void)
1.1       adam      145:          int key;
                    146:          char *key_n;
                    147:          char *key_n2;
                    148: -#if !defined(__NetBSD__)
                    149:          for (key=KEY_MIN;key < KEY_MAX; key++) {
                    150:              key_n = (char *)keyname(key);
                    151:              if (key_n == NULL || strcmp(key_n,"UNKNOWN KEY")==0)
1.5     ! adam      152: @@ -3487,7 +3474,6 @@ PyInit__curses(void)
1.1       adam      153:              if (key_n2 != key_n)
                    154:                  PyMem_Free(key_n2);
                    155:          }
                    156: -#endif
                    157:          SetDictInt("KEY_MIN", KEY_MIN);
                    158:          SetDictInt("KEY_MAX", KEY_MAX);
                    159:      }

CVSweb <webmaster@jp.NetBSD.org>