chiark / gitweb /
expire-8601: wip new version, err on other side
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 19 Aug 2020 20:59:22 +0000 (21:59 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 19 Aug 2020 20:59:22 +0000 (21:59 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
scripts/expire-iso8601.new

index 169961a75d6a3cc1137ffd4caa030499d7db0274..b8a857efe6cc5db1d4b55f7688b5329095000a7e 100755 (executable)
@@ -106,12 +106,12 @@ sub flag ($) {
   my ($int) = @_;
   my $n = $int->{N};
   my $d = $int->{D};
-  my $dmin = $d - $slop;
+  my $dmax = $d + $slop;
   my $spec = $int->{Spec};
   my $start_age = ($n+1) * $d;
   my $i = 0;
 
-  print DEBUG "FLAG $spec sa=$start_age dmin=$dmin\n";
+  print DEBUG "FLAG $spec sa=$start_age dmax=$dmax\n";
 
   # find $i, the youngest which is at least $number x $interval
   for (;;) {
@@ -126,14 +126,14 @@ sub flag ($) {
   for (;;) {
     push @{ $files[$i]{U} }, $spec;
 
-    # find $j, the closest to $i which is at least $d-slop younger
+    # find $j, the closest to $i which is no more than $dmax younger
     my $j = $i;
     for (;;) {
       $j--;
-      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 >= $dmin;
+      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;
     }
     last if $j < 0;