Fix sscanf/wcstod parsing of NaNs.
The parsefloat routines -- which let us pass NaNs and infinities on to
strto(f|d|ld) -- come from NetBSD.
Also fix LP64's strtold to return a NaN, and fix all the architectures
to return quiet NaNs.
Also fix wcstof/wcstod/wcstold to use parsefloat so they support hex
floats.
Lots of new tests.
Bug: http://b/31101647
Change-Id: Id7d46ac2d8acb8770b5e8c445e87cfabfde6f111
diff --git a/libc/stdio/local.h b/libc/stdio/local.h
index 7be5a7c..575a428 100644
--- a/libc/stdio/local.h
+++ b/libc/stdio/local.h
@@ -147,11 +147,7 @@
#define __SNPT 0
#define __SOPT 0
-#if defined(__cplusplus)
-#define _EXT(fp) reinterpret_cast<__sfileext*>((fp)->_ext._base)
-#else
-#define _EXT(fp) ((struct __sfileext *)((fp)->_ext._base))
-#endif
+#define _EXT(fp) __BIONIC_CAST(reinterpret_cast, struct __sfileext*, (fp)->_ext._base)
#define _UB(fp) _EXT(fp)->_ub
#define _FLOCK(fp) _EXT(fp)->_lock
@@ -171,7 +167,7 @@
#define _FILEEXT_SETUP(f, fext) \
do { \
- (f)->_ext._base = (unsigned char *)(fext); \
+ (f)->_ext._base = __BIONIC_CAST(reinterpret_cast, unsigned char*, fext); \
_FILEEXT_INIT(f); \
} while (0)
@@ -259,6 +255,9 @@
extern void __sinit(void); // Not actually implemented.
#define __sdidinit 1
+size_t parsefloat(FILE*, char*, char*);
+size_t wparsefloat(FILE*, wchar_t*, wchar_t*);
+
__END_DECLS
#endif