X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flibpspp%2Fi18n.c;h=bda2676c86788eabcfa24a937f7802cbe19c955d;hb=51996c07fc2b308ad29dcbaa93e4d5d3d21b3331;hp=70780eff968a6ec62c071da23229a4ebaac49fcc;hpb=6f48190d3435800eec4984e927757242dafaef45;p=pspp-builds.git diff --git a/src/libpspp/i18n.c b/src/libpspp/i18n.c index 70780eff..bda2676c 100644 --- a/src/libpspp/i18n.c +++ b/src/libpspp/i18n.c @@ -30,6 +30,10 @@ #include #include "xstrndup.h" +#if HAVE_NL_LANGINFO +#include +#endif + static char *locale = 0; static const char *charset; @@ -213,3 +217,32 @@ i18n_done (void) } } + + + +/* Return the system local's idea of the + decimal seperator character */ +char +get_system_decimal (void) +{ + char *radix_char = NULL; + + char *ol = setlocale (LC_NUMERIC, NULL); + setlocale (LC_NUMERIC, ""); + +#if HAVE_NL_LANGINFO + radix_char = nl_langinfo (RADIXCHAR); +#else + { + char *buf = xmalloc (10); + snprintf (buf, 10, "%f", 2.5); + radix_char = &buf[1]; + } +#endif + + /* We MUST leave LC_NUMERIC untouched, since it would + otherwise interfere with data_{in,out} */ + setlocale (LC_NUMERIC, ol); + return *radix_char; +} +