Explorar o código

Update logic on logsuffix matching to remove possibility of infinite loop if the last file in the array does not match logsuffix

sbingner %!s(int64=23) %!d(string=hai) anos
pai
achega
64ea9fbce0
Modificáronse 1 ficheiros con 15 adicións e 6 borrados
  1. 15 6
      modules/Pisg/Parser/Logfile.pm

+ 15 - 6
modules/Pisg/Parser/Logfile.pm

@@ -151,16 +151,22 @@ sub _parse_dir
                 push @month, $month;
             } else {
                 splice(@filesarray,$#month + 1, 1);
-                $file = $filesarray[$#month + 1];
-                goto LOOPSTART;
+                if ($file = $filesarray[$#month + 1]) {
+                    goto LOOPSTART;
+                } else {
+                    last;
+                }
             }
             if ($file =~ /$dreg/) {
                 push @day, $1;
             } else {
                 splice(@filesarray,$#day + 1, 1);
                 splice(@month,$#day + 1);
-                $file = $filesarray[$#day + 1];
-                goto LOOPSTART;
+                if ($file = $filesarray[$#day + 1]) {
+                    goto LOOPSTART;
+                } else {
+                    last;
+                }
             }
             if ($file =~ /$yreg/) {
                 push @year, $1;
@@ -168,8 +174,11 @@ sub _parse_dir
                 splice(@filesarray,$#year + 1, 1);
                 splice(@month,$#year + 1);
                 splice(@day,$#year + 1);
-                $file = $filesarray[$#year + 1];
-                goto LOOPSTART;
+                if ($file = $filesarray[$#year + 1]) {
+                    goto LOOPSTART;
+                } else {
+                    last;
+                }
             }
         }
         my @newarray = @filesarray[ sort {