X-Git-Url: https://git.exim.org/exim.git/blobdiff_plain/c5722bc5a8df130f4733ca3c4398ae51cc7842e0..107077d7fd6736711bf5cd980221723401d37c51:/src/src/exim_msgdate.src diff --git a/src/src/exim_msgdate.src b/src/src/exim_msgdate.src index bfb5bc81e..4efee04f8 100755 --- a/src/src/exim_msgdate.src +++ b/src/src/exim_msgdate.src @@ -1,13 +1,13 @@ #!PERL_COMMAND -T # +# Copyright (c) The Exim Maintainers 2023 +# SPDX-License-Identifier: GPL-2.0-or-later +# # Utility to convert an exim message-id to a human readable form # # https://bugs.exim.org/show_bug.cgi?id=2956 # Written by Andrew C Aitchison # -# Copyright (c) 2023 The Exim Maintainers 2023 -# SPDX-License-Identifier: GPL-2.0-or-later -# # Portions taken from exicyclog.src, which is # Copyright (c) University of Cambridge, 1995 - 2015 # See the file NOTICE for conditions of use and distribution. @@ -56,7 +56,7 @@ my $localhost_number; # An Exim config value my $nolocalhost_number; my $p_name = basename $0; -my $p_version = "20230304.0"; +my $p_version = "20230501.0"; my $p_cp = < $id_resolution) { - $seconds++; - $fractions -= $id_resolution; - } - while ($fractions < -1e-7) { - $seconds--; - $fractions += $id_resolution; - } - # $seconds += $fractions / $id_resolution; - - # warn "decoded: seconds: $seconds, fractions: $fractions/$id_resolution\n"; + $fractions *= $id_resolution; + #warn "decoded: seconds: $seconds, fractions: $fractions"; + ($fractions < 1000000) or die "bad microsecond count: $fractions\n"; - return ($seconds, $fractions / $id_resolution); + return ($seconds, $fractions); } # sub unpack_time($$) sub print_time($$$$$$) @@ -420,7 +422,7 @@ sub print_time($$$$$$) my $decimalstring = ""; # if ($decimal>0) { - $decimalstring = sprintf(".%6.6d", 1000000*$decimal); + $decimalstring = sprintf(".%6.6d", $decimal); } my $secondsstring; unless (defined $unix or defined $zulu or defined $localtm) { @@ -447,17 +449,31 @@ foreach my $msgid (@ARGV) { my ($seconds, $pid, $fractions, $decimal); if ($msgid =~ - /(^|[\s<])E?([a-zA-Z0-9]{6})-([a-zA-Z0-9]{6})-([a-zA-Z0-9]{2})/) + /(?:(?:^|[\s<])E? + (?[a-zA-Z0-9]{6}) # new format + -(?[a-zA-Z0-9]{11}) + -(?[a-zA-Z0-9]{4}) + | + (?[a-zA-Z0-9]{6}) # old format + -(?[a-zA-Z0-9]{6}) + -(?[a-zA-Z0-9]{2}) + )/x) { +print "saw full mesgid\n" if $debug; + # Should take either the log form of timestamp, # the Message-ID: header form with the leading 'E', ... - ($seconds, $pid, $fractions) = ($2, $3, $4); - ($seconds, $decimal) = unpack_time($seconds, $fractions); - $pid = decode62($pid); - #warn "$seconds, $pid, $fractions\n"; - } elsif ($msgid =~ /(^|[^0-9A-Za-z])([a-zA-Z0-9]{6})$/) { + ($seconds, $decimal) = unpack_time($+{seconds}, $+{fractions}); + $pid = decode62($+{pid}); + #warn "$seconds, $pid, $+{fractions}\n"; + } elsif ($msgid =~ /(?:^|[^0-9A-Za-z]) + (? + [a-zA-Z0-9]{11} # new format + |[a-zA-Z0-9]{6} # old format + )$/x) { # ... or just the timecode section before the first '-' - ($seconds, $pid, $decimal) = (decode62($2), undef, 0); +print "saw just timecode\n" if $debug; + ($seconds, $pid, $decimal) = (decode62($+{seconds}), undef, 0); } else { warn "$msgid not parsed\n"; next;