$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r80094 - trunk/tools/build/v2/engine
From: jurko.gospodnetic_at_[hidden]
Date: 2012-08-20 08:48:10
Author: jurko
Date: 2012-08-20 08:48:09 EDT (Mon, 20 Aug 2012)
New Revision: 80094
URL: http://svn.boost.org/trac/boost/changeset/80094
Log:
Internal Boost Jam cleanup - internal ShortPathToLongPath() function renamed to canonicWindowsPath() and commented better, related normalize_path() function commented better as well.
Text files modified: 
   trunk/tools/build/v2/engine/pathsys.h  |     2                                         
   trunk/tools/build/v2/engine/pathunix.c |    65 ++++++++++++++++++++++++++++----------- 
   2 files changed, 47 insertions(+), 20 deletions(-)
Modified: trunk/tools/build/v2/engine/pathsys.h
==============================================================================
--- trunk/tools/build/v2/engine/pathsys.h	(original)
+++ trunk/tools/build/v2/engine/pathsys.h	2012-08-20 08:48:09 EDT (Mon, 20 Aug 2012)
@@ -62,7 +62,7 @@
  * call to do a potentially expensive path conversion requiring access to the
  * actual underlying file system.
  */
-void path_register_key( OBJECT * path );
+void path_register_key( OBJECT * canonic_path );
 
 #ifdef USE_PATHUNIX
 /* Returns a static pointer to the system dependent path to the temporary
Modified: trunk/tools/build/v2/engine/pathunix.c
==============================================================================
--- trunk/tools/build/v2/engine/pathunix.c	(original)
+++ trunk/tools/build/v2/engine/pathunix.c	2012-08-20 08:48:09 EDT (Mon, 20 Aug 2012)
@@ -258,18 +258,25 @@
 
 
 /*
- * ShortPathToLongPath() - convert a given path into its long format
+ * canonicWindowsPath() - convert a given path into its canonic/long format
  *
- * In the process, automatically registers long paths for all of the parent
- * folders on the path, if they have not already been registered.
+ * Appends the canonic path to the end of the given 'string' object.
+ *
+ * FIXME: This function is still work-in-progress as it originally did not
+ * necessarily return the canonic path format (could return slightly different 
+ * results for certain equivalent path strings) and could accept paths pointing
+ * to non-existing file system entities as well.
+ *
+ * Caches results internally, automatically caching any parent paths it has to
+ * convert to their canonic format in the process.
  *
  * Prerequisites:
- *  - Path to given in normalized form, i.e. all of its folder separators have
- *    already been converted into '\\'.
- *  - path_key_cache path/key mapping cache object has already been initialized.
+ *  - path given in normalized form, i.e. all of its folder separators have
+ *    already been converted into '\\'
+ *  - path_key_cache path/key mapping cache object already initialized
  */
 
-static void ShortPathToLongPath( char const * const path, int const path_length,
+static void canonicWindowsPath( char const * const path, int const path_length,
     string * const out )
 {
     char const * last_element;
@@ -317,9 +324,8 @@
             path_key_cache, dir_obj, &found );
         if ( !found )
         {
-            /* dir is already normalized. */
             result->path = dir_obj;
-            ShortPathToLongPath( dir, dir_length, out );
+            canonicWindowsPath( dir, dir_length, out );
             result->key = object_new( out->value );
         }
         else
@@ -354,6 +360,27 @@
 }
 
 
+/*
+ * normalize_path() - 'normalizes' the given path for the path-key mapping
+ *
+ * The resulting string has nothing to do with 'normalized paths' as used in
+ * Boost Jam build scripts and the built-in NORMALIZE_PATH rule. It is intended
+ * to be used solely as an intermediate step when mapping an arbitrary path to
+ * its canonical representation.
+ *
+ * When choosing the intermediate string the important things are for it to be
+ * inexpensive to calculate and any two paths having different canonical
+ * representations also need to have different calculated intermediate string
+ * representations. Any implemented additional rules serve only to simplify
+ * constructing the canonical path representation from the calculated
+ * intermediate string.
+ *
+ * Implemented returned path rules:
+ *  - use backslashes as path separators
+ *  - lowercase only (since all Windows file systems are case insensitive)
+ *  - trim trailing path separator except in case of a root path, i.e. 'X:\'
+ */
+
 static void normalize_path( string * path )
 {
     char * s;
@@ -367,7 +394,7 @@
 
 
 static path_key_entry * path_key( OBJECT * const path,
-    int const known_to_be_long )
+    int const known_to_be_canonic )
 {
     path_key_entry * result;
     int found;
@@ -395,16 +422,16 @@
         if ( !found || nresult == result )
         {
             nresult->path = normalized;
-            if ( known_to_be_long )
+            if ( known_to_be_canonic )
                 nresult->key = object_copy( path );
             else
             {
-                string long_path[ 1 ];
-                string_new( long_path );
-                ShortPathToLongPath( object_str( normalized ), normalized_size,
-                    long_path );
-                nresult->key = object_new( long_path->value );
-                string_free( long_path );
+                string canonic_path[ 1 ];
+                string_new( canonic_path );
+                canonicWindowsPath( object_str( normalized ), normalized_size,
+                    canonic_path );
+                nresult->key = object_new( canonic_path->value );
+                string_free( canonic_path );
             }
         }
         else
@@ -420,9 +447,9 @@
 }
 
 
-void path_register_key( OBJECT * long_path )
+void path_register_key( OBJECT * canonic_path )
 {
-    path_key( long_path, 1 );
+    path_key( canonic_path, 1 );
 }