X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=src%2Flibpspp%2Fi18n.c;h=db851217c80be27ae129a9c6252824929af51785;hb=26763488cfe4213eb1dfdc5966a3659a0e89887f;hp=ba083fffe2f1a791dca465bd0c4a17b59b4cc63c;hpb=c13375ebe886fc3ed5ce70a260bb2b01cebb4b1f;p=pspp-builds.git diff --git a/src/libpspp/i18n.c b/src/libpspp/i18n.c index ba083fff..db851217 100644 --- a/src/libpspp/i18n.c +++ b/src/libpspp/i18n.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -29,6 +30,10 @@ #include #include "xstrndup.h" +#if HAVE_NL_LANGINFO +#include +#endif + static char *locale = 0; static const char *charset; @@ -45,7 +50,7 @@ create_iconv (const char* tocode, const char* fromcode) /* I don't think it's safe to translate this string or to use messaging as the convertors have not yet been set up */ - if ( (iconv_t) -1 == conv) + if ( (iconv_t) -1 == conv && 0 != strcmp (tocode, fromcode)) { const int err = errno; fprintf (stderr, @@ -212,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; + + char *ol = setlocale (LC_NUMERIC, NULL); + setlocale (LC_NUMERIC, ""); + +#if HAVE_NL_LANGINFO + radix_char = nl_langinfo (RADIXCHAR)[0]; +#else + { + char buf[10]; + snprintf (buf, sizeof buf, "%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; +} +