From: Jim Meyering Date: Sun, 4 Jul 1999 10:22:25 +0000 (+0000) Subject: Include hard-locale.h, memcoll.h. X-Git-Tag: TEXTUTILS-1_22n~61 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3ad83e6ad0f4cc930b04b111af23c320c070b2f3;p=thirdparty%2Fcoreutils.git Include hard-locale.h, memcoll.h. (hard_LC_COLLATE): New variable. (compare_files): Use memcoll to compare if hard_LC_COLLATE. (main): Initialize hard_LC_COLLATE from locale. --- diff --git a/src/comm.c b/src/comm.c index f41b4592a3..7434cc87a8 100644 --- a/src/comm.c +++ b/src/comm.c @@ -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" @@ -38,6 +40,11 @@ /* 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;