From 6dc122b424ca8342362269051496a3ffa6d55add Mon Sep 17 00:00:00 2001 From: David Nadlinger Date: Wed, 20 Feb 2013 23:45:11 +0100 Subject: [PATCH] MinGW: Use __mingw_strtold instead of strtold. The latter fails to parse hex floating point literals. --- dmd2/expression.c | 2 ++ dmd2/lexer.c | 2 ++ dmd2/root/port.c | 15 +++++++++++++++ dmd2/root/port.h | 3 +++ 4 files changed, 22 insertions(+) diff --git a/dmd2/expression.c b/dmd2/expression.c index bac1ed3f..a410a390 100644 --- a/dmd2/expression.c +++ b/dmd2/expression.c @@ -2620,6 +2620,8 @@ void floatToBuffer(OutBuffer *buf, Type *type, real_t value) __locale_decpoint = "."; real_t r = strtold(buffer, NULL); __locale_decpoint = save; +#elif IN_LLVM + real_t r = Port::strtold(buffer, NULL); #else real_t r = strtold(buffer, NULL); #endif diff --git a/dmd2/lexer.c b/dmd2/lexer.c index 2e53a992..a142ad78 100644 --- a/dmd2/lexer.c +++ b/dmd2/lexer.c @@ -2364,6 +2364,8 @@ done: #endif #ifdef IN_GCC t->float80value = real_t::parse((char *)stringbuffer.data, real_t::LongDouble); +#elif IN_LLVM + t->float80value = Port::strtold((char *)stringbuffer.data, NULL); #else t->float80value = strtold((char *)stringbuffer.data, NULL); #endif diff --git a/dmd2/root/port.c b/dmd2/root/port.c index 549f77ba..238059a6 100644 --- a/dmd2/root/port.c +++ b/dmd2/root/port.c @@ -670,3 +670,18 @@ char *Port::strupr(char *s) } #endif + + +#if IN_LLVM +#if __MINGW32__ +longdouble Port::strtold(const char *str, char **pend) +{ + return __mingw_strtold(str, pend); +} +#else +longdouble Port::strtold(const char *str, char **pend) +{ + return ::strtold(str, pend); +} +#endif +#endif diff --git a/dmd2/root/port.h b/dmd2/root/port.h index cdb6d429..8d4136aa 100644 --- a/dmd2/root/port.h +++ b/dmd2/root/port.h @@ -61,6 +61,9 @@ struct Port static longdouble fmodl(longdouble x, longdouble y); static ulonglong strtoull(const char *p, char **pend, int base); +#if IN_LLVM + static longdouble strtold(const char *str, char **pend); +#endif static char *ull_to_string(char *buffer, ulonglong ull); static wchar_t *ull_to_string(wchar_t *buffer, ulonglong ull);