Mesa (master): mesa: use C locale for _mesa_strtod()

Alex Deucher agd5f at kemper.freedesktop.org
Mon Oct 19 16:12:31 UTC 2009


Module: Mesa
Branch: master
Commit: 89b31c9619449d5c9b8ebe4e245c2a926e3583e6
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=89b31c9619449d5c9b8ebe4e245c2a926e3583e6

Author: Brian Paul <brianp at vmware.com>
Date:   Wed Oct 14 14:19:03 2009 -0600

mesa: use C locale for _mesa_strtod()

_mesa_strtod() is used for shader/program parsing where the decimal
point character is always '.'  Use strtod_l() with a "C" locale to
ensure correct string->double conversion when the actual locale uses
another character such as ',' for the decimal point.

Fixes bug 24531.

---

 src/mesa/main/imports.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/src/mesa/main/imports.c b/src/mesa/main/imports.c
index 6ffaddc..87cb5ce 100644
--- a/src/mesa/main/imports.c
+++ b/src/mesa/main/imports.c
@@ -48,6 +48,10 @@
 #include "context.h"
 #include "version.h"
 
+#ifdef _GNU_SOURCE
+#include <locale.h>
+#endif
+
 
 #define MAXSTRING 4000  /* for vsnprintf() */
 
@@ -908,7 +912,15 @@ _mesa_atoi(const char *s)
 double
 _mesa_strtod( const char *s, char **end )
 {
+#ifdef _GNU_SOURCE
+   static locale_t loc = NULL;
+   if (!loc) {
+      loc = newlocale(LC_CTYPE_MASK, "C", NULL);
+   }
+   return strtod_l(s, end, loc);
+#else
    return strtod(s, end);
+#endif
 }
 
 /** Compute simple checksum/hash for a string */




More information about the mesa-commit mailing list