From 1306e78c9852e150e133230a1f07eebb8b08c2a9 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 28 Oct 2016 16:49:31 +0200 Subject: Add --no-line, --no-column options --- build2/b-options | 8 ++++++++ build2/b-options.cxx | 12 ++++++++++++ build2/b-options.ixx | 12 ++++++++++++ build2/b.cli | 10 ++++++++++ build2/context | 3 --- build2/context.cxx | 2 -- build2/diagnostics.cxx | 16 +++++++++++----- build2/test/script/parser.cxx | 18 ++++++++++++++---- build2/utility | 5 +++++ build2/utility.cxx | 1 + 10 files changed, 73 insertions(+), 14 deletions(-) diff --git a/build2/b-options b/build2/b-options index 093a1dc..6a2088d 100644 --- a/build2/b-options +++ b/build2/b-options @@ -410,6 +410,12 @@ namespace build2 bool verbose_specified () const; + const bool& + no_column () const; + + const bool& + no_line () const; + const path& buildfile () const; @@ -470,6 +476,8 @@ namespace build2 bool q_; uint16_t verbose_; bool verbose_specified_; + bool no_column_; + bool no_line_; path buildfile_; bool buildfile_specified_; path config_guess_; diff --git a/build2/b-options.cxx b/build2/b-options.cxx index 9b169d7..7e7a395 100644 --- a/build2/b-options.cxx +++ b/build2/b-options.cxx @@ -574,6 +574,8 @@ namespace build2 q_ (), verbose_ (1), verbose_specified_ (false), + no_column_ (), + no_line_ (), buildfile_ ("buildfile"), buildfile_specified_ (false), config_guess_ (), @@ -684,6 +686,12 @@ namespace build2 << " 6. Even more detailed information, including state dumps." << ::std::endl; os << std::endl + << "\033[1m--no-column\033[0m Don't print column numbers in diagnostics." << ::std::endl; + + os << std::endl + << "\033[1m--no-line\033[0m Don't print line and column numbers in diagnostics." << ::std::endl; + + os << std::endl << "\033[1m--buildfile\033[0m \033[4mpath\033[0m The alternative file to read build information from. The" << ::std::endl << " default is \033[1mbuildfile\033[0m. If \033[4mpath\033[0m is '\033[1m-\033[0m', then read from" << ::std::endl << " \033[1mSTDIN\033[0m. Note that this option only affects the files read" << ::std::endl @@ -751,6 +759,10 @@ namespace build2 _cli_options_map_["--verbose"] = &::build2::cl::thunk< options, uint16_t, &options::verbose_, &options::verbose_specified_ >; + _cli_options_map_["--no-column"] = + &::build2::cl::thunk< options, bool, &options::no_column_ >; + _cli_options_map_["--no-line"] = + &::build2::cl::thunk< options, bool, &options::no_line_ >; _cli_options_map_["--buildfile"] = &::build2::cl::thunk< options, path, &options::buildfile_, &options::buildfile_specified_ >; diff --git a/build2/b-options.ixx b/build2/b-options.ixx index 3b799cb..fb9b10e 100644 --- a/build2/b-options.ixx +++ b/build2/b-options.ixx @@ -246,6 +246,18 @@ namespace build2 return this->verbose_specified_; } + inline const bool& options:: + no_column () const + { + return this->no_column_; + } + + inline const bool& options:: + no_line () const + { + return this->no_line_; + } + inline const path& options:: buildfile () const { diff --git a/build2/b.cli b/build2/b.cli index 16c8fb8..86211bb 100644 --- a/build2/b.cli +++ b/build2/b.cli @@ -241,6 +241,16 @@ namespace build2 \li|Even more detailed information, including state dumps.||" } + bool --no-column + { + "Don't print column numbers in diagnostics." + } + + bool --no-line + { + "Don't print line and column numbers in diagnostics." + } + path --buildfile = "buildfile" { "", diff --git a/build2/context b/build2/context index 9b0af8a..a035c5f 100644 --- a/build2/context +++ b/build2/context @@ -11,14 +11,11 @@ #include #include #include -#include namespace build2 { class file; - extern options ops; - extern string_pool extension_pool; extern string_pool project_name_pool; diff --git a/build2/context.cxx b/build2/context.cxx index 6d39da2..1b5e03c 100644 --- a/build2/context.cxx +++ b/build2/context.cxx @@ -25,8 +25,6 @@ using namespace butl; namespace build2 { - options ops; - string_pool extension_pool; string_pool project_name_pool; diff --git a/build2/diagnostics.cxx b/build2/diagnostics.cxx index ca395ab..945632a 100644 --- a/build2/diagnostics.cxx +++ b/build2/diagnostics.cxx @@ -93,11 +93,17 @@ namespace build2 r << *loc_.file << ':'; - if (loc_.line != 0) - r << loc_.line << ':'; - - if (loc_.column != 0) - r << loc_.column << ':'; + if (!ops.no_line ()) + { + if (loc_.line != 0) + r << loc_.line << ':'; + + if (!ops.no_column ()) + { + if (loc_.column != 0) + r << loc_.column << ':'; + } + } r << ' '; diff --git a/build2/test/script/parser.cxx b/build2/test/script/parser.cxx index e714665..e3194cb 100644 --- a/build2/test/script/parser.cxx +++ b/build2/test/script/parser.cxx @@ -1270,10 +1270,20 @@ namespace build2 { string n (l.file->string ()); n += ':'; - n += to_string (l.line); - n += ':'; - n += to_string (l.column); - n += ": ("; + + if (!ops.no_line ()) + { + n += to_string (l.line); + n += ':'; + + if (!ops.no_column ()) + { + n += to_string (l.column); + n += ':'; + } + } + + n += " ("; n += s; n += ')'; name = path (move (n)); diff --git a/build2/utility b/build2/utility index 7c30395..719eb60 100644 --- a/build2/utility +++ b/build2/utility @@ -19,6 +19,7 @@ #include #include +#include namespace build2 { @@ -83,6 +84,10 @@ namespace build2 next_word (const string&, size_t n, size_t& b, size_t& e, char d1 = ' ', char d2 = '\0'); + // Command line options. + // + extern options ops; + // Build system driver recall path (argv[0]). // extern path argv0; diff --git a/build2/utility.cxx b/build2/utility.cxx index 4b68edb..5b6056d 100644 --- a/build2/utility.cxx +++ b/build2/utility.cxx @@ -89,6 +89,7 @@ namespace build2 return l; } + options ops; path argv0; dir_path work; dir_path home; -- cgit v1.1