diff options
author | Jim Meyering <jim@meyering.net> | 1999-07-04 10:22:25 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 1999-07-04 10:22:25 +0000 |
commit | 3ad83e6ad0f4cc930b04b111af23c320c070b2f3 (patch) | |
tree | f65422da2bb1503302e53fcf68acdd3c368b5fd6 | |
parent | ad72fa61c82418c5f3ec80a393e02358dcdb189c (diff) | |
download | coreutils-3ad83e6ad0f4cc930b04b111af23c320c070b2f3.tar.xz |
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.
-rw-r--r-- | src/comm.c | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/src/comm.c b/src/comm.c index f41b4592a..7434cc87a 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; |