Subject: | overenthusiastic #line detection |
I have a comment in one of my programs that happens to start like this:
# line by itself ...
It causes nytprofhtml to emit a warning about ignoring a directive and
profile data out of sync.
UNIVERSAL::require apparently also has a comment that includes:
#line $call_line "$call_file"
that also causes a warning to be emitted. Of course, I'd prefer not to
see these warnings and according to the Camel book section 24.5.2 the
directive needs a line number. It even gives the specific regex used to
detect a #line directive:
/^#\s*line\s+(\d+)\s*(?:\s"([^"]+)")?\s*$/
Perhaps the following patch to Devel/NYTProf/Reader.pm could be considered:
--- /tmp/Reader-2.03.pm 2008-08-15 14:11:00.000000000 +0100
+++ Devel/NYTProf/Reader.pm 2008-09-19 11:25:36.000000000 +0100
@@ -422,7 +422,7 @@
foreach my $regexp (@{$self->{user_regexp}}) {
$line =~ s/$regexp->{pattern}/$regexp->{replace}/g;
}
- if ($line =~ m/^\# \s* line \b/x) {
+ if ($line =~ m/^\# \s* line \s+ \d+ \b/x) {
# XXX we should be smarter about this - patches welcome!
warn "Ignoring '$line' directive at line $LINE -
profile data for $filestr will be out of sync with source!\n"
unless our $line_directive_warn->{$filestr}++; #
once per file