X-Git-Url: http://cgit.sxemacs.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fent%2Fent-float.c;h=96a2d9b8f74c4575dac29a9cf3bac5a460f8171d;hb=f44c1b5697e1bb9a20437099a28c843b90af8d15;hp=f1a2e7a338a30bf19cf8a73485a8a6c8b495ea72;hpb=c879e5b17b3d5fef34ab58fc66e1cbb4269e5bb4;p=sxemacs diff --git a/src/ent/ent-float.c b/src/ent/ent-float.c index f1a2e7a..96a2d9b 100644 --- a/src/ent/ent-float.c +++ b/src/ent/ent-float.c @@ -26,7 +26,7 @@ along with this program. If not, see . */ #include "lisp.h" #include "sysproc.h" /* For qxe_getpid */ -#include "ent-float.h" +#include "ent.h" Lisp_Object Vmost_positive_float; @@ -41,23 +41,19 @@ Fixnum max_float_print_size = 0; static Lisp_Object -mark_float(Lisp_Object obj) +mark_float(Lisp_Object SXE_UNUSED(obj)) { return Qnil; - - if (obj); } static inline int -float_equal(Lisp_Object obj1, Lisp_Object obj2, int depth) +float_equal(Lisp_Object obj1, Lisp_Object obj2, int SXE_UNUSED(depth)) { return (ent_float(obj1) == ent_float(obj2)); - - if (depth); } static inline unsigned long -float_hash(Lisp_Object obj, int UNUSED(depth)) +float_hash(Lisp_Object obj, int SXE_UNUSED(depth)) { #if 1 fpfloat h = 22.0/7.0*ent_float(obj); @@ -82,7 +78,7 @@ print_float(Lisp_Object obj, Lisp_Object printcharfun, int escapeflag) { char pigbuf[350]; /* see comments in float_to_string */ - float_to_string(pigbuf, XFLOAT_DATA(obj)); + float_to_string(pigbuf, XFLOAT_DATA(obj), sizeof(pigbuf)); write_c_string(pigbuf, printcharfun); } @@ -188,15 +184,13 @@ ent_div_FLOAT_T_INT_T(Lisp_Object l, Lisp_Object r) } static inline Lisp_Object -ent_rem_FLOAT_T(Lisp_Object l, Lisp_Object r) +ent_rem_FLOAT_T(Lisp_Object SXE_UNUSED(l), Lisp_Object SXE_UNUSED(r)) { - if (l); return make_float(0.0); } static inline Lisp_Object -ent_rem_FLOAT_T_INT_T(Lisp_Object l, Lisp_Object r) +ent_rem_FLOAT_T_INT_T(Lisp_Object SXE_UNUSED(l), Lisp_Object SXE_UNUSED(r)) { - if (l); return make_float(0.0); } @@ -383,7 +377,7 @@ ent_lift_INT_T_FLOAT_T(Lisp_Object number, unsigned long precision) return make_float(ent_int(number)); } static inline Lisp_Object -_ent_lift_INT_T_FLOAT_T(Lisp_Object number, ent_lift_args_t UNUSED(unused)) +_ent_lift_INT_T_FLOAT_T(Lisp_Object number, ent_lift_args_t SXE_UNUSED(unused)) { return make_float(ent_int(number)); } @@ -394,7 +388,7 @@ ent_lift_FLOAT_T_INT_T(Lisp_Object number, unsigned long precision) return Ftruncate(number); } static inline Lisp_Object -_ent_lift_FLOAT_T_INT_T(Lisp_Object number, ent_lift_args_t UNUSED(unused)) +_ent_lift_FLOAT_T_INT_T(Lisp_Object number, ent_lift_args_t SXE_UNUSED(unused)) { return Ftruncate(number); } @@ -585,12 +579,17 @@ The float closest in value to -infinity. */); Vmost_negative_float = make_float(fp); + { + char tmp[] = "1.0"; /* let's compute the array we need to print such a float */ #if fpfloat_double_p - max_float_print_size = snprintf(NULL, 0, "%f", fp) + 10; + max_float_print_size = snprintf(tmp, sizeof(tmp), "%f", fp); #elif fpfloat_long_double_p - max_float_print_size = snprintf(NULL, 0, "%Lf", fp) + 10; + max_float_print_size = snprintf(tmp, sizeof(tmp), "%Lf", fp); #endif + } + assert(max_float_print_size>0); + max_float_print_size += 10; DEFVAR_CONST_INT("max-float-print-size", &max_float_print_size /* The maximal string length of a printed float. @@ -611,16 +610,14 @@ The float closest in value to -0. */); Vleast_negative_float = make_float(fp); - f = 1.0; - while ((fp = f, f /= 2) * 2 == fp && f != 0); + for( f = fp = 1.0; (f /= 2) * 2 == fp && f != 0; fp = f ); DEFVAR_CONST_LISP("least-positive-normalised-float", &Vleast_positive_normalised_float /* The float closest in value to +0 without rounding errors. */); Vleast_positive_normalised_float = make_float(fp); - f = -1.0; - while ((fp = f, f /= 2) * 2 == fp && f != 0); + for( f = fp = -1.0; ( f /= 2) * 2 == fp && f != 0; fp = f); DEFVAR_CONST_LISP("least-negative-normalised-float", &Vleast_negative_normalised_float /* The float closest in value to -0 without rounding errors.