[alsa-devel] [PATCH] Check if uselocale() is present

Rémi Denis-Courmont remi at remlab.net
Tue Apr 13 17:54:53 CEST 2010


Otherwise, assume the C run-time does not depend on the locale (at least
not to format floating point numbers).
---
 configure.in |    1 +
 src/conf.c   |    6 ++++++
 2 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/configure.in b/configure.in
index 9d985b8..e62e3bd 100644
--- a/configure.in
+++ b/configure.in
@@ -64,6 +64,7 @@ dnl Checks for library functions.
 AC_PROG_GCC_TRADITIONAL
 AC_CHECK_FUNC([hsearch_r], [HAVE_HSEARCH_R=yes])
 AM_CONDITIONAL(ALSA_HSEARCH_R, [test "x$HAVE_HSEARCH_R" != xyes])
+AC_CHECK_FUNCS([uselocale])
 
 SAVE_LIBRARY_VERSION
 AC_SUBST(LIBTOOL_VERSION_INFO)
diff --git a/src/conf.c b/src/conf.c
index ce252ab..d1d4a5f 100644
--- a/src/conf.c
+++ b/src/conf.c
@@ -499,20 +499,26 @@ static int safe_strtod(const char *str, double *val)
 {
 	char *end;
 	double v;
+#ifdef HAVE_USELOCALE
 	locale_t saved_locale, c_locale;
+#endif
 	int err;
 
 	if (!*str)
 		return -EINVAL;
+#ifdef HAVE_USELOCALE
 	c_locale = newlocale(LC_NUMERIC_MASK, "C", 0);
 	saved_locale = uselocale(c_locale);
+#endif
 	errno = 0;
 	v = strtod(str, &end);
 	err = -errno;
+#ifdef HAVE_USELOCALE
 	if (c_locale != (locale_t)0) {
 		uselocale(saved_locale);
 		freelocale(c_locale);
 	}
+#endif
 	if (err)
 		return err;
 	if (*end)
-- 
1.7.0.4



More information about the Alsa-devel mailing list