diff --git a/cachegrind/cg_annotate.in b/cachegrind/cg_annotate.in index bcb98935b..1daa15da2 100644 --- a/cachegrind/cg_annotate.in +++ b/cachegrind/cg_annotate.in @@ -398,7 +398,9 @@ sub read_input_file() # Read body of input file. while () { - s/#.*$//; # remove comments + # Skip comments and empty lines. + next if /^\s*$/ || /^\#/; + if (s/^(-?\d+)\s+//) { my $lineNum = $1; my $CC = line_to_CC($_); @@ -436,9 +438,6 @@ sub read_input_file() # Assume that a "fn=" line is followed by a "fl=" line. $currFileFuncName = undef; - } elsif (s/^\s*$//) { - # blank, do nothing - } elsif (s/^summary:\s+//) { $summary_CC = line_to_CC($_); (scalar(@$summary_CC) == @events) diff --git a/callgrind/callgrind_annotate.in b/callgrind/callgrind_annotate.in index e18ed4ed9..8854aee13 100644 --- a/callgrind/callgrind_annotate.in +++ b/callgrind/callgrind_annotate.in @@ -420,10 +420,8 @@ sub read_input_file() # Read header while() { - # remove comments - s/#.*$//; - - if (/^$/) { ; } + # Skip comments and empty lines. + if (/^\s*$/ || /^\#/) { ; } elsif (/^version:\s*(\d+)/) { # Can't read format with major version > 1 @@ -540,9 +538,11 @@ sub read_input_file() # Read body of input file. while () { + # Skip comments and empty lines. + next if /^\s*$/ || /^\#/; + $prev_line_num = $curr_line_num; - s/#.*$//; # remove comments s/^\+(\d+)/$prev_line_num+$1/e; s/^\-(\d+)/$prev_line_num-$1/e; s/^\*/$prev_line_num/e; @@ -646,9 +646,6 @@ sub read_input_file() $curr_fn_CC = $fn_totals{$curr_name}; $curr_fn_CC = [] unless (defined $curr_fn_CC); - } elsif (s/^\s*$//) { - # blank, do nothing - } elsif (s/^cob=(.*)$//) { $curr_cobj = uncompressed_name("ob",$1);