diff -urw Python-2.4.2/Include/pyport.h Python-2.4.2-new/Include/pyport.h --- Python-2.4.2/Include/pyport.h Wed Sep 14 14:54:40 2005 +++ Python-2.4.2-new/Include/pyport.h Mon Jan 9 08:50:20 2006 @@ -478,12 +478,12 @@ BeOS and cygwin are the only other autoconf platform requiring special linkage handling and both of these use __declspec(). */ -#if defined(__CYGWIN__) || defined(__BEOS__) +#if defined(__CYGWIN__) || defined(__MINGW32__) || defined(__BEOS__) # define HAVE_DECLSPEC_DLL #endif /* only get special linkage if built as shared or platform is Cygwin */ -#if defined(Py_ENABLE_SHARED) || defined(__CYGWIN__) +#if defined(Py_ENABLE_SHARED) || defined(__CYGWIN__) || defined(__MINGW32__) # if defined(HAVE_DECLSPEC_DLL) # ifdef Py_BUILD_CORE # define PyAPI_FUNC(RTYPE) __declspec(dllexport) RTYPE @@ -500,7 +500,7 @@ /* public Python functions and data are imported */ /* Under Cygwin, auto-import functions to prevent compilation */ /* failures similar to http://python.org/doc/FAQ.html#3.24 */ -# if !defined(__CYGWIN__) +# if !defined(__CYGWIN__) && !defined(__MINGW32__) # define PyAPI_FUNC(RTYPE) __declspec(dllimport) RTYPE # endif /* !__CYGWIN__ */ # define PyAPI_DATA(RTYPE) extern __declspec(dllimport) RTYPE diff -urw Python-2.4.2/Modules/_hotshot.c Python-2.4.2-new/Modules/_hotshot.c --- Python-2.4.2/Modules/_hotshot.c Tue Aug 3 05:33:56 2004 +++ Python-2.4.2-new/Modules/_hotshot.c Mon Jan 9 08:50:20 2006 @@ -911,7 +911,7 @@ /* A couple of useful helper functions. */ #ifdef MS_WINDOWS -static LARGE_INTEGER frequency = {0, 0}; +static LARGE_INTEGER frequency = {{0, 0}}; #endif static unsigned long timeofday_diff = 0; diff -urw Python-2.4.2/Modules/posixmodule.c Python-2.4.2-new/Modules/posixmodule.c --- Python-2.4.2/Modules/posixmodule.c Sun Sep 25 03:16:28 2005 +++ Python-2.4.2-new/Modules/posixmodule.c Sun Jan 22 22:42:04 2006 @@ -95,7 +95,7 @@ #define HAVE_SYSTEM 1 #define HAVE_WAIT 1 #else -#ifdef _MSC_VER /* Microsoft compiler */ +#if defined(_MSC_VER) || defined(__MINGW32__) #define HAVE_GETCWD 1 #define HAVE_SPAWNV 1 #define HAVE_EXECV 1 @@ -131,7 +131,7 @@ #define HAVE_WAIT 1 #define HAVE_TTYNAME 1 #endif /* PYOS_OS2 && PYCC_GCC && __VMS */ -#endif /* _MSC_VER */ +#endif /* _MSC_VER || __MINGW32__ */ #endif /* __BORLANDC__ */ #endif /* ! __WATCOMC__ || __QNX__ */ #endif /* ! __IBMC__ */ @@ -227,17 +227,18 @@ #endif #endif -#ifdef _MSC_VER +#if defined(_MSC_VER) || defined(__MINGW32__) #include #include #include #include "osdefs.h" #define _WIN32_WINNT 0x0400 /* Needed for CryptoAPI on some systems */ #include +#include #include /* for ShellExecute() */ #define popen _popen #define pclose _pclose -#endif /* _MSC_VER */ +#endif /* _MSC_VER || __MINGW32__ */ #if defined(PYCC_VACPP) && defined(PYOS_OS2) #include @@ -377,11 +378,13 @@ { return PyErr_SetFromErrno(PyExc_OSError); } +#if defined(PYOS_OS2) || defined(PYCC_GCC) static PyObject * posix_error_with_filename(char* name) { return PyErr_SetFromErrnoWithFilename(PyExc_OSError, name); } +#endif #ifdef Py_WIN_WIDE_FILENAMES static PyObject * @@ -1490,8 +1493,8 @@ do { if (wFileData.cFileName[0] == L'.' && (wFileData.cFileName[1] == L'\0' || - wFileData.cFileName[1] == L'.' && - wFileData.cFileName[2] == L'\0')) + (wFileData.cFileName[1] == L'.' && + wFileData.cFileName[2] == L'\0'))) continue; v = PyUnicode_FromUnicode(wFileData.cFileName, wcslen(wFileData.cFileName)); if (v == NULL) { @@ -1544,8 +1547,8 @@ do { if (FileData.cFileName[0] == '.' && (FileData.cFileName[1] == '\0' || - FileData.cFileName[1] == '.' && - FileData.cFileName[2] == '\0')) + (FileData.cFileName[1] == '.' && + FileData.cFileName[2] == '\0'))) continue; v = PyString_FromString(FileData.cFileName); if (v == NULL) { @@ -1785,7 +1788,7 @@ Py_FileSystemDefaultEncoding, &path, &mode)) return NULL; Py_BEGIN_ALLOW_THREADS -#if ( defined(__WATCOMC__) || defined(_MSC_VER) || defined(PYCC_VACPP) ) && !defined(__QNX__) +#if ( defined(__WATCOMC__) || defined(_MSC_VER) || defined(PYCC_VACPP) || defined(__MINGW32__) ) && !defined(__QNX__) res = mkdir(path); #else res = mkdir(path, mode); @@ -2029,7 +2032,7 @@ int have_unicode_filename = 0; #ifdef Py_WIN_WIDE_FILENAMES PyUnicodeObject *obwpath; - wchar_t *wpath; + wchar_t *wpath = NULL; if (unicode_file_names()) { if (PyArg_ParseTuple(args, "UO|:utime", &obwpath, &arg)) { wpath = PyUnicode_AS_UNICODE(obwpath); @@ -2196,7 +2199,7 @@ } argvlist[argc] = NULL; - execv(path, argvlist); + execv(path, (const char**)argvlist); /* If we get here it's definitely an error */ @@ -2329,7 +2332,7 @@ } envlist[envc] = 0; - execve(path, argvlist, envlist); + execve(path, (const char**)argvlist, (const char**)envlist); /* If we get here it's definitely an error */ @@ -2419,7 +2422,7 @@ mode = _P_OVERLAY; Py_BEGIN_ALLOW_THREADS - spawnval = _spawnv(mode, path, argvlist); + spawnval = _spawnv(mode, path, (const char**)argvlist); Py_END_ALLOW_THREADS #endif @@ -2563,7 +2566,7 @@ mode = _P_OVERLAY; Py_BEGIN_ALLOW_THREADS - spawnval = _spawnve(mode, path, argvlist, envlist); + spawnval = _spawnve(mode, path, (const char**)argvlist, (const char**)envlist); Py_END_ALLOW_THREADS #endif @@ -4126,7 +4129,7 @@ int i; int x; - if (i = GetEnvironmentVariable("COMSPEC",NULL,0)) { + if ((i = GetEnvironmentVariable("COMSPEC",NULL,0))) { char *comshell; s1 = (char *)alloca(i); @@ -4276,9 +4279,9 @@ SECURITY_ATTRIBUTES saAttr; BOOL fSuccess; int fd1, fd2, fd3; - FILE *f1, *f2, *f3; - long file_count; - PyObject *f; + FILE *f1=NULL, *f2=NULL, *f3=NULL; + long file_count=0; + PyObject *f=NULL; saAttr.nLength = sizeof(SECURITY_ATTRIBUTES); saAttr.bInheritHandle = TRUE; @@ -6192,6 +6195,7 @@ long value; }; +#if defined(HAVE_FPATHCONF) || defined(HAVE_PATHCONF) static int conv_confname(PyObject *arg, int *valuep, struct constdef *table, size_t tablesize) @@ -6226,7 +6230,7 @@ "configuration names must be strings or integers"); return 0; } - +#endif #if defined(HAVE_FPATHCONF) || defined(HAVE_PATHCONF) static struct constdef posix_constants_pathconf[] = { @@ -7084,6 +7088,8 @@ * it easier to add additional entries to the tables. */ +#if defined(HAVE_CONFSTR) || defined(HAVE_SYSCONF) + static int cmp_constdefs(const void *v1, const void *v2) { @@ -7119,6 +7125,8 @@ return PyModule_AddObject(module, tablename, d); } +#endif + /* Return -1 on failure, 0 on success. */ static int setup_confname_tables(PyObject *module) @@ -7849,7 +7857,7 @@ } -#if (defined(_MSC_VER) || defined(__WATCOMC__) || defined(__BORLANDC__)) && !defined(__QNX__) +#if (defined(_MSC_VER) || defined(__WATCOMC__) || defined(__BORLANDC__) || defined(__MINGW32__)) && !defined(__QNX__) #define INITFUNC initnt #define MODNAME "nt" diff -urw Python-2.4.2/Objects/fileobject.c Python-2.4.2-new/Objects/fileobject.c --- Python-2.4.2/Objects/fileobject.c Sun Nov 7 11:15:28 2004 +++ Python-2.4.2-new/Objects/fileobject.c Mon Jan 9 08:50:20 2006 @@ -8,7 +8,9 @@ #endif /* DONT_HAVE_SYS_TYPES_H */ #ifdef MS_WINDOWS +#ifdef __MSC_VER #define fileno _fileno +#endif /* can simulate truncate with Win32 API functions; see file_truncate */ #define HAVE_FTRUNCATE #define WIN32_LEAN_AND_MEAN diff -urw Python-2.4.2/PC/_winreg.c Python-2.4.2-new/PC/_winreg.c --- Python-2.4.2/PC/_winreg.c Sun Nov 30 19:01:44 2003 +++ Python-2.4.2-new/PC/_winreg.c Sun Jan 22 22:55:02 2006 @@ -17,12 +17,22 @@ #include "structmember.h" #include "malloc.h" /* for alloca */ +#if defined(__MINGW32__) +_CRTIMP size_t __cdecl _mbstrlen(const char *s); +#endif + +#if !defined(REG_LEGAL_CHANGE_FILTER) +#define REG_LEGAL_CHANGE_FILTER \ + (REG_NOTIFY_CHANGE_NAME |\ + REG_NOTIFY_CHANGE_ATTRIBUTES |\ + REG_NOTIFY_CHANGE_LAST_SET |\ + REG_NOTIFY_CHANGE_SECURITY) +#endif + static BOOL PyHKEY_AsHKEY(PyObject *ob, HKEY *pRes, BOOL bNoneOK); static PyObject *PyHKEY_FromHKEY(HKEY h); static BOOL PyHKEY_Close(PyObject *obHandle); -static char errNotAHandle[] = "Object is not a handle"; - /* The win32api module reports the function name that failed, but this concept is not in the Python core. Hopefully it will one day, and in the meantime I dont @@ -741,14 +751,16 @@ PyErr_NoMemory(); return FALSE; } - if (value == Py_None) + if (value == Py_None) { strcpy((char *)*retDataBuf, ""); - else + } else { strcpy((char *)*retDataBuf, PyString_AS_STRING( (PyStringObject *)value)); - if (need_decref) + } + if (need_decref) { Py_DECREF(value); + } break; } case REG_MULTI_SZ: @@ -1430,7 +1442,7 @@ {"SaveKey", PySaveKey, METH_VARARGS, SaveKey_doc}, {"SetValue", PySetValue, METH_VARARGS, SetValue_doc}, {"SetValueEx", PySetValueEx, METH_VARARGS, SetValueEx_doc}, - NULL, + {NULL}, }; static void diff -urw Python-2.4.2/PC/getpathp.c Python-2.4.2-new/PC/getpathp.c --- Python-2.4.2/PC/getpathp.c Fri Jul 22 18:48:52 2005 +++ Python-2.4.2-new/PC/getpathp.c Mon Jan 9 08:50:20 2006 @@ -294,7 +294,9 @@ dataBuf = malloc((dataSize+1) * sizeof(TCHAR)); if (dataBuf) { TCHAR *szCur = dataBuf; +#ifdef UNICODE DWORD reqdSize = dataSize; +#endif /* Copy our collected strings */ for (index=0;index 0) { diff -urw Python-2.4.2/PC/import_nt.c Python-2.4.2-new/PC/import_nt.c --- Python-2.4.2/PC/import_nt.c Wed Nov 28 18:03:38 2001 +++ Python-2.4.2-new/PC/import_nt.c Mon Jan 9 08:50:20 2006 @@ -54,14 +54,14 @@ PyWin_DLLVersionString, moduleName, debugString); modNameSize = pathLen; - regStat = RegQueryValue(keyBase, moduleKey, pathBuf, &modNameSize); + regStat = RegQueryValue(keyBase, moduleKey, pathBuf, (LPLONG)&modNameSize); if (regStat != ERROR_SUCCESS) { /* No user setting - lookup in machine settings */ keyBase = HKEY_LOCAL_MACHINE; /* be anal - failure may have reset size param */ modNameSize = pathLen; regStat = RegQueryValue(keyBase, moduleKey, - pathBuf, &modNameSize); + pathBuf, (LPLONG)&modNameSize); if (regStat != ERROR_SUCCESS) return NULL; diff -urw Python-2.4.2/Python/dynload_win.c Python-2.4.2-new/Python/dynload_win.c --- Python-2.4.2/Python/dynload_win.c Fri Jul 2 05:53:58 2004 +++ Python-2.4.2-new/Python/dynload_win.c Mon Jan 9 08:50:20 2006 @@ -19,11 +19,10 @@ {0, 0} }; - /* Case insensitive string compare, to avoid any dependencies on particular C RTL implementations */ -static int strcasecmp (char *string1, char *string2) +static int py_strcasecmp (char *string1, char *string2) { int first, second; @@ -238,7 +237,7 @@ import_python = GetPythonImport(hDLL); if (import_python && - strcasecmp(buffer,import_python)) { + py_strcasecmp(buffer,import_python)) { PyOS_snprintf(buffer, sizeof(buffer), "Module use of %.150s conflicts " "with this version of Python.", diff -urw Python-2.4.2/Python/errors.c Python-2.4.2-new/Python/errors.c --- Python-2.4.2/Python/errors.c Wed Mar 24 19:22:12 2004 +++ Python-2.4.2-new/Python/errors.c Mon Jan 9 08:50:20 2006 @@ -387,7 +387,7 @@ NULL); /* no args */ if (len==0) { /* Only seen this in out of mem situations */ - sprintf(s_small_buf, "Windows Error 0x%X", err); + sprintf(s_small_buf, "Windows Error 0x%X", (unsigned int)err); s = s_small_buf; s_buf = NULL; } else { diff -urw Python-2.4.2/Python/thread_nt.h Python-2.4.2-new/Python/thread_nt.h --- Python-2.4.2/Python/thread_nt.h Fri Jul 8 19:25:18 2005 +++ Python-2.4.2-new/Python/thread_nt.h Mon Jan 9 08:50:20 2006 @@ -153,7 +153,7 @@ HANDLE done; } callobj; -static int +static void bootstrap(void *call) { callobj *obj = (callobj*)call; @@ -164,7 +164,6 @@ obj->id = PyThread_get_thread_ident(); ReleaseSemaphore(obj->done, 1, NULL); func(arg); - return 0; } long @@ -220,11 +219,12 @@ static void do_PyThread_exit_thread(int no_cleanup) { dprintf(("%ld: PyThread_exit_thread called\n", PyThread_get_thread_ident())); - if (!initialized) + if (!initialized) { if (no_cleanup) _exit(0); else exit(0); + } _endthread(); }