source: osm/applications/editors/josm/i18n/langinfo.pl@ 28064

Last change on this file since 28064 was 27039, checked in by stoecker, 13 years ago

small I/O fix

  • Property svn:executable set to *
File size: 1.9 KB
Line 
1#! /usr/bin/perl -w -CDSL
2
3use Term::ReadKey;
4use strict;
5use utf8;
6use Encode;
7
8my $tlen = (GetTerminalSize())[0]-11;
9
10my $data;
11foreach my $file (@ARGV)
12{
13 if(open FILE,"<:raw",$file)
14 {
15 my $miss = 0;
16 my $missm = 0;
17 my $i = 1;
18 my $num = 0;
19 for(;;)
20 {
21 read FILE,$data,2;
22 my $len = unpack("n",$data);
23 last if $len == 65535;
24 if($len == 65534)
25 {
26 printf("%4d +++++\n", $i);
27 ++$num;
28 }
29 elsif($len)
30 {
31 ++$num;
32 read FILE,$data,$len;
33 $data = decode("utf-8", $data);
34 $data =~ s/\r/\\r/g;
35 $data =~ s/\n/\\n/g;
36 $data = substr($data, 0, $tlen);
37 printf("%4d %5d %s\n", $i, $len, $data);
38 }
39 else
40 {
41 printf("%4d -----\n", $i);
42 ++$miss;
43 }
44 ++$i;
45 }
46 my $mul = 0;
47 my $tot = 0;
48 my $max = 0;
49 my $comp = 0;
50 print "multi:\n";
51 $i = 1;
52 for(;;)
53 {
54 last if !read FILE,$data,1;
55 my $cnt = unpack("C",$data);
56 ++$mul if $cnt;
57 if($cnt == 0xFE)
58 {
59 ++$comp;
60 $tot += 2;
61 $cnt = 0;
62 printf("%4d +++++\n",$i);
63 }
64 else
65 {
66 if($cnt > $max)
67 {
68 $comp = 0;
69 $max = $cnt;
70 }
71 ++$comp if $cnt == $max;
72 $tot += $cnt;
73 printf("%4d -----\n",$i) if(!$cnt);
74 }
75 while($cnt--)
76 {
77 read FILE,$data,2;
78 my $len = unpack("n",$data);
79 if($len)
80 {
81 read FILE,$data,$len;
82 $data = decode("utf-8", $data);
83 $data =~ s/\r/\\r/g;
84 $data =~ s/\n/\\n/g;
85 $data = substr($data, 0, $tlen);
86 printf("%4d %5d %s\n", $i, $len, $data);
87 }
88 else
89 {
90 ++$missm;
91 }
92 }
93 ++$i;
94 }
95 close FILE;
96 printf("Status: Missing %d/%d - $num,$mul,$tot,$max,$comp\n",$miss,$missm);
97 }
98 else
99 {
100 print STDERR "Could not load language file $file.\n";
101 }
102}
Note: See TracBrowser for help on using the repository browser.