From: bangerth Date: Sun, 27 Mar 2011 08:53:33 +0000 (+0000) Subject: Allow comments at the end of a line of other stuff, rather than throwing away the... X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=65829e30565bd0800a28bc51bc89352ac22af33a;p=dealii-svn.git Allow comments at the end of a line of other stuff, rather than throwing away the whole line. git-svn-id: https://svn.dealii.org/trunk@23537 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/common/scripts/expand_instantiations.cc b/deal.II/common/scripts/expand_instantiations.cc index ca233ecbd4..8f62d4ed71 100644 --- a/deal.II/common/scripts/expand_instantiations.cc +++ b/deal.II/common/scripts/expand_instantiations.cc @@ -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