2004-11-08 Andrew Cagney <cagney@gnu.org>
[deliverable/binutils-gdb.git] / gdb / ada-valprint.c
index c7440e690f0942bb9acb950c2dd9f776fd8e1801..82e68252e00167cca0a37bfb75b88b254b14944a 100644 (file)
@@ -48,9 +48,6 @@ struct ada_val_print_args
   enum val_prettyprint pretty;
 };
 
-extern int inspect_it;
-extern unsigned int repeat_count_threshold;
-
 static void print_record (struct type *, char *, struct ui_file *, int,
                          int, enum val_prettyprint);
 
@@ -86,10 +83,10 @@ adjust_type_signedness (struct type *type)
     TYPE_FLAGS (type) |= TYPE_FLAG_UNSIGNED;
 }
 
-/* Assuming TYPE is a simple array type, prints its lower bound on STREAM,
-   if non-standard (i.e., other than 1 for numbers, other than lower bound
-   of index type for enumerated type).  Returns 1 if something printed,
-   otherwise 0.  */
+/* Assuming TYPE is a simple, non-empty array type, prints its lower bound 
+   on STREAM, if non-standard (i.e., other than 1 for numbers, other
+   than lower bound of index type for enumerated type).  Returns 1 
+   if something printed, otherwise 0.  */
 
 static int
 print_optional_low_bound (struct ui_file *stream, struct type *type)
@@ -105,6 +102,8 @@ print_optional_low_bound (struct ui_file *stream, struct type *type)
   if (TYPE_CODE (index_type) == TYPE_CODE_RANGE)
     {
       low_bound = TYPE_LOW_BOUND (index_type);
+      if (low_bound > TYPE_HIGH_BOUND (index_type))
+       return 0;
       index_type = TYPE_TARGET_TYPE (index_type);
     }
   else
@@ -315,21 +314,34 @@ ada_print_floating (char *valaddr, struct type *type, struct ui_file *stream)
   len = strlen (result);
 
   /* Modify for Ada rules.  */
-  if ((s = strstr (result, "inf")) != NULL
-      || (s = strstr (result, "Inf")) != NULL
-      || (s = strstr (result, "INF")) != NULL)
+  
+  s = strstr (result, "inf");
+  if (s == NULL)
+    s = strstr (result, "Inf");
+  if (s == NULL)
+    s = strstr (result, "INF");
+  if (s != NULL)
     strcpy (s, "Inf");
-  else if ((s = strstr (result, "nan")) != NULL
-          || (s = strstr (result, "NaN")) != NULL
-          || (s = strstr (result, "Nan")) != NULL)
+
+  if (s == NULL)
     {
-      s[0] = s[2] = 'N';
-      if (result[0] == '-')
-       result += 1;
+      s = strstr (result, "nan");
+      if (s == NULL)
+       s = strstr (result, "NaN");
+      if (s == NULL)
+       s = strstr (result, "Nan");
+      if (s != NULL)
+       {
+         s[0] = s[2] = 'N';
+         if (result[0] == '-')
+           result += 1;
+       }
     }
-  else if (strchr (result, '.') == NULL)
+
+  if (s == NULL && strchr (result, '.') == NULL)
     {
-      if ((s = strchr (result, 'e')) == NULL)
+      s = strchr (result, 'e');
+      if (s == NULL)
        fprintf_filtered (stream, "%s.0", result);
       else
        fprintf_filtered (stream, "%.*s.0%s", (int) (s-result), result, s);
@@ -355,7 +367,7 @@ ada_print_scalar (struct type *type, LONGEST val, struct ui_file *stream)
   unsigned int i;
   unsigned len;
 
-  CHECK_TYPEDEF (type);
+  type = ada_check_typedef (type);
 
   switch (TYPE_CODE (type))
     {
@@ -458,9 +470,9 @@ printstr (struct ui_file *stream, char *string, unsigned int length,
 
       rep1 = i + 1;
       reps = 1;
-      while (rep1 < length &&
-            char_at (string, rep1, type_len) == char_at (string, i,
-                                                         type_len))
+      while (rep1 < length
+            && char_at (string, rep1, type_len) == char_at (string, i,
+                                                            type_len))
        {
          rep1 += 1;
          reps += 1;
@@ -587,7 +599,7 @@ ada_val_print_1 (struct type *type, char *valaddr0, int embedded_offset,
   LONGEST val;
   char *valaddr = valaddr0 + embedded_offset;
 
-  CHECK_TYPEDEF (type);
+  type = ada_check_typedef (type);
 
   if (ada_is_array_descriptor_type (type) || ada_is_packed_array_type (type))
     {
@@ -948,7 +960,7 @@ static void
 print_record (struct type *type, char *valaddr, struct ui_file *stream,
              int format, int recurse, enum val_prettyprint pretty)
 {
-  CHECK_TYPEDEF (type);
+  type = ada_check_typedef (type);
 
   fprintf_filtered (stream, "(");
 
This page took 0.028153 seconds and 4 git commands to generate.