commit 482d0ebc6670ddcd522e42aa2649ec5d222298cd
Author: Kornel Benko <[email protected]>
Date: Sun Jun 4 18:32:47 2017 +0200
Script to finxing linebreaks in po-files.
Bad linebreaks could slip in if merging from branch on a Windows OS.
---
po/removeCR.pl | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 64 insertions(+), 0 deletions(-)
diff --git a/po/removeCR.pl b/po/removeCR.pl
new file mode 100755
index 0000000..3e4e2de
--- /dev/null
+++ b/po/removeCR.pl
@@ -0,0 +1,64 @@
+#! /usr/bin/env perl
+# -*- mode: perl; -*-
+
+# file removeCR.pl
+#
+# This file is part of LyX, the document processor.
+# Licence details can be found in the file COPYING.
+#
+# author: Kornel Benko, [email protected]
+#
+# Remove eventually added CR's from po-file after merging from a Windows OS.
+#
+# Usage: removeCR.pl *.po
+#
+use strict;
+use warnings;
+
+use File::Temp qw/ tempfile tempdir /;
+use File::Copy qw(move);
+
+sub removeCR($);
+
+for my $file (@ARGV) {
+ if ($file =~ /\b[a-z][a-z](_[A-Z][A-Z])?\.po$/) {
+ removeCR($file);
+ }
+ else {
+ print "Not handled $file\n";
+ }
+}
+
+exit(0);
+
+sub removeCR($)
+{
+ my ($file) = @_;
+
+ print "Checking file $file ... ";
+
+ if (open(FI, $file)) {
+ my $found = 0;
+ my $fh = File::Temp->new(UNLINK => 0);
+ my $tmpname = $fh->filename;
+ while (my $l = <FI>) {
+ while ($l =~ s/\r//) {
+ $found = 1;
+ }
+ print $fh $l;
+ }
+ close(FI);
+ close($fh);
+ if ($found) {
+ print "differs from $tmpname --> rewriting\n";
+ move($tmpname, $file);
+ }
+ else {
+ print "Ok\n";
+ unlink($tmpname);
+ }
+ }
+ else {
+ print "Could not read $file\n";
+ }
+}