Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(13)

Delta Between Two Patch Sets: Modules/_cursesmodule.c

Issue 3871: cross and native build of python for mingw32 with distutils
Left Patch Set: Created 9 years, 5 months ago
Right Patch Set: Created 7 years, 2 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « Modules/_ctypes/libffi_msvc/win32.S ('k') | Modules/faulthandler.c » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 /* 1 /*
2 * This is a curses module for Python. 2 * This is a curses module for Python.
3 * 3 *
4 * Based on prior work by Lance Ellinghaus and Oliver Andrich 4 * Based on prior work by Lance Ellinghaus and Oliver Andrich
5 * Version 1.2 of this module: Copyright 1994 by Lance Ellinghouse, 5 * Version 1.2 of this module: Copyright 1994 by Lance Ellinghouse,
6 * Cathedral City, California Republic, United States of America. 6 * Cathedral City, California Republic, United States of America.
7 * 7 *
8 * Version 1.5b1, heavily extended for ncurses by Oliver Andrich: 8 * Version 1.5b1, heavily extended for ncurses by Oliver Andrich:
9 * Copyright 1996,1997 by Oliver Andrich, Koblenz, Germany. 9 * Copyright 1996,1997 by Oliver Andrich, Koblenz, Germany.
10 * 10 *
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 explicit prototypes here. */ 118 explicit prototypes here. */
119 extern int setupterm(char *,int,int *); 119 extern int setupterm(char *,int,int *);
120 #ifdef __sgi 120 #ifdef __sgi
121 #include <term.h> 121 #include <term.h>
122 #endif 122 #endif
123 123
124 #ifdef HAVE_LANGINFO_H 124 #ifdef HAVE_LANGINFO_H
125 #include <langinfo.h> 125 #include <langinfo.h>
126 #endif 126 #endif
127 127
128 #ifdef __MINGW32__
129 #include <windows.h>
130 #endif
131
128 #if !defined(HAVE_NCURSES_H) && (defined(sgi) || defined(__sun) || defined(SCO5) ) 132 #if !defined(HAVE_NCURSES_H) && (defined(sgi) || defined(__sun) || defined(SCO5) )
129 #define STRICT_SYSV_CURSES /* Don't use ncurses extensions */ 133 #define STRICT_SYSV_CURSES /* Don't use ncurses extensions */
130 typedef chtype attr_t; /* No attr_t type is available */ 134 typedef chtype attr_t; /* No attr_t type is available */
131 #endif 135 #endif
132 136
133 #if defined(_AIX) 137 #if defined(_AIX)
134 #define STRICT_SYSV_CURSES 138 #define STRICT_SYSV_CURSES
135 #endif 139 #endif
136 140
137 /* Definition of exception curses.error */ 141 /* Definition of exception curses.error */
(...skipping 1548 matching lines...) Expand 10 before | Expand all | Expand 10 after
1686 return PyCursesCheckERR(rtn, "overwrite"); 1690 return PyCursesCheckERR(rtn, "overwrite");
1687 } 1691 }
1688 } 1692 }
1689 1693
1690 static PyObject * 1694 static PyObject *
1691 PyCursesWindow_PutWin(PyCursesWindowObject *self, PyObject *stream) 1695 PyCursesWindow_PutWin(PyCursesWindowObject *self, PyObject *stream)
1692 { 1696 {
1693 /* We have to simulate this by writing to a temporary FILE*, 1697 /* We have to simulate this by writing to a temporary FILE*,
1694 then reading back, then writing to the argument stream. */ 1698 then reading back, then writing to the argument stream. */
1695 char fn[100]; 1699 char fn[100];
1700 #ifndef MS_WINDOWS
1696 int fd; 1701 int fd;
1702 #endif
1697 FILE *fp; 1703 FILE *fp;
1698 PyObject *res; 1704 PyObject *res;
1699 1705
1706 #ifndef MS_WINDOWS
1707 /* Even on unix /tmp may not exist and the program must prefer $TMPDIR ! */
1700 strcpy(fn, "/tmp/py.curses.putwin.XXXXXX"); 1708 strcpy(fn, "/tmp/py.curses.putwin.XXXXXX");
1701 fd = mkstemp(fn); 1709 fd = mkstemp(fn);
1702 if (fd < 0) 1710 if (fd < 0)
1703 return PyErr_SetFromErrnoWithFilename(PyExc_IOError, fn); 1711 return PyErr_SetFromErrnoWithFilename(PyExc_IOError, fn);
1704 fp = fdopen(fd, "wb+"); 1712 fp = fdopen(fd, "wb+");
1713 #else
1714 strcpy(fn, "py.curses.putwin.XXXXXX");
1715 _mktemp(fn);
1716 if (*fn == 0)
1717 return PyErr_SetFromErrnoWithFilename(PyExc_IOError, fn);
1718 fp = fopen(fn, "wb+");
1719 #endif
1720
1705 if (fp == NULL) { 1721 if (fp == NULL) {
1722 #ifndef MS_WINDOWS
1706 close(fd); 1723 close(fd);
1724 #endif
1707 remove(fn); 1725 remove(fn);
1708 return PyErr_SetFromErrnoWithFilename(PyExc_IOError, fn); 1726 return PyErr_SetFromErrnoWithFilename(PyExc_IOError, fn);
1709 } 1727 }
1710 res = PyCursesCheckERR(putwin(self->win, fp), "putwin"); 1728 res = PyCursesCheckERR(putwin(self->win, fp), "putwin");
1711 if (res == NULL) { 1729 if (res == NULL) {
1712 fclose(fp); 1730 fclose(fp);
1713 remove(fn); 1731 remove(fn);
1714 return res; 1732 return res;
1715 } 1733 }
1716 fseek(fp, 0, 0); 1734 fseek(fp, 0, 0);
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after
2244 return NULL; 2262 return NULL;
2245 2263
2246 return PyCursesCheckERR(ungetmouse(&event), "ungetmouse"); 2264 return PyCursesCheckERR(ungetmouse(&event), "ungetmouse");
2247 } 2265 }
2248 #endif 2266 #endif
2249 2267
2250 static PyObject * 2268 static PyObject *
2251 PyCurses_GetWin(PyCursesWindowObject *self, PyObject *stream) 2269 PyCurses_GetWin(PyCursesWindowObject *self, PyObject *stream)
2252 { 2270 {
2253 char fn[100]; 2271 char fn[100];
2272 #ifndef MS_WINDOWS
2254 int fd; 2273 int fd;
2274 #endif
2255 FILE *fp; 2275 FILE *fp;
2256 PyObject *data; 2276 PyObject *data;
2257 size_t datalen; 2277 size_t datalen;
2258 WINDOW *win; 2278 WINDOW *win;
2259 2279
2260 PyCursesInitialised; 2280 PyCursesInitialised;
2261 _Py_IDENTIFIER(read); 2281 _Py_IDENTIFIER(read);
2262 2282
2283 #ifndef MS_WINDOWS
2284 /* Even on unix /tmp may not exist and the program must prefer $TMPDIR ! */
2263 strcpy(fn, "/tmp/py.curses.getwin.XXXXXX"); 2285 strcpy(fn, "/tmp/py.curses.getwin.XXXXXX");
2264 fd = mkstemp(fn); 2286 fd = mkstemp(fn);
2265 if (fd < 0) 2287 if (fd < 0)
2266 return PyErr_SetFromErrnoWithFilename(PyExc_IOError, fn); 2288 return PyErr_SetFromErrnoWithFilename(PyExc_IOError, fn);
2267 fp = fdopen(fd, "wb+"); 2289 fp = fdopen(fd, "wb+");
2290 #else
2291 strcpy(fn, "py.curses.getwin.XXXXXX");
2292 _mktemp(fn);
2293 if (*fn == 0)
2294 return PyErr_SetFromErrnoWithFilename(PyExc_IOError, fn);
2295 fp = fopen(fn, "wb+");
2296 #endif
2268 if (fp == NULL) { 2297 if (fp == NULL) {
2298 #ifndef MS_WINDOWS
2269 close(fd); 2299 close(fd);
2300 #endif
2270 remove(fn); 2301 remove(fn);
2271 return PyErr_SetFromErrnoWithFilename(PyExc_IOError, fn); 2302 return PyErr_SetFromErrnoWithFilename(PyExc_IOError, fn);
2272 } 2303 }
2273 data = _PyObject_CallMethodId(stream, &PyId_read, ""); 2304 data = _PyObject_CallMethodId(stream, &PyId_read, "");
2274 if (data == NULL) { 2305 if (data == NULL) {
2275 fclose(fp); 2306 fclose(fp);
2276 remove(fn); 2307 remove(fn);
2277 return NULL; 2308 return NULL;
2278 } 2309 }
2279 if (!PyBytes_Check(data)) { 2310 if (!PyBytes_Check(data)) {
(...skipping 1145 matching lines...) Expand 10 before | Expand all | Expand 10 after
3425 SetDictInt(key_n2,key); 3456 SetDictInt(key_n2,key);
3426 if (key_n2 != key_n) 3457 if (key_n2 != key_n)
3427 free(key_n2); 3458 free(key_n2);
3428 } 3459 }
3429 #endif 3460 #endif
3430 SetDictInt("KEY_MIN", KEY_MIN); 3461 SetDictInt("KEY_MIN", KEY_MIN);
3431 SetDictInt("KEY_MAX", KEY_MAX); 3462 SetDictInt("KEY_MAX", KEY_MAX);
3432 } 3463 }
3433 return m; 3464 return m;
3434 } 3465 }
LEFTRIGHT

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+