From 0b5989c51a8bf2d5fb0eb574a31bc6b72af99949 Mon Sep 17 00:00:00 2001 From: David Nadlinger Date: Sun, 26 May 2013 19:10:08 +0200 Subject: [PATCH] MinGW: Use actually working strtold. Like their whole runtime in general, the MSVC version does not handle 80 bit reals/long doubles. --- dmd2/expression.c | 2 +- dmd2/lexer.c | 2 +- dmd2/root/port.c | 23 +++++++++++++++++++++++ dmd2/root/port.h | 4 ++-- 4 files changed, 27 insertions(+), 4 deletions(-) diff --git a/dmd2/expression.c b/dmd2/expression.c index 9fd2eb1c..2e7aeeb6 100644 --- a/dmd2/expression.c +++ b/dmd2/expression.c @@ -2567,7 +2567,7 @@ void floatToBuffer(OutBuffer *buf, Type *type, real_t value) real_t r = strtold(buffer, NULL); __locale_decpoint = save; #else - real_t r = strtold(buffer, NULL); + real_t r = Port::strtold(buffer, NULL); #endif #if IN_LLVM if (r == value) // if exact duplication diff --git a/dmd2/lexer.c b/dmd2/lexer.c index 2e53a992..4d92e357 100644 --- a/dmd2/lexer.c +++ b/dmd2/lexer.c @@ -2365,7 +2365,7 @@ done: #ifdef IN_GCC t->float80value = real_t::parse((char *)stringbuffer.data, real_t::LongDouble); #else - t->float80value = strtold((char *)stringbuffer.data, NULL); + t->float80value = Port::strtold((char *)stringbuffer.data, NULL); #endif errno = 0; float strtofres; diff --git a/dmd2/root/port.c b/dmd2/root/port.c index e486523c..4422809a 100644 --- a/dmd2/root/port.c +++ b/dmd2/root/port.c @@ -348,6 +348,14 @@ int Port::stricmp(const char *s1, const char *s2) return ::stricmp(s1, s2); } +// See vcbuild/strtold.c. +longdouble strtold(const char *p, char **endp); + +longdouble Port::strtold(const char *p, char **endp) +{ + return ::strtold(p, endp); +} + #endif #if __MINGW32__ @@ -527,6 +535,11 @@ int Port::stricmp(const char *s1, const char *s2) return result; } +longdouble Port::strtold(const char *p, char **endp) +{ + return ::__mingw_strtold(p, endp); +} + #endif #if linux || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __HAIKU__ @@ -765,6 +778,11 @@ int Port::stricmp(const char *s1, const char *s2) return result; } +longdouble Port::strtold(const char *p, char **endp) +{ + return ::strtold(p, endp); +} + #endif #if __sun @@ -910,4 +928,9 @@ char *Port::strupr(char *s) return t; } +longdouble Port::strtold(const char *p, char **endp) +{ + return ::strtold(p, endp); +} + #endif diff --git a/dmd2/root/port.h b/dmd2/root/port.h index 770181ca..41c2aaff 100644 --- a/dmd2/root/port.h +++ b/dmd2/root/port.h @@ -19,8 +19,6 @@ #if _MSC_VER #include // for _isnan #include // for alloca -// According to VC 8.0 docs, long double is the same as double -longdouble strtold(const char *p,char **endp); #define strtof strtod #define isnan _isnan @@ -72,6 +70,8 @@ struct Port static int memicmp(const char *s1, const char *s2, int n); static int stricmp(const char *s1, const char *s2); + + static longdouble strtold(const char *p, char **endp); }; #endif