* ada-lang.c (ada_delta): Change the type of numerators and
authorJoel Brobecker <brobecker@gnat.com>
Fri, 13 Mar 2009 01:28:05 +0000 (01:28 +0000)
committerJoel Brobecker <brobecker@gnat.com>
Fri, 13 Mar 2009 01:28:05 +0000 (01:28 +0000)
        denominators to DOUBLEST, as they may not fit into a long.
        (scaling_factor): Ditto.

gdb/ChangeLog
gdb/ada-lang.c

index a8621f9f5448523792d1a9efa966962e1117f29c..985f46da7e9043c8e2023790709613cbb15fa51b 100644 (file)
@@ -1,3 +1,9 @@
+2009-03-12  Jerome Guitton  <guitton@adacore.com>
+
+       * ada-lang.c (ada_delta): Change the type of numerators and
+       denominators to DOUBLEST, as they may not fit into a long.
+       (scaling_factor): Ditto.
+
 2009-03-12  Jerome Guitton  <guitton@adacore.com>
 
        * language.c (lang_bool_type): Set lai->bool_type_symbol to NULL.
index 0ec724f9c3ead849994cb203f52e4c8fb97d63dd..aa5deceb9b5bdd799716c1dfb72d49178fb1025f 100644 (file)
@@ -9296,12 +9296,16 @@ DOUBLEST
 ada_delta (struct type *type)
 {
   const char *encoding = fixed_type_info (type);
-  long num, den;
+  DOUBLEST num, den;
 
-  if (sscanf (encoding, "_%ld_%ld", &num, &den) < 2)
+  /* Strictly speaking, num and den are encoded as integer.  However,
+     they may not fit into a long, and they will have to be converted
+     to DOUBLEST anyway.  So scan them as DOUBLEST.  */
+  if (sscanf (encoding, "_%" DOUBLEST_SCAN_FORMAT "_%" DOUBLEST_SCAN_FORMAT,
+             &num, &den) < 2)
     return -1.0;
   else
-    return (DOUBLEST) num / (DOUBLEST) den;
+    return num / den;
 }
 
 /* Assuming that ada_is_fixed_point_type (TYPE), return the scaling
@@ -9311,17 +9315,23 @@ static DOUBLEST
 scaling_factor (struct type *type)
 {
   const char *encoding = fixed_type_info (type);
-  unsigned long num0, den0, num1, den1;
+  DOUBLEST num0, den0, num1, den1;
   int n;
 
-  n = sscanf (encoding, "_%lu_%lu_%lu_%lu", &num0, &den0, &num1, &den1);
+  /* Strictly speaking, num's and den's are encoded as integer.  However,
+     they may not fit into a long, and they will have to be converted
+     to DOUBLEST anyway.  So scan them as DOUBLEST.  */
+  n = sscanf (encoding,
+             "_%" DOUBLEST_SCAN_FORMAT "_%" DOUBLEST_SCAN_FORMAT
+             "_%" DOUBLEST_SCAN_FORMAT "_%" DOUBLEST_SCAN_FORMAT,
+             &num0, &den0, &num1, &den1);
 
   if (n < 2)
     return 1.0;
   else if (n == 4)
-    return (DOUBLEST) num1 / (DOUBLEST) den1;
+    return num1 / den1;
   else
-    return (DOUBLEST) num0 / (DOUBLEST) den0;
+    return num0 / den0;
 }