Skip to content

Commit 54ecc3d

Browse files
committed
Patches by William Lewis for Nextstep descendants.
1 parent b5cebfe commit 54ecc3d

13 files changed

+689
-328
lines changed

Makefile.in

+8-4
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ DIST= $(DISTFILES) $(DISTDIRS)
161161
CFLAGS= $(OPT) -I. $(DEFS)
162162

163163
LIBRARY= libpython$(VERSION).a
164+
LDLIBRARY= @LDLIBRARY@
164165

165166
# Default target
166167
all: $(LIBRARY) python sharedmods
@@ -173,10 +174,10 @@ python: $(LIBRARY) buildno Modules/python.o
173174
$(srcdir)/Modules/getbuildinfo.c
174175
$(AR) cr $(LIBRARY) getbuildinfo.o
175176
$(RANLIB) $(LIBRARY)
176-
@DGUX_IS_BROKEN@
177+
@MAKE_LDLIBRARY@
177178
cd Modules; $(MAKE) OPT="$(OPT)" VERSION="$(VERSION)" \
178179
prefix="$(prefix)" exec_prefix="$(exec_prefix)" \
179-
LIBRARY=../$(LIBRARY) link
180+
LIBRARY=../$(LDLIBRARY) link
180181

181182
Modules/python.o: $(srcdir)/Modules/python.c
182183
cd Modules; $(MAKE) OPT="$(OPT)" python.o
@@ -204,6 +205,10 @@ libpython$(VERSION).so: $(LIBRARY)
204205
(cd dgux;ar x ../$^;ld -G -o ../$@ * )
205206
/bin/rm -rf ./dgux
206207

208+
# This rule is here for OPENSTEP/Rhapsody/MacOSX
209+
libpython$(VERSION).dylib: $(LIBRARY)
210+
libtool -o $(LDLIBRARY) -dynamic $(OTHER_LIBTOOL_OPT) $(LIBRARY) -framework System @LIBTOOL_CRUFT@
211+
207212
$(SUBDIRS): Makefiles
208213

209214
Parser:
@@ -258,7 +263,6 @@ altbininstall: python
258263
fi; \
259264
done
260265
$(INSTALL_PROGRAM) python$(EXE) $(BINDIR)/python$(VERSION)$(EXE)
261-
@DGUX_IS_BROKEN@
262266
if test -f libpython$(VERSION).so; then \
263267
$(INSTALL_DATA) libpython$(VERSION).so $(LIBDIR); \
264268
else true; \
@@ -504,7 +508,7 @@ clean: localclean
504508
done
505509

506510
localclobber: localclean
507-
-rm -f tags TAGS python $(LIBRARY) *.o
511+
-rm -f tags TAGS python $(LIBRARY) $(LDLIBRARY) *.o
508512
-rm -f config.log config.cache config.h
509513

510514
clobber: localclobber

Modules/Makefile.pre.in

+2-2
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ MAINOBJ= python.o
100100
SYSLIBS= $(LIBM) $(LIBC)
101101

102102
LIBRARY= ../libpython$(VERSION).a
103-
REALLIBRARY= ../@REALLIBRARY@
103+
LDLIBRARY= ../@LDLIBRARY@
104104

105105
# === Rules ===
106106

@@ -123,7 +123,7 @@ EXE=
123123
# This target is used by the master Makefile to link the final binary.
124124
link: $(MAINOBJ)
125125
$(LINKCC) $(LDFLAGS) $(LINKFORSHARED) $(MAINOBJ) \
126-
$(LIBRARY) $(MODLIBS) $(LIBS) $(SYSLIBS) -o python $(LDLAST)
126+
$(LDLIBRARY) $(MODLIBS) $(LIBS) $(SYSLIBS) -o python $(LDLAST)
127127
mv python$(EXE) ../python$(EXE)
128128

129129
clean:

Modules/getbuildinfo.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
const char *
3131
Py_GetBuildInfo()
3232
{
33-
static char buildinfo[40];
34-
sprintf(buildinfo, "#%d, %.12s, %.8s", BUILD, DATE, TIME);
33+
static char buildinfo[50];
34+
sprintf(buildinfo, "#%d, %.20s, %.9s", BUILD, DATE, TIME);
3535
return buildinfo;
3636
}

Modules/getpath.c

+25-1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ PERFORMANCE OF THIS SOFTWARE.
4242
#include <unistd.h>
4343
#endif /* HAVE_UNISTD_H */
4444

