From a4daffe14fd9755beea0eaf8b8450eb9e5199342 Mon Sep 17 00:00:00 2001 From: Nigel McNie Date: Wed, 4 Jun 2008 11:10:46 +1200 Subject: [PATCH] If a line hasn't got a finishing time yet, print an error and exit. Make sure that the line_needs_closing flag is set to 0 correctly at all times when we know we've done the closing time for it. --- tks.pl | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tks.pl b/tks.pl index 1979166..6ed5c57 100755 --- a/tks.pl +++ b/tks.pl @@ -164,6 +164,17 @@ sub load_timesheet_file { } } + foreach my $date ( keys %{$result} ) { + my $found_error = 0; + if ( my @errors = grep { $_->{needs_closing_time} } @{$result->{$date}} ) { + $found_error = 1; + foreach my $error ( @errors ) { + print "Error on line ", $error->{linenumber}, ": no closing time found\n"; + } + } + exit 1 if $found_error; + } + return $result; } @@ -224,6 +235,7 @@ sub parse_line { } else { $lastline->{time} = (convert_to_minutes($time) - $lastline->{time}) / 60 if $lastline->{needs_closing_time}; + $lastline->{needs_closing_time} = 0; # We have a starting date only - need to wait for the next line $result->{needs_closing_time} = 1; -- 2.39.5