Use JS's //@line feature to restore source line number and filename (246286, r=Hixie, sr=bryner).

This commit is contained in:
brendan%mozilla.org 2005-02-23 07:38:17 +00:00
Родитель c8c8405908
Коммит c5598011b1
1 изменённых файлов: 12 добавлений и 0 удалений

Просмотреть файл

@ -109,6 +109,7 @@ sub include {
local $stack->{'variables'}->{'LINE'} = 0;
local *FILE;
open(FILE, $filename) or die "Couldn't open $filename: $!\n";
my $lineout = 0;
while (<FILE>) {
# on cygwin, line endings are screwed up, so normalise them.
s/[\x0D\x0A]+$/\n/os if ($^O eq 'cygwin' || "$^O" eq "MSWin32");
@ -120,6 +121,17 @@ sub include {
} elsif (/^\#/os) { # comment
# ignore it
} elsif ($stack->enabled) {
next if $stack->{'dependencies'};
# set the current line number in JavaScript if necessary
my $linein = $stack->{'variables'}->{'LINE'};
if (++$lineout != $linein) {
if ($filename =~ /\.js(|\.in)$/o) {
$stack->print("//\@line $linein \"$filename\"\n")
}
$lineout = $linein;
}
# print it, including any newlines
$stack->print(filtered($stack, $_));
}