diff options
-rw-r--r-- | usr.bin/comm/comm.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/usr.bin/comm/comm.c b/usr.bin/comm/comm.c index 25e0f2f..28e6bd7 100644 --- a/usr.bin/comm/comm.c +++ b/usr.bin/comm/comm.c @@ -48,9 +48,11 @@ static const char rcsid[] = "$FreeBSD$"; #endif /* not lint */ +#include <ctype.h> #include <err.h> #include <errno.h> #include <limits.h> +#include <locale.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -64,6 +66,19 @@ FILE *file __P((char *)); void show __P((FILE *, char *, char *)); static void usage __P((void)); +int stricoll(char *s1, char *s2) +{ + char *p, line1[MAXLINELEN], line2[MAXLINELEN]; + + for (p = line1; *s1; s1++) + *p++ = toupper((unsigned char)*s1); + *p = '\0'; + for (p = line2; *s2; s2++) + *p++ = toupper((unsigned char)*s2); + *p = '\0'; + return strcoll(s1, s2); +} + int main(argc, argv) int argc; @@ -78,6 +93,8 @@ main(argc, argv) flag1 = flag2 = flag3 = 1; iflag = 0; + (void) setlocale(LC_CTYPE, ""); + while ((ch = getopt(argc, argv, "-123i")) != -1) switch(ch) { case '-': @@ -139,9 +156,9 @@ done: argc -= optind; /* lines are the same */ if(iflag) - comp = strcasecmp(line1, line2); + comp = stricoll(line1, line2); else - comp = strcmp(line1, line2); + comp = strcoll(line1, line2); if (!comp) { read1 = read2 = 1; |