Revision history for Perl extension ExtUtils::ParseXS.
+3.09 - Thu Dec 28 18:48:00 CET 2011
+ - Escape double quotes of file names/commands in #line directives.
+
3.08 - Mon Dec 19 18:03:00 CET 2011
- Silence undefined-value-in-addition warning
(Nothing serious, just happened sometimes when reporting line numbers for
our $VERSION;
BEGIN {
- $VERSION = '3.08';
+ $VERSION = '3.09';
}
use ExtUtils::ParseXS::Constants $VERSION;
use ExtUtils::ParseXS::CountLines $VERSION;
blurt
death
check_conditional_preprocessor_statements
+ escape_file_for_line_directive
);
our @ISA = qw(Exporter);
EOM
- print("#line 1 \"$self->{filepathname}\"\n")
+ print("#line 1 \"" . escape_file_for_line_directive($self->{filepathname}) . "\"\n")
if $self->{WantLineNumbers};
# Open the input file (using $self->{filename} which
# concatenated until 2 steps later, so we are safe.
# - Nicholas Clark
print("#if 0\n \"Skipped embedded POD.\"\n#endif\n");
- printf("#line %d \"$self->{filepathname}\"\n", $. + 1)
+ printf("#line %d \"%s\"\n", $. + 1, escape_file_for_line_directive($self->{filepathname}))
if $self->{WantLineNumbers};
next firstmodule
}
if ($self->check_keyword("BOOT")) {
check_conditional_preprocessor_statements($self);
- push (@{ $BootCode_ref }, "#line $self->{line_no}->[@{ $self->{line_no} } - @{ $self->{line} }] \"$self->{filepathname}\"")
+ push (@{ $BootCode_ref }, "#line $self->{line_no}->[@{ $self->{line_no} } - @{ $self->{line} }] \""
+ . escape_file_for_line_directive($self->{filepathname}) . "\"")
if $self->{WantLineNumbers} && $self->{line}->[0] !~ /^\s*#\s*line\b/;
push (@{ $BootCode_ref }, @{ $self->{line} }, "");
next PARAGRAPH;
my $consumed_code = '';
- print("#line ", $self->{line_no}->[@{ $self->{line_no} } - @{ $self->{line} } -1], " \"$self->{filepathname}\"\n")
+ print("#line ", $self->{line_no}->[@{ $self->{line_no} } - @{ $self->{line} } -1], " \"",
+ escape_file_for_line_directive($self->{filepathname}), "\"\n")
if $self->{WantLineNumbers} && !/^\s*#\s*line\b/ && !/^#if XSubPPtmp/;
for (; defined($_) && !/^$self->{BLOCK_re}/o; $_ = shift(@{ $self->{line} })) {
print "$_\n";
use lib qw( lib );
use ExtUtils::ParseXS::Constants ();
-our $VERSION = '3.08';
+our $VERSION = '3.09';
our (@ISA, @EXPORT_OK);
@ISA = qw(Exporter);
blurt
death
check_conditional_preprocessor_statements
+ escape_file_for_line_directive
);
=head1 NAME
blurt
death
check_conditional_preprocessor_statements
+ escape_file_for_line_directive
);
=head1 SUBROUTINES
}
}
+=head2 C<escape_file_for_line_directive()>
+
+=over 4
+
+=item * Purpose
+
+Escapes a given code source name (typically a file name but can also
+be a command that was read from) so that double-quotes and backslashes are escaped.
+
+=item * Arguments
+
+A string.
+
+=item * Return Value
+
+A string with escapes for double-quotes and backslashes.
+
+=back
+
+=cut
+
+sub escape_file_for_line_directive {
+ my $string = shift;
+ $string =~ s/\\/\\\\/g;
+ $string =~ s/"/\\"/g;
+ return $string;
+}
+
+
1;
# vim: ts=2 sw=2 et: