]> granicus.if.org Git - postgresql/commitdiff
Work around broken strtod() that's present in many Solaris releases.
authorTom Lane <tgl@sss.pgh.pa.us>
Wed, 11 Aug 2004 17:20:50 +0000 (17:20 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 11 Aug 2004 17:20:50 +0000 (17:20 +0000)
Thanks to Michael Fuhr for identifying the problem.

src/backend/utils/adt/float.c
src/include/port/solaris.h

index c300d79f216012b365ffb7b605160a0c39d0acd5..f0d57a1edfad6b8daf0c6c5d00768cc510790c88 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/utils/adt/float.c,v 1.106 2004/08/04 21:34:02 tgl Exp $
+ *       $PostgreSQL: pgsql/src/backend/utils/adt/float.c,v 1.107 2004/08/11 17:20:49 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -317,6 +317,18 @@ float4in(PG_FUNCTION_ARGS)
                                         errmsg("invalid input syntax for type real: \"%s\"",
                                                        orig_num)));
        }
+#ifdef HAVE_BUGGY_SOLARIS_STRTOD
+       else
+       {
+               /*
+                * Many versions of Solaris have a bug wherein strtod sets endptr
+                * to point one byte beyond the end of the string when given
+                * "inf" or "infinity".
+                */
+               if (endptr != num && endptr[-1] == '\0')
+                       endptr--;
+       }
+#endif /* HAVE_BUGGY_SOLARIS_STRTOD */
 
        /* skip trailing whitespace */
        while (*endptr != '\0' && isspace((unsigned char) *endptr))
@@ -482,6 +494,18 @@ float8in(PG_FUNCTION_ARGS)
                                         errmsg("invalid input syntax for type double precision: \"%s\"",
                                                        orig_num)));
        }
+#ifdef HAVE_BUGGY_SOLARIS_STRTOD
+       else
+       {
+               /*
+                * Many versions of Solaris have a bug wherein strtod sets endptr
+                * to point one byte beyond the end of the string when given
+                * "inf" or "infinity".
+                */
+               if (endptr != num && endptr[-1] == '\0')
+                       endptr--;
+       }
+#endif /* HAVE_BUGGY_SOLARIS_STRTOD */
 
        /* skip trailing whitespace */
        while (*endptr != '\0' && isspace((unsigned char) *endptr))
index f37e2a2a88b8f6eaaa172ca5b69c4eecb926dab7..0584d9291c46cb4615f9566791defc4b2a7b684d 100644 (file)
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/src/include/port/solaris.h,v 1.11 2004/03/15 03:29:22 tgl Exp $ */
+/* $PostgreSQL: pgsql/src/include/port/solaris.h,v 1.12 2004/08/11 17:20:50 tgl Exp $ */
 
 /*
  * Sort this out for all operating systems some time.  The __xxx
 #define                 BYTE_ORDER              LITTLE_ENDIAN
 #endif
 #endif
+
+/*
+ * Many versions of Solaris have broken strtod() --- see bug #4751182.
+ * For the moment we just assume they all do; it's probably not worth
+ * the trouble to add a configure test for this.
+ */
+#define HAVE_BUGGY_SOLARIS_STRTOD