summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1999-01-27 17:53:11 (GMT)
committerGuido van Rossum <guido@python.org>1999-01-27 17:53:11 (GMT)
commit54ecc3d24f52ae45ca54a24167e434915c88b60f (patch)
tree2bc2d15f1e6a6178a992a9ce0b4975697f1ef71b /Modules
parentb5cebfe164fbf6c862e8aa9fb91628d1b8cf76be (diff)
downloadcpython-54ecc3d24f52ae45ca54a24167e434915c88b60f.zip
cpython-54ecc3d24f52ae45ca54a24167e434915c88b60f.tar.gz
cpython-54ecc3d24f52ae45ca54a24167e434915c88b60f.tar.bz2
Patches by William Lewis for Nextstep descendants.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/Makefile.pre.in4
-rw-r--r--Modules/getbuildinfo.c4
-rw-r--r--Modules/getpath.c26
-rw-r--r--Modules/posixmodule.c119
-rw-r--r--Modules/readline.c1
5 files changed, 124 insertions, 30 deletions
diff --git a/Modules/Makefile.pre.in b/Modules/Makefile.pre.in
index 4d306e7..4ea78c5 100644
--- a/Modules/Makefile.pre.in
+++ b/Modules/Makefile.pre.in
@@ -100,7 +100,7 @@ MAINOBJ= python.o
SYSLIBS= $(LIBM) $(LIBC)
LIBRARY= ../libpython$(VERSION).a
-REALLIBRARY= ../@REALLIBRARY@
+LDLIBRARY= ../@LDLIBRARY@
# === Rules ===
@@ -123,7 +123,7 @@ EXE=
# This target is used by the master Makefile to link the final binary.
link: $(MAINOBJ)
$(LINKCC) $(LDFLAGS) $(LINKFORSHARED) $(MAINOBJ) \
- $(LIBRARY) $(MODLIBS) $(LIBS) $(SYSLIBS) -o python $(LDLAST)
+ $(LDLIBRARY) $(MODLIBS) $(LIBS) $(SYSLIBS) -o python $(LDLAST)
mv python$(EXE) ../python$(EXE)
clean:
diff --git a/Modules/getbuildinfo.c b/Modules/getbuildinfo.c
index 3f9ee52..49793b8 100644
--- a/Modules/getbuildinfo.c
+++ b/Modules/getbuildinfo.c
@@ -30,7 +30,7 @@
const char *
Py_GetBuildInfo()
{
- static char buildinfo[40];
- sprintf(buildinfo, "#%d, %.12s, %.8s", BUILD, DATE, TIME);
+ static char buildinfo[50];
+ sprintf(buildinfo, "#%d, %.20s, %.9s", BUILD, DATE, TIME);
return buildinfo;
}
diff --git a/Modules/getpath.c b/Modules/getpath.c
index 09b795d..78b4915 100644
--- a/Modules/getpath.c
+++ b/Modules/getpath.c
@@ -42,6 +42,10 @@ PERFORMANCE OF THIS SOFTWARE.
#include <unistd.h>
#endif /* HAVE_UNISTD_H */
+#ifdef WITH_NEXT_FRAMEWORK
+#include <mach-o/dyld.h>
+#endif
+
/* Search in some common locations for the associated Python libraries.
*
* Two directories must be found, the platform independent directory
@@ -394,7 +398,24 @@ calculate_path()
int bufsz;
int prefixsz;
char *defpath = pythonpath;
-
+#ifdef WITH_NEXT_FRAMEWORK
+ NSModule pythonModule;
+#endif
+
+#ifdef WITH_NEXT_FRAMEWORK
+ pythonModule = NSModuleForSymbol(NSLookupAndBindSymbol("_Py_Initialize"));
+ /* Use dylib functions to find out where the framework was loaded from */
+ buf = NSLibraryNameForModule(pythonModule);
+ if (buf != NULL) {
+ /* We're in a framework. */
+ strcpy(progpath, buf);
+
+ /* Frameworks have support for versioning */
+ strcpy(lib_python, "lib");
+ } else {
+ /* If we're not in a framework, fall back to the old way (even though NSNameOfModule() probably does the same thing.) */
+#endif
+
/* Initialize this dynamically for K&R C */
sprintf(lib_python, "lib/python%s", VERSION);
@@ -430,6 +451,9 @@ calculate_path()
}
else
progpath[0] = '\0';
+#ifdef WITH_NEXT_FRAMEWORK
+ }
+#endif
strcpy(argv0_path, progpath);
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 8ac5d96..19c7809 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -146,6 +146,7 @@ corresponding Unix manual entries for more information on calls.";
#undef HAVE_UTIME_H
#define HAVE_WAITPID
/* #undef HAVE_GETCWD */
+#define UNION_WAIT /* This should really be checked for by autoconf */
#endif
#ifdef HAVE_UNISTD_H
@@ -255,6 +256,23 @@ extern int lstat Py_PROTO((const char *, struct stat *));
#include <io.h>
#endif /* OS2 */
+#ifdef UNION_WAIT
+/* Emulate some macros on systems that have a union instead of macros */
+
+#ifndef WIFEXITED
+#define WIFEXITED(u_wait) (!(u_wait).w_termsig && !(u_wait).w_coredump)
+#endif
+
+#ifndef WEXITSTATUS
+#define WEXITSTATUS(u_wait) (WIFEXITED(u_wait)?((u_wait).w_retcode):-1)
+#endif
+
+#ifndef WTERMSIG
+#define WTERMSIG(u_wait) ((u_wait).w_termsig)
+#endif
+
+#endif /* UNION_WAIT */
+
/* Return a dictionary corresponding to the POSIX environment table */
#if !defined(_MSC_VER) && ( !defined(__WATCOMC__) || defined(__QNX__) )
@@ -1986,20 +2004,25 @@ posix_waitpid(self, args)
PyObject *self;
PyObject *args;
{
- int pid, options, sts = 0;
+ int pid, options;
+#ifdef UNION_WAIT
+ union wait status;
+#define status_i (status.w_status)
+#else
+ int status;
+#define status_i status
+#endif
+ status_i = 0;
+
if (!PyArg_Parse(args, "(ii)", &pid, &options))
return NULL;
Py_BEGIN_ALLOW_THREADS
-#ifdef NeXT
- pid = wait4(pid, (union wait *)&sts, options, NULL);
-#else
- pid = waitpid(pid, &sts, options);
-#endif
+ pid = wait4(pid, &status, options, NULL);
Py_END_ALLOW_THREADS
if (pid == -1)
return posix_error();
else
- return Py_BuildValue("ii", pid, sts);
+ return Py_BuildValue("ii", pid, status_i);
}
#endif /* HAVE_WAITPID */
@@ -2015,17 +2038,21 @@ posix_wait(self, args)
PyObject *args;
{
int pid, sts;
- Py_BEGIN_ALLOW_THREADS
-#ifdef NeXT
- pid = wait((union wait *)&sts);
+#ifdef UNION_WAIT
+ union wait status;
+#define status_i (status.w_status)
#else
- pid = wait(&sts);
+ int status;
+#define status_i status
#endif
+ status_i = 0;
+ Py_BEGIN_ALLOW_THREADS
+ pid = wait(&status);
Py_END_ALLOW_THREADS
if (pid == -1)
return posix_error();
else
- return Py_BuildValue("ii", pid, sts);
+ return Py_BuildValue("ii", pid, status_i);
}
#endif
@@ -2821,9 +2848,16 @@ posix_WIFSTOPPED(self, args)
PyObject *self;
PyObject *args;
{
- int status = 0;
+#ifdef UNION_WAIT
+ union wait status;
+#define status_i (status.w_status)
+#else
+ int status;
+#define status_i status
+#endif
+ status_i = 0;
- if (!PyArg_Parse(args, "i", &status))
+ if (!PyArg_Parse(args, "i", &status_i))
{
return NULL;
}
@@ -2842,9 +2876,16 @@ posix_WIFSIGNALED(self, args)
PyObject *self;
PyObject *args;
{
- int status = 0;
+#ifdef UNION_WAIT
+ union wait status;
+#define status_i (status.w_status)
+#else
+ int status;
+#define status_i status
+#endif
+ status_i = 0;
- if (!PyArg_Parse(args, "i", &status))
+ if (!PyArg_Parse(args, "i", &status_i))
{
return NULL;
}
@@ -2863,9 +2904,16 @@ posix_WIFEXITED(self, args)
PyObject *self;
PyObject *args;
{
- int status = 0;
+#ifdef UNION_WAIT
+ union wait status;
+#define status_i (status.w_status)
+#else
+ int status;
+#define status_i status
+#endif
+ status_i = 0;
- if (!PyArg_Parse(args, "i", &status))
+ if (!PyArg_Parse(args, "i", &status_i))
{
return NULL;
}
@@ -2874,7 +2922,7 @@ posix_WIFEXITED(self, args)
}
#endif /* WIFEXITED */
-#ifdef WIFSTOPPED
+#ifdef WEXITSTATUS
static char posix_WEXITSTATUS__doc__[] =
"WEXITSTATUS(status) -> integer\n\
See Unix documentation.";
@@ -2884,9 +2932,16 @@ posix_WEXITSTATUS(self, args)
PyObject *self;
PyObject *args;
{
- int status = 0;
+#ifdef UNION_WAIT
+ union wait status;
+#define status_i (status.w_status)
+#else
+ int status;
+#define status_i status
+#endif
+ status_i = 0;
- if (!PyArg_Parse(args, "i", &status))
+ if (!PyArg_Parse(args, "i", &status_i))
{
return NULL;
}
@@ -2905,9 +2960,16 @@ posix_WTERMSIG(self, args)
PyObject *self;
PyObject *args;
{
- int status = 0;
+#ifdef UNION_WAIT
+ union wait status;
+#define status_i (status.w_status)
+#else
+ int status;
+#define status_i status
+#endif
+ status_i = 0;
- if (!PyArg_Parse(args, "i", &status))
+ if (!PyArg_Parse(args, "i", &status_i))
{
return NULL;
}
@@ -2926,9 +2988,16 @@ posix_WSTOPSIG(self, args)
PyObject *self;
PyObject *args;
{
- int status = 0;
+#ifdef UNION_WAIT
+ union wait status;
+#define status_i (status.w_status)
+#else
+ int status;
+#define status_i status
+#endif
+ status_i = 0;
- if (!PyArg_Parse(args, "i", &status))
+ if (!PyArg_Parse(args, "i", &status_i))
{
return NULL;
}
diff --git a/Modules/readline.c b/Modules/readline.c
index 08569f6..608dd88 100644
--- a/Modules/readline.c
+++ b/Modules/readline.c
@@ -34,6 +34,7 @@ extern int rl_bind_key();
extern int rl_bind_key_in_map();
extern int rl_initialize();
extern int add_history();
+extern Function *rl_event_hook;
#endif
/* Pointers needed from outside (but not declared in a header file). */