1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
#! /usr/bin/perl
# remove a text from *.po files
sub drop;
die "usage: rm_text id\n" if @ARGV != 1;
$id = shift;
$id = "txt_$id" unless $id =~ /^txt_/;
mkdir old, 0755;
for $f ("bootloader.pot", <*.po>) {
if(open F, $f) {
@f = <F>;
close F;
( $new, $old ) = drop @f;
if(open F, ">>old/$f") {
print F @$old;
close F;
open F, ">$f";
print F @$new;
close F;
}
}
}
sub drop
{
local $_;
my (@f, @g, $drop_it, @d);
for (@_) {
push @g, $_;
$drop_it = 1 if /^#\.\s*${id}\s*$/;
if(/^\s*$/) {
if($drop_it) {
push @d, @g;
}
else {
push @f, @g;
}
undef $drop_it;
undef @g;
}
}
if(@g) {
if($drop_it) {
push @d, @g;
}
else {
push @f, @g;
}
}
return ( \@f, \@d );
}
|