diff options
author | ache <ache@FreeBSD.org> | 1999-10-24 04:08:15 +0000 |
---|---|---|
committer | ache <ache@FreeBSD.org> | 1999-10-24 04:08:15 +0000 |
commit | 9fbc2f9470f3420f43c0d1fffd44b82e171dcd8e (patch) | |
tree | beff96405c5712499c0ccc633aff03bfd7f4958e /usr.bin/uniq | |
parent | c594629213790c0e8db9fa5de9cf030e3dea312d (diff) | |
download | FreeBSD-src-9fbc2f9470f3420f43c0d1fffd44b82e171dcd8e.zip FreeBSD-src-9fbc2f9470f3420f43c0d1fffd44b82e171dcd8e.tar.gz |
Use strcoll to provide the same results as sort and comm
Use LINE_MAX for max line size (as comm does)
Diffstat (limited to 'usr.bin/uniq')
-rw-r--r-- | usr.bin/uniq/uniq.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/usr.bin/uniq/uniq.c b/usr.bin/uniq/uniq.c index 0cc7977..11f5ea5 100644 --- a/usr.bin/uniq/uniq.c +++ b/usr.bin/uniq/uniq.c @@ -50,13 +50,14 @@ static const char rcsid[] = #include <ctype.h> #include <err.h> +#include <limits.h> #include <locale.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> -#define MAXLINELEN (8 * 1024) +#define MAXLINELEN (LINE_MAX + 1) int cflag, dflag, uflag; int numchars, numfields, repeats; @@ -67,6 +68,19 @@ char *skip __P((char *)); void obsolete __P((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; @@ -160,9 +174,9 @@ done: argc -= optind; /* If different, print; set previous to new value. */ if (iflag) - comp = strcasecmp(t1, t2); + comp = stricoll(t1, t2); else - comp = strcmp(t1, t2); + comp = strcoll(t1, t2); if (comp) { show(ofp, prevline); |