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

Unified Diff: Modules/_cursesmodule.c

Issue 3871: cross and native build of python for mingw32 with distutils
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Modules/_ctypes/libffi_msvc/win32.S ('k') | Modules/faulthandler.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Modules/_cursesmodule.c Thu Dec 27 23:52:36 2012 +0200
+++ b/Modules/_cursesmodule.c Thu Dec 27 17:35:12 2012 -0500
@@ -125,6 +125,10 @@
#include <langinfo.h>
#endif
+#ifdef __MINGW32__
+#include <windows.h>
+#endif
+
#if !defined(HAVE_NCURSES_H) && (defined(sgi) || defined(__sun) || defined(SCO5))
#define STRICT_SYSV_CURSES /* Don't use ncurses extensions */
typedef chtype attr_t; /* No attr_t type is available */
@@ -1693,17 +1697,31 @@
/* We have to simulate this by writing to a temporary FILE*,
then reading back, then writing to the argument stream. */
char fn[100];
+#ifndef MS_WINDOWS
int fd;
+#endif
FILE *fp;
PyObject *res;
+#ifndef MS_WINDOWS
+/* Even on unix /tmp may not exist and the program must prefer $TMPDIR ! */
strcpy(fn, "/tmp/py.curses.putwin.XXXXXX");
fd = mkstemp(fn);
if (fd < 0)
return PyErr_SetFromErrnoWithFilename(PyExc_IOError, fn);
fp = fdopen(fd, "wb+");
+#else
+ strcpy(fn, "py.curses.putwin.XXXXXX");
+ _mktemp(fn);
+ if (*fn == 0)
+ return PyErr_SetFromErrnoWithFilename(PyExc_IOError, fn);
+ fp = fopen(fn, "wb+");
+#endif
+
if (fp == NULL) {
+ #ifndef MS_WINDOWS
close(fd);
+ #endif
remove(fn);
return PyErr_SetFromErrnoWithFilename(PyExc_IOError, fn);
}
@@ -2251,7 +2269,9 @@
PyCurses_GetWin(PyCursesWindowObject *self, PyObject *stream)
{
char fn[100];
+#ifndef MS_WINDOWS
int fd;
+#endif
FILE *fp;
PyObject *data;
size_t datalen;
@@ -2260,13 +2280,24 @@
PyCursesInitialised;
_Py_IDENTIFIER(read);
+#ifndef MS_WINDOWS
+/* Even on unix /tmp may not exist and the program must prefer $TMPDIR ! */
strcpy(fn, "/tmp/py.curses.getwin.XXXXXX");
fd = mkstemp(fn);
if (fd < 0)
return PyErr_SetFromErrnoWithFilename(PyExc_IOError, fn);
fp = fdopen(fd, "wb+");
+#else
+ strcpy(fn, "py.curses.getwin.XXXXXX");
+ _mktemp(fn);
+ if (*fn == 0)
+ return PyErr_SetFromErrnoWithFilename(PyExc_IOError, fn);
+ fp = fopen(fn, "wb+");
+#endif
if (fp == NULL) {
+ #ifndef MS_WINDOWS
close(fd);
+ #endif
remove(fn);
return PyErr_SetFromErrnoWithFilename(PyExc_IOError, fn);
}
« no previous file with comments | « Modules/_ctypes/libffi_msvc/win32.S ('k') | Modules/faulthandler.c » ('j') | no next file with comments »

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