From: Marcin B. <ma...@gm...> - 2010-03-13 13:35:52
|
2010/3/13 Karl Schultz <kar...@gm...>: > In some locales, a comma can be used as a decimal place. That is, 5,2 is a > number between 5 and 6. (I think I have that right) I would guess that the > shader language, like C, wouldn't allow this form in code. So, it makes > sense to force the C locale when parsing numbers from shader source code, as > the code does above. > > strtof doesn't show up until C99 and not all compilers support it, including > the MSFT Windows compilers. Ian says that all usages of this function want > a float anyway, so we may end up with something like: > > float > _mesa_strtof( const char *s, char **end ) > { > #ifdef _GNU_SOURCE > static locale_t loc = NULL; > if (!loc) { > loc = newlocale(LC_CTYPE_MASK, "C", NULL); > } > return (float) strtod_l(s, end, loc); > #else > return (float) strtod(s, end); > #endif > } > > And then change all _mesa_strtod to _mesa_strtof. > > If Ian doesn't care for the casts here, then I'm fine with silencing > warnings in the Studio with a compiler option. Attached patch uses strtof when it is available. |