Fixed output of mode_P constants
authorMichael Beck <beck@ipd.info.uni-karlsruhe.de>
Thu, 8 Jun 2006 16:03:19 +0000 (16:03 +0000)
committerMichael Beck <beck@ipd.info.uni-karlsruhe.de>
Thu, 8 Jun 2006 16:03:19 +0000 (16:03 +0000)
[r7897]

ir/tv/tv.c

index 6c50d1d..0e6a172 100644 (file)
@@ -1474,23 +1474,26 @@ 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 */
     case irms_int_number:
     case irms_character:
       switch (mode_info->mode_output) {
 
       case TVO_DECIMAL:
         str = sc_print(tv->value, get_mode_size_bits(tv->mode), SC_DEC);
-    break;
+        break;
 
       case TVO_OCTAL:
         str = sc_print(tv->value, get_mode_size_bits(tv->mode), SC_OCT);
-    break;
+        break;
 
       case TVO_HEX:
       case TVO_NATIVE:
       default:
         str = sc_print(tv->value, get_mode_size_bits(tv->mode), SC_HEX);
-    break;
+        break;
       }
       return snprintf(buf, len, "%s%s%s", prefix, str, suffix);
 
@@ -1509,23 +1512,6 @@ int tarval_snprintf(char *buf, size_t len, tarval *tv)
       }
       break;
 
-    case irms_reference:
-      if (tv == tv->mode->null) return snprintf(buf, len, "NULL");
-      if (tv->value != NULL) {
-        if (len > tv->length) {
-          memcpy(buf, tv->value, tv->length);
-          buf[tv->length] = '\0';
-        }
-        else {
-          /* truncated */
-          memcpy(buf, tv->value, len-1);
-          buf[len-1] = '\0';
-        }
-        return tv->length;
-      }
-      else
-        return snprintf(buf, len, "void");
-
     case irms_internal_boolean:
       switch (mode_info->mode_output) {
 
@@ -1703,15 +1689,6 @@ static const tarval_mode_info hex_output = {
   NULL,
 };
 
-/**
- * default mode_info for output as reference
- */
-static const tarval_mode_info reference_output = {
-  TVO_NATIVE,
-  "&(",
-  ")",
-};
-
 /*
  * Initialization of the tarval module: called before init_mode()
  */
@@ -1767,7 +1744,7 @@ void init_tarval_2(void)
   set_tarval_mode_output_option(mode_Iu, &hex_output);
   set_tarval_mode_output_option(mode_Ls, &hex_output);
   set_tarval_mode_output_option(mode_Lu, &hex_output);
-  set_tarval_mode_output_option(mode_P,  &reference_output);
+  set_tarval_mode_output_option(mode_P,  &hex_output);
 }
 
 /* free all memory occupied by tarval. */