legacy strtof inline: don't set errno for "inf"

Bug: https://github.com/android/ndk/issues/415
Test: libc++'s std/strings/string.conversions/stof.pass.cpp
Change-Id: I2c6bab9e31fb1c916be991f72b04735b5df279c2
diff --git a/libc/include/android/legacy_stdlib_inlines.h b/libc/include/android/legacy_stdlib_inlines.h
index aeb1575..6903536 100644
--- a/libc/include/android/legacy_stdlib_inlines.h
+++ b/libc/include/android/legacy_stdlib_inlines.h
@@ -57,13 +57,11 @@
 __BEGIN_DECLS
 
 static __inline float strtof(const char* nptr, char** endptr) {
+  // N.B. Double-rounding makes this function incorrect for some inputs.
   double d = strtod(nptr, endptr);
-  if (d > FLT_MAX) {
+  if (__builtin_isfinite(d) && __builtin_fabs(d) > FLT_MAX) {
     errno = ERANGE;
-    return __builtin_huge_valf();
-  } else if (d < -FLT_MAX) {
-    errno = ERANGE;
-    return -__builtin_huge_valf();
+    return __builtin_copysign(__builtin_huge_valf(), d);
   }
   return __BIONIC_CAST(static_cast, float, d);
 }