diff options
author | Kevin Ryde <user42@zip.com.au> | 2002-11-19 22:58:02 +0100 |
---|---|---|
committer | Kevin Ryde <user42@zip.com.au> | 2002-11-19 22:58:02 +0100 |
commit | 1958e047ee6478cc49a17b3568e620c71bbb5414 (patch) | |
tree | 066ab11118e88a8200a45291d490fad5030aaf9f /scanf | |
parent | 0e83baa85df7a45ccea7f98b7366e5f2c3011c62 (diff) | |
download | gmp-1958e047ee6478cc49a17b3568e620c71bbb5414.tar.gz |
* gmp-impl.h (GMP_DECIMAL_POINT): New macro.
* mpf/out_str.c, mpf/set_str.c, scanf/doscan.c: Use it, and don't
bother with special code for non-locale systems.
* mpf/set_str.c, scanf/doscan.c: Cast through "unsigned char" for
decimal point string, same as input chars.
Diffstat (limited to 'scanf')
-rw-r--r-- | scanf/doscan.c | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/scanf/doscan.c b/scanf/doscan.c index 51a0e64d9..fb4b345ac 100644 --- a/scanf/doscan.c +++ b/scanf/doscan.c @@ -23,6 +23,8 @@ along with the GNU MP Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#define _GNU_SOURCE /* for DECIMAL_POINT in langinfo.h */ + #include "config.h" #if HAVE_STDARG @@ -36,6 +38,10 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <string.h> +#if HAVE_LANGINFO_H +#include <langinfo.h> /* for nl_langinfo */ +#endif + #if HAVE_LOCALE_H #include <locale.h> /* for localeconv */ #endif @@ -235,21 +241,18 @@ gmpscan (const struct gmp_doscan_funs_t *funs, void *data, /* decimal point */ if (p->type == 'F' && ! seen_point) { -#if HAVE_LOCALECONV /* For a multi-character decimal point, if the first character is present then all of it must be, otherwise the input is considered invalid. */ - const char *point; - int pc; - point = localeconv()->decimal_point; - pc = *point++; + const char *point = GMP_DECIMAL_POINT; + int pc = (unsigned char) *point++; if (c == pc) { for (;;) { STORE (c); GET (c); - pc = *point++; + pc = (unsigned char) *point++; if (pc == '\0') break; if (c != pc) @@ -258,13 +261,6 @@ gmpscan (const struct gmp_doscan_funs_t *funs, void *data, seen_point = 1; goto digits; } -#else - if (c == '.') - { - seen_point = 1; - goto store_get_digits; - } -#endif } /* exponent */ |