bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Misleading cast in glob.c


From: Paul Eggert
Subject: Re: Misleading cast in glob.c
Date: Thu, 22 Jun 2006 16:43:02 -0700
User-agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.4 (gnu/linux)

Thanks for reporting that.  Looks to me like someone just got
frustrated by 'const' without really understanding it, and put in a
'const' everywhere they could think of.  (Sounds like some of my
students.  :-)

I installed the following somewhat more-aggressive patch, which
removes eight uses of 'const' and two casts.

2006-06-22  Paul Eggert  <address@hidden>

        * glob.c (collated_compare): Remove 'const' uses that weren't needed.
        Some compiler complained about some of them.  Problem reported by
        Larry Jones in
        <http://lists.gnu.org/archive/html/bug-gnulib/2006-06/msg00172.html>.

--- glob.c      8 Mar 2006 01:37:15 -0000       1.5
+++ glob.c      22 Jun 2006 23:40:20 -0000      1.6
@@ -909,8 +909,8 @@ libc_hidden_def (globfree)
 static int
 collated_compare (const void *a, const void *b)
 {
-  const char *const s1 = *(const char *const * const) a;
-  const char *const s2 = *(const char *const * const) b;
+  char *const *ps1 = a; char *s1 = *ps1;
+  char *const *ps2 = b; char *s2 = *ps2;
 
   if (s1 == s2)
     return 0;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]