Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b2d9fbe

Browse files
committed
Work around broken strtod() that's present in many Solaris releases.
Thanks to Michael Fuhr for identifying the problem.
1 parent 178ec6f commit b2d9fbe

File tree

2 files changed

+33
-2
lines changed

2 files changed

+33
-2
lines changed

src/backend/utils/adt/float.c

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/utils/adt/float.c,v 1.106 2004/08/04 21:34:02 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/utils/adt/float.c,v 1.107 2004/08/11 17:20:49 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -317,6 +317,18 @@ float4in(PG_FUNCTION_ARGS)
317317
errmsg("invalid input syntax for type real: \"%s\"",
318318
orig_num)));
319319
}
320+
#ifdef HAVE_BUGGY_SOLARIS_STRTOD
321+
else
322+
{
323+
/*
324+
* Many versions of Solaris have a bug wherein strtod sets endptr
325+
* to point one byte beyond the end of the string when given
326+
* "inf" or "infinity".
327+
*/
328+
if (endptr != num && endptr[-1] == '\0')
329+
endptr--;
330+
}
331+
#endif /* HAVE_BUGGY_SOLARIS_STRTOD */
320332

321333
/* skip trailing whitespace */
322334
while (*endptr != '\0' && isspace((unsigned char) *endptr))
@@ -482,6 +494,18 @@ float8in(PG_FUNCTION_ARGS)
482494
errmsg("invalid input syntax for type double precision: \"%s\"",
483495
orig_num)));
484496
}
497+
#ifdef HAVE_BUGGY_SOLARIS_STRTOD
498+
else
499+
{
500+
/*
501+
* Many versions of Solaris have a bug wherein strtod sets endptr
502+
* to point one byte beyond the end of the string when given
503+
* "inf" or "infinity".
504+
*/
505+
if (endptr != num && endptr[-1] == '\0')
506+
endptr--;
507+
}
508+
#endif /* HAVE_BUGGY_SOLARIS_STRTOD */
485509

486510
/* skip trailing whitespace */
487511
while (*endptr != '\0' && isspace((unsigned char) *endptr))

src/include/port/solaris.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/include/port/solaris.h,v 1.11 2004/03/15 03:29:22 tgl Exp $ */
1+
/* $PostgreSQL: pgsql/src/include/port/solaris.h,v 1.12 2004/08/11 17:20:50 tgl Exp $ */
22

33
/*
44
* Sort this out for all operating systems some time. The __xxx
@@ -35,3 +35,10 @@
3535
#define BYTE_ORDER LITTLE_ENDIAN
3636
#endif
3737
#endif
38+
39+
/*
40+
* Many versions of Solaris have broken strtod() --- see bug #4751182.
41+
* For the moment we just assume they all do; it's probably not worth
42+
* the trouble to add a configure test for this.
43+
*/
44+
#define HAVE_BUGGY_SOLARIS_STRTOD

0 commit comments

Comments
 (0)