r1873 - in packages/libparse-syslog-perl/branches/upstream/current: . lib/Parse t

Joachim Breitner nomeata at costa.debian.org
Sun Jan 8 16:22:54 UTC 2006


Author: nomeata
Date: 2006-01-08 16:22:53 +0000 (Sun, 08 Jan 2006)
New Revision: 1873

Modified:
   packages/libparse-syslog-perl/branches/upstream/current/Changes
   packages/libparse-syslog-perl/branches/upstream/current/META.yml
   packages/libparse-syslog-perl/branches/upstream/current/lib/Parse/Syslog.pm
   packages/libparse-syslog-perl/branches/upstream/current/t/dst.t
Log:
Load /tmp/tmp.6tS2QF/libparse-syslog-perl-1.09 into
packages/libparse-syslog-perl/branches/upstream/current.


Modified: packages/libparse-syslog-perl/branches/upstream/current/Changes
===================================================================
--- packages/libparse-syslog-perl/branches/upstream/current/Changes	2006-01-06 22:48:34 UTC (rev 1872)
+++ packages/libparse-syslog-perl/branches/upstream/current/Changes	2006-01-08 16:22:53 UTC (rev 1873)
@@ -1,5 +1,17 @@
 Revision history for Perl extension Parse::Syslog.
 
+2006-01-01
+
+     * release 1.09
+     * t/dst.t: don't use IO::Scalar if not available
+     * fix '-' for STDIN
+
+2005-12-31
+
+     * release 1.08
+     * really fix the DST-handling code (thanks a lot to Randy Smith for the
+       debugging)
+
 2005-12-29
 
      * released 1.06

Modified: packages/libparse-syslog-perl/branches/upstream/current/META.yml
===================================================================
--- packages/libparse-syslog-perl/branches/upstream/current/META.yml	2006-01-06 22:48:34 UTC (rev 1872)
+++ packages/libparse-syslog-perl/branches/upstream/current/META.yml	2006-01-08 16:22:53 UTC (rev 1873)
@@ -1,7 +1,7 @@
 # http://module-build.sourceforge.net/META-spec.html
 #XXXXXXX This is a prototype!!!  It will change in the future!!! XXXXX#
 name:         Parse-Syslog
-version:      1.06
+version:      1.09
 version_from: lib/Parse/Syslog.pm
 installdirs:  site
 requires:

Modified: packages/libparse-syslog-perl/branches/upstream/current/lib/Parse/Syslog.pm
===================================================================
--- packages/libparse-syslog-perl/branches/upstream/current/lib/Parse/Syslog.pm	2006-01-06 22:48:34 UTC (rev 1872)
+++ packages/libparse-syslog-perl/branches/upstream/current/lib/Parse/Syslog.pm	2006-01-08 16:22:53 UTC (rev 1873)
@@ -7,7 +7,7 @@
 use strict;
 use vars qw($VERSION);
 
-$VERSION = '1.06';
+$VERSION = '1.09';
 
 my %months_map = (
     'Jan' => 0, 'Feb' => 1, 'Mar' => 2,
@@ -42,11 +42,13 @@
     my $time_plus_1h = timelocal($t->[0], $t->[1], $t->[2]+1, $t->[3], $t->[4], $t->[5]);
 
     if($time_plus_1h - $time > 4000) {
-        return 3600, $time-$time%3600+3600;
+        @{$self->{is_dst_switch_result}} = (3600, $time-$time%3600+3600);
     }
     else {
-        return 0, undef;
+        @{$self->{is_dst_switch_result}} = (0, undef);
     }
+
+    return @{$self->{is_dst_switch_result}};
 }
 
 # fast timelocal, cache minute's timestamp
@@ -81,6 +83,13 @@
     # - if a timewarp is detected (1:00 -> 1:30 -> 1:00):
     # - test if we are in a DST-switch-hour
     # - compensate if yes
