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
#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
#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 ();