[comp.unix.wizards] bug in strtod in SunOS 3.2

dan@srs.UUCP (Dan Kegel) (07/22/88)

Sun's strtod is supposed to pass a pointer to the first char after the float
that was parsed, but it seems to think that the terminating null char is
part of the float.
Is this 'fixed in 4.0'?

Repeat by running this program:
    #include <stdio.h>

    main()
    {
	double strtod();
	char *str = "42";
	char *p;
	float foo;

	foo = strtod(str, &p);
	printf("str = %s; strtod(str,&p) returns %f, p - str = %d, *p = %d\n",
	    str, foo, p - str, *p);
    }
Here's the output of the program on an IBM PC running MSC 4.0, showing correct
result:
    str = 42; strtod(str,&p) returns 42.000000, p - str = 2, *p = 0

Here's the output of the program on a Sun-3 running SunOS 3.2, showing wrong
result:
    str = 42; strtod(str,&p) returns 42.000000, p - str = 3, *p = 115

----
Dan Kegel   "We had to get it passed before the columnists attacked!"
srs!dan@cs.rochester.edu  rochester!srs!dan dan%srs.uucp@harvard.harvard.edu

p.s.  What kind of tests does Sun use to check every library function before
shipping a new release?
-- 
  Dan Kegel   "We had to get it passed before the columnists attacked!"
  srs!dan@cs.rochester.edu  rochester!srs!dan dan%srs.uucp@harvard.harvard.edu

guy@gorodish.Sun.COM (Guy Harris) (07/22/88)

In article <936@srs.UUCP>, dan@srs.UUCP (Dan Kegel) writes:
> Sun's strtod is supposed to pass a pointer to the first char after the float
> that was parsed, but it seems to think that the terminating null char is
> part of the float.

So do lots of other people's; our "strtod" is the System V Release 2.0 one,
changed only so that it properly decides which machines are IEEE ones.

> Is this 'fixed in 4.0'?

Yes.  Our version is fixed in 4.0; AT&T's is fixed in S5R3, I think, or perhaps
earlier (although the versions now share no common code).