Commit c5a0f532 authored by Guido van Rossum's avatar Guido van Rossum

Patch for QNX, by Chris Herborth. Also left-aligned preprocessor

directives and changed C++ comments to C comments.
parent 7bf22de7
...@@ -75,24 +75,24 @@ corresponding Unix manual entries for more information on calls."; ...@@ -75,24 +75,24 @@ corresponding Unix manual entries for more information on calls.";
/* Various compilers have only certain posix functions */ /* Various compilers have only certain posix functions */
/* XXX Gosh I wish these were all moved into config.h */ /* XXX Gosh I wish these were all moved into config.h */
#if defined(PYCC_VACPP) && defined(PYOS_OS2) #if defined(PYCC_VACPP) && defined(PYOS_OS2)
#define HAVE_EXECV 1 #define HAVE_EXECV 1
#define HAVE_GETCWD 1 #define HAVE_GETCWD 1
#define HAVE_SYSTEM 1 #define HAVE_SYSTEM 1
#define HAVE_WAIT 1 #define HAVE_WAIT 1
#define HAVE_KILL 1 #define HAVE_KILL 1
#define HAVE_PIPE 1 #define HAVE_PIPE 1
#define HAVE_POPEN 1 #define HAVE_POPEN 1
// #define HAVE_FORK 1 /* #define HAVE_FORK 1 */
// #define HAVE_GETEGID 1 /* #define HAVE_GETEGID 1 */
// #define HAVE_GETEUID 1 /* #define HAVE_GETEUID 1 */
// #define HAVE_GETGID 1 /* #define HAVE_GETGID 1 */
// #define HAVE_GETPPID 1 /* #define HAVE_GETPPID 1 */
// #define HAVE_GETUID 1 /* #define HAVE_GETUID 1 */
// #define HAVE_OPENDIR 1 /* #define HAVE_OPENDIR 1 */
#include <process.h> #include <process.h>
#else #else
#ifdef __WATCOMC__ /* Watcom compiler */ #if defined(__WATCOMC__) && !defined(__QNX__) /* Watcom compiler */
#define HAVE_GETCWD 1 #define HAVE_GETCWD 1
#define HAVE_OPENDIR 1 #define HAVE_OPENDIR 1
#define HAVE_SYSTEM 1 #define HAVE_SYSTEM 1
...@@ -144,7 +144,7 @@ corresponding Unix manual entries for more information on calls."; ...@@ -144,7 +144,7 @@ corresponding Unix manual entries for more information on calls.";
#define HAVE_WAIT 1 #define HAVE_WAIT 1
#endif /* _MSC_VER */ #endif /* _MSC_VER */
#endif /* __BORLANDC__ */ #endif /* __BORLANDC__ */
#endif /* ! __WATCOMC__ */ #endif /* ! __WATCOMC__ || __QNX__ */
#endif /* ! __IBMC__ */ #endif /* ! __IBMC__ */
#ifndef _MSC_VER #ifndef _MSC_VER
...@@ -171,7 +171,7 @@ extern int symlink(); ...@@ -171,7 +171,7 @@ extern int symlink();
#if defined(PYCC_VACPP) #if defined(PYCC_VACPP)
extern int mkdir Py_PROTO((char *)); extern int mkdir Py_PROTO((char *));
#else #else
#if defined(__WATCOMC__) || defined(_MSC_VER) #if ( defined(__WATCOMC__) || defined(_MSC_VER) ) && !defined(__QNX__)
extern int mkdir Py_PROTO((const char *)); extern int mkdir Py_PROTO((const char *));
#else #else
extern int mkdir Py_PROTO((const char *, mode_t)); extern int mkdir Py_PROTO((const char *, mode_t));
...@@ -232,7 +232,7 @@ extern int lstat Py_PROTO((const char *, struct stat *)); ...@@ -232,7 +232,7 @@ extern int lstat Py_PROTO((const char *, struct stat *));
#include <dirent.h> #include <dirent.h>
#define NAMLEN(dirent) strlen((dirent)->d_name) #define NAMLEN(dirent) strlen((dirent)->d_name)
#else #else
#ifdef __WATCOMC__ #if defined(__WATCOMC__) && !defined(__QNX__)
#include <direct.h> #include <direct.h>
#define NAMLEN(dirent) strlen((dirent)->d_name) #define NAMLEN(dirent) strlen((dirent)->d_name)
#else #else
...@@ -270,7 +270,7 @@ extern int lstat Py_PROTO((const char *, struct stat *)); ...@@ -270,7 +270,7 @@ extern int lstat Py_PROTO((const char *, struct stat *));
/* Return a dictionary corresponding to the POSIX environment table */ /* Return a dictionary corresponding to the POSIX environment table */
#if !defined(_MSC_VER) && !defined(__WATCOMC__) #if !defined(_MSC_VER) && ( !defined(__WATCOMC__) || defined(__QNX__) )
extern char **environ; extern char **environ;
#endif /* !_MSC_VER */ #endif /* !_MSC_VER */
...@@ -666,28 +666,28 @@ posix_listdir(self, args) ...@@ -666,28 +666,28 @@ posix_listdir(self, args)
if ((d = PyList_New(0)) == NULL) if ((d = PyList_New(0)) == NULL)
return NULL; return NULL;
rc = DosFindFirst(namebuf, // Wildcard Pattern to Match rc = DosFindFirst(namebuf, /* Wildcard Pattern to Match */
&hdir, // Handle to Use While Search Directory &hdir, /* Handle to Use While Search Directory */
FILE_READONLY | FILE_HIDDEN | FILE_SYSTEM | FILE_DIRECTORY, FILE_READONLY | FILE_HIDDEN | FILE_SYSTEM | FILE_DIRECTORY,
&ep, sizeof(ep), // Structure to Receive Directory Entry &ep, sizeof(ep), /* Structure to Receive Directory Entry */
&srchcnt, // Max and Actual Count of Entries Per Iteration &srchcnt, /* Max and Actual Count of Entries Per Iteration */
FIL_STANDARD); // Format of Entry (EAs or Not) FIL_STANDARD); /* Format of Entry (EAs or Not) */
if (rc != NO_ERROR) { if (rc != NO_ERROR) {
errno = ENOENT; errno = ENOENT;
return posix_error(); return posix_error();
} }
if (srchcnt > 0) { // If Directory is NOT Totally Empty, if (srchcnt > 0) { /* If Directory is NOT Totally Empty, */
do { do {
if (ep.achName[0] == '.' if (ep.achName[0] == '.'
&& (ep.achName[1] == '\0' || ep.achName[1] == '.' && ep.achName[2] == '\0')) && (ep.achName[1] == '\0' || ep.achName[1] == '.' && ep.achName[2] == '\0'))
continue; // Skip Over "." and ".." Names continue; /* Skip Over "." and ".." Names */
strcpy(namebuf, ep.achName); strcpy(namebuf, ep.achName);
// Leave Case of Name Alone -- In Native Form /* Leave Case of Name Alone -- In Native Form */
// (Removed Forced Lowercasing Code) /* (Removed Forced Lowercasing Code) */
v = PyString_FromString(namebuf); v = PyString_FromString(namebuf);
if (v == NULL) { if (v == NULL) {
...@@ -768,7 +768,7 @@ posix_mkdir(self, args) ...@@ -768,7 +768,7 @@ posix_mkdir(self, args)
if (!PyArg_ParseTuple(args, "s|i", &path, &mode)) if (!PyArg_ParseTuple(args, "s|i", &path, &mode))
return NULL; return NULL;
Py_BEGIN_ALLOW_THREADS Py_BEGIN_ALLOW_THREADS
#if defined(__WATCOMC__) || defined(_MSC_VER) || defined(PYCC_VACPP) #if ( defined(__WATCOMC__) || defined(_MSC_VER) || defined(PYCC_VACPP) ) && !defined(__QNX__)
res = mkdir(path); res = mkdir(path);
#else #else
res = mkdir(path, mode); res = mkdir(path, mode);
...@@ -1365,7 +1365,7 @@ posix_kill(self, args) ...@@ -1365,7 +1365,7 @@ posix_kill(self, args)
return posix_error(); return posix_error();
} else } else
return NULL; // Unrecognized Signal Requested return NULL; /* Unrecognized Signal Requested */
#else #else
if (kill(pid, sig) == -1) if (kill(pid, sig) == -1)
return posix_error(); return posix_error();
...@@ -1425,9 +1425,9 @@ async_system(const char *command) ...@@ -1425,9 +1425,9 @@ async_system(const char *command)
*p = '\0'; *p = '\0';
rc = DosExecPgm(errormsg, sizeof(errormsg), rc = DosExecPgm(errormsg, sizeof(errormsg),
EXEC_ASYNC, // Execute Async w/o Wait for Results EXEC_ASYNC, /* Execute Async w/o Wait for Results */
args, args,
NULL, // Inherit Parent's Environment NULL, /* Inherit Parent's Environment */
&rcodes, shell); &rcodes, shell);
return rc; return rc;
} }
...@@ -1440,48 +1440,48 @@ popen(const char *command, const char *mode, int pipesize) ...@@ -1440,48 +1440,48 @@ popen(const char *command, const char *mode, int pipesize)
APIRET rc = DosCreatePipe(&rhan, &whan, pipesize); APIRET rc = DosCreatePipe(&rhan, &whan, pipesize);
if (rc != NO_ERROR) if (rc != NO_ERROR)
return NULL; // ERROR - Unable to Create Anon Pipe return NULL; /* ERROR - Unable to Create Anon Pipe */
if (strchr(mode, 'r') != NULL) { // Treat Command as a Data Source if (strchr(mode, 'r') != NULL) { /* Treat Command as a Data Source */
int oldfd = dup(1); // Save STDOUT Handle in Another Handle int oldfd = dup(1); /* Save STDOUT Handle in Another Handle */
DosEnterCritSec(); // Stop Other Threads While Changing Handles DosEnterCritSec(); /* Stop Other Threads While Changing Handles */
close(1); // Make STDOUT Available for Reallocation close(1); /* Make STDOUT Available for Reallocation */
if (dup2(whan, 1) == 0) { // Connect STDOUT to Pipe Write Side if (dup2(whan, 1) == 0) { /* Connect STDOUT to Pipe Write Side */
DosClose(whan); // Close Now-Unused Pipe Write Handle DosClose(whan); /* Close Now-Unused Pipe Write Handle */
if (async_system(command) == NO_ERROR) if (async_system(command) == NO_ERROR)
retfd = fdopen(rhan, "rb"); // And Return Pipe Read Handle retfd = fdopen(rhan, "rb"); /* And Return Pipe Read Handle */
} }
dup2(oldfd, 1); // Reconnect STDOUT to Original Handle dup2(oldfd, 1); /* Reconnect STDOUT to Original Handle */
DosExitCritSec(); // Now Allow Other Threads to Run DosExitCritSec(); /* Now Allow Other Threads to Run */
close(oldfd); // And Close Saved STDOUT Handle close(oldfd); /* And Close Saved STDOUT Handle */
return retfd; // Return fd of Pipe or NULL if Error return retfd; /* Return fd of Pipe or NULL if Error */
} else if (strchr(mode, 'w')) { // Treat Command as a Data Sink } else if (strchr(mode, 'w')) { /* Treat Command as a Data Sink */
int oldfd = dup(0); // Save STDIN Handle in Another Handle int oldfd = dup(0); /* Save STDIN Handle in Another Handle */
DosEnterCritSec(); // Stop Other Threads While Changing Handles DosEnterCritSec(); /* Stop Other Threads While Changing Handles */
close(0); // Make STDIN Available for Reallocation close(0); /* Make STDIN Available for Reallocation */
if (dup2(rhan, 0) == 0) { // Connect STDIN to Pipe Read Side if (dup2(rhan, 0) == 0) { /* Connect STDIN to Pipe Read Side */
DosClose(rhan); // Close Now-Unused Pipe Read Handle DosClose(rhan); /* Close Now-Unused Pipe Read Handle */
if (async_system(command) == NO_ERROR) if (async_system(command) == NO_ERROR)
retfd = fdopen(whan, "wb"); // And Return Pipe Write Handle retfd = fdopen(whan, "wb"); /* And Return Pipe Write Handle */
} }
dup2(oldfd, 0); // Reconnect STDIN to Original Handle dup2(oldfd, 0); /* Reconnect STDIN to Original Handle */
DosExitCritSec(); // Now Allow Other Threads to Run DosExitCritSec(); /* Now Allow Other Threads to Run */
close(oldfd); // And Close Saved STDIN Handle close(oldfd); /* And Close Saved STDIN Handle */
return retfd; // Return fd of Pipe or NULL if Error return retfd; /* Return fd of Pipe or NULL if Error */
} else } else
return NULL; // ERROR - Invalid Mode (Neither Read nor Write) return NULL; /* ERROR - Invalid Mode (Neither Read nor Write) */
} }
static PyObject * static PyObject *
...@@ -2497,7 +2497,7 @@ all_ins(d) ...@@ -2497,7 +2497,7 @@ all_ins(d)
} }
#if defined(_MSC_VER) || defined(__WATCOMC__) #if ( defined(_MSC_VER) || defined(__WATCOMC__) ) && !defined(__QNX__)
#define INITFUNC initnt #define INITFUNC initnt
#define MODNAME "nt" #define MODNAME "nt"
#else #else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment