aboutsummaryrefslogtreecommitdiff
path: root/gnu/usr.bin/sort
diff options
context:
space:
mode:
authorAndrey A. Chernov <ache@FreeBSD.org>2002-04-08 22:00:28 +0000
committerAndrey A. Chernov <ache@FreeBSD.org>2002-04-08 22:00:28 +0000
commit93e293bff0b11bf02f8e2ba274ee9a55107b4ef8 (patch)
treeb719ab9ef1061710d8c31713559a5d4599ecb103 /gnu/usr.bin/sort
parentd2c10ccbd88cb4498de8aac98bda11f375996ed2 (diff)
Notes
Diffstat (limited to 'gnu/usr.bin/sort')
-rw-r--r--gnu/usr.bin/sort/sort.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/gnu/usr.bin/sort/sort.c b/gnu/usr.bin/sort/sort.c
index 90082eff3d242..5b1893b8278af 100644
--- a/gnu/usr.bin/sort/sort.c
+++ b/gnu/usr.bin/sort/sort.c
@@ -198,6 +198,8 @@ static int have_read_stdin;
static struct keyfield keyhead;
#ifdef __FreeBSD__
+static unsigned char decimal_point;
+
static int
COLLDIFF (int a, int b)
{
@@ -751,7 +753,11 @@ fraccompare (register const char *a, register const char *b)
{
register tmpa = UCHAR (*a), tmpb = UCHAR (*b);
+#ifdef __FreeBSD__
+ if (tmpa == decimal_point && tmpb == decimal_point)
+#else
if (tmpa == '.' && tmpb == '.')
+#endif
{
do
tmpa = UCHAR (*++a), tmpb = UCHAR (*++b);
@@ -776,7 +782,11 @@ fraccompare (register const char *a, register const char *b)
}
return 0;
}
+#ifdef __FreeBSD__
+ else if (tmpa == decimal_point)
+#else
else if (tmpa == '.')
+#endif
{
do
tmpa = UCHAR (*++a);
@@ -785,7 +795,11 @@ fraccompare (register const char *a, register const char *b)
return 1;
return 0;
}
+#ifdef __FreeBSD__
+ else if (tmpb == decimal_point)
+#else
else if (tmpb == '.')
+#endif
{
do
tmpb = UCHAR (*++b);
@@ -821,7 +835,11 @@ numcompare (register const char *a, register const char *b)
while (tmpa == '0');
if (tmpb != '-')
{
+#ifdef __FreeBSD__
+ if (tmpa == decimal_point)
+#else
if (tmpa == '.')
+#endif
do
tmpa = UCHAR (*++a);
while (tmpa == '0');
@@ -829,7 +847,11 @@ numcompare (register const char *a, register const char *b)
return -1;
while (tmpb == '0')
tmpb = UCHAR (*++b);
+#ifdef __FreeBSD__
+ if (tmpb == decimal_point)
+#else
if (tmpb == '.')
+#endif
do
tmpb = UCHAR (*++b);
while (tmpb == '0');
@@ -844,7 +866,12 @@ numcompare (register const char *a, register const char *b)
while (tmpa == tmpb && digits[tmpa])
tmpa = UCHAR (*++a), tmpb = UCHAR (*++b);
+#ifdef __FreeBSD__
+ if ((tmpa == decimal_point && !digits[tmpb]) ||
+ (tmpb == decimal_point && !digits[tmpa]))
+#else
if ((tmpa == '.' && !digits[tmpb]) || (tmpb == '.' && !digits[tmpa]))
+#endif
return -fraccompare (a, b);
if (digits[tmpa])
@@ -876,7 +903,11 @@ numcompare (register const char *a, register const char *b)
do
tmpb = UCHAR (*++b);
while (tmpb == '0');
+#ifdef __FreeBSD__
+ if (tmpb == decimal_point)
+#else
if (tmpb == '.')
+#endif
do
tmpb = UCHAR (*++b);
while (tmpb == '0');
@@ -884,7 +915,11 @@ numcompare (register const char *a, register const char *b)
return 1;
while (tmpa == '0')
tmpa = UCHAR (*++a);
+#ifdef __FreeBSD__
+ if (tmpa == decimal_point)
+#else
if (tmpa == '.')
+#endif
do
tmpa = UCHAR (*++a);
while (tmpa == '0');
@@ -902,7 +937,12 @@ numcompare (register const char *a, register const char *b)
while (tmpa == tmpb && digits[tmpa])
tmpa = UCHAR (*++a), tmpb = UCHAR (*++b);
+#ifdef __FreeBSD__
+ if ((tmpa == decimal_point && !digits[tmpb]) ||
+ (tmpb == decimal_point && !digits[tmpa]))
+#else
if ((tmpa == '.' && !digits[tmpb]) || (tmpb == '.' && !digits[tmpa]))
+#endif
return fraccompare (a, b);
if (digits[tmpa])
@@ -1738,6 +1778,7 @@ main (int argc, char **argv)
#ifdef __FreeBSD__
(void) setlocale(LC_ALL, "");
+ decimal_point = localeconv()->decimal_point[0];
#endif
program_name = argv[0];