From d04cd568c85262d486f7a0de0a374c80d466c58e Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Fri, 2 Dec 2016 01:24:02 +0300 Subject: Use empty path for root scope --- build2/context.cxx | 8 +++----- build2/dump.cxx | 15 ++++++++++----- build2/parser.cxx | 9 +++------ 3 files changed, 16 insertions(+), 16 deletions(-) (limited to 'build2') diff --git a/build2/context.cxx b/build2/context.cxx index a193abf..0966c3a 100644 --- a/build2/context.cxx +++ b/build2/context.cxx @@ -80,19 +80,17 @@ namespace build2 operation_table.insert ("install"); operation_table.insert ("uninstall"); - // Create global scope. For Win32 this is not a "real" root path. - // On POSIX, however, this is a real path. See the comment in - // for details. + // Create global scope. Note that the empty path is a prefix for any other + // path. See the comment in for details. // { - auto i (scopes.insert (dir_path ("/"), false)); + auto i (scopes.insert (dir_path (), false)); global_scope = &i->second; global_scope->out_path_ = &i->first; } scope& gs (*global_scope); - // Parse and enter the command line variables. We do it before entering // any other variables so that all the variables that are overriden are // marked as such first. Then, as we enter variables, we can verify that diff --git a/build2/dump.cxx b/build2/dump.cxx index 9c26235..b959d9d 100644 --- a/build2/dump.cxx +++ b/build2/dump.cxx @@ -260,12 +260,17 @@ namespace build2 const dir_path& d (i->first); ++i; - // We don't want the extra notations (e.g., ~/) provided by - // diag_relative() since we want the path to be relative to - // the outer scope. + // We don't want the extra notations (e.g., ~/) provided by diag_relative() + // since we want the path to be relative to the outer scope. Print the root + // scope path (represented by an empty one) as a platform-dependent path + // separator. // - os << ind << relative (d) << ":" << endl - << ind << '{'; + if (d.empty ()) + os << ind << dir_path::traits::directory_separator; + else + os << ind << relative (d); + + os << ":" << endl << ind << '{'; const dir_path* orb (relative_base); relative_base = &d; diff --git a/build2/parser.cxx b/build2/parser.cxx index 2776020..1d2766c 100644 --- a/build2/parser.cxx +++ b/build2/parser.cxx @@ -24,7 +24,7 @@ namespace build2 { using type = token_type; - static const dir_path root_dir ("/"); + static const dir_path root_dir; class parser::enter_scope { @@ -33,11 +33,8 @@ namespace build2 enter_scope (parser& p, dir_path&& d): p_ (&p), r_ (p.root_), s_ (p.scope_) { - // Check for the global scope as a special case. While on POSIX the - // check is redundant, on Windows the path completion/normalization - // would otherwise transform it to the out path of the current scope - // since "/" is a relative path on Windows (and we use "/" even on - // Windows for that gloabl scope). + // Check for the global scope as a special case. Note that the global + // scope (empty) path is a prefix for any other scope path. // if (d != root_dir) { -- cgit v1.1