summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 647cfb1)
raw | patch | inline | side by side (parent: 647cfb1)
author | Florian Forster <octo@google.com> | |
Wed, 17 Sep 2014 08:52:36 +0000 (10:52 +0200) | ||
committer | Florian Forster <octo@collectd.org> | |
Thu, 18 Sep 2014 05:31:49 +0000 (07:31 +0200) |
When using ASCII protocols, such as the Graphite protocol, doubles are
converted to strings using sprintf(3) and parsed with strtod(3). If the
effective locale uses something different from a dot (".") as the
decimal separator (e.g. Portuguese, German), this breaks.
This patch sets the LC_NUMERIC locale to "C" on start-up, so that
strings are produced and parsed in a well-defined manner.
Fixes: #512
converted to strings using sprintf(3) and parsed with strtod(3). If the
effective locale uses something different from a dot (".") as the
decimal separator (e.g. Portuguese, German), this breaks.
This patch sets the LC_NUMERIC locale to "C" on start-up, so that
strings are produced and parsed in a well-defined manner.
Fixes: #512
configure.ac | patch | blob | history | |
src/collectd.c | patch | blob | history |
diff --git a/configure.ac b/configure.ac
index bcd8b6021b677ce0d14ff7efafe7f31476a2f532..65e535a66e159d129343571e94e32478a8f5158c 100644 (file)
--- a/configure.ac
+++ b/configure.ac
#endif
])
-AC_CHECK_HEADERS(pwd.h grp.h sys/un.h ctype.h limits.h xfs/xqm.h fs_info.h fshelp.h paths.h mntent.h mnttab.h sys/fstyp.h sys/fs_types.h sys/mntent.h sys/mnttab.h sys/statfs.h sys/statvfs.h sys/vfs.h sys/vfstab.h kvm.h wordexp.h)
+AC_CHECK_HEADERS(pwd.h grp.h sys/un.h ctype.h limits.h xfs/xqm.h fs_info.h fshelp.h paths.h mntent.h mnttab.h sys/fstyp.h sys/fs_types.h sys/mntent.h sys/mnttab.h sys/statfs.h sys/statvfs.h sys/vfs.h sys/vfstab.h kvm.h wordexp.h locale.h)
# For the dns plugin
AC_CHECK_HEADERS(arpa/nameser.h)
# Checks for library functions.
#
AC_PROG_GCC_TRADITIONAL
-AC_CHECK_FUNCS(gettimeofday select strdup strtol getaddrinfo getnameinfo strchr memcpy strstr strcmp strncmp strncpy strlen strncasecmp strcasecmp openlog closelog sysconf setenv if_indextoname)
+AC_CHECK_FUNCS(gettimeofday select strdup strtol getaddrinfo getnameinfo strchr memcpy strstr strcmp strncmp strncpy strlen strncasecmp strcasecmp openlog closelog sysconf setenv if_indextoname setlocale)
AC_FUNC_STRERROR_R
diff --git a/src/collectd.c b/src/collectd.c
index f711fb705a744fa44b92ec386595aef5e34a1efa..2e2d821aade194873c923ceabcf8951291d0dc69 100644 (file)
--- a/src/collectd.c
+++ b/src/collectd.c
#include "collectd.h"
#include "common.h"
+#include "plugin.h"
+#include "configfile.h"
+
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <pthread.h>
-#include "plugin.h"
-#include "configfile.h"
+#if HAVE_LOCALE_H
+# include <locale.h>
+#endif
#if HAVE_STATGRAB_H
# include <statgrab.h>
#endif
+#ifndef COLLECTD_LOCALE
+# define COLLECTD_LOCALE "C"
+#endif
+
/*
* Global variables
*/
static int do_init (void)
{
+#if HAVE_SETLOCALE
+ if (setlocale (LC_NUMERIC, COLLECTD_LOCALE) == NULL)
+ WARNING ("setlocale (\"%s\") failed.", COLLECTD_LOCALE);
+#endif
+
#if HAVE_LIBKSTAT
kc = NULL;
update_kstat ();