dbTalk Databases Forums  

[BUGS] BUG #2192: misbehaving IRIX strtod() subverts parsing of "infinity"

mailing.database.pgsql-bugs mailing.database.pgsql-bugs


Discuss [BUGS] BUG #2192: misbehaving IRIX strtod() subverts parsing of "infinity" in the mailing.database.pgsql-bugs forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
John Jorgensen
 
Posts: n/a

Default [BUGS] BUG #2192: misbehaving IRIX strtod() subverts parsing of "infinity" - 01-21-2006 , 07:57 PM







The following bug has been logged online:

Bug reference: 2192
Logged by: John Jorgensen
Email address: John.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

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.