[Mesa-dev] [PATCH] tgsi: fix parsing nan float inputs

Roland Scheidegger sroland at vmware.com
Tue Oct 11 00:46:08 UTC 2016


Am 10.10.2016 um 23:57 schrieb Roland Mainz:
> On Mon, Oct 10, 2016 at 11:40 PM, Ilia Mirkin <imirkin at alum.mit.edu> wrote:
>> On Mon, Oct 10, 2016 at 5:36 PM, Roland Mainz <roland.mainz at nrubsig.org> wrote:
>>> On Mon, Oct 10, 2016 at 6:12 PM, Ilia Mirkin <imirkin at alum.mit.edu> wrote:
>>>> Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>
>>>> ---
>>>>  src/gallium/auxiliary/tgsi/tgsi_text.c | 7 ++++++-
>>>>  1 file changed, 6 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/src/gallium/auxiliary/tgsi/tgsi_text.c b/src/gallium/auxiliary/tgsi/tgsi_text.c
>>>> index be80842..36dc979 100644
>>>> --- a/src/gallium/auxiliary/tgsi/tgsi_text.c
>>>> +++ b/src/gallium/auxiliary/tgsi/tgsi_text.c
>>>> @@ -257,8 +257,13 @@ static boolean parse_float( const char **pcur, float *val )
>>>>              cur++;
>>>>        }
>>>>     }
>>>> -   if (!integral_part && !fractional_part)
>>>> +   if (!integral_part && !fractional_part) {
>>>> +      if (uprcase(*cur++) == 'N' &&
>>>> +          uprcase(*cur++) == 'A' &&
>>>> +          uprcase(*cur++) == 'N')
>>>> +         goto out;
>>>>        return FALSE;
>>>> +   }
>>>>     if (uprcase( *cur ) == 'E') {
>>>>        cur++;
>>>>        if (*cur == '-' || *cur == '+')
>>>
>>> Not digging around in the code... but...
>>> ... do you handle -nan and +nan ?
>>
>> Further up:
>>
>>    *val = (float) atof( cur );
>>    if (*cur == '-' || *cur == '+')
>>       cur++;
> 
> Thanks... :-)
> 
>> I'd kinda prefer to use strtof() and get rid of this function. Does
>> that work on MSVC?
> 
> No idea... ;-(
> 

According to docs, it should work starting with msvc 12.0 (vs 2013).

Roland




More information about the mesa-dev mailing list