This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ 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]

[Patch] Small simplification of generic/c_locale.cc


Hi,

this is small cleanup that I have mentioned some days ago: in principle could
be a little risky, but I'm confident is correct and would really like to see
those functions as simple as possible: this should also help understanding the
long standing, mysterious fail of basic_istream/extractors_arithmetic/12.cc
on some platforms (e.g. aix).


Tested x86/x86_64 --enable-clocale=generic --disable-c99, if nobody objects
will commit tomorrow morning.

Paolo.

/////////////
2004-03-31  Paolo Carlini  <pcarlini@suse.de>

	* config/locale/generic/c_locale.cc (__convert_to_v(long double&)):
	In v3 uses of sscanf, the special floating-point numbers INF,
	INFINITY, etc., cannot occur in input, therefore, if the latter
	is too large, ERANGE is always stored in errno, no need of finitel.
diff -urN libstdc++-v3-orig/config/locale/generic/c_locale.cc libstdc++-v3/config/locale/generic/c_locale.cc
--- libstdc++-v3-orig/config/locale/generic/c_locale.cc	2004-01-27 01:49:01.000000000 +0100
+++ libstdc++-v3/config/locale/generic/c_locale.cc	2004-03-30 23:06:47.000000000 +0200
@@ -128,13 +128,8 @@
 	  long double __ld;
 	  errno = 0;
 	  int __p = sscanf(__s, "%Lf", &__ld);
-	  if (errno == ERANGE)
-	    __p = 0;
-#ifdef _GLIBCXX_HAVE_FINITEL
-	  if ((__p == 1) && !finitel (__ld))
-	    __p = 0;
-#endif
-	  if (__p && static_cast<int_type>(__p) != char_traits<char>::eof())
+	  if (__p && static_cast<int_type>(__p) != char_traits<char>::eof()
+	      && errno != ERANGE)
 	    __v = __ld;
 #endif
 	  else

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