locale_facets.tcc: Conditionalize use of strtold.
authorBenjamin Kosnik <bkoz@redhat.com>
Fri, 14 Sep 2001 07:43:36 +0000 (07:43 +0000)
committerBenjamin Kosnik <bkoz@gcc.gnu.org>
Fri, 14 Sep 2001 07:43:36 +0000 (07:43 +0000)
2001-09-14  Benjamin Kosnik  <bkoz@redhat.com>

* include/bits/locale_facets.tcc: Conditionalize use of strtold.

From-SVN: r45591

libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/locale_facets.tcc

index 66a4b8e759c663d954a007e54e66972e3bb29e4f..e22c32a05d7991baaf0306824788a22b885b3969 100644 (file)
@@ -1,4 +1,8 @@
-2001-09-13   Benjamin Kosnik  <bkoz@redhat.com>
+2001-09-14  Benjamin Kosnik  <bkoz@redhat.com>
+
+       * include/bits/locale_facets.tcc: Conditionalize use of strtold.
+
+2001-09-13  Benjamin Kosnik  <bkoz@redhat.com>
 
        Implement std::money_get.
        * include/bits/locale_facets.tcc (money_get::do_get): Implement.
index ccf227e19cd0095a7c4d303e5743c23b3bfe28ed..b3dcca8d7eaca1a9a3bd7269a9dc35e2e5373513 100644 (file)
@@ -244,12 +244,21 @@ namespace std
       const _CharT* __wcs = __str.c_str();
       __ctype.narrow(__wcs, __wcs + __str.size() + 1, char(), __cs);      
 
+#if defined(_GLIBCPP_USE_C99) && !defined(__hpux)
       char* __sanity;
       errno = 0;
       long double __ld = strtold(__cs, &__sanity);
       if (!(__err & ios_base::failbit)
           && __sanity != __cs && *__sanity == '\0' && errno == 0)
         __units = __ld;
+#else
+      typedef typename char_traits<_CharT>::int_type int_type;
+      long double __ld;
+      int __p = sscanf(__cs, "%Lf", &__ld);
+      if (!(__err & ios_base::failbit)
+         && __p && static_cast<int_type>(__p) != char_traits<_CharT>::eof())
+        __units = __ld;
+#endif
       return __s;
     }
 
@@ -998,7 +1007,6 @@ namespace std
       return __beg;
     }
 
-#if defined(_GLIBCPP_USE_C99) && !defined(__hpux)
   template<typename _CharT, typename _InIter>
     _InIter
     num_get<_CharT, _InIter>::
@@ -1012,6 +1020,7 @@ namespace std
       int __base;
       _M_extract(__beg, __end, __io, __err, __xtrc, __base, true);
 
+#if defined(_GLIBCPP_USE_C99) && !defined(__hpux)
       // Stage 2: convert and store results.
       char* __sanity;
       errno = 0;
@@ -1019,23 +1028,7 @@ namespace std
       if (!(__err & ios_base::failbit)
           && __sanity != __xtrc && *__sanity == '\0' && errno == 0)
         __v = __ld;
-      else
-        __err |= ios_base::failbit;
-
-      return __beg;
-    }
 #else
-  template<typename _CharT, typename _InIter>
-    _InIter
-    num_get<_CharT, _InIter>::
-    do_get(iter_type __beg, iter_type __end, ios_base& __io,
-           ios_base::iostate& __err, long double& __v) const
-    {
-      // Stage 1: extract
-      char __xtrc[32]= {'\0'};
-      int __base;
-      _M_extract(__beg, __end, __io, __err, __xtrc, __base, true);
-
       // Stage 2: determine a conversion specifier.
       ios_base::fmtflags __basefield = __io.flags() & ios_base::basefield;
       const char* __conv;
@@ -1046,21 +1039,21 @@ namespace std
       else if (__basefield == 0)
         __conv = "%Li";
       else
-        __conv = "%Lg";
+        __conv = "%Lf";
 
       // Stage 3: store results.
+      typedef typename __traits_type::int_type int_type;
       long double __ld;
       int __p = sscanf(__xtrc, __conv, &__ld);
-      if (__p
-          && static_cast<typename __traits_type::int_type>(__p)
-        != __traits_type::eof())
+      if (!(__err & ios_base::failbit) && __p 
+         && static_cast<int_type>(__p) != __traits_type::eof())
         __v = __ld;
+#endif
       else
         __err |= ios_base::failbit;
 
       return __beg;
     }
-#endif
 
   template<typename _CharT, typename _InIter>
     _InIter