public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Carlos O'Donell <carlos@redhat.com>
To: libc-alpha@sourceware.org, siddhesh@gotplt.org
Cc: Carlos O'Donell <carlos@redhat.com>
Subject: [PATCH 1/5] scripts: sort-makefile-lines.py
Date: Thu, 18 May 2023 09:03:21 -0400	[thread overview]
Message-ID: <20230518130325.59309-2-carlos@redhat.com> (raw)
In-Reply-To: <20230518130325.59309-1-carlos@redhat.com>

We must return < 0, 0, or > 0 as the result of the comparison function
for cmp_to_key() to work correctly across all comparisons.
---
 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)
 
-- 
2.40.0


  reply	other threads:[~2023-05-18 13:03 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-18 13:03 [PATCH 0/5] Fix defect in sort-makefile-lines.py Carlos O'Donell
2023-05-18 13:03 ` Carlos O'Donell [this message]
2023-05-18 15:56   ` [PATCH 1/5] scripts: sort-makefile-lines.py Siddhesh Poyarekar
2023-05-18 16:53     ` Carlos O'Donell
2023-05-18 13:03 ` [PATCH 2/5] elf: Adjust tests in Makefile Carlos O'Donell
2023-05-18 16:05   ` Siddhesh Poyarekar
2023-05-18 13:03 ` [PATCH 3/5] stdio-common: " Carlos O'Donell
2023-05-18 16:05   ` Siddhesh Poyarekar
2023-05-18 13:03 ` [PATCH 4/5] misc: Reformat Makefile Carlos O'Donell
2023-05-18 16:06   ` Siddhesh Poyarekar
2023-05-18 13:03 ` [PATCH 5/5] wcsmbs: " Carlos O'Donell
2023-05-18 16:06   ` Siddhesh Poyarekar

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=20230518130325.59309-2-carlos@redhat.com \
    --to=carlos@redhat.com \
    --cc=libc-alpha@sourceware.org \
    --cc=siddhesh@gotplt.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).