[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [5480] Refactor
From: |
Greg Chicares |
Subject: |
[lmi-commits] [5480] Refactor |
Date: |
Sun, 03 Jun 2012 18:29:28 +0000 |
Revision: 5480
http://svn.sv.gnu.org/viewvc/?view=rev&root=lmi&revision=5480
Author: chicares
Date: 2012-06-03 18:29:28 +0000 (Sun, 03 Jun 2012)
Log Message:
-----------
Refactor
Modified Paths:
--------------
lmi/trunk/config.hpp
lmi/trunk/config_ming323.hpp
lmi/trunk/numeric_io_cast.hpp
lmi/trunk/numeric_io_traits.hpp
Modified: lmi/trunk/config.hpp
===================================================================
--- lmi/trunk/config.hpp 2012-05-31 17:26:12 UTC (rev 5479)
+++ lmi/trunk/config.hpp 2012-06-03 18:29:28 UTC (rev 5480)
@@ -129,6 +129,10 @@
# define LMI_MSC
#endif // defined _MSC_VER && !defined LMI_GCC_VERSION && !defined
LMI_COMO_WITH_MINGW
+#if defined LMI_COMO_WITH_MINGW || defined LMI_MSC || defined __MINGW32__ &&
defined LMI_GCC_VERSION && LMI_GCC_VERSION < 30405
+# define LMI_MSVCRT
+#endif // Compilers that use the msvc C runtime, without corrections such as
libmingwex.
+
#if defined HAVE_CONFIG_H // Using autoconf.
# include "config.h"
#else // Not using autoconf.
Modified: lmi/trunk/config_ming323.hpp
===================================================================
--- lmi/trunk/config_ming323.hpp 2012-05-31 17:26:12 UTC (rev 5479)
+++ lmi/trunk/config_ming323.hpp 2012-06-03 18:29:28 UTC (rev 5480)
@@ -47,10 +47,6 @@
# define LMI_COMPILER_PROVIDES_EXPM1L
#endif // 308 <= LMI_MINGW_VERSION
-#if 200 <= LMI_MINGW_VERSION
-# define LMI_COMPILER_PROVIDES_ISNAN
-#endif // 200 <= LMI_MINGW_VERSION
-
#if 202 <= LMI_MINGW_VERSION
# define LMI_COMPILER_PROVIDES_LOG1PL
#endif // 202 <= LMI_MINGW_VERSION
@@ -59,13 +55,5 @@
# define LMI_COMPILER_PROVIDES_RINT
#endif // 200 <= LMI_MINGW_VERSION
-#if 200 <= LMI_MINGW_VERSION
-# define LMI_COMPILER_PROVIDES_STRTOF
-#endif // 200 <= LMI_MINGW_VERSION
-
-#if 204 <= LMI_MINGW_VERSION
-# define LMI_COMPILER_PROVIDES_STRTOLD
-#endif // 204 <= LMI_MINGW_VERSION
-
#endif // config_ming323_hpp
Modified: lmi/trunk/numeric_io_cast.hpp
===================================================================
--- lmi/trunk/numeric_io_cast.hpp 2012-05-31 17:26:12 UTC (rev 5479)
+++ lmi/trunk/numeric_io_cast.hpp 2012-06-03 18:29:28 UTC (rev 5480)
@@ -310,14 +310,14 @@
}
else
{
-#if defined LMI_MSC || defined LMI_COMO_WITH_MINGW
- // COMPILER !! MSVC formats infinity into a string as "1.#INF", not
- // "inf" as gcc does and C99/C++11 mandates. Translate it manually.
+#if defined LMI_MSVCRT
+ // COMPILER !! This C runtime formats infinity as "1.#INF".
+ // Instead, force C99 "inf".
if(0 == std::strcmp(buffer, "1.#INF"))
{
return "inf";
}
-#endif // defined LMI_MSC || defined LMI_COMO_WITH_MINGW
+#endif // defined LMI_MSVCRT
return numeric_conversion_traits<From>::simplify(To(buffer));
}
}
Modified: lmi/trunk/numeric_io_traits.hpp
===================================================================
--- lmi/trunk/numeric_io_traits.hpp 2012-05-31 17:26:12 UTC (rev 5479)
+++ lmi/trunk/numeric_io_traits.hpp 2012-06-03 18:29:28 UTC (rev 5480)
@@ -81,15 +81,16 @@
inline int floating_point_decimals(T t)
{
BOOST_STATIC_ASSERT(boost::is_float<T>::value);
-#if defined LMI_MSC || defined LMI_COMO_WITH_MINGW
- // COMPILER !! Not only does MSVC write infinity as "1.#INF" rather
- // than "inf", it respects decimals specification, "shortening" it
- // into "1." if we return 0 here.
+#if defined LMI_MSVCRT
+ // COMPILER !! This C runtime not only writes infinity as "1.#INF"
+ // instead of "inf" but also "respects" the precision specifier
+ // when doing so, truncating it to "1." if this function were to
+ // return zero.
if(is_infinite(t))
{
return 4;
}
-#endif // defined LMI_MSC || defined LMI_COMO_WITH_MINGW
+#endif // defined LMI_MSVCRT
// Avoid taking the logarithm of zero or infinity.
if(0 == t || is_infinite(t))
{
@@ -328,11 +329,11 @@
{return simplify_floating_point(s);}
};
-#if !defined LMI_COMPILER_PROVIDES_STRTOF
+#if defined LMI_MSVCRT
// COMPILER !! This workaround is rather poor, of course.
inline float strtof(char const* nptr, char** endptr)
{return std::strtod(nptr, endptr);}
-#endif // !defined LMI_COMPILER_PROVIDES_STRTOF
+#endif // defined LMI_MSVCRT
template<> struct numeric_conversion_traits<float>
:public numeric_conversion_traits<Floating>
@@ -342,8 +343,8 @@
static char const* fmt() {return "%#.*f";}
static T strtoT(char const* nptr, char** endptr)
{
-#if defined LMI_MSC || defined LMI_COMO_WITH_MINGW
- // COMPILER !! MSVC strtod() doesn't support C99 "inf[inity]" nor
+#if defined LMI_MSVCRT
+ // COMPILER !! This C runtime's strtod() doesn't support C99
"inf[inity]" nor
// "nan[(...)]" strings nor hexadecimal notation so provide our
// work around for at least the first one of them which we actually
// need. This workaround is, of course, incomplete as it doesn't
@@ -357,7 +358,7 @@
}
return std::numeric_limits<T>::infinity();
}
-#endif // defined LMI_MSC || defined LMI_COMO_WITH_MINGW
+#endif // defined LMI_MSVCRT
return strtof(nptr, endptr);
}
};
@@ -370,8 +371,8 @@
static char const* fmt() {return "%#.*f";}
static T strtoT(char const* nptr, char** endptr)
{
-#if defined LMI_MSC || defined LMI_COMO_WITH_MINGW
- // COMPILER !! MSVC strtod() doesn't support C99 "inf[inity]" nor
+#if defined LMI_MSVCRT
+ // COMPILER !! This C runtime's strtod() doesn't support C99
"inf[inity]" nor
// "nan[(...)]" strings nor hexadecimal notation so provide our
// work around for at least the first one of them which we actually
// need. This workaround is, of course, incomplete as it doesn't
@@ -385,31 +386,29 @@
}
return std::numeric_limits<T>::infinity();
}
-#endif // defined LMI_MSC || defined LMI_COMO_WITH_MINGW
+#endif // defined LMI_MSVCRT
return std::strtod(nptr, endptr);
}
};
-#if !defined LMI_COMPILER_PROVIDES_STRTOLD
+#if defined LMI_MSVCRT
// COMPILER !! This workaround is rather poor, of course.
inline long double strtold(char const* nptr, char** endptr)
{return std::strtod(nptr, endptr);}
-#endif // !defined LMI_COMPILER_PROVIDES_STRTOLD
+#endif // defined LMI_MSVCRT
-// COMPILER !! MinGW gcc-3.x doesn't support "%Lf" correctly because
-// it uses the defective ms C runtime library.
-
template<> struct numeric_conversion_traits<long double>
:public numeric_conversion_traits<Floating>
{
typedef long double T;
static int digits(T t) {return floating_point_decimals(t);}
-#if defined __MINGW32__ && defined __GNUC__ && __GNUC__ == 3
+#if defined LMI_MSVCRT
+// COMPILER !! This C runtime doesn't support "%Lf" correctly.
static char const* fmt()
{throw std::domain_error("Type 'long double' not supported.");}
-#else // Not MinGW gcc prior to version 4.
+#else // !defined LMI_MSVCRT
static char const* fmt() {return "%#.*Lf";}
-#endif // Not MinGW gcc prior to version 4.
+#endif // !defined LMI_MSVCRT
static T strtoT(char const* nptr, char** endptr)
{return strtold(nptr, endptr);}
};
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [lmi-commits] [5480] Refactor,
Greg Chicares <=