never set the startblock to bad (even without the self-referencing loop)
[libfirm] / ir / tv / fltcalc.c
index 857650c..69ba024 100644 (file)
 #endif
 
 #ifdef HAVE_INTTYPES_H
-#include <inttypes.h>
+# include <inttypes.h>
+#endif
+#ifdef HAVE_STRING_H
+# include <string.h>
+#endif
+#ifdef HAVE_STDLIB_H
+# include <stdlib.h>
 #endif
-
-#include <string.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <assert.h>
 #ifdef HAVE_ALLOCA_H
 # include <alloca.h>
 #endif
 #ifdef HAVE_MALLOC_H
 # include <malloc.h>
 #endif
+#include <stdio.h>
+#include <assert.h>
 
 #include "xmalloc.h"
 
@@ -708,6 +711,7 @@ static char* _fdiv(const char* a, const char* b, char* result)
   return _normalize(result, result, sc_had_carry());
 }
 
+#if 0
 static void _power_of_ten(int exp, descriptor_t *desc, char *result)
 {
   char *build;
@@ -745,6 +749,7 @@ static void _power_of_ten(int exp, descriptor_t *desc, char *result)
     _normalize(result, result, 0);
   }
 }
+#endif
 
 /**
  * Truncate the fractional part away.
@@ -878,7 +883,7 @@ const void *fc_get_buffer(void)
   return calc_buffer;
 }
 
-const int fc_get_buffer_length(void)
+int fc_get_buffer_length(void)
 {
   return calc_buffer_size;
 }
@@ -1525,7 +1530,8 @@ char *fc_print(const void *a, char *buf, int buflen, unsigned base)
 
     case FC_PACKED:
     default:
-      snprintf(buf, buflen, "%s", sc_print(_pack(val, mul_1), value_size*4, SC_HEX));
+      snprintf(buf, buflen, "%s", sc_print(_pack(val, mul_1), value_size*4, SC_HEX, 0));
+      buf[buflen - 1] = '\0';
       break;
   }
   return buf;
@@ -1580,6 +1586,7 @@ void init_fltcalc(int precision)
     calc_buffer_size = DESCRIPTOR_POS + sizeof(descriptor_t);
 
     calc_buffer = xmalloc(calc_buffer_size);
+    memset(calc_buffer, 0, calc_buffer_size);
     DEBUGPRINTF(("init fltcalc:\n\tVALUE_SIZE = %d\n\tSIGN_POS = %d\n\tEXPONENT_POS = %d\n\tMANTISSA_POS = %d\n\tDESCRIPTOR_POS = %d\n\tCALC_BUFFER_SIZE = %d\n\tcalc_buffer = %p\n\n", value_size, SIGN_POS, EXPONENT_POS, MANTISSA_POS, DESCRIPTOR_POS, calc_buffer_size, calc_buffer));
 #ifdef HAVE_LONG_DOUBLE
     DEBUGPRINTF(("\tUsing long double (1-15-64) interface\n"));