Commits

Guido van Rossum  committed 533e36d

* Configure.py: use #!/usr/local/bin/python
* posixmodule.c: move extern function declarations to top
* listobject.c: cmp() arguments must be void* if __STDC__
* Makefile, allobjects.h, panelmodule.c, modsupport.c: get rid of
strdup() -- it is a portability risk
* Makefile: enclosed ranlib command in parentheses for Sequent Make
which aborts if the command is not found even if '-' is present
* timemodule.c: time() returns a floating point number, in microsecond
precision if BSD_TIME is defined.

  • Participants
  • Parent commits 27154a2
  • Branches legacy-trunk

Comments (0)

Files changed (6)

File Include/allobjects.h

 #include "errors.h"
 #include "mymalloc.h"
 
-extern char *strdup PROTO((const char *));
 extern void fatal PROTO((char *));

File Modules/config.c.in

 #ifdef __DATE__
 #define DATE __DATE__
 #else
-#define DATE ">= 10 Aug 1992"
+#define DATE ">= 1 Jan 1993"
 #endif
 
 #include <stdio.h>

File Modules/posixmodule.c

 #include "modsupport.h"
 #include "ceval.h"
 
+/* XXX Aren't these always declared in unistd.h? */
 extern char *strerror PROTO((int));
+extern int chmod PROTO((const char *, mode_t));
+extern char *getcwd PROTO((char *, int)); /* XXX or size_t? */
+extern int mkdir PROTO((const char *, mode_t));
+extern int chdir PROTO((const char *));
+extern int link PROTO((const char *, const char *));
+extern int rename PROTO((const char *, const char *));
+extern int rmdir PROTO((const char *));
+extern int stat PROTO((const char *, struct stat *));
+extern int unlink PROTO((const char *));
+extern int pclose PROTO((FILE *));
+#ifdef NO_LSTAT
+#define lstat stat
+#else
+extern int lstat PROTO((const char *, struct stat *));
+extern int symlink PROTO((const char *, const char *));
+#endif
 
 
 /* Return a dictionary corresponding to the POSIX environment table */
 	object *self;
 	object *args;
 {
-	extern int chdir PROTO((const char *));
 	return posix_1str(args, chdir);
 }
 
 	object *self;
 	object *args;
 {
-	extern int chmod PROTO((const char *, mode_t));
 	return posix_strint(args, chmod);
 }
 
 {
 	char buf[1026];
 	char *res;
-	extern char *getcwd PROTO((char *, int));
 	if (!getnoarg(args))
 		return NULL;
 	BGN_SAVE
 	object *self;
 	object *args;
 {
-	extern int link PROTO((const char *, const char *));
 	return posix_2str(args, link);
 }
 #endif /* !MSDOS */
 	object *self;
 	object *args;
 {
-	extern int mkdir PROTO((const char *, mode_t));
 	return posix_strint(args, mkdir);
 }
 
 	object *self;
 	object *args;
 {
-	extern int rename PROTO((const char *, const char *));
 	return posix_2str(args, rename);
 }
 
 	object *self;
 	object *args;
 {
-	extern int rmdir PROTO((const char *));
 	return posix_1str(args, rmdir);
 }
 
 	object *self;
 	object *args;
 {
-	extern int stat PROTO((const char *, struct stat *));
 	return posix_do_stat(self, args, stat);
 }
 
 	object *self;
 	object *args;
 {
-	extern int unlink PROTO((const char *));
 	return posix_1str(args, unlink);
 }
 
 #ifndef NO_UNAME
 #include <sys/utsname.h>
 
+extern int uname PROTO((struct utsname *));
+
 static object *
 posix_uname(self, args)
 	object *self;
 	object *args;
 {
-	extern int uname PROTO((struct utsname *));
 	struct utsname u;
 	object *v;
 	int res;
 	object *self;
 	object *args;
 {
-	extern int pclose PROTO((FILE *));
 	char *name, *mode;
 	FILE *fp;
 	if (!getargs(args, "(ss)", &name, &mode))
 	object *self;
 	object *args;
 {
-#ifdef NO_LSTAT
-#define lstat stat
-#endif
-	extern int lstat PROTO((const char *, struct stat *));
 	return posix_do_stat(self, args, lstat);
 }
 
 	err_setstr(PosixError, "symlink not implemented on this system");
 	return NULL;
 #else
-	extern int symlink PROTO((const char *, const char *));
 	return posix_2str(args, symlink);
 #endif
 }

File Modules/timemodule.c

 #include <signal.h>
 #include <setjmp.h>
 
+#ifdef BSD_TIME
+#define HAVE_GETTIMEOFDAY
+#endif
+
 #ifdef macintosh
 #define NO_UNISTD
 #endif
 	object *self;
 	object *args;
 {
+#ifdef HAVE_GETTIMEOFDAY
+	struct timeval t;
+	struct timezone tz;
+	if (!getnoarg(args))
+		return NULL;
+	if (gettimeofday(&t, &tz) != 0) {
+		err_errno(IOError);
+		return NULL;
+	}
+	return newfloatobject(t.tv_sec*1.0 + t.tv_usec*0.000001);
+#else /* !HAVE_GETTIMEOFDAY */
 	time_t secs;
 	if (!getnoarg(args))
 		return NULL;
 	(((1970-1904)*365L + (1970-1904)/4) * 24 * 3600))
 	secs -= TIMEDIFF;
 #endif
-	return newintobject((long)secs);
+	return newfloatobject((double)secs);
+#endif /* !HAVE_GETTIMEOFDAY */
 }
 
 static jmp_buf sleep_intr;

File Objects/listobject.c

 
 static int
 cmp(v, w)
+#ifdef __STDC__
+	void *v, *w;
+#else
 	char *v, *w;
+#endif
 {
 	object *t, *res;
 	long i;

File Python/modsupport.c

 {
 	object *m, *d, *v;
 	struct methodlist *ml;
-	char namebuf[256];
+	char *namebuf;
 	if ((m = add_module(name)) == NULL) {
 		fprintf(stderr, "initializing module: %s\n", name);
 		fatal("can't create a module");
 	}
 	d = getmoduledict(m);
 	for (ml = methods; ml->ml_name != NULL; ml++) {
+		namebuf = NEW(char, strlen(name) + strlen(ml->ml_name) + 2);
+		if (namebuf == NULL)
+			fatal("out of mem for method name");
 		sprintf(namebuf, "%s.%s", name, ml->ml_name);
-		v = newmethodobject(strdup(namebuf), ml->ml_meth,
+		v = newmethodobject(namebuf, ml->ml_meth,
 					(object *)NULL, ml->ml_varargs);
-		/* XXX The strdup'ed memory is never freed */
+		/* XXX The malloc'ed memory in namebuf is never freed */
 		if (v == NULL || dictinsert(d, ml->ml_name, v) != 0) {
 			fprintf(stderr, "initializing module: %s\n", name);
 			fatal("can't initialize module");