Re: BUG #2192: misbehaving IRIX strtod() subverts parsing of

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: John Jorgensen <John(dot)Jorgensen(at)uregina(dot)ca>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #2192: misbehaving IRIX strtod() subverts parsing of
Date: 2006-01-26 22:33:54
Message-ID: 200601262233.k0QMXs323482@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs


Would you ask SGI to fix the bug?

+ /* The IRIX strtod() accepts "infinity" or
+ * "-infinity", but it leaves endptr pointing at
+ * "inity" and seems to ignore the negative sign. */

---------------------------------------------------------------------------

John Jorgensen wrote:
>
> The following bug has been logged online:
>
> Bug reference: 2192
> Logged by: John Jorgensen
> Email address: John(dot)Jorgensen(at)uregina(dot)ca
> PostgreSQL version: 8.1.1
> Operating system: IRIX 6.5.22f
> Description: misbehaving IRIX strtod() subverts parsing of "infinity"
> Details:
>
> When I ran "gmake check", the float4 and float8 tests failed because syntax
> errors were reported for "infinity" and "-infinity". I was able to make the
> test pass by applying the appended patch, made on the model of the existing
> patch for Solaris's strtod() (I understand that IRIX is probably becoming
> rare enough that you might not want to clutter your source tree with the
> patch).
>
>
> diff -ur /nobackup/src/postgresql-8.1.1/./src/backend/utils/adt/float.c
> ./src/backend/utils/adt/float.c
> --- /nobackup/src/postgresql-8.1.1/./src/backend/utils/adt/float.c
> 2005-10-14 20:49:28.000000000 -0600
> +++ ./src/backend/utils/adt/float.c 2006-01-20 10:44:25.000000000 -0600
> @@ -326,6 +326,32 @@
> if (endptr != num && endptr[-1] == '\0')
> endptr--;
> }
> +#else
> +#ifdef HAVE_BUGGY_IRIX_STRTOD
> + else
> + {
> + /* The IRIX strtod() accepts "infinity" or
> + * "-infinity", but it leaves endptr pointing at
> + * "inity" and seems to ignore the negative sign. */
> + if (isinf(val))
> + {
> + if (endptr == (num + 3)
> + && (! strncasecmp(endptr, "inity",
> sizeof("inity") - 1)))
> + {
> + endptr += sizeof("inity") - 1;
> + }
> + if (endptr == (num + 4) && *num == '-'
> + && (! strncasecmp(endptr, "inity",
> sizeof("inity") - 1)))
> + {
> + if (is_infinite(val) == 1)
> + {
> + val = -val;
> + }
> + endptr += sizeof("inity") - 1;
> + }
> + }
> + }
> +#endif /* HAVE_BUGGY_IRIX_STRTOD */
> #endif /* HAVE_BUGGY_SOLARIS_STRTOD */
>
> /* skip trailing whitespace */
> @@ -493,6 +519,32 @@
> if (endptr != num && endptr[-1] == '\0')
> endptr--;
> }
> +#else
> +#ifdef HAVE_BUGGY_IRIX_STRTOD
> + else
> + {
> + /* The IRIX strtod() accepts "infinity" or
> + * "-infinity", but it leaves endptr pointing at
> + * "inity" and seems to ignore the negative sign. */
> + if (isinf(val))
> + {
> + if (endptr == (num + 3)
> + && (! strncasecmp(endptr, "inity",
> sizeof("inity") - 1)))
> + {
> + endptr += sizeof("inity") - 1;
> + }
> + if (endptr == (num + 4) && *num == '-'
> + && (! strncasecmp(endptr, "inity",
> sizeof("inity") - 1)))
> + {
> + if (is_infinite(val) == 1)
> + {
> + val = -val;
> + }
> + endptr += sizeof("inity") - 1;
> + }
> + }
> + }
> +#endif /* HAVE_BUGGY_IRIX_STRTOD */
> #endif /* HAVE_BUGGY_SOLARIS_STRTOD */
>
> /* skip trailing whitespace */
> diff -ur /nobackup/src/postgresql-8.1.1/./src/include/port/irix.h
> ./src/include/port/irix.h
> --- /nobackup/src/postgresql-8.1.1/./src/include/port/irix.h 2006-01-19
> 14:10:38.000000000 -0600
> +++ ./src/include/port/irix.h 2006-01-19 17:10:44.000000000 -0600
> @@ -1 +1,5 @@
> -
> +/*
> + * IRIX 6.5.26f and 6.5.22f (at least) have a strtod() that accepts
> + * "infinity", but leaves endptr pointing to "inity".
> + */
> +#define HAVE_BUGGY_IRIX_STRTOD
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: Don't 'kill -9' the postmaster
>

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Bruce Momjian 2006-01-26 22:42:27 Re: improper estimates even with high statistic values
Previous Message Bruce Momjian 2006-01-26 19:24:55 Re: BUG #2195: log_min_messages crash server when in DEBUG3 to