From 7296bb64c84029d08e36624c8544007bcd3c2cbe Mon Sep 17 00:00:00 2001 From: Nathaniel Wesley Filardo Date: Sun, 1 Mar 2015 22:04:01 -0500 Subject: [PATCH] Missed comment handling in grade.pl While here, add test for EOF inside comments --- grade.pl | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/grade.pl b/grade.pl index 45551ec..1a3a77f 100755 --- a/grade.pl +++ b/grade.pl @@ -85,6 +85,7 @@ sub doDing($) { # {{{ while(my $line = ) { last if ($line =~ /^@/); chomp $line; + $line =~ s/#.*$//; if ($line =~ /^:$ding\s+(.*)$/) { my $dingmod = $1; if ($dingmod =~ /^!(.*)$/) { @@ -142,7 +143,7 @@ sub finishOverall() { # {{{ } # }}} # Main dispatch {{{ while(my $line = ) { - $line =~ s/#.*$//; # trim line comments + $line =~ s/#.*$//; # trim line comments next if ($line =~ /^\s*$/) ; chomp $line; @@ -181,11 +182,16 @@ while(my $line = ) { my $seen_text = 0; while (my $cline = ) { chomp $cline; - last if $cline =~ /^\$END_COMMENTS/; - next if (not $seen_text and $cline =~ /^$/); + if ($cline =~ /^\$END_COMMENTS/) { + $seen_text = 2; + last; + } + next if (not $seen_text and $cline =~ /^$/); # Ignore leading blank lines $seen_text = 1; push @$commenttext, $cline; } + + die "EOF inside a comment block\n" if eof(STDIN) and $seen_text ne 2; } else { die "Unknown directive in: $line\n"; } -- 2.50.1