[Python-checkins] CVS: python/dist/src/Modules _cursesmodule.c,2.57,2.58

Martin v. L?wis loewis@users.sourceforge.net
Wed, 24 Oct 2001 10:10:51 -0700


Update of /cvsroot/python/python/dist/src/Modules
In directory usw-pr-cvs1:/tmp/cvs-serv27487/Modules

Modified Files:
	_cursesmodule.c 
Log Message:
Check for HP/UX curses problems. Define  _XOPEN_SOURCE_EXTENDED and
STRICT_SYSV_CURSES when compiling curses module on HP/UX. Generalize
access to _flags on systems where WINDOW is opaque. Fixes bugs
#432497, #422265, and the curses parts of #467145 and #473150.


Index: _cursesmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/_cursesmodule.c,v
retrieving revision 2.57
retrieving revision 2.58
diff -C2 -d -r2.57 -r2.58
*** _cursesmodule.c	2001/10/20 16:05:52	2.57
--- _cursesmodule.c	2001/10/24 17:10:49	2.58
***************
*** 108,111 ****
--- 108,116 ----
  #endif
  
+ #ifdef __hpux
+ #define _XOPEN_SOURCE_EXTENDED
+ #define STRICT_SYSV_CURSES
+ #endif
+ 
  #define CURSES_MODULE
  #include "py_curses.h"
***************
*** 120,124 ****
  #endif
  
! #if defined(sgi) || defined(__sun)
  #define STRICT_SYSV_CURSES       /* Don't use ncurses extensions */
  typedef chtype attr_t;           /* No attr_t type is available */
--- 125,129 ----
  #endif
  
! #if !defined(HAVE_NCURSES_H) && (defined(sgi) || defined(__sun))
  #define STRICT_SYSV_CURSES       /* Don't use ncurses extensions */
  typedef chtype attr_t;           /* No attr_t type is available */
***************
*** 606,609 ****
--- 611,627 ----
  }
  
+ #if defined(HAVE_NCURSES_H) || defined(MVWDELCH_IS_EXPRESSION)
+ #define py_mvwdelch mvwdelch
+ #else
+ int py_mvwdelch(WINDOW *w, int y, int x)
+ {
+   mvwdelch(w,y,x);
+   /* On HP/UX, mvwdelch already returns. On other systems,
+      we may well run into this return statement. */
+   return 0;
+ }
+ #endif
+ 
+ 
  static PyObject *
  PyCursesWindow_DelCh(PyCursesWindowObject *self, PyObject *args)
***************
*** 619,623 ****
      if (!PyArg_Parse(args,"(ii);y,x", &y, &x))
        return NULL;
!     rtn = mvwdelch(self->win,y,x);
      break;
    default:
--- 637,641 ----
      if (!PyArg_Parse(args,"(ii);y,x", &y, &x))
        return NULL;
!     rtn = py_mvwdelch(self->win,y,x);
      break;
    default:
***************
*** 689,693 ****
    }
    
! #if !defined(__NetBSD__)
    if (self->win->_flags & _ISPAD)
      return PyCursesCheckERR(pechochar(self->win, ch | attr), 
--- 707,711 ----
    }
    
! #ifdef WINDOW_HAS_FLAGS
    if (self->win->_flags & _ISPAD)
      return PyCursesCheckERR(pechochar(self->win, ch | attr), 
***************
*** 1095,1099 ****
    int rtn;
  
! #if defined(__NetBSD__)
    if (0) {
  #else
--- 1113,1117 ----
    int rtn;
  
! #ifndef WINDOW_HAS_FLAGS
    if (0) {
  #else
***************
*** 1237,1241 ****
    int rtn;
    
! #if defined(__NetBSD__)
    if (0) {
  #else
--- 1255,1259 ----
    int rtn;
    
! #ifndef WINDOW_HAS_FLAGS
    if (0) {
  #else
***************
*** 1305,1309 ****
  
    /* printf("Subwin: %i %i %i %i   \n", nlines, ncols, begin_y, begin_x); */
! #if !defined(__NetBSD__)
    if (self->win->_flags & _ISPAD)
      win = subpad(self->win, nlines, ncols, begin_y, begin_x);
--- 1323,1327 ----
  
    /* printf("Subwin: %i %i %i %i   \n", nlines, ncols, begin_y, begin_x); */
! #ifdef WINDOW_HAS_FLAGS
    if (self->win->_flags & _ISPAD)
      win = subpad(self->win, nlines, ncols, begin_y, begin_x);
***************
*** 1833,1836 ****
--- 1851,1859 ----
  	SetDictInt("ACS_VLINE",         (ACS_VLINE));
  	SetDictInt("ACS_PLUS",          (ACS_PLUS));
+ #if !defined(__hpux) || defined(HAVE_NCURSES_H)
+         /* On HP/UX 11, these are of type cchar_t, which is not an
+            integral type. If this is a problem on more platforms, a
+            configure test should be added to determine whether ACS_S1
+            is of integral type. */
  	SetDictInt("ACS_S1",            (ACS_S1));
  	SetDictInt("ACS_S9",            (ACS_S9));
***************
*** 1847,1850 ****
--- 1870,1874 ----
  	SetDictInt("ACS_LANTERN",       (ACS_LANTERN));
  	SetDictInt("ACS_BLOCK",         (ACS_BLOCK));
+ #endif
  	SetDictInt("ACS_BSSB",          (ACS_ULCORNER));
  	SetDictInt("ACS_SSBB",          (ACS_LLCORNER));
***************
*** 2287,2290 ****
--- 2311,2323 ----
  	}
  	
+ #ifdef __hpux
+         /* tparm is declared with 10 arguments on HP/UX 11.
+            If this is a problem on other platforms as well,
+            an autoconf test should be added to determine
+            whether tparm can be called with a variable number
+            of arguments. Perhaps the other arguments should
+            be initialized in this case also. */
+         result = tparm(fmt,i1,i2,i3,i4,i5,i6,i7,i8,i9);
+ #else
  	switch (PyTuple_GET_SIZE(args)) {
  	case 1:
***************
*** 2319,2323 ****
  		break;
  	}
! 
  	return PyString_FromString(result);
  }
--- 2352,2356 ----
  		break;
  	}
! #endif /* __hpux */
  	return PyString_FromString(result);
  }