Message ID | 20230518130325.59309-2-carlos@redhat.com |
---|---|
State | New |
Headers | show |
Series | Fix defect in sort-makefile-lines.py | expand |
On 2023-05-18 09:03, Carlos O'Donell wrote: > We must return < 0, 0, or > 0 as the result of the comparison function > for cmp_to_key() to work correctly across all comparisons. > --- LGTM. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org> > scripts/sort-makefile-lines.py | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/scripts/sort-makefile-lines.py b/scripts/sort-makefile-lines.py > index fd657df970..c0badebf8c 100755 > --- a/scripts/sort-makefile-lines.py > +++ b/scripts/sort-makefile-lines.py > @@ -102,7 +102,10 @@ def glibc_makefile_numeric(string1, string2): > # string1 and string2 both share a prefix and > # have a numeric suffix that can be compared. > # Sort order is based on the numeric suffix. > - return int(var1.group(1)) > int(var2.group(1)) > + # If the suffix is the same return 0, otherwise > + # > 0 for greater-than, and < 0 for less-than. > + # This is equivalent to the numerical difference. > + return int(var1.group(1)) - int(var2.group(1)) > # Default to strcoll. > return locale.strcoll(string1, string2) >
On 5/18/23 11:56, Siddhesh Poyarekar wrote: > > > On 2023-05-18 09:03, Carlos O'Donell wrote: >> We must return < 0, 0, or > 0 as the result of the comparison function >> for cmp_to_key() to work correctly across all comparisons. >> --- > > LGTM. > > Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org> Thanks for the series review! I've pushed this along with a rewrite of nptl/Makefile as consensus. >> scripts/sort-makefile-lines.py | 5 ++++- >> 1 file changed, 4 insertions(+), 1 deletion(-) >> >> diff --git a/scripts/sort-makefile-lines.py b/scripts/sort-makefile-lines.py >> index fd657df970..c0badebf8c 100755 >> --- a/scripts/sort-makefile-lines.py >> +++ b/scripts/sort-makefile-lines.py >> @@ -102,7 +102,10 @@ def glibc_makefile_numeric(string1, string2): >> # string1 and string2 both share a prefix and >> # have a numeric suffix that can be compared. >> # Sort order is based on the numeric suffix. >> - return int(var1.group(1)) > int(var2.group(1)) >> + # If the suffix is the same return 0, otherwise >> + # > 0 for greater-than, and < 0 for less-than. >> + # This is equivalent to the numerical difference. >> + return int(var1.group(1)) - int(var2.group(1)) >> # Default to strcoll. >> return locale.strcoll(string1, string2) >> >
diff --git a/scripts/sort-makefile-lines.py b/scripts/sort-makefile-lines.py index fd657df970..c0badebf8c 100755 --- a/scripts/sort-makefile-lines.py +++ b/scripts/sort-makefile-lines.py @@ -102,7 +102,10 @@ def glibc_makefile_numeric(string1, string2): # string1 and string2 both share a prefix and # have a numeric suffix that can be compared. # Sort order is based on the numeric suffix. - return int(var1.group(1)) > int(var2.group(1)) + # If the suffix is the same return 0, otherwise + # > 0 for greater-than, and < 0 for less-than. + # This is equivalent to the numerical difference. + return int(var1.group(1)) - int(var2.group(1)) # Default to strcoll. return locale.strcoll(string1, string2)