Use strcoll to provide the same results as sort and comm

Use LINE_MAX for max line size (as comm does)
This commit is contained in:
Andrey A. Chernov 1999-10-24 04:08:15 +00:00
parent 2c2b14e162
commit c02e589456
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=52455

View File

@ -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);