Summary is not a doxygen tag
[libfirm] / ir / tv / tv.c
index 269b3e2..1892f6f 100644 (file)
@@ -24,7 +24,7 @@
  * @date     2003
  * @author   Mathias Heil
  * @version  $Id$
- * @summary
+ * @brief
  *
  * Values are stored in a format depending upon chosen arithmetic
  * module. Default uses strcalc and fltcalc.
@@ -35,9 +35,7 @@
 
 #include <assert.h>         /* assertions */
 #include <stdlib.h>         /* atoi() */
-#ifdef HAVE_STRING_H
-# include <string.h>         /* nice things for strings */
-#endif
+#include <string.h>
 #ifdef HAVE_STRINGS_H
 #include <strings.h>        /* strings.h also includes bsd only function strcasecmp */
 #endif
@@ -337,10 +335,10 @@ tarval *new_tarval_from_str(const char *str, size_t len, ir_mode *mode)
 
        case irms_internal_boolean:
                /* match [tT][rR][uU][eE]|[fF][aA][lL][sS][eE] */
-               if (strcasecmp(str, "true"))
-                       return tarval_b_true;
-               else if (strcasecmp(str, "false"))
+               if (!strcasecmp(str, "true"))
                        return tarval_b_true;
+               else if (!strcasecmp(str, "false"))
+                       return tarval_b_false;
                else
                        /* XXX This is C semantics */
                        return atoi(str) ? tarval_b_true : tarval_b_false;
@@ -351,7 +349,9 @@ tarval *new_tarval_from_str(const char *str, size_t len, ir_mode *mode)
                return get_tarval(fc_get_buffer(), fc_get_buffer_length(), mode);
 
        case irms_reference:
-               /* same as integer modes */
+               if (!strcasecmp(str, "null"))
+                       return get_tarval_null(mode);
+               /* FALLTHROUGH */
        case irms_int_number:
                sc_val_from_str(str, len, NULL, mode);
                return get_tarval(sc_get_buffer(), sc_get_buffer_length(), mode);
@@ -1439,7 +1439,7 @@ int tarval_snprintf(char *buf, size_t len, tarval *tv) {
        switch (get_mode_sort(tv->mode)) {
        case irms_reference:
                if (tv == tv->mode->null) return snprintf(buf, len, "NULL");
-               /* fall through */
+               /* FALLTHROUGH */
        case irms_int_number:
                switch (mode_info->mode_output) {
 
@@ -1451,8 +1451,9 @@ int tarval_snprintf(char *buf, size_t len, tarval *tv) {
                        str = sc_print(tv->value, get_mode_size_bits(tv->mode), SC_OCT, 0);
                        break;
 
-               case TVO_HEX:
                case TVO_NATIVE:
+                       prefix = "0x";
+               case TVO_HEX:
                default:
                        str = sc_print(tv->value, get_mode_size_bits(tv->mode), SC_HEX, 0);
                        break;
@@ -1688,11 +1689,12 @@ tarval_int_overflow_mode_t tarval_get_integer_overflow_mode(void) {
 }
 
 /* Enable/Disable floating point constant folding. */
-int tarval_enable_fp_ops(int enable) {
-       int old = !no_float;
-
+void tarval_enable_fp_ops(int enable) {
        no_float = !enable;
-       return old;
+}
+
+int tarval_fp_ops_enabled(void) {
+       return !no_float;
 }
 
 /**