mirror of
https://github.com/boostorg/wave.git
synced 2026-02-01 21:12:11 +00:00
Wave: merging from trunk
[SVN r72164]
This commit is contained in:
76
tool/cpp.cpp
76
tool/cpp.cpp
@@ -143,10 +143,10 @@ int print_copyright()
|
||||
"LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)",
|
||||
0
|
||||
};
|
||||
|
||||
|
||||
for (int i = 0; 0 != copyright[i]; ++i)
|
||||
cout << copyright[i] << endl;
|
||||
|
||||
|
||||
return 0; // exit app
|
||||
}
|
||||
|
||||
@@ -216,7 +216,7 @@ namespace cmd_line_utils {
|
||||
else {
|
||||
// store this path as an user path
|
||||
p->paths.push_back(t);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -236,7 +236,7 @@ namespace cmd_line_utils {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
vector<std::string> options;
|
||||
std::string line;
|
||||
|
||||
@@ -245,7 +245,7 @@ namespace cmd_line_utils {
|
||||
std::string::size_type pos = line.find_first_not_of(" \t");
|
||||
if (pos == std::string::npos)
|
||||
continue;
|
||||
|
||||
|
||||
// skip comment lines
|
||||
if ('#' != line[pos]) {
|
||||
// strip leading and trailing whitespace
|
||||
@@ -281,7 +281,7 @@ namespace cmd_line_utils {
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
}
|
||||
|
||||
@@ -311,7 +311,7 @@ namespace {
|
||||
: print_time(false), outstrm(outstrm_)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
~auto_stop_watch()
|
||||
{
|
||||
if (print_time) {
|
||||
@@ -320,7 +320,7 @@ namespace {
|
||||
<< std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void set_print_time(bool print_time_)
|
||||
{
|
||||
print_time = print_time_;
|
||||
@@ -350,7 +350,7 @@ namespace {
|
||||
"end-of-file while writing to the stream\n";
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Retrieve the position of a macro definition
|
||||
@@ -364,7 +364,7 @@ namespace {
|
||||
bool is_predefined = false;
|
||||
std::vector<typename Context::token_type> parameters;
|
||||
typename Context::token_sequence_type definition;
|
||||
|
||||
|
||||
return ctx.get_macro_definition(name, has_parameters, is_predefined,
|
||||
pos, parameters, definition);
|
||||
}
|
||||
@@ -422,7 +422,7 @@ namespace {
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Read one logical line of text
|
||||
inline bool
|
||||
@@ -560,13 +560,13 @@ namespace {
|
||||
for (name_iterator it = ctx.macro_names_begin(); it != end; ++it)
|
||||
{
|
||||
typedef std::vector<context_type::token_type> parameters_type;
|
||||
|
||||
|
||||
bool has_pars = false;
|
||||
bool predef = false;
|
||||
context_type::position_type pos;
|
||||
parameters_type pars;
|
||||
context_type::token_sequence_type def;
|
||||
|
||||
|
||||
if (ctx.get_macro_definition(*it, has_pars, predef, pos, pars, def))
|
||||
{
|
||||
macronames_out << (predef ? "-P" : "-D") << *it;
|
||||
@@ -666,7 +666,7 @@ int error_count = 0;
|
||||
std::istreambuf_iterator<char>());
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
// The preprocessing of the input stream is done on the fly behind the
|
||||
// scenes during iteration over the context_type::iterator_type stream.
|
||||
std::ofstream output;
|
||||
@@ -871,13 +871,13 @@ int error_count = 0;
|
||||
ctx.get_language(), false));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
// enable preserving comments mode
|
||||
if (preserve_comments) {
|
||||
ctx.set_language(
|
||||
boost::wave::enable_preserve_comments(ctx.get_language()));
|
||||
}
|
||||
|
||||
|
||||
// control the generation of #line directives
|
||||
if (vm.count("line")) {
|
||||
int lineopt = vm["line"].as<int>();
|
||||
@@ -910,7 +910,7 @@ int error_count = 0;
|
||||
// add include directories to the system include search paths
|
||||
if (vm.count("sysinclude")) {
|
||||
vector<std::string> syspaths = vm["sysinclude"].as<vector<std::string> >();
|
||||
|
||||
|
||||
vector<std::string>::const_iterator end = syspaths.end();
|
||||
for (vector<std::string>::const_iterator cit = syspaths.begin();
|
||||
cit != end; ++cit)
|
||||
@@ -918,7 +918,7 @@ int error_count = 0;
|
||||
ctx.add_sysinclude_path(cmd_line_utils::trim_quotes(*cit).c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// add include directories to the include search paths
|
||||
if (vm.count("include")) {
|
||||
cmd_line_utils::include_paths const &ip =
|
||||
@@ -934,7 +934,7 @@ int error_count = 0;
|
||||
// if -I- was given on the command line, this has to be propagated
|
||||
if (ip.seen_separator)
|
||||
ctx.set_sysinclude_delimiter();
|
||||
|
||||
|
||||
// add system include directories to the include path
|
||||
vector<std::string>::const_iterator sysend = ip.syspaths.end();
|
||||
for (vector<std::string>::const_iterator syscit = ip.syspaths.begin();
|
||||
@@ -943,7 +943,7 @@ int error_count = 0;
|
||||
ctx.add_sysinclude_path(cmd_line_utils::trim_quotes(*syscit).c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// add additional defined macros
|
||||
if (vm.count("define")) {
|
||||
vector<std::string> const ¯os = vm["define"].as<vector<std::string> >();
|
||||
@@ -980,7 +980,7 @@ int error_count = 0;
|
||||
}
|
||||
|
||||
#if BOOST_WAVE_USE_DEPRECIATED_PREPROCESSING_HOOKS == 0
|
||||
// suppress expansion of, specified macros
|
||||
// suppress expansion of specified macros
|
||||
if (vm.count("noexpand")) {
|
||||
vector<std::string> const &noexpandmacros =
|
||||
vm["noexpand"].as<vector<std::string> >();
|
||||
@@ -1003,7 +1003,7 @@ int error_count = 0;
|
||||
}
|
||||
ctx.set_max_include_nesting_depth(max_depth);
|
||||
}
|
||||
|
||||
|
||||
// open the output file
|
||||
if (vm.count("output")) {
|
||||
// try to open the file, where to put the preprocessed output
|
||||
@@ -1049,17 +1049,17 @@ int error_count = 0;
|
||||
// we assume the session to be interactive if input is stdin and output is
|
||||
// stdout and the output is not inhibited
|
||||
bool is_interactive = input_is_stdin && !output.is_open() && allow_output;
|
||||
|
||||
|
||||
if (is_interactive) {
|
||||
// if interactive we don't warn for missing endif's etc.
|
||||
ctx.set_language(
|
||||
boost::wave::enable_single_line(ctx.get_language()));
|
||||
boost::wave::enable_single_line(ctx.get_language()), false);
|
||||
}
|
||||
|
||||
|
||||
// analyze the input file
|
||||
context_type::iterator_type first = ctx.begin();
|
||||
context_type::iterator_type last = ctx.end();
|
||||
|
||||
|
||||
// preprocess the required include files
|
||||
if (vm.count("forceinclude")) {
|
||||
// add the filenames to force as include files in _reverse_ order
|
||||
@@ -1093,7 +1093,7 @@ int error_count = 0;
|
||||
do {
|
||||
// loop over all generated tokens outputting the generated text
|
||||
bool finished = false;
|
||||
|
||||
|
||||
if (input_is_stdin) {
|
||||
if (is_interactive)
|
||||
cout << ">>> "; // prompt if is interactive
|
||||
@@ -1104,16 +1104,16 @@ int error_count = 0;
|
||||
break; // end of input reached
|
||||
first = ctx.begin(instring.begin(), instring.end());
|
||||
}
|
||||
|
||||
|
||||
bool need_to_advanve = false;
|
||||
|
||||
|
||||
do {
|
||||
try {
|
||||
if (need_to_advanve) {
|
||||
++first;
|
||||
need_to_advanve = false;
|
||||
}
|
||||
|
||||
|
||||
while (first != last) {
|
||||
// store the last known good token position
|
||||
current_position = (*first).get_position();
|
||||
@@ -1131,7 +1131,7 @@ int error_count = 0;
|
||||
else
|
||||
cout << (*first).get_value();
|
||||
}
|
||||
|
||||
|
||||
// advance to the next token
|
||||
++first;
|
||||
}
|
||||
@@ -1215,12 +1215,12 @@ main (int argc, char *argv[])
|
||||
<< " using a different configuration (see wave_config.hpp)."
|
||||
<< endl;
|
||||
}
|
||||
|
||||
|
||||
// analyze the command line options and arguments
|
||||
try {
|
||||
// declare the options allowed on the command line only
|
||||
po::options_description desc_cmdline ("Options allowed on the command line only");
|
||||
|
||||
|
||||
desc_cmdline.add_options()
|
||||
("help,h", "print out program usage (this message)")
|
||||
("version,v", "print the version number")
|
||||
@@ -1257,7 +1257,7 @@ main (int argc, char *argv[])
|
||||
("nesting,n", po::value<int>(),
|
||||
"specify a new maximal include nesting depth")
|
||||
;
|
||||
|
||||
|
||||
po::options_description desc_ext ("Extended options (allowed everywhere)");
|
||||
|
||||
desc_ext.add_options()
|
||||
@@ -1309,21 +1309,21 @@ main (int argc, char *argv[])
|
||||
"or 'wave.state' [-] (interactive mode only)")
|
||||
#endif
|
||||
;
|
||||
|
||||
|
||||
// combine the options for the different usage schemes
|
||||
po::options_description desc_overall_cmdline;
|
||||
po::options_description desc_overall_cfgfile;
|
||||
|
||||
desc_overall_cmdline.add(desc_cmdline).add(desc_generic).add(desc_ext);
|
||||
desc_overall_cfgfile.add(desc_generic).add(desc_ext);
|
||||
|
||||
|
||||
// parse command line and store results
|
||||
using namespace boost::program_options::command_line_style;
|
||||
|
||||
po::parsed_options opts(po::parse_command_line(argc, argv,
|
||||
desc_overall_cmdline, unix_style, cmd_line_utils::at_option_parser));
|
||||
po::variables_map vm;
|
||||
|
||||
|
||||
po::store(opts, vm);
|
||||
po::notify(vm);
|
||||
|
||||
@@ -1389,7 +1389,7 @@ main (int argc, char *argv[])
|
||||
cout << desc_help << endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
if (vm.count("version")) {
|
||||
cout << get_version() << endl;
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user