Change 16204 by jhi@alpha on 2002/04/26 22:33:45

        Integrate changes #16199 and #16201 from macperl;
        
        Time::Local compatibility patches, from Graham
        
        MacPerl require() portability patches

Affected files ...

.... //depot/perl/lib/Time/Local.pm#26 integrate
.... //depot/perl/pp_ctl.c#315 integrate

Differences ...

==== //depot/perl/lib/Time/Local.pm#26 (text) ====
Index: perl/lib/Time/Local.pm
--- perl/lib/Time/Local.pm.~1~  Fri Apr 26 16:45:05 2002
+++ perl/lib/Time/Local.pm      Fri Apr 26 16:45:05 2002
@@ -19,25 +19,36 @@
 my $NextCentury  = $ThisYear - $ThisYear % 100;
    $NextCentury += 100 if $Breakpoint < 50;
 my $Century      = $NextCentury - 100;
+my $SecOff       = 0;
 
 my (%Options, %Cheat);
 
+my $MaxInt = ((1<<(8 * $Config{intsize} - 2))-1)*2 + 1;
+my $MaxDay = int(($MaxInt-43200)/86400)-1;
+
 # Determine the EPOC day for this machine
 my $Epoc = 0;
 if ($^O eq 'vos') {
 # work around posix-977 -- VOS doesn't handle dates in
 # the range 1970-1980.
   $Epoc = _daygm((0, 0, 0, 1, 0, 70, 4, 0));
-} else {
+}
+elsif ($^O eq 'MacOS') {
+  no integer;
+
+  $MaxDay *=2 if $^O eq 'MacOS';  # time_t unsigned ... quick hack?
+  # MacOS time() is seconds since 1 Jan 1904, localtime
+  # so we need to calculate an offset to apply later
+  $Epoc = 693901;
+  $SecOff = timelocal(localtime(0)) - timelocal(gmtime(0));
+  $Epoc += _daygm(gmtime(0));
+}
+else {
   $Epoc = _daygm(gmtime(0));
 }
 
 %Cheat=(); # clear the cache as epoc has changed
 
-my $MaxInt = ((1<<(8 * $Config{intsize} - 2))-1)*2 + 1;
-my $MaxDay = int(($MaxInt-43200)/86400)-1;
-
-
 sub _daygm {
     $_[3] + ($Cheat{pack("ss",@_[4,5])} ||= do {
        my $month = ($_[4] + 10) % 12;
@@ -48,7 +59,11 @@
 
 
 sub _timegm {
-    $_[0]  +  60 * $_[1]  +  3600 * $_[2]  +  86400 * &_daygm;
+    my $sec = $SecOff + $_[0]  +  60 * $_[1]  +  3600 * $_[2];
+
+    no integer;
+
+    $sec +  86400 * &_daygm;
 }
 
 
@@ -86,7 +101,11 @@
        croak "Cannot handle date ($sec, $min, $hour, $mday, $month, $year)";
     }
 
-    $sec + 60*$min + 3600*$hour + 86400*$days;
+    $sec += $SecOff + 60*$min + 3600*$hour;
+
+    no integer;
+
+    $sec + 86400*$days;
 }
 
 
@@ -97,6 +116,7 @@
 
 
 sub timelocal {
+    no integer;
     my $ref_t = &timegm;
     my $loc_t = _timegm(localtime($ref_t));
 

==== //depot/perl/pp_ctl.c#315 (text) ====
Index: perl/pp_ctl.c
--- perl/pp_ctl.c.~1~   Fri Apr 26 16:45:05 2002
+++ perl/pp_ctl.c       Fri Apr 26 16:45:05 2002
@@ -2976,6 +2976,17 @@
        tryname = name;
        tryrsfp = doopen_pmc(name,PERL_SCRIPT_MODE);
     }
+#ifdef MACOS_TRADITIONAL
+    if (!tryrsfp) {
+       char newname[256];
+
+       MacPerl_CanonDir(name, newname, 1);
+       if (path_is_absolute(newname)) {
+           tryname = newname;
+           tryrsfp = doopen_pmc(newname,PERL_SCRIPT_MODE);
+       }
+    }
+#endif
     if (!tryrsfp) {
        AV *ar = GvAVn(PL_incgv);
        I32 i;
@@ -3109,8 +3120,11 @@
                  ) {
                    char *dir = SvPVx(dirsv, n_a);
 #ifdef MACOS_TRADITIONAL
-                   char buf[256];
-                   Perl_sv_setpvf(aTHX_ namesv, "%s%s", MacPerl_CanonDir(dir, buf), 
name+(name[0] == ':'));
+                   char buf1[256];
+                   char buf2[256];
+
+                   MacPerl_CanonDir(name, buf2, 1);
+                   Perl_sv_setpvf(aTHX_ namesv, "%s%s", MacPerl_CanonDir(dir, buf1, 
+0), buf2+(buf2[0] == ':'));
 #else
 #ifdef VMS
                    char *unixdir;
@@ -3124,14 +3138,6 @@
 #endif
                    TAINT_PROPER("require");
                    tryname = SvPVX(namesv);
-#ifdef MACOS_TRADITIONAL
-                   {
-                       /* Convert slashes in the name part, but not the directory 
part, to colons */
-                       char * colon;
-                       for (colon = tryname+strlen(dir); colon = strchr(colon, '/'); )
-                           *colon++ = ':';
-                   }
-#endif
                    tryrsfp = doopen_pmc(tryname, PERL_SCRIPT_MODE);
                    if (tryrsfp) {
                        if (tryname[0] == '.' && tryname[1] == '/')
@@ -3743,7 +3749,7 @@
 {
     if (PERL_FILE_IS_ABSOLUTE(name)
 #ifdef MACOS_TRADITIONAL
-       || (*name == ':' && name[1] != ':' && strchr(name+2, ':')))
+       || (*name == ':'))
 #else
        || (*name == '.' && (name[1] == '/' ||
                             (name[1] == '.' && name[2] == '/'))))
End of Patch.

Reply via email to