texinfo-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

branch master updated: Avoid UTF-8 encoded file name in make rule prereq


From: Patrice Dumas
Subject: branch master updated: Avoid UTF-8 encoded file name in make rule prerequisite
Date: Sun, 23 Oct 2022 08:01:41 -0400

This is an automated email from the git hooks/post-receive script.

pertusus pushed a commit to branch master
in repository texinfo.

The following commit(s) were added to refs/heads/master by this push:
     new d9a947dd76 Avoid UTF-8 encoded file name in make rule prerequisite
d9a947dd76 is described below

commit d9a947dd76999d0f84499f4cac048363957305bc
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Oct 23 13:58:38 2022 +0200

    Avoid UTF-8 encoded file name in make rule prerequisite
    
    * tp/maintain/copy_change_file_name_encoding.pl, tp/tests/Makefile.am:
    convert to latin1 from plain ASCII filename, substituting accented
    letters in tp/maintain/copy_change_file_name_encoding.pl.  report from
    Eli Zaretskii.
---
 ChangeLog                                            |  9 +++++++++
 tp/maintain/copy_change_file_name_encoding.pl        | 20 +++++++++++++++-----
 tp/tests/Makefile.am                                 |  6 +++---
 .../tests/input/included_latin1.texi                 |  0
 4 files changed, 27 insertions(+), 8 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 39c02ccd6b..76f8a20004 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2022-10-23  Patrice Dumas  <pertusus@free.fr>
+
+       Avoid UTF-8 encoded file name in make rule prerequisite
+
+       * tp/maintain/copy_change_file_name_encoding.pl, tp/tests/Makefile.am:
+       convert to latin1 from plain ASCII filename, substituting accented
+       letters in tp/maintain/copy_change_file_name_encoding.pl.  report from
+       Eli Zaretskii.
+
 2022-10-23  Gavin Smith  <gavinsmith0123@gmail.com>
 
        * info/t/where-dir-file.sh: Remove $ from argument to grep,
diff --git a/tp/maintain/copy_change_file_name_encoding.pl 
b/tp/maintain/copy_change_file_name_encoding.pl
index 786faad9bc..fdc5b589dd 100755
--- a/tp/maintain/copy_change_file_name_encoding.pl
+++ b/tp/maintain/copy_change_file_name_encoding.pl
@@ -1,7 +1,7 @@
 #! /usr/bin/env perl
 
 # copy_change_file_name_encoding.pl: copy file changing
-# the encoding of the file name
+# the encoding of the file name and substituting to have accented letters.
 #
 # Copyright 2022 Free Software Foundation, Inc.
 #
@@ -20,6 +20,9 @@
 #
 # Original author: Patrice Dumas <pertusus@free.fr>
 
+use strict;
+use utf8;
+
 use File::Copy;
 use File::Basename;
 use File::Spec;
@@ -28,7 +31,7 @@ use Encode qw(from_to);
 
 use Getopt::Long qw(GetOptions);
 
-my $from = 'UTF-8';
+my $from = 'US-ASCII';
 my $to = 'ISO-8859-1';
 my $result_options = Getopt::Long::GetOptions (
  'from|f=s' => \$from,
@@ -51,14 +54,21 @@ if (defined($dest_dir)) {
   $dest_path = $src_path;
 }
 
-my $succeeded = from_to($dest_path, $from, $to);
+my $converted_dest_path = Encode::decode($from, $dest_path);
+# not that converted_dest_path may not be in UTF-8, depends what perl 
internally
+# does
+$converted_dest_path =~ s/latin/latîn/;
+my $dest_path_in_utf8 = Encode::encode('UTF-8', $converted_dest_path);
+# use another variable, since from_to argument is converted in-place
+my $dest_path_in_to_encoding = $dest_path_in_utf8;
+my $succeeded = from_to($dest_path_in_to_encoding, 'UTF-8', $to);
 
 if (not defined($succeeded)) {
-  warn "could not recode $src_path\n";
+  warn "could not decode, substitute and recode $src_path\n";
   exit(1);
 }
 
-my $copy_succeeded = copy($src_path, $dest_path);
+my $copy_succeeded = copy($src_path, $dest_path_in_to_encoding);
 if (not $copy_succeeded) {
   warn "could not copy $src_path: $!\n";
   exit(1);
diff --git a/tp/tests/Makefile.am b/tp/tests/Makefile.am
index 63113ba566..1973cacd0d 100644
--- a/tp/tests/Makefile.am
+++ b/tp/tests/Makefile.am
@@ -63,12 +63,12 @@ other-checks: all
 
 check_DATA = input_file_names_recoded_stamp.txt
 
-input_file_names_recoded_stamp.txt: $(srcdir)/input/included_latîn1.texi
-       if $(PERL) $(srcdir)/../maintain/copy_change_file_name_encoding.pl 
$(srcdir)/input/included_latîn1.texi . ; then echo 'OK' > $@ ; else echo 
'FAILED' > $@ ; fi
+input_file_names_recoded_stamp.txt: $(srcdir)/input/included_latin1.texi
+       if $(PERL) $(srcdir)/../maintain/copy_change_file_name_encoding.pl 
$(srcdir)/input/included_latin1.texi . ; then echo 'OK' > $@ ; else echo 
'FAILED' > $@ ; fi
 
 distclean-local:
        rm -f input_file_names_recoded_stamp.txt included_lat*n1.texi
 
 EXTRA_DIST = run_parser_all.sh parser_tests.sh \
  $(one_test_files_generated_list) coverage_macro.texi included_akçentêd.texi \
- input/included_latîn1.texi
+ input/included_latin1.texi
diff --git "a/tp/tests/input/included_lat\303\256n1.texi" 
b/tp/tests/input/included_latin1.texi
similarity index 100%
rename from "tp/tests/input/included_lat\303\256n1.texi"
rename to tp/tests/input/included_latin1.texi



reply via email to

[Prev in Thread] Current Thread [Next in Thread]