+    # note that we assume that the DST-switch goes like this:
+    # time   1:00  1:30  2:00  2:30  2:00  2:30  3:00  3:30
+    # stamp   1     2     3     4     3     3     7     8  
+    # comp.   0     0     0     0     2     2     0     0
+    # result  1     2     3     4     5     6     7     8
+    # old Time::Local versions behave differently (1 2  5 6 5 6 7 8)
+
     if(!$GMT and !defined $self->{dst_comp} and
         defined $self->{last_time} and
         $self->{last_time}-$time > 1200 and
@@ -136,8 +145,14 @@
         $data{filetail}=1;
     }
     elsif(! ref $file) {
-        $data{file} = new IO::File($file, "<");
-        defined $data{file} or croak "can't open $file: $!";
+        if($file eq '-') {
+            my $io = new IO::Handle;
+            $data{file} = $io->fdopen(fileno(STDIN),"r");
+        }
+        else {
+            $data{file} = new IO::File($file, "<");
+            defined $data{file} or croak "can't open $file: $!";
+        }
     }
     else {
         croak "argument must be either a file-name or an IO::Handle object.";

Modified: packages/libparse-syslog-perl/branches/upstream/current/t/dst.t
===================================================================
--- packages/libparse-syslog-perl/branches/upstream/current/t/dst.t	2006-01-06 22:48:34 UTC (rev 1872)
+++ packages/libparse-syslog-perl/branches/upstream/current/t/dst.t	2006-01-08 16:22:53 UTC (rev 1873)
@@ -1,8 +1,8 @@
 use lib 'lib';
 use Parse::Syslog;
-use IO::Scalar;
 use Test;
 use POSIX;
+use Time::Local;
 
 BEGIN {
 	# only test if IO::Scalar is available
@@ -11,61 +11,57 @@
 		warn "IO::Scalar not available: test skipped.\n";
 		exit;
 	};
+	if($Time::Local::VERSION lt '1.07_94') {
+		warn "Time::Local too old for DST-switch code to work (is: $Time::Local::VERSION, must be: 1.07_94)";
+		plan test => 0;
+		exit;
+	}
 
-	plan tests => 16
+	plan tests => 20
 };
 
-#  00:00  01:00  01:00  02:00
-# ---|------|------|------|-----
-# 
-
 $ENV{TZ} = 'CET-1CEST-2,M3.5.0/02:00:00,M10.5.0/03:00:00';
 POSIX::tzset();
 
 my $data = <<END;
-Oct 30 00:59:53 ivr3 bla: bla
-Oct 30 01:09:53 ivr3 bla: bla
-Oct 30 01:19:53 ivr3 bla: bla
-Oct 30 01:29:53 ivr3 bla: bla
-Oct 30 01:39:53 ivr3 bla: bla
-Oct 30 01:49:53 ivr3 bla: bla
-Oct 30 01:59:58 ivr3 bla: bla
-Oct 30 01:59:58 ivr3 bla: bla
-Oct 30 01:00:00 ivr3 bla: bla
-Oct 30 01:00:04 ivr3 bla: bla
-Oct 30 01:10:04 ivr3 bla: bla
-Oct 30 01:20:04 ivr3 bla: bla
-Oct 30 01:30:04 ivr3 bla: bla
-Oct 30 01:40:04 ivr3 bla: bla
-Oct 30 01:50:04 ivr3 bla: bla
-Oct 30 02:00:04 ivr3 bla: bla
+Oct 30 01:40:00 ivr3 bla: bla
+Oct 30 02:00:00 ivr3 bla: bla
+Oct 30 02:20:00 ivr3 bla: bla
+Oct 30 02:40:00 ivr3 bla: bla
+Oct 30 02:59:58 ivr3 bla: bla
+Oct 30 02:00:00 ivr3 bla: bla
+Oct 30 02:20:00 ivr3 bla: bla
+Oct 30 02:40:00 ivr3 bla: bla
+Oct 30 03:00:00 ivr3 bla: bla
+Oct 30 03:20:00 ivr3 bla: bla
 END
 
 my $file = IO::Scalar->new(\$data);
 
-my $parser = Parse::Syslog->new($file);
+my $parser = Parse::Syslog->new($file, year=>2005);
 
-my @result = qw(
-1130626793
-1130627393
-1130627993
-1130628593
-1130629193
-1130629793
-1130630398
-1130630398
-1130630400
-1130630404
-1130631004
-1130631604
-1130632204
-1130632804
-1130633404
-1130634004
-);
+my $result = <<END;
+Sun Oct 30 01:40:00 2005
+Sun Oct 30 02:00:00 2005
+Sun Oct 30 02:20:00 2005
+Sun Oct 30 02:40:00 2005
+Sun Oct 30 02:59:58 2005
+Sun Oct 30 02:00:00 2005
+Sun Oct 30 02:20:00 2005
+Sun Oct 30 02:40:00 2005
+Sun Oct 30 03:00:00 2005
+Sun Oct 30 03:20:00 2005
+END
+my @result = split(/\n/, $result);
 
+my $last_t=0;
 while(my $sl = $parser->next) {
-	ok($sl->{timestamp}, shift @result);
+	# check that we get the correct localtime where a timewarp is noticeable
+	# but always an increasing timestamp
+	my $lt = localtime($sl->{timestamp});
+	ok($lt, shift @result);
+	ok($sl->{timestamp} > $last_t);
+	$last_t = $sl->{timestamp};
 }
 
 # vim: ft=perl




More information about the Pkg-perl-cvs-commits mailing list