]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Allow comments at the end of a line of other stuff, rather than throwing away the...
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Sun, 27 Mar 2011 08:53:33 +0000 (08:53 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Sun, 27 Mar 2011 08:53:33 +0000 (08:53 +0000)
git-svn-id: https://svn.dealii.org/trunk@23537 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/common/scripts/expand_instantiations.cc

index ca233ecbd46cebb7f91855d9f8052ca67106bb6a..8f62d4ed7141c8c6ebf6e15f7b4886980cc8e905 100644 (file)
@@ -2,7 +2,7 @@
 //    $Id$
 //    Version: $Name$
 //
-//    Copyright (C) 2007, 2008, 2009, 2010 by the deal.II authors
+//    Copyright (C) 2007, 2008, 2009, 2010, 2011 by the deal.II authors
 //
 //    This file is subject to QPL and may not be  distributed
 //    without copyright and license information. Please refer
@@ -117,6 +117,30 @@ skip_space (std::string &in)
 }
 
 
+std::string remove_comments (std::string line)
+{
+  const std::string::size_type double_slash_comment = line.find ("//");
+  if (double_slash_comment != std::string::npos)
+    line.erase (double_slash_comment, std::string::npos);
+
+  const std::string::size_type slash_star_comment_begin = line.find ("/*");
+  if (slash_star_comment_begin != std::string::npos)
+    {
+      const std::string::size_type slash_star_comment_end = line.find ("*/");
+      if (slash_star_comment_end == std::string::npos)
+       {
+         std::cerr << "The program can currently only handle /* block */"
+                   << "comments that start and end within the same line."
+                   << std::endl;
+         std::exit (1);
+       }
+      line.erase (slash_star_comment_begin,
+                 slash_star_comment_end - slash_star_comment_begin + 2);
+    }
+
+  return line;
+}
+
 
 // read the whole file specified by the stream given as argument into a string
 // for simpler parsing, and return it
@@ -128,11 +152,8 @@ std::string read_whole_file (std::istream &in)
       std::string line;
       getline (in, line);
 
-      if (line.find ("//") != 0)
-       {
-         whole_file += line;
-         whole_file += '\n';
-       }
+      whole_file += remove_comments (line);
+      whole_file += '\n';
     }
                                   // substitute tabs by spaces, multiple
                                   // spaces by single ones

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.