Fix MPFR Flog implementation
[sxemacs] / src / ent / ent-float.c
index f1a2e7a..96a2d9b 100644 (file)
@@ -26,7 +26,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>. */
 #include "lisp.h"
 #include "sysproc.h"    /* For qxe_getpid */
 
-#include "ent-float.h"
+#include "ent.h"
 
 \f
 Lisp_Object Vmost_positive_float;
@@ -41,23 +41,19 @@ Fixnum max_float_print_size = 0;
 
 \f
 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.