#
# patch "ChangeLog"
# from [9b4a3253567c46c51190eb8174a08ff651273f09]
# to [d8c8b6f6d7c069754cdbc017ea2e6d18cc59597e]
#
# patch "paths.cc"
# from [7f37aa38ee4c273d555f49b665a157efed9808c8]
# to [f7dd2e61be1d6bf17092af94749435f520020c02]
#
========================================================================
--- ChangeLog 9b4a3253567c46c51190eb8174a08ff651273f09
+++ ChangeLog d8c8b6f6d7c069754cdbc017ea2e6d18cc59597e
@@ -1,5 +1,10 @@
2005-08-24 Nathaniel Smith
+ * paths.cc (struct access_tracker): Add invariant checking on
+ lifetime usage of path roots.
+
+2005-08-24 Nathaniel Smith
+
* paths.hh (any_path::operator =): return *this.
2005-08-24 Nathaniel Smith
========================================================================
--- paths.cc 7f37aa38ee4c273d555f49b665a157efed9808c8
+++ paths.cc f7dd2e61be1d6bf17092af94749435f520020c02
@@ -14,17 +14,41 @@
#include "platform.hh"
#include "sanity.hh"
+// some structure to ensure we aren't doing anything broken when resolving
+// filenames. the idea is to make sure
+// -- we don't depend on the existence of something before it has been set
+// -- we don't re-set something that has already been used
+template
+struct access_tracker
+{
+ void set(T const & val, bool may_be_initialized)
+ {
+ I(may_be_initialized || !initialized);
+ I(!used);
+ value = val;
+ }
+ T const & get() const
+ {
+ I(initialized);
+ used = true;
+ return value;
+ }
+ T value;
+ bool initialized, used;
+ access_tracker() : initialized(false), used(false);
+}
+
// paths to use in interpreting paths from various sources,
// conceptually:
// working_root / initial_rel_path == initial_abs_path
// initial_abs_path is for interpreting relative system_path's
-static system_path initial_abs_path;
+static access_tracker initial_abs_path;
// initial_rel_path is for interpreting external file_path's
-static file_path initial_rel_path;
+static access_tracker initial_rel_path;
// working_root is for converting file_path's and bookkeeping_path's to
// system_path's.
-static system_path working_root;
+static access_tracker working_root;
bookkeeping_path const bookkeeping_root("MT");
@@ -144,7 +168,7 @@
data = path;
break;
external:
- fs::path tmp(initial_rel_path.as_internal());
+ fs::path tmp(initial_rel_path.get().as_internal());
tmp /= fs::path(path, fs::native);
tmp = tmp.normalize();
data = utf8(tmp.string());