]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/commit
MFC r308904
authorvangyzen <vangyzen@ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f>
Wed, 30 Nov 2016 20:48:44 +0000 (20:48 +0000)
committervangyzen <vangyzen@ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f>
Wed, 30 Nov 2016 20:48:44 +0000 (20:48 +0000)
commitff709d07519a08b801aac9e5007a0aea9f230e9b
tree7c6e0b6a2e675962a8a192d039e487c0db63e780
parentebc8393a3cc90a6525b3010ff58e28232cd6d3ff
MFC r308904

Fix error reporting from wcstof()

When wcstof() skipped initial space and then parsing failed, it set
endptr to the first non-space character.  Fix it to correctly report
failure by setting endptr to the beginning of the input string.
The fix is from theraven@, who fixed this bug in wcstod() and
wcstold() in r227753.

While I'm here:

Move assignments out of declarations in wcstod() and wcstold().
This is against my personal preference, but it is our agreed style(9).

Set endptr correctly on malloc() failure in all three functions.

Remove an incorrect comment:  This is pointer arithmetic,
so the code was not actually making that assumption.

wcstold() advanced the wcp pointer beyond leading whitespace
and then reset it back to the beginning of the string.
Do not reset it.  This seems to have no functional effect,
since strtold_l() also skips leading whitespace.  I'm making
the change to keep this function consistent with wcstof() and
wcstod(), and because the C11 spec prescribes the use of iswspace()
to skip leading space.

Reported by: libc++ unit test for std::stof(std::wstring)
Sponsored by: Dell EMC

git-svn-id: svn://svn.freebsd.org/base/stable/10@309334 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
lib/libc/locale/wcstod.c
lib/libc/locale/wcstof.c
lib/libc/locale/wcstold.c