<h3>Specific improvements</h3>
<ol>
+ <li> Fixed: Utilities::string_to_int() did not catch if the
+ string given started with an integer but contained additional
+ text. It now throws an exception if this happens.
+ <br>
+ (Wolfgang Bangerth, 2014/07/14)
+ </li>
+
<li> New: The function GridOut::write, can now be used also in
the codimension one case.
<br>
(Luca Heltai, 2014/07/18)
</li>
-
<li> New: The GridReordering::reorder_cells() function used a
numbering format for the vertices in a cell that was last used in
deal.II version 5.2. This format is still used internally, but
int
string_to_int (const std::string &s)
{
- std::istringstream ss(s);
-
- int i = std::numeric_limits<int>::max();
- ss >> i;
- // check for errors
- AssertThrow (i != std::numeric_limits<int>::max(),
- ExcCantConvertString (s));
-
-//TODO: The test for errors above doesn't work, as can easily be
-//verified. furthermore, it doesn't catch cases like when calling
-//string_to_int("1.23.4") since it just reads in however much it can, without
-//realizing that there is more
+ char *p;
+ const int i = std::strtol(s.c_str(), &p, 10);
+ AssertThrow ( !((errno != 0) || (s.size() == 0) || ((s.size()>0) && (*p != '\0'))),
+ ExcMessage ("Can't convert <" + s + "> to an integer."));
return i;
}