From 78c789dce597225f5f3f3b2ba0f1476959c0baed Mon Sep 17 00:00:00 2001 From: Kevin Ryde Date: Sat, 18 Oct 2003 01:16:12 +0200 Subject: * 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. --- cxx/ismpq.cc | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) (limited to 'cxx') 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& ct = use_facet< ctype >(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); -- cgit v1.2.1