[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#6020: coreutils-8.x: a simple feature enhancement, and how to do it
From: |
Pádraig Brady |
Subject: |
bug#6020: coreutils-8.x: a simple feature enhancement, and how to do it |
Date: |
Fri, 30 Apr 2010 23:33:21 +0100 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.8) Gecko/20100227 Thunderbird/3.0.3 |
On 30/04/10 19:16, Paul Eggert wrote:
> Pádraig Brady <address@hidden> writes:
>
>> +#if HAVE_C99_STRTOLD /* provided by c-strtold module. */
>> +# define STRTOD strtold
>> +#else
>> +# define STRTOD strtod
>> +#endif
>> +
>> char *ea;
>> char *eb;
>> - double a = strtod (sa, &ea);
>> - double b = strtod (sb, &eb);
>> + long double a = STRTOD (sa, &ea);
>> + long double b = STRTOD (sb, &eb);
>
> This could cause performance problems on machines that have slow
> long-double operations (implemented via traps, say) and that lack
> strtold.
An unusual combination, buy you're right.
I'll push this soon in your name.
thanks for the review,
Pádraig.
commit 1a2afe2adde1f4e864ac098e5d0ede6fcc6b46db
Author: Paul Eggert <address@hidden>
Date: Fri Apr 30 23:23:38 2010 +0100
sort: use long doubles only when effective
* src/sort.c (general_numcompare): Don't use long double if strtold
is not available, as it may introduce needless overhead.
diff --git a/src/sort.c b/src/sort.c
index a815244..54b97e2 100644
--- a/src/sort.c
+++ b/src/sort.c
@@ -1856,15 +1856,17 @@ general_numcompare (const char *sa, const char *sb)
only if A and B can't be compared more cheaply/accurately. */
#if HAVE_C99_STRTOLD /* provided by c-strtold module. */
-# define STRTOD strtold
+# define long_double long double
#else
-# define STRTOD strtod
+# define long_double double
+# undef strtold
+# define strtold strtod
#endif
char *ea;
char *eb;
- long double a = STRTOD (sa, &ea);
- long double b = STRTOD (sb, &eb);
+ long_double a = strtold (sa, &ea);
+ long_double b = strtold (sb, &eb);
/* Put conversion errors at the start of the collating sequence. */
if (sa == ea)