This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[commit] Fix warnings for non-long-double


Alexandre's SCANF_HAS_LONG_DOUBLE patch used the wrong value for
DOUBLEST_FORMAT: you print a double with %g, but must scanf it with
%lg.  While fixing that I also made us more consistent between
printf and scanf, not that I expect any system to have one and not
the other, and fixed a very strange arrangement of long double tests
in ada-lex.l.

Tested and committed.

-- 
Daniel Jacobowitz
CodeSourcery

2006-02-23  Daniel Jacobowitz  <dan@codesourcery.com>

	* doublest.h: Conditionalize DOUBLEST on PRINTF_HAS_LONG_DOUBLE
	also.
	(DOUBLEST_FORMAT): Rename to DOUBLEST_PRINT_FORMAT.
	(DOUBLEST_SCAN_FORMAT): New.
	* ada-lex.l (PRINTF_HAS_LONG_DOUBLE): Remove redefinitions.
	(processReal): Use DOUBLEST_SCAN_FORMAT.
	* c-exp.y (parse_number): Likewise.
	* jv-exp.y (parse_number): Likewise.
	* objc-exp.y (parse_number): Likewise.
	* p-exp.y (parse_number): Likewise.

Index: src/gdb/ada-lex.l
===================================================================
--- src.orig/gdb/ada-lex.l	2006-01-08 02:19:40.000000000 -0500
+++ src/gdb/ada-lex.l	2006-02-23 10:11:38.000000000 -0500
@@ -432,26 +432,10 @@ processInt (const char *base0, const cha
   return INT;
 }
 
-#if defined (PRINTF_HAS_LONG_DOUBLE)
-#  undef PRINTF_HAS_LONG_DOUBLE
-#  define PRINTF_HAS_LONG_DOUBLE 1
-#else
-#  define PRINTF_HAS_LONG_DOUBLE 0
-#endif
-
 static int
 processReal (const char *num0)
 {
-#if defined (PRINTF_HAS_LONG_DOUBLE)
-  if (sizeof (DOUBLEST) > sizeof (double))
-    sscanf (num0, "%Lg", &yylval.typed_val_float.dval);
-  else
-#endif
-    {
-      double temp;
-      sscanf (num0, "%lg", &temp);
-      yylval.typed_val_float.dval = temp;
-    }
+  sscanf (num0, DOUBLEST_SCAN_FORMAT, &yylval.typed_val_float.dval);
 
   yylval.typed_val_float.type = type_float ();
   if (sizeof(DOUBLEST) >= TARGET_DOUBLE_BIT / TARGET_CHAR_BIT)
Index: src/gdb/doublest.h
===================================================================
--- src.orig/gdb/doublest.h	2006-02-22 15:02:32.000000000 -0500
+++ src/gdb/doublest.h	2006-02-23 10:09:33.000000000 -0500
@@ -48,15 +48,20 @@ struct floatformat;
    host's `long double'.  In general, we'll probably reduce the precision of
    any such values and print a warning.  */
 
-#if defined HAVE_LONG_DOUBLE && defined SCANF_HAS_LONG_DOUBLE
+#if (defined HAVE_LONG_DOUBLE && defined PRINTF_HAS_LONG_DOUBLE \
+     && defined SCANF_HAS_LONG_DOUBLE)
 typedef long double DOUBLEST;
-# define DOUBLEST_FORMAT "%Lg"
+# define DOUBLEST_PRINT_FORMAT "%Lg"
+# define DOUBLEST_SCAN_FORMAT "%Lg"
 #else
 typedef double DOUBLEST;
-# define DOUBLEST_FORMAT "%g"
+# define DOUBLEST_PRINT_FORMAT "%g"
+# define DOUBLEST_SCAN_FORMAT "%lg"
 /* If we can't scan or print long double, we don't want to use it
    anywhere.  */
 # undef HAVE_LONG_DOUBLE
+# undef PRINTF_HAS_LONG_DOUBLE
+# undef SCANF_HAS_LONG_DOUBLE
 #endif
 
 extern void floatformat_to_doublest (const struct floatformat *,
Index: src/gdb/c-exp.y
===================================================================
--- src.orig/gdb/c-exp.y	2006-02-22 15:02:31.000000000 -0500
+++ src/gdb/c-exp.y	2006-02-23 10:10:43.000000000 -0500
@@ -1080,7 +1080,7 @@ parse_number (p, len, parsed_float, puti
       char saved_char = p[len];
 
       p[len] = 0;	/* null-terminate the token */
-      num = sscanf (p, DOUBLEST_FORMAT "%s",
+      num = sscanf (p, DOUBLEST_SCAN_FORMAT "%s",
 		    &putithere->typed_val_float.dval, s);
       p[len] = saved_char;	/* restore the input stream */
 
Index: src/gdb/jv-exp.y
===================================================================
--- src.orig/gdb/jv-exp.y	2006-02-22 15:02:32.000000000 -0500
+++ src/gdb/jv-exp.y	2006-02-23 10:10:40.000000000 -0500
@@ -713,7 +713,7 @@ parse_number (p, len, parsed_float, puti
       char saved_char = p[len];
 
       p[len] = 0;	/* null-terminate the token */
-      num = sscanf (p, DOUBLEST_FORMAT "%c",
+      num = sscanf (p, DOUBLEST_SCAN_FORMAT "%c",
 		    &putithere->typed_val_float.dval, &c);
       p[len] = saved_char;	/* restore the input stream */
       if (num != 1) 		/* check scanf found ONLY a float ... */
Index: src/gdb/objc-exp.y
===================================================================
--- src.orig/gdb/objc-exp.y	2006-02-22 15:02:32.000000000 -0500
+++ src/gdb/objc-exp.y	2006-02-23 10:10:35.000000000 -0500
@@ -1025,7 +1025,7 @@ parse_number (p, len, parsed_float, puti
 
       /* It's a float since it contains a point or an exponent.  */
 
-      sscanf (p, DOUBLEST_FORMAT "%c",
+      sscanf (p, DOUBLEST_SCAN_FORMAT "%c",
 	      &putithere->typed_val_float.dval, &c);
 
       /* See if it has `f' or `l' suffix (float or long double).  */
Index: src/gdb/p-exp.y
===================================================================
--- src.orig/gdb/p-exp.y	2006-02-22 15:02:32.000000000 -0500
+++ src/gdb/p-exp.y	2006-02-23 10:10:29.000000000 -0500
@@ -799,7 +799,7 @@ parse_number (p, len, parsed_float, puti
       char saved_char = p[len];
 
       p[len] = 0;	/* null-terminate the token */
-      num = sscanf (p, DOUBLEST_FORMAT "%c",
+      num = sscanf (p, DOUBLEST_SCAN_FORMAT "%c",
 		    &putithere->typed_val_float.dval, &c);
       p[len] = saved_char;	/* restore the input stream */
       if (num != 1) 		/* check scanf found ONLY a float ... */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]