public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Carlos O'Donell <carlos@sourceware.org>
To: glibc-cvs@sourceware.org
Subject: [glibc] scripts: sort-makefile-lines.py
Date: Thu, 18 May 2023 16:51:47 +0000 (GMT)	[thread overview]
Message-ID: <20230518165147.9845C3858C5F@sourceware.org> (raw)

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)

                 reply	other threads:[~2023-05-18 16:51 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230518165147.9845C3858C5F@sourceware.org \
    --to=carlos@sourceware.org \
    --cc=glibc-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).