diff options
| author | Andrey A. Chernov <ache@FreeBSD.org> | 1999-10-24 03:42:35 +0000 |
|---|---|---|
| committer | Andrey A. Chernov <ache@FreeBSD.org> | 1999-10-24 03:42:35 +0000 |
| commit | 2c2b14e1624e218fdbe60bf75d78e91fe11e99b8 (patch) | |
| tree | 66066db5eeff4232131bd5e16af11cf52ec49a20 | |
| parent | 9782fb62094879e38d2601b84f8eb9d4218dcfe7 (diff) | |
Notes
| -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 25e0f2f77439..28e6bd7f6c27 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; |
