From: "Rémi Denis-Courmont" <remi@remlab.net>
To: alsa-devel@alsa-project.org
Subject: [PATCH] Check if uselocale() is present
Date: Tue, 13 Apr 2010 18:54:53 +0300 [thread overview]
Message-ID: <1271174093-2559-1-git-send-email-remi@remlab.net> (raw)
In-Reply-To: <4BC48B96.7040002@ladisch.de>
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
prev parent reply other threads:[~2010-04-13 15:54 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-13 14:50 [PATCH] Use thread-safe locale functions Rémi Denis-Courmont
2010-04-13 15:19 ` Clemens Ladisch
2010-04-13 15:25 ` Rémi Denis-Courmont
2010-04-13 15:54 ` Rémi Denis-Courmont [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1271174093-2559-1-git-send-email-remi@remlab.net \
--to=remi@remlab.net \
--cc=alsa-devel@alsa-project.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).