X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flibpspp%2Fi18n.c;h=db851217c80be27ae129a9c6252824929af51785;hb=ca7da17a401e015805db0ea70234c267d67535a3;hp=c214fb55b0a0147514949e03311be172099276dc;hpb=2ad5fe55e454b8ccb271a710e2c4b1b53c57fc8c;p=pspp-builds.git diff --git a/src/libpspp/i18n.c b/src/libpspp/i18n.c index c214fb55..db851217 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; @@ -46,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, @@ -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; + + 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; +} +