From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2191) id 9845C3858C5F; Thu, 18 May 2023 16:51:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9845C3858C5F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1684428707; bh=/j3OAeyXH9nOKhujvdKqXMKI/ZOsQOPgcs0KMgErhPc=; h=From:To:Subject:Date:From; b=mC36PRxcUUkuig2EPSPi2cpdL+SMVeryosRU0qQe0d07lrdV7pUVqx9kilkA4wVyR WM1gPsoy8R9edAYeRw7gZG0ZheRL3N0BLczLgohy6nn0dUSVjugK40ngpfQgkECSVf cdRXAtxpORYk1Q1xzb0KbKFLZ9n57gQkmRKsW6jQ= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Carlos O'Donell To: glibc-cvs@sourceware.org Subject: [glibc] scripts: sort-makefile-lines.py X-Act-Checkin: glibc X-Git-Author: Carlos O'Donell X-Git-Refname: refs/heads/master X-Git-Oldrev: c4098bc256a892aee214ec7c722a4a45f661a55c X-Git-Newrev: b0528456a606faf996ae8046512d623a6d22d0cc Message-Id: <20230518165147.9845C3858C5F@sourceware.org> Date: Thu, 18 May 2023 16:51:47 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=b0528456a606faf996ae8046512d623a6d22d0cc commit b0528456a606faf996ae8046512d623a6d22d0cc Author: Carlos O'Donell 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 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)