summaryrefslogtreecommitdiffstats
path: root/usr.bin/uniq
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>2002-06-06 13:44:14 +0000
committerache <ache@FreeBSD.org>2002-06-06 13:44:14 +0000
commit37d7c3a7dfacca0aa405b2e7e18025633a202cf1 (patch)
treec212fdd5f0dddc55b97710bfefef46117f8b1fce /usr.bin/uniq
parent3be5f8e9018ab74ba968d04eb034c0e8b11c6042 (diff)
downloadFreeBSD-src-37d7c3a7dfacca0aa405b2e7e18025633a202cf1.zip
FreeBSD-src-37d7c3a7dfacca0aa405b2e7e18025633a202cf1.tar.gz
Back out rev 1.19 because
1) It breaks uniq for real life languages when "substitute" directive used in the collating table. 2) It breaks uniq usage in tool chain with other localized utilities which use collate. 3) To follow LC_COLLATE it is directly allowed for uniq by POSIX P1003.1 Draft7 (7.3.2). It means that rev 1.19 gains no additional POSIX conformance.
Diffstat (limited to 'usr.bin/uniq')
-rw-r--r--usr.bin/uniq/uniq.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/usr.bin/uniq/uniq.c b/usr.bin/uniq/uniq.c
index 4727c14..701e58b 100644
--- a/usr.bin/uniq/uniq.c
+++ b/usr.bin/uniq/uniq.c
@@ -67,6 +67,7 @@ void show(FILE *, char *);
char *skip(char *);
void obsolete(char *[]);
static void usage(void);
+int stricoll(char *, char*);
int
main (argc, argv)
@@ -151,9 +152,9 @@ main (argc, argv)
/* 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);
@@ -251,3 +252,18 @@ usage()
"usage: uniq [-c | -d | -u] [-i] [-f fields] [-s chars] [input [output]]\n");
exit(1);
}
+
+int
+stricoll(s1, s2)
+ char *s1, *s2;
+{
+ char *p, line1[MAXLINELEN], line2[MAXLINELEN];
+
+ for (p = line1; *s1; s1++)
+ *p++ = tolower((unsigned char)*s1);
+ *p = '\0';
+ for (p = line2; *s2; s2++)
+ *p++ = tolower((unsigned char)*s2);
+ *p = '\0';
+ return strcoll(line1, line2);
+}
OpenPOWER on IntegriCloud