comparison libtommath/filter.pl @ 1511:5916af64acd4 fuzz

merge from main
author Matt Johnston <matt@ucc.asn.au>
date Sat, 17 Feb 2018 19:29:51 +0800
parents 8bba51a55704
children
comparison
equal deleted inserted replaced
1457:32f990cc96b1 1511:5916af64acd4
1 #!/usr/bin/perl 1 #!/usr/bin/perl
2 2
3 # we want to filter every between START_INS and END_INS out and then insert crap from another file (this is fun) 3 # we want to filter every between START_INS and END_INS out and then insert crap from another file (this is fun)
4 4
5 $dst = shift; 5 use strict;
6 $ins = shift; 6 use warnings;
7 7
8 open(SRC,"<$dst"); 8 open(my $src, '<', shift);
9 open(INS,"<$ins"); 9 open(my $ins, '<', shift);
10 open(TMP,">tmp.delme"); 10 open(my $tmp, '>', 'tmp.delme');
11 11
12 $l = 0; 12 my $l = 0;
13 while (<SRC>) { 13 while (<$src>) {
14 if ($_ =~ /START_INS/) { 14 if ($_ =~ /START_INS/) {
15 print TMP $_; 15 print {$tmp} $_;
16 $l = 1; 16 $l = 1;
17 while (<INS>) { 17 while (<$ins>) {
18 print TMP $_; 18 print {$tmp} $_;
19 } 19 }
20 close INS; 20 close $ins;
21 } elsif ($_ =~ /END_INS/) { 21 } elsif ($_ =~ /END_INS/) {
22 print TMP $_; 22 print {$tmp} $_;
23 $l = 0; 23 $l = 0;
24 } elsif ($l == 0) { 24 } elsif ($l == 0) {
25 print TMP $_; 25 print {$tmp} $_;
26 } 26 }
27 } 27 }
28 28
29 close TMP; 29 close $tmp;
30 close SRC; 30 close $src;
31 31
32 # $Source$ 32 # ref: $Format:%D$
33 # $Revision$ 33 # git commit: $Format:%H$
34 # $Date$ 34 # commit time: $Format:%ai$