[v2] sort-makefile-lines.py: Allow '_' in name and "^# name"

Message ID 20240215122903.394220-1-hjl.tools@gmail.com
State Committed
Commit 6a2512bf1605a4208dd94ef67408488d8acb2409
Headers
Series [v2] sort-makefile-lines.py: Allow '_' in name and "^# name" |

Checks

Context Check Description
redhat-pt-bot/TryBot-apply_patch success Patch applied to master at the time it was sent
redhat-pt-bot/TryBot-32bit success Build for i686
linaro-tcwg-bot/tcwg_glibc_build--master-arm success Testing passed
linaro-tcwg-bot/tcwg_glibc_build--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_glibc_check--master-arm fail Testing failed
linaro-tcwg-bot/tcwg_glibc_check--master-aarch64 fail Testing failed

Commit Message

H.J. Lu Feb. 15, 2024, 12:29 p.m. UTC
  '_' 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 | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Comments

Sunil Pandey Feb. 15, 2024, 5:28 p.m. UTC | #1
On Thu, Feb 15, 2024 at 4:29 AM H.J. Lu <hjl.tools@gmail.com> wrote:

> '_' 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 | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/scripts/sort-makefile-lines.py
> b/scripts/sort-makefile-lines.py
> index f65ee40e27..b2249aef6d 100755
> --- a/scripts/sort-makefile-lines.py
> +++ b/scripts/sort-makefile-lines.py
> @@ -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).
> --
> 2.43.0
>

LGTM

--Sunil
  
H.J. Lu Feb. 15, 2024, 6:46 p.m. UTC | #2
On Thu, Feb 15, 2024 at 9:28 AM Sunil Pandey <skpgkp2@gmail.com> wrote:
>
>
>
> On Thu, Feb 15, 2024 at 4:29 AM H.J. Lu <hjl.tools@gmail.com> wrote:
>>
>> '_' 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 | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/scripts/sort-makefile-lines.py b/scripts/sort-makefile-lines.py
>> index f65ee40e27..b2249aef6d 100755
>> --- a/scripts/sort-makefile-lines.py
>> +++ b/scripts/sort-makefile-lines.py
>> @@ -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).
>> --
>> 2.43.0
>
>
> LGTM
>
> --Sunil

I checked it in.  I am pushing:

https://patchwork.sourceware.org/project/glibc/list/?series=30990

to update Makefiles.
  

Patch

diff --git a/scripts/sort-makefile-lines.py b/scripts/sort-makefile-lines.py
index f65ee40e27..b2249aef6d 100755
--- a/scripts/sort-makefile-lines.py
+++ b/scripts/sort-makefile-lines.py
@@ -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).