From 2713d3105cf4ac177fcb1e75ab68a89fe0dd4778 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=BCbinette=20=28Hubbe=29?= <hubbe@hubbe.net> Date: Tue, 28 Mar 2000 21:17:44 -0800 Subject: [PATCH] bugfix for rint problems Rev: src/modules/_math/math.c:1.29 Rev: src/modules/sprintf/sprintf.c:1.61 Rev: src/port.h:1.23 Rev: src/uncompressor.c:1.2 --- src/modules/_math/math.c | 4 ++-- src/modules/sprintf/sprintf.c | 4 ++-- src/port.h | 6 ++++-- src/uncompressor.c | 6 +++--- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/modules/_math/math.c b/src/modules/_math/math.c index 161248c8a5..f0b84cba24 100644 --- a/src/modules/_math/math.c +++ b/src/modules/_math/math.c @@ -27,7 +27,7 @@ #include <floatingpoint.h> #endif -RCSID("$Id: math.c,v 1.28 2000/03/28 19:37:23 grubba Exp $"); +RCSID("$Id: math.c,v 1.29 2000/03/29 05:17:38 hubbe Exp $"); #ifndef M_PI #define M_PI 3.1415926535897932384626433832795080 @@ -221,7 +221,7 @@ void f_round(INT32 args) { if(args<1) error("Too few arguments to round()\n"); if(sp[-args].type!=T_FLOAT) error("Bad argument 1 to round()\n"); - sp[-args].u.float_number=rint(sp[-args].u.float_number); + sp[-args].u.float_number=RINT(sp[-args].u.float_number); } void f_min(INT32 args) diff --git a/src/modules/sprintf/sprintf.c b/src/modules/sprintf/sprintf.c index bb2955ea18..ac3f0b0eaa 100644 --- a/src/modules/sprintf/sprintf.c +++ b/src/modules/sprintf/sprintf.c @@ -102,7 +102,7 @@ */ #include "global.h" -RCSID("$Id: sprintf.c,v 1.60 1999/11/01 15:11:09 mirar Exp $"); +RCSID("$Id: sprintf.c,v 1.61 2000/03/29 05:17:44 hubbe Exp $"); #include "error.h" #include "array.h" #include "svalue.h" @@ -1195,7 +1195,7 @@ static void low_pike_sprintf(struct format_stack *fs, if(fs->fsp->precision<0) { double m=pow(10.0, (double)fs->fsp->precision); - tf=rint(tf*m)/m; + tf=RINT(tf*m)/m; } sprintf(x,buffer,1,fs->fsp->precision<0?0:fs->fsp->precision,tf); diff --git a/src/port.h b/src/port.h index 0963dc61a7..f7da545bfd 100644 --- a/src/port.h +++ b/src/port.h @@ -5,7 +5,7 @@ \*/ /* - * $Id: port.h,v 1.22 1999/08/14 15:09:17 per Exp $ + * $Id: port.h,v 1.23 2000/03/29 05:17:15 hubbe Exp $ */ #ifndef PORT_H #define PORT_H @@ -39,7 +39,9 @@ time_t TIME(time_t *); #endif #ifndef HAVE_RINT -#define rint(X) floor( (X) + 0.5 ) +#define RINT rint +#else +#define RINT(X) floor( (X) + 0.5 ) #endif #if defined(HAVE_STRTOL) && defined(HAVE_WORKING_STRTOL) diff --git a/src/uncompressor.c b/src/uncompressor.c index 95f0fc4af9..13323b3dee 100644 --- a/src/uncompressor.c +++ b/src/uncompressor.c @@ -38,7 +38,7 @@ static void gr(char *ptr, int len) } #define GR(X) gr( (char *) & (X), sizeof(X)) -static unsigned int rint(void) +static unsigned int read_int(void) { unsigned char x[4]; gr(x,4); @@ -101,7 +101,7 @@ void my_uncompress(char *file) char *data; GR(type); - len=rint(); + len=read_int(); /* fprintf(stderr,"namelen=%d\n",len); */ gr(buffer, len); @@ -155,7 +155,7 @@ void my_uncompress(char *file) fprintf(stderr,"Failed to open %s\n",buffer); exit(1); } - len=rint(); + len=read_int(); while(len) { int r=len > sizeof(buffer) ? sizeof(buffer) : len; -- GitLab