]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
Include hard-locale.h, memcoll.h.
authorJim Meyering <jim@meyering.net>
Sun, 4 Jul 1999 10:22:25 +0000 (10:22 +0000)
committerJim Meyering <jim@meyering.net>
Sun, 4 Jul 1999 10:22:25 +0000 (10:22 +0000)
(hard_LC_COLLATE): New variable.
(compare_files): Use memcoll to compare if hard_LC_COLLATE.
(main): Initialize hard_LC_COLLATE from locale.

src/comm.c

index f41b4592a31cc8162440c2819ca78a26ca07250a..7434cc87a83f55b2ee54369d3d5d46f0a3d72006 100644 (file)
@@ -25,6 +25,8 @@
 #include "system.h"
 #include "linebuffer.h"
 #include "error.h"
+#include "hard-locale.h"
+#include "memcoll.h"
 
 /* The official name of this program (e.g., no `g' prefix).  */
 #define PROGRAM_NAME "comm"
 /* The name this program was run with. */
 char *program_name;
 
+#ifdef ENABLE_NLS
+/* Nonzero if the LC_COLLATE locale is hard.  */
+static int hard_LC_COLLATE;
+#endif
+
 /* If nonzero, print lines that are found only in file 1. */
 static int only_file_1;
 
@@ -168,11 +175,18 @@ compare_files (char **infiles)
        order = -1;
       else
        {
-         /* Cannot use bcmp -- it only returns a boolean value. */
-         order = memcmp (thisline[0]->buffer, thisline[1]->buffer,
-                         min (thisline[0]->length, thisline[1]->length));
-         if (order == 0)
-           order = thisline[0]->length - thisline[1]->length;
+#ifdef ENABLE_NLS
+         if (hard_LC_COLLATE)
+           order = memcoll (thisline[0]->buffer, thisline[0]->length,
+                            thisline[1]->buffer, thisline[1]->length);
+         else
+#endif
+           {
+             order = memcmp (thisline[0]->buffer, thisline[1]->buffer,
+                             min (thisline[0]->length, thisline[1]->length));
+             if (order == 0)
+               order = thisline[0]->length - thisline[1]->length;
+           }
        }
 
       /* Output the line that is lesser. */
@@ -219,6 +233,10 @@ main (int argc, char **argv)
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 
+#ifdef ENABLE_NLS
+  hard_LC_COLLATE = hard_locale (LC_COLLATE);
+#endif
+
   only_file_1 = 1;
   only_file_2 = 1;
   both = 1;