$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
From: bdawes_at_[hidden]
Date: 2007-11-13 08:54:58
Author: bemandawes
Date: 2007-11-13 08:54:58 EST (Tue, 13 Nov 2007)
New Revision: 41060
URL: http://svn.boost.org/trac/boost/changeset/41060
Log:
Correct detection of failure to run in a boost tree, and refactor code as a separate set_boost_root function.
Text files modified: 
   trunk/tools/regression/src/process_jam_log.cpp |    47 +++++++++++++++++++++++++++------------ 
   1 files changed, 32 insertions(+), 15 deletions(-)
Modified: trunk/tools/regression/src/process_jam_log.cpp
==============================================================================
--- trunk/tools/regression/src/process_jam_log.cpp	(original)
+++ trunk/tools/regression/src/process_jam_log.cpp	2007-11-13 08:54:58 EST (Tue, 13 Nov 2007)
@@ -16,9 +16,10 @@
 #include <string>
 #include <cstring>
 #include <map>
-#include <utility> // for make_pair
+#include <utility>  // for make_pair
 #include <ctime>
 #include <cctype>   // for tolower
+#include <cstdlib>  // for exit
 
 using std::string;
 namespace xml = boost::tiny_xml;
@@ -44,7 +45,33 @@
   fs::path boost_root;
   fs::path locate_root; // ALL_LOCATE_TARGET (or boost_root if none)
 
-//  append_html  -------------------------------------------------------------//
+  //  set_boost_root  --------------------------------------------------------//
+
+  void set_boost_root()
+  {
+    
+    boost_root = fs::initial_path();
+
+    for(;;)
+    {
+      if ( fs::exists( boost_root / "libs" ) )
+      {
+        fs::current_path( fs::initial_path() ); // restore initial path
+        return;
+      }
+      fs::current_path( ".." );
+      if ( boost_root == fs::current_path() )
+      {
+        fs::current_path( fs::initial_path() ); // restore initial path
+        std::cout <<
+          "Abort: process_jam_log must be run from within a boost directory tree\n";
+        std::exit(1);
+      }
+      boost_root = fs::current_path();
+    }
+  }
+ 
+ //  append_html  -------------------------------------------------------------//
 
   void append_html( const string & src, string & target )
   {
@@ -527,6 +554,8 @@
   // streams are implemented using standard C files.
   std::ios::sync_with_stdio(false);
 
+  fs::initial_path();
+
   if ( argc <= 1 )
     std::cout << "Usage: bjam [bjam-args] | process_jam_log [--echo] [--create-directories] [--v1|v2] [locate-root]\n"
                  "locate-root         - the same as the bjam ALL_LOCATE_TARGET\n"
@@ -537,19 +566,7 @@
                  "v1                  - bjam version 1 used.\n"
                  ;
 
-  boost_root = fs::initial_path();
-
-  while ( !boost_root.empty()
-    && !fs::exists( boost_root / "libs" ) )
-  {
-    boost_root /=  "..";
-  }
-
-  if ( boost_root.empty() )
-  {
-    std::cout << "must be run from within the boost-root directory tree\n";
-    return 1;
-  }
+  set_boost_root();
 
   boost_root.normalize();