-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathmsg.pl
44 lines (44 loc) · 857 Bytes
/
msg.pl
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
#!/usr/bin/perl -w
my @msgs;
my $exitcode = 0;
use strict;
while (<>) {
while (m!/\*(.*?)\*/([0-9]+)\b!g) {
if (defined $msgs[$2] && $msgs[$2] ne $1) {
print STDERR "Message $2 has two different versions:\n";
print STDERR "\"$msgs[$2]\"\n\"$1\"\n";
$exitcode = 1;
}
$msgs[$2] = $1;
}
}
my $i = 0;
my $xxx;
for my $msg (@msgs) {
if (!defined $msg) {
if (!defined $xxx) {
$xxx = $i;
}
} else {
if (defined $xxx) {
print "# XXX $xxx";
print "-", ($i - 1) if ($i - 1 > $xxx);
print "\n";
$xxx = undef;
}
printf "en:%3d ", $i;
if ($msg =~ /^\s/ || $msg =~ /\s$/) {
print "\"$msg\"\n";
} else {
print "$msg\n";
}
}
++$i;
}
if (defined $xxx) {
print "# XXX $xxx";
print "-", ($i - 1) if ($i - 1 > $xxx);
print "\n";
$xxx = undef;
}
exit $exitcode;