File: pocomp.pl

package info (click to toggle)
eboard 1.1.3-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,156 kB
  • sloc: cpp: 24,340; perl: 1,038; ansic: 279; sh: 105; makefile: 52
file content (77 lines) | stat: -rwxr-xr-x 1,113 bytes parent folder | download | duplicates (11)
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/perl

#
# ...because it's easier to write my own internationalization
# support than understanding gnu gettext and all the incompatibilities
# between its versions
#

my $msgcount = 0;

my $id  = "";
my $msg = "";

my $state = 0;

while($_=<>) {
    chomp;

    if ($state == 0) {
	if (/^msgid\s+\"(.*)\"/) {
	    $id  = $1;
	    $msg = "";
	    $state = 1;
	    next;
	}
	next;
    }

    if ($state == 1) {
	if (/^\"(.*)\"/) {
	    $id = "$id$1";
	    next;
	}
	if (/^msgstr\s+\"(.*)\"/) {
	    $msg = $1;
	    $state = 2;
	    next;
	}
	next;
    }

    if ($state == 2) {
	if (/^\"(.*)\"/) {
	    $msg = "$msg$1";
	    next;
	}

	$id  =~ s/\\"/"/g;
	$msg =~ s/\\"/"/g;
	
	$idlen = length($id);
	$msglen = length($msg);
	if ($idlen > 0 && $msglen > 0) {
	    $msgcount++;
	    print "L$idlen $msglen\n";
	    print "$id\n";
	    print "$msg\n";
	}
	$state = 0;
	next;
    }
}

if ($state != 0) {
    $idlen = length($id);
    $msglen = length($msg);
    if ($idlen > 0 && $msglen > 0) {   
	$msgcount++;
	print "L$idlen $msglen\n";
	print "$id\n";
	print "$msg\n";
    }
}

print "E $msgcount\n";