45+
#ifdef WITH_NEXT_FRAMEWORK
46+
#include <mach-o/dyld.h>
47+
#endif
48+
4549
/* Search in some common locations for the associated Python libraries.
4650
*
4751
* Two directories must be found, the platform independent directory
@@ -394,7 +398,24 @@ calculate_path()
394398
int bufsz;
395399
int prefixsz;
396400
char *defpath = pythonpath;
397-
401+
#ifdef WITH_NEXT_FRAMEWORK
402+
NSModule pythonModule;
403+
#endif
404+
405+
#ifdef WITH_NEXT_FRAMEWORK
406+
pythonModule = NSModuleForSymbol(NSLookupAndBindSymbol("_Py_Initialize"));
407+
/* Use dylib functions to find out where the framework was loaded from */
408+
buf = NSLibraryNameForModule(pythonModule);
409+
if (buf != NULL) {
410+
/* We're in a framework. */
411+
strcpy(progpath, buf);
412+
413+
/* Frameworks have support for versioning */
414+
strcpy(lib_python, "lib");
415+
} else {
416+
/* If we're not in a framework, fall back to the old way (even though NSNameOfModule() probably does the same thing.) */
417+
#endif
418+
398419
/* Initialize this dynamically for K&R C */
399420
sprintf(lib_python, "lib/python%s", VERSION);
400421

@@ -430,6 +451,9 @@ calculate_path()
430451
}
431452
else
432453
progpath[0] = '\0';
454+
#ifdef WITH_NEXT_FRAMEWORK
455+
}
456+
#endif
433457

434458
strcpy(argv0_path, progpath);
435459

Modules/posixmodule.c

+94-25
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ corresponding Unix manual entries for more information on calls.";
146146
#undef HAVE_UTIME_H
147147
#define HAVE_WAITPID
148148
/* #undef HAVE_GETCWD */
149+
#define UNION_WAIT /* This should really be checked for by autoconf */
149150
#endif
150151

151152
#ifdef HAVE_UNISTD_H
@@ -255,6 +256,23 @@ extern int lstat Py_PROTO((const char *, struct stat *));
255256
#include <io.h>
256257
#endif /* OS2 */
257258

259+
#ifdef UNION_WAIT
260+
/* Emulate some macros on systems that have a union instead of macros */
261+
262+
#ifndef WIFEXITED
263+
#define WIFEXITED(u_wait) (!(u_wait).w_termsig && !(u_wait).w_coredump)
264+
#endif
265+
266+
#ifndef WEXITSTATUS
267+
#define WEXITSTATUS(u_wait) (WIFEXITED(u_wait)?((u_wait).w_retcode):-1)
268+
#endif
269+
270+
#ifndef WTERMSIG
271+
#define WTERMSIG(u_wait) ((u_wait).w_termsig)
272+
#endif
273+
274+
#endif /* UNION_WAIT */
275+
258276
/* Return a dictionary corresponding to the POSIX environment table */
259277

260278
#if !defined(_MSC_VER) && ( !defined(__WATCOMC__) || defined(__QNX__) )
@@ -1986,20 +2004,25 @@ posix_waitpid(self, args)
19862004
PyObject *self;
19872005
PyObject *args;
19882006
{
1989-
int pid, options, sts = 0;
2007+
int pid, options;
2008+
#ifdef UNION_WAIT
2009+
union wait status;
2010+
#define status_i (status.w_status)
2011+
#else
2012+
int status;
2013+
#define status_i status
2014+
#endif
2015+
status_i = 0;
2016+
19902017
if (!PyArg_Parse(args, "(ii)", &pid, &options))
19912018
return NULL;
19922019
Py_BEGIN_ALLOW_THREADS
1993-
#ifdef NeXT
1994-
pid = wait4(pid, (union wait *)&sts, options, NULL);
1995-
#else
1996-
pid = waitpid(pid, &sts, options);
1997-
#endif
2020+
pid = wait4(pid, &status, options, NULL);
19982021
Py_END_ALLOW_THREADS
19992022
if (pid == -1)
20002023
return posix_error();
20012024
else
2002-
return Py_BuildValue("ii", pid, sts);
2025+
return Py_BuildValue("ii", pid, status_i);
20032026
}
20042027
#endif /* HAVE_WAITPID */
20052028

@@ -2015,17 +2038,21 @@ posix_wait(self, args)
20152038
PyObject *args;
20162039
{
20172040
int pid, sts;
2018-
Py_BEGIN_ALLOW_THREADS
2019-
#ifdef NeXT
2020-
pid = wait((union wait *)&sts);
2041+
#ifdef UNION_WAIT
2042+
union wait status;
2043+
#define status_i (status.w_status)
20212044
#else
2022-
pid = wait(&sts);
2045+
int status;
2046+
#define status_i status
20232047
#endif
2048+
status_i = 0;
2049+
Py_BEGIN_ALLOW_THREADS
2050+
pid = wait(&status);
20242051
Py_END_ALLOW_THREADS
20252052
if (pid == -1)
20262053
return posix_error();
20272054
else
2028-
return Py_BuildValue("ii", pid, sts);
2055+
return Py_BuildValue("ii", pid, status_i);
20292056
}
20302057
#endif
20312058

