]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Replaced several checks for spaces by checks for whitespaces. The
authorkayser-herold <kayser-herold@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 26 Jul 2007 19:07:05 +0000 (19:07 +0000)
committerkayser-herold <kayser-herold@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 26 Jul 2007 19:07:05 +0000 (19:07 +0000)
motivation were problems under cygwin, where under certain conditions
the CR of a CR LF was stuck at the end of an identifier, which made
it unrecognisable by the parser. The parsing is hopefully a little
more robust now.

git-svn-id: https://svn.dealii.org/trunk@14870 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/base/source/parameter_handler.cc

index 6dd3ed457dec5f5cc9108d9b777c1a80bfba445b..2b8ded2088436f77f9031e156d2e607c34e84127 100644 (file)
@@ -23,6 +23,7 @@
 #include <algorithm>
 #include <list>
 #include <sstream>
+#include <cctype>
 
 #ifdef HAVE_STD_NUMERIC_LIMITS
 # include <limits>
@@ -315,10 +316,10 @@ namespace Patterns
          tmp = "";
       
        while ((name.length() != 0) &&
-              (name[0] == ' '))
+              (std::isspace (name[0])))
          name.erase (0,1);
 
-       while (name[name.length()-1] == ' ')
+       while (std::isspace (name[name.length()-1]))
          name.erase (name.length()-1, 1);
 
        split_list.push_back (name);
@@ -402,9 +403,9 @@ namespace Patterns
          tmp = "";
       
        while ((name.length() != 0) &&
-              (name[0] == ' '))
+              (std::isspace (name[0])))
          name.erase (0,1);
-       while (name[name.length()-1] == ' ')
+       while (std::isspace (name[name.length()-1]))
          name.erase (name.length()-1, 1);
 
        split_list.push_back (name);
@@ -1253,11 +1254,11 @@ ParameterHandler::scan_line (std::string        line,
                                   // now every existing whitespace
                                   // should be exactly one ' ';
                                   // if at end or beginning: delete
-  if ((line.length() != 0) && (line[0] == ' '))  line.erase (0, 1);
+  if ((line.length() != 0) && (std::isspace (line[0])))  line.erase (0, 1);
                                   // if line is now empty: leave
   if (line.length() == 0) return true;
 
-  if (line[line.length()-1] == ' ')
+  if (std::isspace (line[line.length()-1]))
     line.erase (line.size()-1, 1);
 
                                   // enter subsection
@@ -1780,8 +1781,8 @@ void MultipleParameterLoop::Entry::split_different_values ()
     multiple.erase (multiple.size()-1, 1);
                                   // erase leading and trailing spaces
                                   // in multiple
-  while (multiple[0] == ' ') multiple.erase (0,1);
-  while (multiple[multiple.size()-1] == ' ') multiple.erase (multiple.size()-1,1);
+  while (std::isspace (multiple[0])) multiple.erase (0,1);
+  while (std::isspace (multiple[multiple.size()-1])) multiple.erase (multiple.size()-1,1);
   
                                   // delete spaces around '|'
   while (multiple.find(" |") != std::string::npos)

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.