]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
sort-makefile-lines.py: Allow '_' in name and "^# name"
authorH.J. Lu <hjl.tools@gmail.com>
Thu, 15 Feb 2024 11:22:55 +0000 (03:22 -0800)
committerH.J. Lu <hjl.tools@gmail.com>
Thu, 15 Feb 2024 12:28:27 +0000 (04:28 -0800)
'_' is used in Makefile variable names and many variables end with
"^# name".  Relax sort-makefile-lines.py to allow '_' in name and
"^# name" as variable end.  This fixes BZ #31385.

scripts/sort-makefile-lines.py

index f65ee40e27fb85ffabe6489a6926667f3ebe525d..b2249aef6d028cf71c0559c95de4375c4f68aa36 100755 (executable)
@@ -129,7 +129,7 @@ def sort_makefile_lines():
     for i in range(len(lines)):
         # Look for things like "var = \", "var := \" or "var += \"
         # to start the sorted list.
-        var = re.search(r'^([a-zA-Z0-9-]*) [\+:]?\= \\$', lines[i])
+        var = re.search(r'^([-_a-zA-Z0-9]*) [\+:]?\= \\$', lines[i])
         if var:
             # Remember the index and the name.
             startmarks.append((i, var.group(1)))
@@ -140,7 +140,7 @@ def sort_makefile_lines():
     rangemarks = []
     for sm in startmarks:
         # Look for things like "  # var" to end the sorted list.
-        reg = r'^  # ' + sm[1] + r'$'
+        reg = r'^ *# ' + sm[1] + r'$'
         for j in range(sm[0] + 1, len(lines)):
             if re.search(reg, lines[j]):
                 # Remember the block to sort (inclusive).