[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl-Porters] time patches for everyone



This patch, in combination with GUSI 2.1.1, should make time, 
localtime, and gmtime return correct results for all compilers.

Index: perl.c
===================================================================
RCS file: /home/neeri/MacCVS/MacPerl/perl-5.6/perl.c,v
retrieving revision 1.2
diff -u -r1.2 perl.c
--- perl.c	2000/05/14 21:44:57	1.2
+++ perl.c	2000/06/11 22:53:04
@@ -3440,12 +3440,6 @@
  	    sv_setpv(libdir, PERLLIB_MANGLE(p, 0));
  	    p = Nullch;	/* break out */
  	}
-#ifdef MACOS_TRADITIONAL
-	if (!strchr(SvPVX(libdir), ':'))
-	    sv_insert(libdir, 0, 0, ":", 1);
-	if (SvPVX(libdir)[SvCUR(libdir)-1] != ':')
-	    sv_catpv(libdir, ":");
-#endif

  	/*
  	 * BEFORE pushing libdir onto @INC we may first push version- and
Index: pp_ctl.c
===================================================================
RCS file: /home/neeri/MacCVS/MacPerl/perl-5.6/pp_ctl.c,v
retrieving revision 1.2
diff -u -r1.2 pp_ctl.c
--- pp_ctl.c	2000/05/14 21:44:58	1.2
+++ pp_ctl.c	2000/06/11 22:53:37
@@ -3120,8 +3120,8 @@
  		else {
  		    char *dir = SvPVx(dirsv, n_a);
  #ifdef MACOS_TRADITIONAL
-		    /* We have ensured in incpush that library ends with ':' */
-		    Perl_sv_setpvf(aTHX_ namesv, "%s%s", dir, 
name+(name[0] == ':'));
+		    char buf[256];
+		    Perl_sv_setpvf(aTHX_ namesv, "%s%s", 
MacPerl_CanonDir(dir, buf), name+(name[0] == ':'));
  #else
  #ifdef VMS
  		    char *unixdir;
Index: macos/config.h
===================================================================
RCS file: /home/neeri/MacCVS/MacPerl/perl-5.6/macos/config.h,v
retrieving revision 1.1
diff -u -r1.1 config.h
--- config.h	2000/05/14 21:45:03	1.1
+++ config.h	2000/06/11 22:54:13
@@ -2780,6 +2780,7 @@
  #else
  #define __STDIO__	1
  #endif
+#define BIG_TIME
  #endif

  #define Sock_size_t socklen_t
Index: macos/macish.c
===================================================================
RCS file: /home/neeri/MacCVS/MacPerl/perl-5.6/macos/macish.c,v
retrieving revision 1.1
diff -u -r1.1 macish.c
--- macish.c	2000/05/14 21:45:04	1.1
+++ macish.c	2000/06/11 22:54:21
@@ -672,3 +672,71 @@
  	return isnan(f) ? 0.0 : f;
  }
  #endif
+
+const char * MacPerl_CanonDir(const char * dir, char * buf)
+{
+	char * out = buf;
+	char * slash;
+	struct stat s;
+
+	if (!strchr(dir, ':'))
+		*out++ = ':';
+
+	if (!stat(dir, &s))
+		goto done;
+
+	while (dir[0] == '.') {
+		switch (dir[1]) {
+		case '/':
+			if (out == buf)
+				*out++	= ':';
+			dir += 2;
+			continue;
+		case '.':
+			if (dir[2] == '/') {
+				if (out == buf)
+					*out++	= ':';
+				*out++ = ':';
+			}
+			dir += 3;
+			continue;
+		}
+		break;
+	}
+
+	while (slash = strchr(dir, '/')) {
+		memcpy(out, dir, slash-dir);
+		out += slash-dir;
+		*out++ = ':';
+		for (;;) {
+			while (*++slash == '/')
+				;
+			if (slash[0] == '.') {
+				switch (slash[1]) {
+				case '/':
+					slash = slash+2;
+					break;
+				case '.':
+					if (slash[2] == '/') {
+						*out++ = ':';
+						slash = slash+3;
+						break;
+					}
+				default:
+					goto nomoreslashes;
+				}
+			}
+		}
+nomoreslashes:
+		dir = slash;
+	}
+done:
+	strcpy(out, dir);
+	out += strlen(out);
+	if (out[-1] != ':')
+		*out++ = ':';
+	*out = 0;
+
+	return buf;
+}
+
Index: macos/macish.h
===================================================================
RCS file: /home/neeri/MacCVS/MacPerl/perl-5.6/macos/macish.h,v
retrieving revision 1.1
diff -u -r1.1 macish.h
--- macish.h	2000/05/14 21:45:04	1.1
+++ macish.h	2000/06/11 22:54:21
@@ -54,6 +54,7 @@
  char * MacPerl_MPWFileName(char * file);
  char * GetSysErrText(short, char *);
  unsigned char * MacPerl_CopyC2P(const char * c, unsigned char * p);
+const char * MacPerl_CanonDir(const char * dir, char * buf);

  #define SH_PATH    "Shell ? We don't need no stinking shell!"

@@ -166,21 +167,8 @@
  #define Fflush(fp)         fflush(fp)
  #define Mkdir(path,mode)   mkdir((path),(mode))

-/* these should be set in a hint file, not here */
  #ifndef PERL_SYS_INIT
-#ifdef PERL_SCO5
-#  define PERL_SYS_INIT(c,v)	fpsetmask(0); MALLOC_INIT
-#else
-#  ifdef POSIX_BC
-#    define PERL_SYS_INIT(c,v)	sigignore(SIGFPE); MALLOC_INIT
-#  else
-#    ifdef CYGWIN
-#      define PERL_SYS_INIT(c,v) Perl_my_setenv_init(&environ); MALLOC_INIT
-#    else
-#      define PERL_SYS_INIT(c,v) MALLOC_INIT
-#    endif
-#  endif
-#endif
+#	define PERL_SYS_INIT(c,v) PL_opargs[OP_TIME] &= 
~OA_RETINTEGER; MALLOC_INIT
  #endif

  #ifndef PERL_SYS_TERM
__END__

==== Want to unsubscribe from this list?
==== Send mail with body "unsubscribe" to macperl-porters-request@macperl.org