Author: tewk
Date: Wed Jun 13 11:20:47 2007
New Revision: 18979
Modified:
branches/pmc2c/lib/Parrot/Pmc2c/Emitter.pm
branches/pmc2c/lib/Parrot/Pmc2c/UtilFunctions.pm
Log:
[Pmc2c branch] fix filename escaping
Modified: branches/pmc2c/lib/Parrot/Pmc2c/Emitter.pm
==============================================================================
--- branches/pmc2c/lib/Parrot/Pmc2c/Emitter.pm (original)
+++ branches/pmc2c/lib/Parrot/Pmc2c/Emitter.pm Wed Jun 13 11:20:47 2007
@@ -5,7 +5,7 @@
use warnings;
use base qw( Exporter );
our @EXPORT_OK = qw();
-use Parrot::Pmc2c::UtilFunctions qw(count_newlines spew);
+use Parrot::Pmc2c::UtilFunctions qw(count_newlines spew escape_filename);
use overload '""' => \&stringify;
use overload 'bool' => \&boolify;
use Data::Dumper;
@@ -132,8 +132,8 @@
$data = $it->{data};
}
else {
- $line = $self->{current_line} if $line == -1;;
- ( my $filename_escaped = $filename) =~ s|(\\)|$1$1|g;
+ $line = $self->{current_line} if $line == -1;
+ my $filename_escaped = escape_filename($filename);
$data .= "#line $line \"$filename_escaped\"\n";
$data .= $it->{data};
}
Modified: branches/pmc2c/lib/Parrot/Pmc2c/UtilFunctions.pm
==============================================================================
--- branches/pmc2c/lib/Parrot/Pmc2c/UtilFunctions.pm (original)
+++ branches/pmc2c/lib/Parrot/Pmc2c/UtilFunctions.pm Wed Jun 13 11:20:47 2007
@@ -6,7 +6,7 @@
use warnings;
use base qw( Exporter );
our @EXPORT_OK = qw( count_newlines gen_ret dont_edit dynext_load_code
- c_code_coda slurp spew splat open_file filename);
+ c_code_coda slurp spew splat open_file filename escape_filename );
=over 4
@@ -20,6 +20,11 @@
return scalar $_[0] =~ tr/\n//;
}
+sub escape_filename {
+ (my $filename = shift) =~ s|(\\)|$1$1|g;
+ return $filename;
+}
+
=item C<dont_edit($pmcfile)>
Returns the "DO NOT EDIT THIS FILE" warning text. C<$pmcfile> is the name