public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc] scripts: sort-makefile-lines.py
@ 2023-05-18 16:51 Carlos O'Donell
  0 siblings, 0 replies; only message in thread
From: Carlos O'Donell @ 2023-05-18 16:51 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=b0528456a606faf996ae8046512d623a6d22d0cc

commit b0528456a606faf996ae8046512d623a6d22d0cc
Author: Carlos O'Donell <carlos@redhat.com>
Date:   Wed May 17 09:16:41 2023 -0400

    scripts: sort-makefile-lines.py
    
    We must return < 0, 0, or > 0 as the result of the comparison function
    for cmp_to_key() to work correctly across all comparisons.
    
    Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>

Diff:
---
 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)

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-05-18 16:51 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-18 16:51 [glibc] scripts: sort-makefile-lines.py Carlos O'Donell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).