lists.zerezo.com
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
***BOGO*** Re: [Mingw-users] strtod is not C99-compatible
- Date: Thu, 01 May 2008 22:22:38 +0100
- From: Ramiro Polla <ramiro@xxxxxxxxxxxxx>
- Subject: ***BOGO*** Re: [Mingw-users] strtod is not C99-compatible
Hello,
Is it possible that a function to replace strtod() with a C99-compliant
implementation be made the same way it was done with snprintf? And then
one would have to call _strtod to get the original MSVCRT version.
This is really the kind of thing that gnulib excels at. You just add
the strtod module to your project and you get a working replacement
strtod() that is guaranteed standards-compliant, on any of many dozens
of platforms, with fallback to the native target's underlying strtod()
if it is non-broken.
FFmpeg doesn't use autotools, and gnulib seems to have some license
implications (GPL might have to be used. I haven't checked though).
I think the same reasoning used to implment _mingw_snprintf() should be
used for a _mingw_strtod(). And I volunteer to implement it.
There already is one implementation in libmingwex, it's just not
exported. Attached (untested) patch should be alright.
Ramiro Polla
Index: mingw/include/stdlib.h
===================================================================
RCS file: /cvs/src/src/winsup/mingw/include/stdlib.h,v
retrieving revision 1.32
diff -u -r1.32 stdlib.h
--- mingw/include/stdlib.h 12 Jul 2007 09:38:17 -0000 1.32
+++ mingw/include/stdlib.h 1 May 2008 22:20:01 -0000
@@ -307,8 +307,9 @@
_CRTIMP int __cdecl __MINGW_NOTHROW _wtoi (const wchar_t *);
_CRTIMP long __cdecl __MINGW_NOTHROW _wtol (const wchar_t *);
#endif
-_CRTIMP double __cdecl __MINGW_NOTHROW strtod (const char*, char**);
+_CRTIMP double __cdecl __MINGW_NOTHROW _strtod (const char*, char**);
#if !defined __NO_ISOCEXT /* in libmingwex.a */
+double __cdecl __MINGW_NOTHROW strtod (const char*, char**);
float __cdecl __MINGW_NOTHROW strtof (const char * __restrict__, char ** __restrict__);
long double __cdecl __MINGW_NOTHROW strtold (const char * __restrict__, char ** __restrict__);
#endif /* __NO_ISOCEXT */
Index: mingw/mingwex/gdtoa/strtodnrp.c
===================================================================
RCS file: /cvs/src/src/winsup/mingw/mingwex/gdtoa/strtodnrp.c,v
retrieving revision 1.1
diff -u -r1.1 strtodnrp.c
--- mingw/mingwex/gdtoa/strtodnrp.c 31 Aug 2006 23:48:56 -0000 1.1
+++ mingw/mingwex/gdtoa/strtodnrp.c 1 May 2008 22:20:01 -0000
@@ -85,3 +85,6 @@
u.L[_0] |= 0x80000000L;
return u.d;
}
+
+double __cdecl strtod(const char *s, char **sp)
+ __attribute__((alias("__strtod")));
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
MinGW-users mailing list
MinGW-users@xxxxxxxxxxxxxxxxxxxxx
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users