diff options
author | Rob Landley | 2006-05-09 23:14:39 +0000 |
---|---|---|
committer | Rob Landley | 2006-05-09 23:14:39 +0000 |
commit | f893250a3be0ca1f63cec7e1bd6cd4a5a8914508 (patch) | |
tree | 70394e4ab58e089fb53a54f6c8b24cf0101f93ef /coreutils | |
parent | c503df5bdda79ee9ed755325c0d76350a7a719c8 (diff) | |
download | busybox-f893250a3be0ca1f63cec7e1bd6cd4a5a8914508.zip busybox-f893250a3be0ca1f63cec7e1bd6cd4a5a8914508.tar.gz |
Replace isnan() and isinf() with inline tests so uClibc doesn't want us to
link sort against libm. This adds 22 bytes for glibc but is a win for uClibc,
and since glibc is bigger than all of busybox it seems kind of silly to worry
about it.
Diffstat (limited to 'coreutils')
-rw-r--r-- | coreutils/sort.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/coreutils/sort.c b/coreutils/sort.c index 60fc952..fb58f62 100644 --- a/coreutils/sort.c +++ b/coreutils/sort.c @@ -176,12 +176,14 @@ static int compare_keys(const void *xarg, const void *yarg) /* not numbers < NaN < -infinity < numbers < +infinity) */ if(x==xx) retval=(y==yy ? 0 : -1); else if(y==yy) retval=1; - else if(isnan(dx)) retval=isnan(dy) ? 0 : -1; - else if(isnan(dy)) retval=1; - else if(isinf(dx)) { - if(dx<0) retval=((isinf(dy) && dy<0) ? 0 : -1); - else retval=((isinf(dy) && dy>0) ? 0 : 1); - } else if(isinf(dy)) retval=dy<0 ? 1 : -1; + /* Check for isnan */ + else if(dx != dx) retval = (dy != dy) ? 0 : -1; + else if(dy != dy) retval = 1; + /* Check for infinity. Could underflow, but it avoids libm. */ + else if(1.0/dx == 0.0) { + if(dx<0) retval=((1.0/dy == 0.0 && dy<0) ? 0 : -1); + else retval=((1.0/dy == 0.0 && dy>0) ? 0 : 1); + } else if(1.0/dy == 0.0) retval=dy<0 ? 1 : -1; else retval=dx>dy ? 1 : (dx<dy ? -1 : 0); break; } |