changeset 12079:4af326308905

argp: fix test failure * lib/argp-help.c (hol_entry_cmp): Don't use _tolower on values that are not upper-case. Pass correct range to tolower. Signed-off-by: Eric Blake <ebb9@byu.net>
author Eric Blake <ebb9@byu.net>
date Sat, 26 Sep 2009 21:32:14 -0600
parents 3710e1c3943e
children 6b1f45c2820d
files ChangeLog lib/argp-help.c
diffstat 2 files changed, 11 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2009-09-28  Eric Blake  <ebb9@byu.net>
+
+	argp: fix test failure
+	* lib/argp-help.c (hol_entry_cmp): Don't use _tolower on values
+	that are not upper-case.  Pass correct range to tolower.
+
 2009-09-27  Jim Meyering  <meyering@redhat.com>
 
 	test-yesno: work around sparc-dash here-document infelicity
--- a/lib/argp-help.c
+++ b/lib/argp-help.c
@@ -1,5 +1,5 @@
 /* Hierarchial argument parsing help output
-   Copyright (C) 1995-2005, 2007 Free Software Foundation, Inc.
+   Copyright (C) 1995-2005, 2007, 2009 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Written by Miles Bader <miles@gnu.ai.mit.edu>.
 
@@ -797,13 +797,11 @@
 	   first, but as they're not displayed, it doesn't matter where
 	   they are.  */
 	{
-	  char first1 = short1 ? short1 : long1 ? *long1 : 0;
-	  char first2 = short2 ? short2 : long2 ? *long2 : 0;
-#ifdef _tolower
-	  int lower_cmp = _tolower (first1) - _tolower (first2);
-#else
+	  unsigned char first1 = short1 ? short1 : long1 ? *long1 : 0;
+	  unsigned char first2 = short2 ? short2 : long2 ? *long2 : 0;
+	  /* Use tolower, not _tolower, since only the former is
+	     guaranteed to work on something already lower case.  */
 	  int lower_cmp = tolower (first1) - tolower (first2);
-#endif
 	  /* Compare ignoring case, except when the options are both the
 	     same letter, in which case lower-case always comes first.  */
 	  return lower_cmp ? lower_cmp :