Permalink
Browse files

Print newlines only for lines not to be included

- to preserve line number info for mapping setting to original source code
- still removes "# vim:" lines (as they are at the end of the file anyways)
- still adds a "$# vim:..." line at the end, to force non-modifiability

Inspired by http://perl6.party/post/Perl-6-Core-Hacking-Wheres-Da-Sauce-Boss
by Zoffix++
  • Loading branch information...
lizmat committed Aug 5, 2016
1 parent 552d9cb commit 715b822bfd7dc66efbf041e19d11cf4841fbf12f
Showing with 6 additions and 2 deletions.
  1. +6 −2 tools/build/gen-cat.nqp
@@ -30,6 +30,7 @@ sub MAIN(*@ARGS) {
nqp::die("Nested conditionals not supported") if $in_cond;
$in_cond := 1;
$in_omit := $x[0] && $x[1] eq $backend || !$x[0] && $x[1] ne $backend;
print("\n");
} elsif $_ ~~ /^ '#?endif' / {
unless $in_cond {
nqp::sayfh($stderr,
@@ -38,8 +39,11 @@ sub MAIN(*@ARGS) {
}
$in_cond := 0;
$in_omit := 0;
} elsif !$in_omit {
print($_) unless $_ ~~ /^ '# ' \w /;
print("\n");
} elsif $in_omit {
print("\n");
} else {
print($_) unless nqp::eqat($_,"# vim:",0);
}
$line++;
}

0 comments on commit 715b822

Please sign in to comment.