bug-gnulib
[Top][All Lists]
Advanced

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

gnulib-tool.py: Sort file lists case-sensitively


From: Bruno Haible
Subject: gnulib-tool.py: Sort file lists case-sensitively
Date: Sat, 20 Apr 2024 23:05:56 +0200

When computing the list of old and new file, gnulib-tool.sh sorts them in
ASCII order, i.e. case-sensitively. (gnulib.tool.sh lines 5507 and 5513.)
gnulib-tool.py needs to be consistent with that.


2024-04-20  Bruno Haible  <bruno@clisp.org>

        gnulib-tool.py: Sort file lists case-sensitively.
        * pygnulib/GLImport.py (GLImport.prepare, GLImport.execute): Omit
        .lower() call in sort key computation.

diff --git a/pygnulib/GLImport.py b/pygnulib/GLImport.py
index b38808a353..e65e3e1235 100644
--- a/pygnulib/GLImport.py
+++ b/pygnulib/GLImport.py
@@ -943,11 +943,14 @@ def prepare(self) -> tuple[dict[str, list[str]], 
dict[str, str]]:
 
         # Prepare basic filelist and basic old_files/new_files variables.
         filelist = sorted(set(filelist))
+        # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
         new_files = filelist + ['m4/gnulib-tool.m4']
         old_files = list(self.cache['files'])
         path = joinpath(destdir, m4base, 'gnulib-tool.m4')
         if isfile(path):
             old_files.append(joinpath('m4', 'gnulib-tool.m4'))
+        # old_files is the list of files according to the last gnulib-tool 
invocation.
+        # new_files is the list of files after this gnulib-tool invocation.
 
         # Construct tables and transformers.
         transformers = dict()
@@ -965,14 +968,18 @@ def prepare(self) -> tuple[dict[str, list[str]], 
dict[str, str]]:
             new_table.append(tuple([dest, src]))
         old_table = sorted(set(old_table))
         new_table = sorted(set(new_table))
+        # old_table is a table with two columns: (rewritten-file-name 
original-file-name),
+        # representing the files according to the last gnulib-tool invocation.
+        # new_table is a table with two columns: (rewritten-file-name 
original-file-name),
+        # representing the files after this gnulib-tool invocation.
 
         # Prepare the filetable.
         filetable = dict()
         filetable['all'] = sorted(set(filelist))
         filetable['old'] = \
-            sorted(set(old_table), key=lambda t: tuple(t[0].lower()))
+            sorted(set(old_table), key=lambda pair: pair[0])
         filetable['new'] = \
-            sorted(set(new_table), key=lambda t: tuple(t[0].lower()))
+            sorted(set(new_table), key=lambda pair: pair[0])
         filetable['added'] = []
         filetable['removed'] = []
 
@@ -1046,7 +1053,7 @@ def execute(self, filetable: dict[str, list[str]], 
transformers: dict[str, str])
         pairs = [ f
                   for f in filetable['old']
                   if f not in filetable['new'] ]
-        pairs = sorted(set(pairs), key=lambda t: tuple(t[0].lower()))
+        pairs = sorted(set(pairs), key=lambda pair: pair[0])
         files = sorted(set(pair[0] for pair in pairs))
         for file in files:
             path = joinpath(destdir, file)






reply via email to

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