bug-gnu-utils
[Top][All Lists]
Advanced

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

Re: Bug Found in diffutils-2.8.1, diffutils-2.8.4


From: Paul Eggert
Subject: Re: Bug Found in diffutils-2.8.1, diffutils-2.8.4
Date: Mon, 9 Dec 2002 16:08:29 -0800

> Date: Mon, 9 Dec 2002 01:19:25 -0800
> From: "Greg McLaren" <address@hidden>
> 
> This is a multi-part message in MIME format.

Can you please send text mail as plain text?  That saves time for me
and for many others.  Please see "Internet mail: living with Microsoft
Outlook" <http://www.lemis.com/email/fixing-outlook.html>.  Thanks.

> If I delete the "if (r)" so that it looks like:
> =20
>     if (ignore_file_name_case)
>         {
>             int r =3D strcasecmp (name1, name2);
>             return r;
>         }
> =20
> Then it seems to work fine!

Thanks for the bug report and patch.  Unfortunately, that fix won't
work in general, but I'll install something like the following fix
instead, along with the corresponding Autoconf magic to define
HAVE_STRCASECOLL and HAVE_STRICOLL on hosts that have those functions.

--- system.h    2002/06/11 06:06:32     1.29
+++ system.h    2002/12/10 00:07:28
@@ -211,6 +211,16 @@ char *strchr (), *strrchr ();
 void *memchr ();
 # endif
 #endif
+#if ! HAVE_STRCASECOLL
+# if HAVE_STRICOLL || defined stricoll
+#  define strcasecoll(a, b) stricoll (a, b)
+# else
+#  define strcasecoll(a, b) strcasecmp (a, b) /* best we can do */
+# endif
+#endif
+#if ! (HAVE_STRCASECMP || defined strcasecmp)
+int strcasecmp (char const *, char const *);
+#endif
 
 #if HAVE_LOCALE_H
 # include <locale.h>
--- dir.c       2002/03/11 08:00:47     1.18
+++ dir.c       2002/12/09 23:59:24
@@ -38,11 +38,12 @@ struct dirdata
   char *data;  /* Allocated storage for file names.  */
 };
 
-/* Whether file names in directories should be compared with strcoll.  */
+/* Whether file names in directories should be compared with
+   locale-specific sorting.  */
 static bool locale_specific_sorting;
 
-/* Where to go if strcoll fails.  */
-static jmp_buf failed_strcoll;
+/* Where to go if locale-specific sorting fails.  */
+static jmp_buf failed_locale_specific_sorting;
 
 static bool dir_loop (struct comparison const *, int);
 static int compare_names_for_qsort (void const *, void const *);
@@ -145,29 +146,27 @@ dir_read (struct file_data const *dir, s
 static int
 compare_names (char const *name1, char const *name2)
 {
-  if (ignore_file_name_case)
-    {
-      int r = strcasecmp (name1, name2);
-      if (r)
-       return r;
-    }
-
   if (locale_specific_sorting)
     {
       int r;
       errno = 0;
-      r = strcoll (name1, name2);
+      if (ignore_file_name_case)
+       r = strcasecoll (name1, name2);
+      else
+       r = strcoll (name1, name2);
       if (errno)
        {
          error (0, errno, _("cannot compare file names `%s' and `%s'"),
                 name1, name2);
-         longjmp (failed_strcoll, 1);
+         longjmp (failed_locale_specific_sorting, 1);
        }
       if (r)
        return r;
     }
 
-  return file_name_cmp (name1, name2);
+  return (ignore_file_name_case
+         ? strcasecmp (name1, name2)
+         : file_name_cmp (name1, name2));
 }
 
 /* A wrapper for compare_names suitable as an argument for qsort.  */
@@ -230,7 +229,7 @@ diff_dirs (struct comparison const *cmp,
 
       /* Use locale-specific sorting if possible, else native byte order.  */
       locale_specific_sorting = 1;
-      if (setjmp (failed_strcoll))
+      if (setjmp (failed_locale_specific_sorting))
        locale_specific_sorting = 0;
 
       /* Sort the directories.  */



reply via email to

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