@@ -2821,9 +2848,16 @@ posix_WIFSTOPPED(self, args)
28212848
PyObject *self;
28222849
PyObject *args;
28232850
{
2824-
int status = 0;
2851+
#ifdef UNION_WAIT
2852+
union wait status;
2853+
#define status_i (status.w_status)
2854+
#else
2855+
int status;
2856+
#define status_i status
2857+
#endif
2858+
status_i = 0;
28252859

2826-
if (!PyArg_Parse(args, "i", &status))
2860+
if (!PyArg_Parse(args, "i", &status_i))
28272861
{
28282862
return NULL;
28292863
}
@@ -2842,9 +2876,16 @@ posix_WIFSIGNALED(self, args)
28422876
PyObject *self;
28432877
PyObject *args;
28442878
{
2845-
int status = 0;
2879+
#ifdef UNION_WAIT
2880+
union wait status;
2881+
#define status_i (status.w_status)
2882+
#else
2883+
int status;
2884+
#define status_i status
2885+
#endif
2886+
status_i = 0;
28462887

2847-
if (!PyArg_Parse(args, "i", &status))
2888+
if (!PyArg_Parse(args, "i", &status_i))
28482889
{
28492890
return NULL;
28502891
}
@@ -2863,9 +2904,16 @@ posix_WIFEXITED(self, args)
28632904
PyObject *self;
28642905
PyObject *args;
28652906
{
2866-
int status = 0;
2907+
#ifdef UNION_WAIT
2908+
union wait status;
2909+
#define status_i (status.w_status)
2910+
#else
2911+
int status;
2912+
#define status_i status
2913+
#endif
2914+
status_i = 0;
28672915

2868-
if (!PyArg_Parse(args, "i", &status))
2916+
if (!PyArg_Parse(args, "i", &status_i))
28692917
{
28702918
return NULL;
28712919
}
@@ -2874,7 +2922,7 @@ posix_WIFEXITED(self, args)
28742922
}
28752923
#endif /* WIFEXITED */
28762924

2877-
#ifdef WIFSTOPPED
2925+
#ifdef WEXITSTATUS
28782926
static char posix_WEXITSTATUS__doc__[] =
28792927
"WEXITSTATUS(status) -> integer\n\
28802928
See Unix documentation.";
@@ -2884,9 +2932,16 @@ posix_WEXITSTATUS(self, args)
28842932
PyObject *self;
28852933
PyObject *args;
28862934
{
2887-
int status = 0;
2935+
#ifdef UNION_WAIT
2936+
union wait status;
2937+
#define status_i (status.w_status)
2938+
#else
2939+
int status;
2940+
#define status_i status
2941+
#endif
2942+
status_i = 0;
28882943

2889-
if (!PyArg_Parse(args, "i", &status))
2944+
if (!PyArg_Parse(args, "i", &status_i))
28902945
{
28912946
return NULL;
28922947
}
@@ -2905,9 +2960,16 @@ posix_WTERMSIG(self, args)
29052960
PyObject *self;
29062961
PyObject *args;
29072962
{
2908-
int status = 0;
2963+
#ifdef UNION_WAIT
2964+
union wait status;
2965+
#define status_i (status.w_status)
2966+
#else
2967+
int status;
2968+
#define status_i status
2969+
#endif
2970+
status_i = 0;
29092971

2910-
if (!PyArg_Parse(args, "i", &status))
2972+
if (!PyArg_Parse(args, "i", &status_i))
29112973
{
29122974
return NULL;
29132975
}
@@ -2926,9 +2988,16 @@ posix_WSTOPSIG(self, args)
29262988
PyObject *self;
29272989
PyObject *args;
29282990
{
2929-
int status = 0;
2991+
#ifdef UNION_WAIT
2992+
union wait status;
2993+
#define status_i (status.w_status)
2994+
#else
2995+
int status;
2996+
#define status_i status
2997+
#endif
2998+
status_i = 0;
29302999

2931-
if (!PyArg_Parse(args, "i", &status))
3000+
if (!PyArg_Parse(args, "i", &status_i))
29323001
{
29333002
return NULL;
29343003
}

Modules/readline.c

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ extern int rl_bind_key();
3434
extern int rl_bind_key_in_map();
3535
extern int rl_initialize();
3636
extern int add_history();
37+
extern Function *rl_event_hook;
3738
#endif
3839

3940
/* Pointers needed from outside (but not declared in a header file). */

Python/getversion.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ PERFORMANCE OF THIS SOFTWARE.
3838
const char *
3939
Py_GetVersion()
4040
{
41-
static char version[80];
42-
sprintf(version, "%.10s (%.30s) %.30s", PY_VERSION,
41+
static char version[100];
42+
sprintf(version, "%.10s (%.40s) %.40s", PY_VERSION,
4343
Py_GetBuildInfo(), Py_GetCompiler());
4444
return version;
4545
}

0 commit comments

Comments
 (0)