bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: strtod error handling


From: Eric Blake
Subject: Re: strtod error handling
Date: Sat, 24 Jan 2009 06:38:29 -0700
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.19) Gecko/20081209 Thunderbird/2.0.0.19 Mnenhy/0.7.5.666

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Bruno Haible on 1/24/2009 6:34 AM:
> 
>>> +   - In case of other error, return 0 and set errno, for example to EINVAL
>>> +     or ENOMEM.  */
>> I think that POSIX is explicit that the only way to fail strtod() with
>> EINVAL is if nothing was parsed
> 
> No, other reasons are allowed as well. See  
> <http://www.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_03>
>   "Implementations may support additional errors not included in this list,
>    may generate errors included in this list under circumstances other than
>    those described here, or ..."

Finish reading that paragraph:

"...if and only if all those error conditions can always be treated
identically to the error conditions as described in this volume of
POSIX.1-2008. Implementations shall not generate a different error number
from one required by this volume of POSIX.1-2008 for an error condition
described in this volume of POSIX.1-2008, but may generate additional
errors unless explicitly disallowed for a particular function."

ENOMEM is an additional error not mentioned in POSIX, but for which the
semantics of the error make sense.  But returning EINVAL for any reason
other than an invalid parse where *endptr == nptr, is a condition of
returning an error specified by POSIX but for a different reason than
allowed by POSIX.

- --
Don't work too hard, make some time for fun as well!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkl7GdUACgkQ84KuGfSFAYA1ggCfXTV2NA7AUXU0sBcS2Bd92pkS
wyQAnjwfd+8leXOgKSoSahX6H6ycvSLK
=fTa3
-----END PGP SIGNATURE-----




reply via email to

[Prev in Thread] Current Thread [Next in Thread]