diff options
author | Kevin Ryde <user42@zip.com.au> | 2003-10-18 01:16:12 +0200 |
---|---|---|
committer | Kevin Ryde <user42@zip.com.au> | 2003-10-18 01:16:12 +0200 |
commit | 78c789dce597225f5f3f3b2ba0f1476959c0baed (patch) | |
tree | 01a97c4ef16b24b3ac969e8a2fab1083365ca7f7 /cxx | |
parent | 85aa317f7e4b47553d1ebadc047d872bcabe35a1 (diff) | |
download | gmp-78c789dce597225f5f3f3b2ba0f1476959c0baed.tar.gz |
* cxx/ismpz.cc, cxx/ismpq.cc, cxx/ismpf.cc: Use istream std::locale
ctype facet for isspace when available. Only accept space at the
start of the input, same as g++ libstdc++. Use ASSERT_NOCARRY to
check result of mpz_set_str etc.
Diffstat (limited to 'cxx')
-rw-r--r-- | cxx/ismpq.cc | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/cxx/ismpq.cc b/cxx/ismpq.cc index bdcdade10..d325e57ee 100644 --- a/cxx/ismpq.cc +++ b/cxx/ismpq.cc @@ -1,6 +1,6 @@ /* operator>> -- C++-style input of mpq_t. -Copyright 2001 Free Software Foundation, Inc. +Copyright 2001, 2003 Free Software Foundation, Inc. This file is part of the GNU MP Library. @@ -39,9 +39,17 @@ operator>> (istream &i, mpq_ptr q) i.get(c); // start reading if (i.flags() & ios::skipws) // skip initial whitespace - while (isspace(c) && i.get(c)) - ; - + { +#if HAVE_STD__LOCALE + const ctype<char>& ct = use_facet< ctype<char> >(i.getloc()); +#define cxx_isspace(c) (ct.is(ctype_base::space,(c))) +#else +#define cxx_isspace(c) isspace(c) +#endif + + while (cxx_isspace(c) && i.get(c)) + ; + } if (c == '-' || c == '+') // sign { if (c == '-') @@ -49,9 +57,6 @@ operator>> (istream &i, mpq_ptr q) i.get(c); } - while (isspace(c) && i.get(c)) // skip whitespace - ; - base = __gmp_istream_set_base(i, c, zero, showbase); // select the base __gmp_istream_set_digits(s, i, c, ok, base); // read the numerator @@ -62,10 +67,6 @@ operator>> (istream &i, mpq_ptr q) ok = true; } - if (i.flags() & ios::skipws) - while (isspace(c) && i.get(c)) // skip whitespace - ; - if (c == '/') // there's a denominator { bool zero2 = false; @@ -75,9 +76,6 @@ operator>> (istream &i, mpq_ptr q) ok = false; // denominator is mandatory i.get(c); - while (isspace(c) && i.get(c)) // skip whitespace - ; - if (showbase) // check base of denominator base2 = __gmp_istream_set_base(i, c, zero2, showbase); |