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

Last change on this file since 34865 was 34025, checked in by stoecker, 7 years ago

add a note where to find the fileformat specification

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