Annotation of pkgsrc/lang/python34/patches/patch-Modules___cursesmodule.c, revision 1.1

1.1     ! adam        1: $NetBSD: patch-ah,v 1.5 2017/01/05 23:16:42 roy Exp $
        !             2: 
        !             3: Allow py-curses to use NetBSD curses as well as ncurses
        !             4: http://bugs.python.org/issue21457
        !             5: Use is_pad() when supported (taken from Python 3.7).
        !             6: 
        !             7: --- Modules/_cursesmodule.c.orig       2018-02-04 23:40:38.000000000 +0000
        !             8: +++ Modules/_cursesmodule.c
        !             9: @@ -112,13 +112,13 @@ char *PyCursesVersion = "2.2";
        !            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
        !            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. */
        !            22:  #include <term.h>
        !            23: +/* Including <term.h> #defines many common symbols. */
        !            24: +#undef lines
        !            25: +#undef columns
        !            26:  #endif
        !            27:  
        !            28:  #ifdef HAVE_LANGINFO_H
        !            29: @@ -484,17 +484,9 @@ Window_NoArg2TupleReturnFunction(getpary
        !            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")
        !            47: @@ -993,6 +985,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: @@ -1133,7 +1131,7 @@ PyCursesWindow_EchoChar(PyCursesWindowOb
        !            61:          return NULL;
        !            62:  
        !            63:  #ifdef WINDOW_HAS_FLAGS
        !            64: -    if (self->win->_flags & _ISPAD)
        !            65: +    if (py_is_pad(self->win))
        !            66:          return PyCursesCheckERR(pechochar(self->win, ch | attr),
        !            67:                                  "echochar");
        !            68:      else
        !            69: @@ -1219,11 +1217,7 @@ PyCursesWindow_GetKey(PyCursesWindowObje
        !            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:  }
        !            81: @@ -1672,7 +1666,7 @@ PyCursesWindow_NoOutRefresh(PyCursesWind
        !            82:  #ifndef WINDOW_HAS_FLAGS
        !            83:      if (0)
        !            84:  #else
        !            85: -        if (self->win->_flags & _ISPAD)
        !            86: +        if (py_is_pad(self->win))
        !            87:  #endif
        !            88:          {
        !            89:              switch(PyTuple_Size(args)) {
        !            90: @@ -1847,7 +1841,7 @@ PyCursesWindow_Refresh(PyCursesWindowObj
        !            91:  #ifndef WINDOW_HAS_FLAGS
        !            92:      if (0)
        !            93:  #else
        !            94: -        if (self->win->_flags & _ISPAD)
        !            95: +        if (py_is_pad(self->win))
        !            96:  #endif
        !            97:          {
        !            98:              switch(PyTuple_Size(args)) {
        !            99: @@ -1914,7 +1908,7 @@ PyCursesWindow_SubWin(PyCursesWindowObje
        !           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)
        !           104: +    if (py_is_pad(self->win))
        !           105:          win = subpad(self->win, nlines, ncols, begin_y, begin_x);
        !           106:      else
        !           107:  #endif
        !           108: @@ -2674,7 +2668,6 @@ PyCurses_Is_Term_Resized(PyObject *self,
        !           109:  }
        !           110:  #endif /* HAVE_CURSES_IS_TERM_RESIZED */
        !           111:  
        !           112: -#if !defined(__NetBSD__)
        !           113:  static PyObject *
        !           114:  PyCurses_KeyName(PyObject *self, PyObject *args)
        !           115:  {
        !           116: @@ -2693,7 +2686,6 @@ PyCurses_KeyName(PyObject *self, PyObjec
        !           117:  
        !           118:      return PyBytes_FromString((knp == NULL) ? "" : (char *)knp);
        !           119:  }
        !           120: -#endif
        !           121:  
        !           122:  static PyObject *
        !           123:  PyCurses_KillChar(PyObject *self)
        !           124: @@ -3300,9 +3292,7 @@ static PyMethodDef PyCurses_methods[] = 
        !           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},
        !           134: @@ -3428,9 +3418,7 @@ PyInit__curses(void)
        !           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);
        !           144: @@ -3502,7 +3490,6 @@ PyInit__curses(void)
        !           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)
        !           152: @@ -3530,7 +3517,6 @@ PyInit__curses(void)
        !           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>