diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2004-08-11 17:20:50 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2004-08-11 17:20:50 +0000 |
commit | b2d9fbeef24deb640f8eef90c83625464ecd3c46 (patch) | |
tree | 3699388cefa54e7761645609dac3fd7085c056f3 /src/backend/utils/adt/float.c | |
parent | 178ec6f40e15f0bd161b5b30d77c8c6bcb61b649 (diff) | |
download | postgresql-b2d9fbeef24deb640f8eef90c83625464ecd3c46.tar.gz postgresql-b2d9fbeef24deb640f8eef90c83625464ecd3c46.zip |
Work around broken strtod() that's present in many Solaris releases.
Thanks to Michael Fuhr for identifying the problem.
Diffstat (limited to 'src/backend/utils/adt/float.c')
-rw-r--r-- | src/backend/utils/adt/float.c | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/src/backend/utils/adt/float.c b/src/backend/utils/adt/float.c index c300d79f216..f0d57a1edfa 100644 --- a/src/backend/utils/adt/float.c +++ b/src/backend/utils/adt/float.c @@ -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)) |