diff options
author | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2017-09-05 12:54:34 +0000 |
---|---|---|
committer | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2017-09-05 12:54:34 +0000 |
commit | ae27a2418129b6718c2159a5124a4c9179cce1a5 (patch) | |
tree | ef9422d7ee602968ed9a19cf1e2493623c42a1e3 | |
parent | 3f968b48c0f990bf760a5737e0ff2aa54f7e2ea9 (diff) | |
download | mpfr-ae27a2418129b6718c2159a5124a4c9179cce1a5.tar.gz |
[src/mpfr-impl.h] In case decimal_point and/or thousands_sep are
non-single-byte characters (as found on FreeBSD 11 in fr_FR.UTF-8),
revert to the default value. Added a FIXME to support multibyte
decimal_point and thousands_sep.
(merged changeset r11705 from the trunk)
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/branches/3.1@11707 280ebfd0-de03-0410-8827-d642c229c3f4
-rw-r--r-- | src/mpfr-impl.h | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/mpfr-impl.h b/src/mpfr-impl.h index bee38a909..42fa3a5b0 100644 --- a/src/mpfr-impl.h +++ b/src/mpfr-impl.h @@ -1210,15 +1210,28 @@ do { \ # endif #endif +/* FIXME: Add support for multibyte decimal_point and thousands_sep since + this can be found in practice: https://reviews.llvm.org/D27167 says: + "I found this problem on FreeBSD 11, where thousands_sep in fr_FR.UTF-8 + is a no-break space (U+00A0)." + Note, however, that this is not allowed by the C standard, which just + says "character" and not "multibyte character". + In the mean time, in case of non-single-byte character, revert to the + default value. */ #if MPFR_LCONV_DPTS #include <locale.h> /* Warning! In case of signed char, the value of MPFR_DECIMAL_POINT may be negative (the ISO C99 does not seem to forbid negative values). */ -#define MPFR_DECIMAL_POINT (localeconv()->decimal_point[0]) -#define MPFR_THOUSANDS_SEPARATOR (localeconv()->thousands_sep[0]) +#define MPFR_DECIMAL_POINT \ + (localeconv()->decimal_point[1] != '\0' ? \ + (char) '.' : localeconv()->decimal_point[0]) +#define MPFR_THOUSANDS_SEPARATOR \ + (localeconv()->thousands_sep[0] == '\0' || \ + localeconv()->thousands_sep[1] != '\0' ? \ + (char) '\0' : localeconv()->thousands_sep[0]) #else #define MPFR_DECIMAL_POINT ((char) '.') -#define MPFR_THOUSANDS_SEPARATOR ('\0') +#define MPFR_THOUSANDS_SEPARATOR ((char) '\0') #endif |