source: git/lib/launchpad-merge-po@ da9d788

RELEASE/1.2 debug-ci debug-ci-sanitisers faster-cavernlog log-select main stereo stereo-2025 walls-data walls-data-hanging-as-warning warn-only-for-hanging-survey
Last change on this file since da9d788 was bb51ecd, checked in by Olly Betts <olly@…>, 13 years ago

lib/launchpad-merge-po: New script to eliminate unwanted differences
introduced by launchpad.
lib/Makefile.am: Make launchpad-diff target use launchpad-merge-po
and skip files missing in the launchpad export.

  • Property mode set to 100755
File size: 1.4 KB
Line 
1#!/usr/bin/perl -w
2use strict;
3
4open O, '<', $ARGV[0] or die $!;
5open N, '<', "lib/survex-$ARGV[0]" or die $!;
6
7my $fuzzy = 0;
8my $diff = 0;
9my ($o, $n);
10while (1) {
11 $o //= <O>;
12 $n //= <N>;
13 if (!defined $n) {
14 last unless defined $o;
15 print '-' if $diff;
16 print $o;
17 $o = undef;
18 next;
19 }
20 if (!defined $o) {
21 print '+' if $diff;
22 print $n;
23 $n = undef;
24 next;
25 }
26
27 if ($o eq '' || $n eq '') {
28 $fuzzy = 0;
29 }
30
31 if ($o eq $n) {
32 print ' ' if $diff;
33 print $n;
34 $n = $o = undef;
35 next;
36 }
37
38 if ($o eq "#~ $n") {
39 print ' ' if $diff;
40 print $o;
41 $n = $o = undef;
42 next;
43 }
44
45 if ($o =~ /^("PO(?:-Revision|T-Creation)-Date: \d+-\d+-\d+ \d+:\d+):\d\d (.*\n)$/ &&
46 $n eq "$1:00 $2") {
47 print ' ' if $diff;
48 print $o;
49 $n = $o = undef;
50 next;
51 }
52
53 if ($o =~ /^"PO-Revision-Date:/ && $n =~ /^"PO-Revision-Date:/) {
54 print ' ' if $diff;
55 print $o;
56 $n = $o = undef;
57 next;
58 }
59
60 if ($o eq "#, fuzzy\n") {
61 print ' ' if $diff;
62 print $o;
63 $o = undef;
64 $fuzzy = 1;
65 next;
66 }
67
68 my $tmp = $o;
69 if ($tmp =~ s/, fuzzy// && $n eq $tmp) {
70 print ' ' if $diff;
71 print $o;
72 $n = $o = undef;
73 $fuzzy = 1;
74 next;
75 }
76
77 if ($fuzzy && $o =~ /^(?:#~ )?msgstr / && $n eq "msgstr \"\"\n") {
78 print ' ' if $diff;
79 print $o;
80 $n = $o = undef;
81 $fuzzy = 0;
82 next;
83 }
84
85 print "-$o" if $diff;
86 print '+' if $diff;
87 print $n;
88 $n = $o = undef;
89}
Note: See TracBrowser for help on using the repository browser.