summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorLarry Wall <lwall@netlabs.com>1992-06-08 04:53:03 +0000
committerLarry Wall <lwall@netlabs.com>1992-06-08 04:53:03 +0000
commit7c0587c85ff56c1fa1d95bc5228a7aff2da43d6c (patch)
tree89ac53b3686082f0fd8568003b57256f097f9165 /lib
parent2b69d0c297460bce3a8d8eefe2bd0de0a6451872 (diff)
downloadperl-7c0587c85ff56c1fa1d95bc5228a7aff2da43d6c.tar.gz
perl 4.0 patch 32: patch #20, continued
See patch #20.
Diffstat (limited to 'lib')
-rw-r--r--lib/termcap.pl6
-rw-r--r--lib/timelocal.pl18
2 files changed, 14 insertions, 10 deletions
diff --git a/lib/termcap.pl b/lib/termcap.pl
index 46ac858247..aa221dfc39 100644
--- a/lib/termcap.pl
+++ b/lib/termcap.pl
@@ -1,4 +1,4 @@
-;# $Header: termcap.pl,v 4.0 91/03/20 01:26:33 lwall Locked $
+;# $RCSfile: termcap.pl,v $$Revision: 4.0.1.1 $$Date: 92/06/08 13:49:17 $
;#
;# Usage:
;# require 'ioctl.pl';
@@ -21,7 +21,7 @@ sub Tgetent {
$TERMCAP = $ENV{'TERMCAP'};
$TERMCAP = '/etc/termcap' unless $TERMCAP;
if ($TERMCAP !~ m:^/:) {
- if (index($TERMCAP,"|$TERM|") < $[) {
+ if ($TERMCAP !~ /(^|\|)$TERM[:\|]/) {
$TERMCAP = '/etc/termcap';
}
}
@@ -33,7 +33,7 @@ sub Tgetent {
while (<TERMCAP>) {
next if /^#/;
next if /^\t/;
- if (/\\|$TERM[:\\|]/) {
+ if (/(^|\\|)$TERM[:\\|]/) {
chop;
while (chop eq '\\\\') {
\$_ .= <TERMCAP>;
diff --git a/lib/timelocal.pl b/lib/timelocal.pl
index a228041637..5be3840035 100644
--- a/lib/timelocal.pl
+++ b/lib/timelocal.pl
@@ -1,7 +1,7 @@
;# timelocal.pl
;#
;# Usage:
-;# $time = timelocal($sec,$min,$hours,$mday,$mon,$year,$junk,$junk,$isdst);
+;# $time = timelocal($sec,$min,$hours,$mday,$mon,$year);
;# $time = timegm($sec,$min,$hours,$mday,$mon,$year);
;# These routines are quite efficient and yet are always guaranteed to agree
@@ -24,6 +24,7 @@
CONFIG: {
package timelocal;
+ local($[) = 0;
@epoch = localtime(0);
$tzmin = $epoch[2] * 60 + $epoch[1]; # minutes east of GMT
if ($tzmin > 0) {
@@ -40,6 +41,7 @@ CONFIG: {
sub timegm {
package timelocal;
+ local($[) = 0;
$ym = pack(C2, @_[5,4]);
$cheat = $cheat{$ym} || &cheat;
$cheat + $_[0] * $SEC + $_[1] * $MIN + $_[2] * $HR + ($_[3]-1) * $DAYS;
@@ -48,10 +50,11 @@ sub timegm {
sub timelocal {
package timelocal;
- $ym = pack(C2, @_[5,4]);
- $cheat = $cheat{$ym} || &cheat;
- $cheat + $_[0] * $SEC + $_[1] * $MIN + $_[2] * $HR + ($_[3]-1) * $DAYS
- + $tzmin * $MIN - 60 * 60 * ($_[8] != 0);
+ local($[) = 0;
+ $time = &main'timegm + $tzmin*$MIN;
+ @test = localtime($time);
+ $time -= $HR if $test[2] != $_[2];
+ $time;
}
package timelocal;
@@ -59,14 +62,15 @@ package timelocal;
sub cheat {
$year = $_[5];
$month = $_[4];
+ die "Month out of range 0..11 in ctime.pl\n" if $month > 11;
$guess = $^T;
@g = gmtime($guess);
while ($diff = $year - $g[5]) {
- $guess += $diff * (364 * $DAYS);
+ $guess += $diff * (363 * $DAYS);
@g = gmtime($guess);
}
while ($diff = $month - $g[4]) {
- $guess += $diff * (28 * $DAYS);
+ $guess += $diff * (27 * $DAYS);
@g = gmtime($guess);
}
$g[3]--;