From cf564ca374a91282d1fb727d8407214fe453450f Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Wed, 19 Aug 2020 22:18:30 +0100 Subject: [PATCH] expire-8601: new version seems good now Signed-off-by: Ian Jackson --- scripts/expire-iso8601.new | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/scripts/expire-iso8601.new b/scripts/expire-iso8601.new index b8a857e..d9e009c 100755 --- a/scripts/expire-iso8601.new +++ b/scripts/expire-iso8601.new @@ -55,7 +55,7 @@ our $rm = 1; our $recurse = 1; our $unit = 86400; our $slop; -our $debug; +our $debug = 0; our @intervals; sub badusage ($) { @@ -108,17 +108,17 @@ sub flag ($) { my $d = $int->{D}; my $dmax = $d + $slop; my $spec = $int->{Spec}; - my $start_age = ($n+1) * $d; + my $start_age = ($n-1) * $d - $slop; my $i = 0; print DEBUG "FLAG $spec sa=$start_age dmax=$dmax\n"; - # find $i, the youngest which is at least $number x $interval + # find $i, the youngest which is at least $start_age for (;;) { print DEBUG "i #$i $files[$i]{A}\n"; last if $files[$i]{A} >= $start_age; if ($i == $#files) { - print STDERR "insufficient for $spec\n"; + print STDERR "insufficiently old for $spec\n"; } $i++; } @@ -126,16 +126,23 @@ sub flag ($) { for (;;) { push @{ $files[$i]{U} }, $spec; - # find $j, the closest to $i which is no more than $dmax younger + # find $j, the closest to $i, preferably no more than $dmax younger my $j = $i; for (;;) { $j--; - last if $j <= 0; - my $ndt = $files[$i]{A} - $files[$j-1]{A}; - print DEBUG "j #$j $files[$j]{A} ndt=$ndt\n"; - last if $ndt > $dmax; + # at each point in this loop $j is the next candidate + last if $j < 0; + my $dt = $files[$i]{A} - $files[$j]{A}; + print DEBUG "j #$j $files[$j]{A} dt=$dt\n"; + last if $dt > $dmax; } last if $j < 0; + $j++; + if ($j == $i) { + $j--; + print STDERR "insufficiently dense for $spec after $files[$j]{F}\n"; + } + print DEBUG "i #$j\n"; $i = $j; } -- 2.30.2