$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r79569 - in trunk/tools/build/v2: build engine engine/modules test/dependency-test util
From: jurko.gospodnetic_at_[hidden]
Date: 2012-07-17 04:56:52
Author: jurko
Date: 2012-07-17 04:56:49 EDT (Tue, 17 Jul 2012)
New Revision: 79569
URL: http://svn.boost.org/trac/boost/changeset/79569
Log:
Boost Jam/Build cleanup - minor stylistic changes (comment updates; line wrapping; removed some dead/unused function declarations, parameters & code; declared variables as const; reordered some #include directives alphabetically, removed some unnecessary ones and added several missing ones discovered by the reordering).
Text files modified: 
   trunk/tools/build/v2/build/scanner.jam             |   153 ++++++++++++++++++---------------       
   trunk/tools/build/v2/build/virtual-target.jam      |    42 ++++----                                
   trunk/tools/build/v2/engine/builtins.c             |    85 +++++++++++-------                      
   trunk/tools/build/v2/engine/class.c                |    36 ++++---                                 
   trunk/tools/build/v2/engine/compile.c              |   101 ++++++++++-----------                   
   trunk/tools/build/v2/engine/filent.c               |    66 +++++++------                           
   trunk/tools/build/v2/engine/fileunix.c             |     2                                         
   trunk/tools/build/v2/engine/function.c             |     2                                         
   trunk/tools/build/v2/engine/modules/order.c        |   183 +++++++++++++++++++++------------------ 
   trunk/tools/build/v2/engine/modules/property-set.c |   126 ++++++++++++---------------             
   trunk/tools/build/v2/engine/modules/regex.c        |    86 +++++++++--------                       
   trunk/tools/build/v2/engine/pathsys.h              |     4                                         
   trunk/tools/build/v2/engine/pathunix.c             |     5                                         
   trunk/tools/build/v2/engine/regexp.c               |     3                                         
   trunk/tools/build/v2/engine/regexp.h               |    20 ++-                                     
   trunk/tools/build/v2/engine/rules.c                |    17 +--                                     
   trunk/tools/build/v2/engine/rules.h                |    32 +++---                                  
   trunk/tools/build/v2/engine/search.c               |     6                                         
   trunk/tools/build/v2/engine/timestamp.c            |     4                                         
   trunk/tools/build/v2/test/dependency-test/foo.jam  |    11 +-                                      
   trunk/tools/build/v2/util/print.jam                |    44 ++++----                                
   21 files changed, 532 insertions(+), 496 deletions(-)
Modified: trunk/tools/build/v2/build/scanner.jam
==============================================================================
--- trunk/tools/build/v2/build/scanner.jam	(original)
+++ trunk/tools/build/v2/build/scanner.jam	2012-07-17 04:56:49 EDT (Tue, 17 Jul 2012)
@@ -1,78 +1,84 @@
-# Copyright 2003 Dave Abrahams 
-# Copyright 2002, 2003, 2004, 2005 Vladimir Prus 
-# Distributed under the Boost Software License, Version 1.0. 
-# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) 
-
-#  Implements scanners: objects that compute implicit dependencies for
-#  files, such as includes in C++.
-#
-#  Scanner has a regular expression used to find dependencies, some
-#  data needed to interpret those dependencies (for example, include
-#  paths), and a code which actually established needed relationship
-#  between actual jam targets.
-#
-#  Scanner objects are created by actions, when they try to actualize
-#  virtual targets, passed to 'virtual-target.actualize' method and are
-#  then associated with actual targets. It is possible to use
-#  several scanners for a virtual-target. For example, a single source
-#  might be used by to compile actions, with different include paths.
-#  In this case, two different actual targets will be created, each 
-#  having scanner of its own.
-#
-#  Typically, scanners are created from target type and action's 
-#  properties, using the rule 'get' in this module. Directly creating
-#  scanners is not recommended, because it might create many equvivalent
-#  but different instances, and lead in unneeded duplication of
-#  actual targets. However, actions can also create scanners in a special
-#  way, instead of relying on just target type.
+# Copyright 2003 Dave Abrahams
+# Copyright 2002, 2003, 2004, 2005 Vladimir Prus
+# Distributed under the Boost Software License, Version 1.0.
+# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
+
+# Implements scanners: objects computing implicit dependencies for files, such
+# as includes in C++.
+#
+# A scanner has a regular expression used to find the dependencies, some data
+# needed to interpret those dependencies (e.g., include paths), and code which
+# establishing needed relationships between actual jam targets.
+#
+# Scanner objects are created by actions when they try to actualize virtual
+# targets, passed to the virtual-target.actualize() method and are then
+# associated with actual targets. It is possible to use several scanners for a
+# single virtual-target. For example, a single source file might be compiled
+# twice - each time using a different include path. In this case, two separate
+# actual targets will be created, each having a scanner of its own.
+#
+# Typically, scanners are created from target type and the action's properties,
+# using the rule 'get' in this module. Directly creating scanners is not
+# recommended, as it might create multiple equvivalent but different instances,
+# and lead to unnecessary actual target duplication. However, actions can also
+# create scanners in a special way, instead of relying on just the target type.
 
 import "class" : new ;
-import property virtual-target property-set ;
-import errors : error ;
+import property ;
+import property-set ;
+import virtual-target ;
 
-#  Base scanner class. 
-class scanner 
+# Base scanner class.
+#
+class scanner
 {
     rule __init__ ( )
     {
     }
-    
-    # Returns a pattern to use for scanning
+
+    # Returns a pattern to use for scanning.
+    #
     rule pattern ( )
     {
-        error "method must be overriden" ;
+        import errors ;
+        errors.error "method must be overriden" ;
     }
 
-    # Establish necessary relationship between targets,
-    # given actual target beeing scanned, and a list of
-    # pattern matches in that file.
+    # Establish necessary relationship between targets, given an actual target
+    # beeing scanned and a list of pattern matches in that file.
+    #
     rule process ( target : matches * )
     {
-        error "method must be overriden" ;
-    }        
+        import errors ;
+        errors.error "method must be overriden" ;
+    }
 }
 
-# Registers a new generator class, specifying a set of 
-# properties relevant to this scanner.  Ctor for that class
-# should have one parameter: list of properties.
+
+# Registers a new generator class, specifying a set of properties relevant to
+# this scanner. Constructor for that class should have one parameter: a list of
+# properties.
+#
 rule register ( scanner-class : relevant-properties * )
 {
     .registered += $(scanner-class) ;
     .relevant-properties.$(scanner-class) = $(relevant-properties) ;
 }
 
-# Common scanner class, which can be used when there's only one
-# kind of includes (unlike C, where "" and <> includes have different
-# search paths).
-class common-scanner : scanner 
+
+# Common scanner class, usable when there is only one kind of includes (unlike
+# C, where "" and <> includes have different search paths).
+#
+class common-scanner : scanner
 {
     import scanner ;
+
     rule __init__ ( includes * )
     {
         scanner.__init__ ;
         self.includes = $(includes) ;
     }
-            
+
     rule process ( target : matches * : binding )
     {
         local target_path = [ NORMALIZE_PATH $(binding:D) ] ;
@@ -81,55 +87,61 @@
         INCLUDES $(target) : $(matches) ;
         SEARCH on $(matches) = $(target_path) $(self.includes:G=) ;
         ISFILE $(matches) ;
-    
-        scanner.propagate $(__name__) : $(matches) : $(target) ;     
+
+        scanner.propagate $(__name__) : $(matches) : $(target) ;
     }
 }
 
 
-# Returns an instance of previously registered scanner,
-# with the specified properties.
-rule get ( scanner-class : property-set ) 
+# Returns an instance of a previously registered scanner, with the specified
+# properties.
+#
+rule get ( scanner-class : property-set )
 {
     if ! $(scanner-class) in $(.registered)
     {
-        error "attempt to get unregisted scanner" ;
+        import errors ;
+        errors.error "attempt to get an unregisted scanner" ;
     }
-    
+
     local r = $(.rv-cache.$(property-set)) ;
     if ! $(r)
     {
-        r = [ property-set.create 
+        r = [ property-set.create
             [ property.select $(.relevant-properties.$(scanner-class)) :
-              [ $(property-set).raw ] ] ] ;        
+              [ $(property-set).raw ] ] ] ;
         .rv-cache.$(property-set) = $(r) ;
     }
-        
+
     if ! $(scanner.$(scanner-class).$(r:J=-))
     {
-        scanner.$(scanner-class).$(r:J=-) = [ new $(scanner-class) [ $(r).raw ] ] ;
+        local s = [ new $(scanner-class) [ $(r).raw ] ] ;
+        scanner.$(scanner-class).$(r:J=-) = $(s) ;
     }
-    return $(scanner.$(scanner-class).$(r:J=-)) ;    
+    return $(scanner.$(scanner-class).$(r:J=-)) ;
 }
 
 
-# Installs the specified scanner on actual target 'target'. 
+# Installs the specified scanner on the actual target 'target'.
+#
 rule install ( scanner : target 
-    vtarget # virtual target from which 'target' was actualized
+    vtarget  # virtual target from which 'target' was actualized
 )
 {
     HDRSCAN on $(target) = [ $(scanner).pattern ] ;
     SCANNER on $(target) = $(scanner) ;
     HDRRULE on $(target) = scanner.hdrrule ;
-    
-    # scanner reflects difference in properties affecting    
-    # binding of 'target', which will be known when processing
-    # includes for it, will give information on how to
-    # interpret quoted includes.
+
+    # Scanner reflects differences in properties affecting binding of 'target',
+    # which will be known when processing includes for it, and give information
+    # on how to interpret different include types (e.g. quoted vs. those in
+    # angle brackets in C files).
     HDRGRIST on $(target) = $(scanner) ;
 }
 
-# Propagate scanner setting from 'including-target' to 'targets'.
+
+# Propagate scanner settings from 'including-target' to 'targets'.
+#
 rule propagate ( scanner : targets * : including-target )
 {
     HDRSCAN on $(targets) = [ on $(including-target) return $(HDRSCAN) ] ;
@@ -144,8 +156,11 @@
     local scanner = [ on $(target) return $(SCANNER) ] ;
     $(scanner).process $(target) : $(matches) : $(binding) ;
 }
-# hdrrule must be available at global scope so that it can be invoked
-# by header scanning
+
+
+# hdrrule must be available at global scope so it can be invoked by header
+# scanning.
+#
 IMPORT scanner : hdrrule : : scanner.hdrrule ;
 
 
Modified: trunk/tools/build/v2/build/virtual-target.jam
==============================================================================
--- trunk/tools/build/v2/build/virtual-target.jam	(original)
+++ trunk/tools/build/v2/build/virtual-target.jam	2012-07-17 04:56:49 EDT (Tue, 17 Jul 2012)
@@ -113,12 +113,12 @@
     {
         return $(self.dependencies) ;
     }
-    
+
     rule always ( )
     {
         .always = 1 ;
     }
-    
+
     # Generates all the actual targets and sets up build actions for this
     # target.
     #
@@ -133,12 +133,12 @@
     rule actualize ( scanner ? )
     {
         local actual-name = [ actualize-no-scanner ] ;
-        
+
         if $(.always)
         {
             ALWAYS $(actual-name) ;
         }
-        
+
         if ! $(scanner)
         {
             return $(actual-name) ;
@@ -203,7 +203,7 @@
         # In fact, we just need to merge virtual-target with
         # abstract-file-target as the latter is the only class derived from the
         # former. But that has been left for later.
-	
+
         errors.error "method should be defined in derived classes" ;
     }
 }
@@ -760,20 +760,20 @@
 
             DEPENDS $(actual-targets) : $(self.actual-sources)
                 $(self.dependency-only-sources) ;
-            
-            # This works around a bug with -j and actions that
-            # produce multiple target, where:
-            # - dependency on the first output is found, and
-            #   the action is started
-            # - dependency on the second output is found, and
-            #   bjam noticed that command is already running
-            # - instead of waiting for the command, dependents
-            #   of the second targets are immediately updated.
+
+            # This works around a bug with -j and actions that produce multiple
+            # target, where:
+            # - dependency on the first output is found, and the action is
+            #   started
+            # - dependency on the second output is found, and bjam noticed that
+            #   command is already running
+            # - instead of waiting for the command, dependents of the second
+            #   targets are immediately updated.
             if $(actual-targets[2])
-            {                
+            {
                 INCLUDES $(actual-targets) : $(actual-targets) ;
             }
-            
+
             # Action name can include additional argument to rule, which should
             # not be passed to 'set-target-variables'
             toolset.set-target-variables
@@ -1104,7 +1104,8 @@
         {
             if ! [ $(t).root ]
             {
-                result += [ traverse $(t) : $(include-roots) : $(include-sources) ] ;
+                result += [ traverse $(t) : $(include-roots) :
+                    $(include-sources) ] ;
             }
             else if $(include-roots)
             {
@@ -1125,7 +1126,8 @@
 # 'new-rule-name' and 'new-properties', if those are specified. Returns the
 # cloned action.
 #
-rule clone-action ( action : new-project : new-action-name ? : new-properties ? )
+rule clone-action ( action : new-project : new-action-name ? : new-properties ?
+    )
 {
     if ! $(new-action-name)
     {
@@ -1245,7 +1247,7 @@
             {
                 $(theset).add $(t) ;
                 r += [ $(t:G=).creating-subvariant ] ;
-            }            
+            }
         }
         r = [ sequence.unique $(r) ] ;
         for local s in $(r)
@@ -1259,7 +1261,7 @@
 
     # Returns the properties specifying implicit include paths to generated
     # headers. This traverses all targets in this subvariant and subvariants
-    # referred by <implcit-dependecy> properties. For all targets of type
+    # referred by <implicit-dependecy> properties. For all targets of type
     # 'target-type' (or for all targets, if 'target-type' is not specified), the
     # result will contain <$(feature)>path-to-that-target.
     #
Modified: trunk/tools/build/v2/engine/builtins.c
==============================================================================
--- trunk/tools/build/v2/engine/builtins.c	(original)
+++ trunk/tools/build/v2/engine/builtins.c	2012-07-17 04:56:49 EDT (Tue, 17 Jul 2012)
@@ -497,6 +497,7 @@
 {
     LIST * const targets = lol_get( frame->args, 0 );
     LIST * const sources = lol_get( frame->args, 1 );
+
     LISTITER iter = list_begin( targets );
     LISTITER end = list_end( targets );
     for ( ; iter != end; iter = list_next( iter ) )
@@ -664,7 +665,7 @@
     }
 
     string_new( buf );
-    path_build( &f, buf, 0 );
+    path_build( &f, buf );
 
     if ( globbing->case_insensitive )
         downcase_inplace( buf->value );
@@ -675,7 +676,8 @@
     {
         if ( !glob( object_str( list_item( iter ) ), buf->value ) )
         {
-            globbing->results = list_push_back( globbing->results, object_copy( file ) );
+            globbing->results = list_push_back( globbing->results, object_copy(
+                file ) );
             break;
         }
     }
@@ -824,7 +826,7 @@
             path->f_grist.len = 0;
             path->f_dir.ptr = 0;
             path->f_dir.len = 0;
-            path_build( path, basename, 0 );
+            path_build( path, basename );
 
             dirs =  has_wildcards( dirname->value )
                 ? glob_recursive( dirname->value )
@@ -836,7 +838,8 @@
                 LISTITER iter = list_begin( dirs );
                 LISTITER const end = list_end( dirs );
                 for ( ; iter != end; iter = list_next( iter ) )
-                    result = list_append( result, glob1( list_item( iter ), b ) );
+                    result = list_append( result, glob1( list_item( iter ), b )
+                        );
                 object_free( b );
             }
             else
@@ -852,7 +855,7 @@
                     OBJECT * p;
                     path->f_dir.ptr = object_str( list_item( iter ) );
                     path->f_dir.len = strlen( object_str( list_item( iter ) ) );
-                    path_build( path, file_string, 0 );
+                    path_build( path, file_string );
 
                     p = object_new( file_string->value );
 
@@ -1028,8 +1031,8 @@
 
 static void add_rule_name( void * r_, void * result_ )
 {
-    RULE * r = (RULE *)r_;
-    LIST * * result = (LIST * *)result_;
+    RULE * const r = (RULE *)r_;
+    LIST * * const result = (LIST * *)result_;
     if ( r->exported )
         *result = list_push_back( *result, object_copy( r->name ) );
 }
@@ -1039,8 +1042,9 @@
 {
     LIST * arg0 = lol_get( frame->args, 0 );
     LIST * result = L0;
-    module_t * source_module = bindmodule( !list_empty( arg0 ) ?
-        list_front( arg0 ) : 0 );
+    module_t * const source_module = bindmodule( list_empty( arg0 )
+        ? 0
+        : list_front( arg0 ) );
 
     if ( source_module->rules )
         hashenumerate( source_module->rules, add_rule_name, &result );
@@ -1069,10 +1073,11 @@
 {
     LIST * arg0 = lol_get( frame->args, 0 );
     LIST * result = L0;
-    module_t * source_module = bindmodule( !list_empty(arg0) ? list_front(arg0) : 0 );
-
-    struct hash * vars = source_module->variables;
+    module_t * source_module = bindmodule( list_empty( arg0 )
+        ? 0
+        : list_front( arg0 ) );
 
+    struct hash * const vars = source_module->variables;
     if ( vars )
         hashenumerate( vars, add_hash_key, &result );
     return result;
@@ -1148,13 +1153,17 @@
     LIST * target_rules       = lol_get( frame->args, 3 );
     LIST * localize           = lol_get( frame->args, 4 );
 
-    module_t * target_module =
-        bindmodule( !list_empty( target_module_list ) ? list_front( target_module_list ) : 0 );
-    module_t * source_module =
-        bindmodule( !list_empty( source_module_list ) ? list_front( source_module_list ) : 0 );
+    module_t * target_module = bindmodule( list_empty( target_module_list )
+        ? 0
+        : list_front( target_module_list ) );
+    module_t * source_module = bindmodule( list_empty( source_module_list )
+        ? 0
+        : list_front( source_module_list ) );
 
-    LISTITER source_iter = list_begin( source_rules ), source_end = list_end( source_rules );
-    LISTITER target_iter = list_begin( target_rules ), target_end = list_end( target_rules );
+    LISTITER source_iter = list_begin( source_rules );
+    LISTITER const source_end = list_end( source_rules );
+    LISTITER target_iter = list_begin( target_rules );
+    LISTITER const target_end = list_end( target_rules );
 
     for ( ;
           source_iter != source_end && target_iter != target_end;
@@ -1164,9 +1173,10 @@
         RULE * r;
         RULE * imported;
 
-        if ( !source_module->rules ||
-            !(r = (RULE *)hash_find( source_module->rules, list_item( source_iter ) ) ) )
-            unknown_rule( frame, "IMPORT", source_module, list_item( source_iter ) );
+        if ( !source_module->rules || !(r = (RULE *)hash_find(
+            source_module->rules, list_item( source_iter ) ) ) )
+            unknown_rule( frame, "IMPORT", source_module, list_item( source_iter
+                ) );
 
         imported = import_rule( r, target_module, list_item( target_iter ) );
         if ( !list_empty( localize ) )
@@ -1180,7 +1190,8 @@
     if ( source_iter != source_end || target_iter != target_end )
     {
         backtrace_line( frame->prev );
-        printf( "import error: length of source and target rule name lists don't match!\n" );
+        printf( "import error: length of source and target rule name lists "
+            "don't match!\n" );
         printf( "    source: " );
         list_print( source_rules );
         printf( "\n    target: " );
@@ -1575,13 +1586,14 @@
             /* Found a trailing or duplicate '/'. Remove it. */
             *current = '\1';
         }
-        else if ( ( end - current == 1 ) && ( *(current + 1) == '.' ) )
+        else if ( ( end - current == 1 ) && ( *( current + 1 ) == '.' ) )
         {
             /* Found '/.'. Remove them all. */
             *current = '\1';
             *(current + 1) = '\1';
         }
-        else if ( ( end - current == 2 ) && ( *(current + 1) == '.' ) && ( *(current + 2) == '.' ) )
+        else if ( ( end - current == 2 ) && ( *( current + 1 ) == '.' ) &&
+            ( *( current + 2 ) == '.' ) )
         {
             /* Found '/..'. Remove them all. */
             *current = '\1';
@@ -1629,7 +1641,9 @@
      * the original path was rooted and we have an empty path we need to add
      * back the '/'.
      */
-    result = object_new( out->size ? out->value + !rooted : ( rooted ? "/" : "." ) );
+    result = object_new( out->size
+        ? out->value + !rooted
+        : ( rooted ? "/" : "." ) );
 
     string_free( out );
     string_free( in );
@@ -1646,7 +1660,8 @@
     module_t * module = bindmodule( list_front( module_name ) );
 
     native_rule_t * np;
-    if ( module->native_rules && (np = (native_rule_t *)hash_find( module->native_rules, list_front( rule_name ) ) ) )
+    if ( module->native_rules && (np = (native_rule_t *)hash_find(
+        module->native_rules, list_front( rule_name ) ) ) )
     {
         new_rule_body( module, np->name, np->procedure, 1 );
     }
@@ -1654,7 +1669,7 @@
     {
         backtrace_line( frame->prev );
         printf( "error: no native rule \"%s\" defined in module \"%s.\"\n",
-                object_str( list_front( rule_name ) ), object_str( module->name ) );
+            object_str( list_front( rule_name ) ), object_str( module->name ) );
         backtrace( frame->prev );
         exit( 1 );
     }
@@ -1671,7 +1686,8 @@
     module_t * module = bindmodule( list_front( module_name ) );
 
     native_rule_t * np;
-    if ( module->native_rules && (np = (native_rule_t *)hash_find( module->native_rules, list_front( rule_name ) ) ) )
+    if ( module->native_rules && (np = (native_rule_t *)hash_find(
+        module->native_rules, list_front( rule_name ) ) ) )
     {
         int expected_version = atoi( object_str( list_front( version ) ) );
         if ( np->version == expected_version )
@@ -1832,8 +1848,10 @@
 LIST * builtin_python_import_rule( FRAME * frame, int flags )
 {
     static int first_time = 1;
-    char const * python_module   = object_str( list_front( lol_get( frame->args, 0 ) ) );
-    char const * python_function = object_str( list_front( lol_get( frame->args, 1 ) ) );
+    char const * python_module   = object_str( list_front( lol_get( frame->args,
+        0 ) ) );
+    char const * python_function = object_str( list_front( lol_get( frame->args,
+        1 ) ) );
     OBJECT     * jam_module      = list_front( lol_get( frame->args, 2 ) );
     OBJECT     * jam_rule        = list_front( lol_get( frame->args, 3 ) );
 
@@ -2014,8 +2032,8 @@
  * - rule name,
  * - Python callable.
  * - (optional) bjam language function signature.
- * Creates a bjam rule with the specified name in the specified module, which will
- * invoke the Python callable.
+ * Creates a bjam rule with the specified name in the specified module, which
+ * will invoke the Python callable.
  */
 
 PyObject * bjam_import_rule( PyObject * self, PyObject * args )
@@ -2309,7 +2327,8 @@
 
     string_new( &s );
 
-    while ( ( ret = fread( buffer, sizeof( char ), sizeof( buffer ) - 1, p ) ) > 0 )
+    while ( ( ret = fread( buffer, sizeof( char ), sizeof( buffer ) - 1, p ) ) >
+        0 )
     {
         buffer[ ret ] = 0;
         if ( !no_output_opt )
Modified: trunk/tools/build/v2/engine/class.c
==============================================================================
--- trunk/tools/build/v2/engine/class.c	(original)
+++ trunk/tools/build/v2/engine/class.c	2012-07-17 04:56:49 EDT (Tue, 17 Jul 2012)
@@ -3,13 +3,14 @@
 /* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) */
 
 #include "class.h"
-#include "strings.h"
-#include "variable.h"
-#include "frames.h"
-#include "rules.h"
-#include "object.h"
 
+#include "constants.h"
+#include "frames.h"
 #include "hash.h"
+#include "object.h"
+#include "rules.h"
+#include "strings.h"
+#include "variable.h"
 
 
 static struct hash * classes = 0;
@@ -17,12 +18,14 @@
 
 static void check_defined( LIST * class_names )
 {
-    LISTITER iter = list_begin( class_names ), end = list_end( class_names );
+    LISTITER iter = list_begin( class_names );
+    LISTITER const end = list_end( class_names );
     for ( ; iter != end; iter = list_next( iter ) )
     {
         if ( !hash_find( classes, list_item( iter ) ) )
         {
-            printf( "Class %s is not defined\n", object_str( list_item( iter ) ) );
+            printf( "Class %s is not defined\n", object_str( list_item( iter ) )
+                );
             abort();
         }
     }
@@ -59,15 +62,15 @@
     RULE * ir1;
     RULE * ir2;
     struct import_base_data * d = (struct import_base_data *)d_;
-    string qualified_name[ 1 ];
     OBJECT * qname;
 
-    string_new      ( qualified_name               );
+    string qualified_name[ 1 ];
+    string_new      ( qualified_name                             );
     string_append   ( qualified_name, object_str( d->base_name ) );
-    string_push_back( qualified_name, '.'          );
-    string_append   ( qualified_name, object_str( r->name ) );
-
+    string_push_back( qualified_name, '.'                        );
+    string_append   ( qualified_name, object_str( r->name )      );
     qname = object_new( qualified_name->value );
+    string_free( qualified_name );
 
     ir1 = import_rule( r, d->class_module, r->name );
     ir2 = import_rule( r, d->class_module, qname );
@@ -84,8 +87,6 @@
         rule_localize( ir1, d->class_module );
         rule_localize( ir2, d->class_module );
     }
-
-    string_free( qualified_name );
 }
 
 
@@ -144,21 +145,24 @@
     var_set( class_module, constant_name, xname, VAR_SET );
     var_set( class_module, constant_bases, bases, VAR_SET );
 
-    iter = list_begin( bases ), end = list_end( bases );
+    iter = list_begin( bases );
+    end = list_end( bases );
     for ( ; iter != end; iter = list_next( iter ) )
         import_base_rules( class_module, list_item( iter ) );
 
     return name;
 }
 
+
 static void free_class( void * xclass, void * data )
 {
     object_free( *(OBJECT * *)xclass );
 }
 
+
 void class_done( void )
 {
-    if( classes )
+    if ( classes )
     {
         hashenumerate( classes, free_class, (void *)0 );
         hashdone( classes );
Modified: trunk/tools/build/v2/engine/compile.c
==============================================================================
--- trunk/tools/build/v2/engine/compile.c	(original)
+++ trunk/tools/build/v2/engine/compile.c	2012-07-17 04:56:49 EDT (Tue, 17 Jul 2012)
@@ -10,33 +10,10 @@
  *  (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
  */
 
-# include "jam.h"
-
-# include "lists.h"
-# include "parse.h"
-# include "compile.h"
-# include "variable.h"
-# include "rules.h"
-# include "object.h"
-# include "make.h"
-# include "search.h"
-# include "hdrmacro.h"
-# include "hash.h"
-# include "modules.h"
-# include "strings.h"
-# include "builtins.h"
-# include "class.h"
-# include "constants.h"
-
-# include <assert.h>
-# include <string.h>
-# include <stdarg.h>
-
 /*
  * compile.c - compile parsed jam statements
  *
  * External routines:
- *
  *  compile_append() - append list results of two statements
  *  compile_eval() - evaluate if to determine which leg to compile
  *  compile_foreach() - compile the "for x in y" statement
@@ -56,17 +33,34 @@
  *  compile_switch() - compile 'switch' rule
  *
  * Internal routines:
- *
- *  debug_compile() - printf with indent to show rule expansion.
+ *  debug_compile() - printf with indent to show rule expansion
  *  evaluate_rule() - execute a rule invocation
- *
- *  builtin_depends() - DEPENDS/INCLUDES rule
- *  builtin_echo() - ECHO rule
- *  builtin_exit() - EXIT rule
- *  builtin_flags() - NOCARE, NOTFILE, TEMPORARY rule
  */
 
-static void debug_compile( int which, const char * s, FRAME * );
+#include "jam.h"
+#include "compile.h"
+
+#include "builtins.h"
+#include "class.h"
+#include "constants.h"
+#include "hash.h"
+#include "hdrmacro.h"
+#include "lists.h"
+#include "make.h"
+#include "modules.h"
+#include "object.h"
+#include "parse.h"
+#include "rules.h"
+#include "search.h"
+#include "strings.h"
+#include "variable.h"
+
+#include <assert.h>
+#include <stdarg.h>
+#include <string.h>
+
+
+static void debug_compile( int which, char const * s, FRAME * );
 
 /* Internal functions from builtins.c */
 void backtrace( FRAME * );
@@ -76,7 +70,7 @@
 
 
 /*
- * evaluate_rule() - execute a rule invocation.
+ * evaluate_rule() - execute a rule invocation
  */
 
 LIST * evaluate_rule( OBJECT * rulename, FRAME * frame )
@@ -91,13 +85,14 @@
     if ( DEBUG_COMPILE )
     {
         /* Try hard to indicate in which module the rule is going to execute. */
-        if ( rule->module != frame->module
-             && rule->procedure != 0 && !object_equal( rulename, function_rulename( rule->procedure ) ) )
+        if ( rule->module != frame->module && rule->procedure && !object_equal(
+            rulename, function_rulename( rule->procedure ) ) )
         {
-            char buf[256] = "";
+            char buf[ 256 ] = "";
             if ( rule->module->name )
             {
-                strncat( buf, object_str( rule->module->name ), sizeof( buf ) - 1 );
+                strncat( buf, object_str( rule->module->name ), sizeof( buf ) -
+                    1 );
                 strncat( buf, ".", sizeof( buf ) - 1 );
             }
             strncat( buf, object_str( rule->name ), sizeof( buf ) - 1 );
@@ -150,11 +145,12 @@
 
         /* If we have a group of targets all being built using the same action
          * then we must not allow any of them to be used as sources unless they
-         * had all already been built in the first place or their joined action
-         * has had a chance to finish its work and build all of them anew.
+         * are all up to date and their action does not need to be run or their
+         * action has had a chance to finish its work and build all of them
+         * anew.
          *
          * Without this it might be possible, in case of a multi-process build,
-         * for their action, triggered by buiding one of the targets, to still
+         * for their action, triggered to building one of the targets, to still
          * be running when another target in the group reports as done in order
          * to avoid triggering the same action again and gets used prematurely.
          *
@@ -168,7 +164,7 @@
          * dependency' issue.
          *
          * TODO: Although the current implementation solves the problem of one
-         * of the targets getting used before its action completes its work it
+         * of the targets getting used before its action completes its work, it
          * also forces the action to run whenever any of the targets in the
          * group is not up to date even though some of them might not actually
          * be used by the targets being built. We should see how we can
@@ -182,7 +178,7 @@
          */
         if ( action->targets )
         {
-            TARGET * t0 = action->targets->target;
+            TARGET * const t0 = action->targets->target;
             for ( t = action->targets->next; t; t = t->next )
             {
                 target_include( t->target, t0 );
@@ -198,13 +194,12 @@
     }
 
     /* Now recursively compile any parse tree associated with this rule.
-     * function_refer()/function_free() call pair added to ensure rule not freed
-     * during use.
+     * function_refer()/function_free() call pair added to ensure the rule does
+     * not get freed while in use.
      */
     if ( rule->procedure )
     {
-        FUNCTION * function = rule->procedure;
-
+        FUNCTION * const function = rule->procedure;
         function_refer( function );
         result = function_run( function, frame, stack_global() );
         function_free( function );
@@ -214,7 +209,7 @@
         profile_exit( prof );
 
     if ( DEBUG_COMPILE )
-        debug_compile( -1, 0, frame);
+        debug_compile( -1, 0, frame );
 
     return result;
 }
@@ -234,17 +229,18 @@
     va_list va;
     LIST * result;
 
-    FRAME       inner[1];
+    FRAME inner[ 1 ];
     frame_init( inner );
     inner->prev = caller_frame;
-    inner->prev_user = caller_frame->module->user_module ?
-        caller_frame : caller_frame->prev_user;
+    inner->prev_user = caller_frame->module->user_module
+        ? caller_frame
+        : caller_frame->prev_user;
     inner->module = caller_frame->module;
 
     va_start( va, caller_frame );
     for ( ; ; )
     {
-        LIST * l = va_arg( va, LIST* );
+        LIST * const l = va_arg( va, LIST * );
         if ( !l )
             break;
         lol_add( inner->args, l );
@@ -259,12 +255,11 @@
 }
 
 
-
 /*
- * debug_compile() - printf with indent to show rule expansion.
+ * debug_compile() - printf with indent to show rule expansion
  */
 
-static void debug_compile( int which, const char * s, FRAME * frame )
+static void debug_compile( int which, char const * s, FRAME * frame )
 {
     static int level = 0;
     static char indent[36] = ">>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|";
Modified: trunk/tools/build/v2/engine/filent.c
==============================================================================
--- trunk/tools/build/v2/engine/filent.c	(original)
+++ trunk/tools/build/v2/engine/filent.c	2012-07-17 04:56:49 EDT (Tue, 17 Jul 2012)
@@ -38,7 +38,6 @@
 #  include <dos.h>
 # endif
 # undef FILENAME  /* cpp namespace collision */
-# define _finddata_t ffblk
 #endif
 
 #define WIN32_LEAN_AND_MEAN
@@ -59,7 +58,6 @@
     PATHNAME f;
     string pathspec[ 1 ];
     string pathname[ 1 ];
-    struct _finddata_t finfo[ 1 ];
     LIST * files = L0;
     int d_length;
 
@@ -90,34 +88,38 @@
     }
 
 #if defined(__BORLANDC__) && __BORLANDC__ < 0x550
-    if ( findfirst( pathspec->value, finfo, FA_NORMAL | FA_DIREC ) )
     {
-        string_free( pathspec );
-        return -1;
-    }
+        struct ffblk finfo;
+        if ( findfirst( pathspec->value, &finfo, FA_NORMAL | FA_DIREC ) )
+        {
+            string_free( pathspec );
+            return -1;
+        }
 
-    string_new( pathname );
-    do
-    {
-        f.f_base.ptr = finfo->ff_name;
-        f.f_base.len = strlen( finfo->ff_name );
-        string_truncate( pathname, 0 );
-        path_build( &f, pathname );
-
-        files = list_push_back( files, object_new( pathname->value ) );
-        {
-            file_info_t * const ff = file_info( pathname->value );
-            ff->is_file = finfo->ff_attrib & FA_DIREC ? 0 : 1;
-            ff->is_dir = !ff->is_file;
-            ff->size = finfo->ff_fsize;
-            timestamp_init( &ff->time, ( finfo->ff_ftime << 16 ) |
-                finfo->ff_ftime, 0 );
+        string_new( pathname );
+        do
+        {
+            f.f_base.ptr = finfo.ff_name;
+            f.f_base.len = strlen( finfo.ff_name );
+            string_truncate( pathname, 0 );
+            path_build( &f, pathname );
+
+            {
+                file_info_t * const ff = file_info( pathname->value );
+                ff->is_dir = finfo.ff_attrib & FA_DIREC ? 1 : 0;
+                ff->is_file = !ff->is_dir;
+                ff->size = finfo.ff_fsize;
+                timestamp_init( &ff->time, ( finfo.ff_ftime << 16 ) |
+                    finfo.ff_ftime, 0 );
+                files = list_push_back( files, object_new( pathname->value ) );
+            }
         }
+        while ( !findnext( &finfo ) );
     }
-    while ( !findnext( finfo ) );
 #else  /* defined(__BORLANDC__) && __BORLANDC__ < 0x550 */
     {
-        long const handle = _findfirst( pathspec->value, finfo );
+        struct _finddata_t finfo;
+        long const handle = _findfirst( pathspec->value, &finfo );
         if ( handle < 0L )
         {
             string_free( pathspec );
@@ -129,23 +131,23 @@
         {
             OBJECT * pathname_obj;
 
-            f.f_base.ptr = finfo->name;
-            f.f_base.len = strlen( finfo->name );
+            f.f_base.ptr = finfo.name;
+            f.f_base.len = strlen( finfo.name );
             string_truncate( pathname, 0 );
-            path_build( &f, pathname, 0 );
+            path_build( &f, pathname );
 
             pathname_obj = object_new( pathname->value );
             path_key__register_long_path( pathname_obj );
             files = list_push_back( files, pathname_obj );
             {
                 file_info_t * const ff = file_info( pathname_obj );
-                ff->is_file = finfo->attrib & _A_SUBDIR ? 0 : 1;
-                ff->is_dir = !ff->is_file;
-                ff->size = finfo->size;
-                timestamp_init( &ff->time, finfo->time_write, 0 );
+                ff->is_dir = finfo.attrib & _A_SUBDIR ? 1 : 0;
+                ff->is_file = !ff->is_dir;
+                ff->size = finfo.size;
+                timestamp_init( &ff->time, finfo.time_write, 0 );
             }
         }
-        while ( !_findnext( handle, finfo ) );
+        while ( !_findnext( handle, &finfo ) );
 
         _findclose( handle );
     }
Modified: trunk/tools/build/v2/engine/fileunix.c
==============================================================================
--- trunk/tools/build/v2/engine/fileunix.c	(original)
+++ trunk/tools/build/v2/engine/fileunix.c	2012-07-17 04:56:49 EDT (Tue, 17 Jul 2012)
@@ -134,7 +134,7 @@
         f.f_base.len = strlen( f.f_base.ptr );
 
         string_truncate( path, 0 );
-        path_build( &f, path, 0 );
+        path_build( &f, path );
         files = list_push_back( files, object_new( path->value ) );
     }
     string_free( path );
Modified: trunk/tools/build/v2/engine/function.c
==============================================================================
--- trunk/tools/build/v2/engine/function.c	(original)
+++ trunk/tools/build/v2/engine/function.c	2012-07-17 04:56:49 EDT (Tue, 17 Jul 2012)
@@ -631,7 +631,7 @@
             path_parent( &pathname );
 
         /* Put filename back together. */
-        path_build( &pathname, out, 0 );
+        path_build( &pathname, out );
     }
     else
         string_append( out, in );
Modified: trunk/tools/build/v2/engine/modules/order.c
==============================================================================
--- trunk/tools/build/v2/engine/modules/order.c	(original)
+++ trunk/tools/build/v2/engine/modules/order.c	2012-07-17 04:56:49 EDT (Tue, 17 Jul 2012)
@@ -2,146 +2,157 @@
 /* Software License, Version 1.0. (See accompanying */
 /* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) */
 
-#include "../native.h"
 #include "../lists.h"
-#include "../strings.h"
+#include "../mem.h"
+#include "../native.h"
 #include "../object.h"
+#include "../strings.h"
 #include "../variable.h"
 
 
-/* Use quite klugy approach: when we add order dependency from 'a' to 'b',
-   just append 'b' to of value of variable 'a'.
-*/
-LIST *add_pair( FRAME *frame, int flags )
-{
-    LIST* arg = lol_get( frame->args, 0 );    
-    LISTITER iter = list_begin( arg ), end = list_end( arg );
-
-    var_set( frame->module, list_item( iter ), list_copy_range( arg, list_next( iter ), end ), VAR_APPEND );
-
+/* Use quite klugy approach: when we add order dependency from 'a' to 'b', just
+ * append 'b' to of value of variable 'a'.
+ */
+LIST * add_pair( FRAME * frame, int flags )
+{
+    LIST * arg = lol_get( frame->args, 0 );
+    LISTITER iter = list_begin( arg );
+    LISTITER const end = list_end( arg );
+    var_set( frame->module, list_item( iter ), list_copy_range( arg, list_next(
+        iter ), end ), VAR_APPEND );
     return L0;
 }
 
-/** Given a list and a value, returns position of that value in
-    the list, or -1 if not found.
-*/
-int list_index(LIST* list, OBJECT* value)
+
+/* Given a list and a value, returns position of that value in the list, or -1
+ * if not found.
+ */
+int list_index( LIST * list, OBJECT * value )
 {
     int result = 0;
-    LISTITER iter = list_begin(list), end = list_end(list);
-    for(; iter != end; iter = list_next(iter), ++result) {
-        if (object_equal(list_item(iter), value))
+    LISTITER iter = list_begin( list );
+    LISTITER const end = list_end( list );
+    for ( ; iter != end; iter = list_next( iter ), ++result )
+        if ( object_equal( list_item( iter ), value ) )
             return result;
-    }
     return -1;
 }
 
 enum colors { white, gray, black };
 
-/* Main routite of topological sort. Calls itself recursively on all
-   adjacent vertices which were not yet visited. After that, 'current_vertex'
-   is added to '*result_ptr'.
-*/
-void do_ts(int** graph, int current_vertex, int* colors, int** result_ptr)
+
+/* Main routine for topological sort. Calls itself recursively on all adjacent
+ * vertices which were not yet visited. After that, 'current_vertex' is added to
+ * '*result_ptr'.
+ */
+void do_ts( int * * graph, int current_vertex, int * colors, int * * result_ptr
+    )
 {
     int i;
 
-    colors[current_vertex] = gray;
-    for(i = 0; graph[current_vertex][i] != -1; ++i) {
-        int adjacent_vertex = graph[current_vertex][i];
-
-        if (colors[adjacent_vertex] == white)
-            do_ts(graph, adjacent_vertex, colors, result_ptr);
-        /* The vertex is either black, in which case we don't have to do
-           anything, a gray, in which case we have a loop. If we have a loop,
-           it's not clear what useful diagnostic we can emit, so we emit
-           nothing.  */
-    }
-    colors[current_vertex] = black;
-    **result_ptr = current_vertex;    
-    (*result_ptr)++;
+    colors[ current_vertex ] = gray;
+    for ( i = 0; graph[ current_vertex ][ i ] != -1; ++i )
+    {
+        int adjacent_vertex = graph[ current_vertex ][ i ];
+        if ( colors[ adjacent_vertex ] == white )
+            do_ts( graph, adjacent_vertex, colors, result_ptr );
+        /* The vertex is either black, in which case we do not have to do
+         * anything, or gray, in which case we have a loop. If we have a loop,
+         * it is not clear what useful diagnostic we can emit, so we emit
+         * nothing.
+         */
+    }
+    colors[ current_vertex ] = black;
+    **result_ptr = current_vertex;
+    ( *result_ptr )++;
 }
 
-void topological_sort(int** graph, int num_vertices, int* result)
+
+void topological_sort( int * * graph, int num_vertices, int * result )
 {
     int i;
-    int* colors = (int*)BJAM_CALLOC(num_vertices, sizeof(int));
-    for (i = 0; i < num_vertices; ++i)
-        colors[i] = white;
+    int * colors = ( int * )BJAM_CALLOC( num_vertices, sizeof( int ) );
+    for ( i = 0; i < num_vertices; ++i )
+        colors[ i ] = white;
 
-    for(i = 0; i < num_vertices; ++i)
-        if (colors[i] == white)
-            do_ts(graph, i, colors, &result);
+    for ( i = 0; i < num_vertices; ++i )
+        if ( colors[ i ] == white )
+            do_ts( graph, i, colors, &result );
 
-    BJAM_FREE(colors);
+    BJAM_FREE( colors );
 }
 
-LIST *order( FRAME *frame, int flags )
+
+LIST * order( FRAME * frame, int flags )
 {
-    LIST* arg = lol_get( frame->args, 0 );
-    LIST* result = L0;
+    LIST * arg = lol_get( frame->args, 0 );
+    LIST * result = L0;
     int src;
-    LISTITER iter = list_begin(arg), end = list_end(arg);
+    LISTITER iter = list_begin( arg );
+    LISTITER const end = list_end( arg );
+
+    /* We need to create a graph of order dependencies between the passed
+     * objects. We assume there are no duplicates passed to 'add_pair'.
+     */
+    int length = list_length( arg );
+    int * * graph = ( int * * )BJAM_CALLOC( length, sizeof( int * ) );
+    int * order = ( int * )BJAM_MALLOC( ( length + 1 ) * sizeof( int ) );
 
-    /* We need to create a graph of order dependencies between
-       the passed objects. We assume that there are no duplicates
-       passed to 'add_pair'.
-    */
-    int length = list_length(arg);
-    int** graph = (int**)BJAM_CALLOC(length, sizeof(int*));
-    int* order = (int*)BJAM_MALLOC((length+1)*sizeof(int));
-   
-    for(src = 0; iter != end; iter = list_next(iter), ++src) {
-        /* For all object this one depend upon, add elements
-           to 'graph' */
-        LIST* dependencies = var_get(frame->module, list_item(iter));
+    for ( src = 0; iter != end; iter = list_next( iter ), ++src )
+    {
+        /* For all objects this one depends upon, add elements to 'graph'. */
+        LIST * dependencies = var_get( frame->module, list_item( iter ) );
         int index = 0;
-        LISTITER dep_iter = list_begin(dependencies), dep_end = list_end(dependencies);
+        LISTITER dep_iter = list_begin( dependencies );
+        LISTITER const dep_end = list_end( dependencies );
 
-        graph[src] = (int*)BJAM_CALLOC(list_length(dependencies)+1, sizeof(int));
-        for(; dep_iter != dep_end; dep_iter = list_next(dep_iter)) {          
-            int dst = list_index(arg, list_item(dep_iter));
-            if (dst != -1)
-                graph[src][index++] = dst;
+        graph[ src ] = ( int * )BJAM_CALLOC( list_length( dependencies ) + 1,
+            sizeof( int ) );
+        for ( ; dep_iter != dep_end; dep_iter = list_next( dep_iter ) )
+        {
+            int const dst = list_index( arg, list_item( dep_iter ) );
+            if ( dst != -1 )
+                graph[ src ][ index++ ] = dst;
         }
-        graph[src][index] = -1;               
+        graph[ src ][ index ] = -1;
     }
 
-    topological_sort(graph, length, order);
+    topological_sort( graph, length, order );
 
     {
-        int index = length-1;
-        for(; index >= 0; --index) {
+        int index = length - 1;
+        for ( ; index >= 0; --index )
+        {
             int i;
-            iter = list_begin(arg), end = list_end(arg);
-            for (i = 0; i < order[index]; ++i, iter = list_next(iter));
-            result = list_push_back(result, object_copy(list_item(iter)));
+            LISTITER iter = list_begin( arg );
+            LISTITER const end = list_end( arg );
+            for ( i = 0; i < order[ index ]; ++i, iter = list_next( iter ) );
+            result = list_push_back( result, object_copy( list_item( iter ) ) );
         }
     }
 
     /* Clean up */
     {
         int i;
-        for(i = 0; i < length; ++i)
-            BJAM_FREE(graph[i]);
-        BJAM_FREE(graph);
-        BJAM_FREE(order);
+        for ( i = 0; i < length; ++i )
+            BJAM_FREE( graph[ i ] );
+        BJAM_FREE( graph );
+        BJAM_FREE( order );
     }
 
     return result;
 }
 
+
 void init_order()
 {
     {
-        const char* args[] = { "first", "second", 0 };
-        declare_native_rule("class_at_order", "add-pair", args, add_pair, 1);
+        char const * args[] = { "first", "second", 0 };
+        declare_native_rule( "class_at_order", "add-pair", args, add_pair, 1 );
     }
 
     {
-        const char* args[] = { "objects", "*", 0 };
-        declare_native_rule("class_at_order", "order", args, order, 1);
+        char const * args[] = { "objects", "*", 0 };
+        declare_native_rule( "class_at_order", "order", args, order, 1 );
     }
-
-
 }
Modified: trunk/tools/build/v2/engine/modules/property-set.c
==============================================================================
--- trunk/tools/build/v2/engine/modules/property-set.c	(original)
+++ trunk/tools/build/v2/engine/modules/property-set.c	2012-07-17 04:56:49 EDT (Tue, 17 Jul 2012)
@@ -2,29 +2,33 @@
 /* Software License, Version 1.0. (See accompanying */
 /* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) */
 
+#include "../compile.h"
+#include "../lists.h"
 #include "../native.h"
-#include "../timestamp.h"
 #include "../object.h"
 #include "../strings.h"
-#include "../lists.h"
+#include "../timestamp.h"
 #include "../variable.h"
-#include "../compile.h"
 
-LIST* get_grist(char* f)
+#include <string.h>
+
+
+LIST * get_grist( char const * const f )
 {
-    char* end = strchr(f, '>');
-    string s[1];
-    LIST* result;
+    char const * const end = strchr( f, '>' );
+    string s[ 1 ];
+    LIST * result;
 
-    string_new(s);
+    string_new( s );
 
-    string_append_range(s, f, end+1);
-    result = list_new(object_new(s->value));
+    string_append_range( s, f, end + 1 );
+    result = list_new( object_new( s->value ) );
 
-    string_free(s);
+    string_free( s );
     return result;
 }
 
+
 /*
 rule create ( raw-properties * )
 {
@@ -41,77 +45,57 @@
 }
 */
 
-LIST *property_set_create( FRAME *frame, int flags )
+LIST * property_set_create( FRAME * frame, int flags )
 {
-    LIST* properties = lol_get( frame->args, 0 );
-    LIST* sorted = L0;
-#if 0
-    LIST* order_sensitive = 0;
-#endif
-    LIST* unique;
-    LIST* val;
-    string var[1];
-    OBJECT* name;
-    LISTITER iter, end;
-
-#if 0
-    /* Sort all properties which are not order sensitive */
-    for(tmp = properties; tmp; tmp = tmp->next) {
-        LIST* g = get_grist(tmp->string);
-        LIST* att = call_rule("feature.attributes", frame, g, 0);
-        if (list_in(att, "order-sensitive")) {
-            order_sensitive = list_new( order_sensitive, copystr(tmp->string));
-        } else {
-            sorted = list_new( sorted, copystr(tmp->string));
-        }
-        list_free(att);
-    }
-
-    sorted = list_sort(sorted);
-    sorted = list_append(sorted, order_sensitive);
-    unique = list_unique(sorted);
-#endif
-    sorted = list_sort(properties);
-    unique = list_unique(sorted);
-
-    string_new(var);
-    string_append(var, ".ps.");
-
-    iter = list_begin( unique ), end = list_end( unique );
-    for( ; iter != end; iter = list_next( iter ) ) {
-        string_append(var, object_str( list_item( iter ) ));
-        string_push_back(var, '-');
+    LIST * properties = lol_get( frame->args, 0 );
+    LIST * sorted = L0;
+    LIST * unique;
+    LIST * val;
+    string var[ 1 ];
+    OBJECT * name;
+    LISTITER iter;
+    LISTITER end;
+
+    sorted = list_sort( properties );
+    unique = list_unique( sorted );
+
+    string_new( var );
+    string_append( var, ".ps." );
+
+    iter = list_begin( unique );
+    end = list_end( unique );
+    for ( ; iter != end; iter = list_next( iter ) )
+    {
+        string_append( var, object_str( list_item( iter ) ) );
+        string_push_back( var, '-' );
     }
-    name = object_new(var->value);
-    val = var_get(frame->module, name);
-    if (list_empty(val))
+    name = object_new( var->value );
+    val = var_get( frame->module, name );
+    if ( list_empty( val ) )
     {
-        OBJECT* rulename = object_new("new");
-        val = call_rule(rulename, frame,
-                        list_append(list_new(object_new("property-set")), unique), 0);
-        object_free(rulename);
-
-        var_set(frame->module, name, list_copy(val), VAR_SET);
+        OBJECT * const rulename = object_new( "new" );
+        val = call_rule( rulename, frame, list_append( list_new( object_new(
+            "property-set" ) ), unique ), 0 );
+        /* The 'unique' variable is freed in 'call_rule'. */
+        object_free( rulename );
+        var_set( frame->module, name, list_copy( val ), VAR_SET );
     }
     else
     {
-        list_free(unique);
-        val = list_copy(val);
+        list_free( unique );
+        val = list_copy( val );
     }
-    object_free(name);
-
-    string_free(var);
-    /* The 'unique' variable is freed in 'call_rule'. */
-    list_free(sorted);
+    object_free( name );
+    string_free( var );
+    list_free( sorted );
 
     return val;
-
 }
 
+
 void init_property_set()
 {
-    {
-        const char* args[] = { "raw-properties", "*", 0 };
-        declare_native_rule("property-set", "create", args, property_set_create, 1);
-    }
+    char const * args[] = { "raw-properties", "*", 0 };
+    declare_native_rule( "property-set", "create", args, property_set_create, 1
+        );
 }
Modified: trunk/tools/build/v2/engine/modules/regex.c
==============================================================================
--- trunk/tools/build/v2/engine/modules/regex.c	(original)
+++ trunk/tools/build/v2/engine/modules/regex.c	2012-07-17 04:56:49 EDT (Tue, 17 Jul 2012)
@@ -2,12 +2,13 @@
 /* Software License, Version 1.0. (See accompanying */
 /* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) */
 
+#include "../compile.h"
+#include "../mem.h"
 #include "../native.h"
-#include "../timestamp.h"
 #include "../object.h"
-#include "../strings.h"
 #include "../regexp.h"
-#include "../compile.h"
+#include "../strings.h"
+
 
 /*
 rule transform ( list * : pattern : indices * )
@@ -20,62 +21,65 @@
         if $(m)
         {
             result += $(m[$(indices)]) ;
-        }        
+        }
     }
     return $(result) ;
 }
 */
-LIST *regex_transform( FRAME *frame, int flags )
+
+LIST * regex_transform( FRAME * frame, int flags )
 {
-    LIST* l = lol_get( frame->args, 0 );    
-    LIST* pattern = lol_get( frame->args, 1 );    
-    LIST* indices_list = lol_get(frame->args, 2);
-    int* indices = 0;
+    LIST * l = lol_get( frame->args, 0 );
+    LIST * pattern = lol_get( frame->args, 1 );
+    LIST * indices_list = lol_get( frame->args, 2 );
+    int * indices = 0;
     int size;
-    int* p;
+    int * p;
     LIST* result = L0;
 
-    string buf[1];
-    string_new(buf);
+    string buf[ 1 ];
+    string_new( buf );
 
-    if (!list_empty(indices_list))
+    if ( !list_empty( indices_list ) )
     {
-        LISTITER iter = list_begin(indices_list), end = list_end(indices_list);
-        size = list_length(indices_list);
-        indices = (int*)BJAM_MALLOC(size*sizeof(int));
-        for(p = indices; iter != end; iter = list_next(iter))
-        {
-            *p++ = atoi(object_str(list_item(iter)));
-        }        
+        LISTITER iter = list_begin( indices_list );
+        LISTITER const end = list_end( indices_list );
+        size = list_length( indices_list );
+        indices = ( int * )BJAM_MALLOC( size * sizeof( int ) );
+        for ( p = indices; iter != end; iter = list_next( iter ) )
+            *p++ = atoi( object_str( list_item( iter ) ) );
     }
-    else 
+    else
     {
         size = 1;
-        indices = (int*)BJAM_MALLOC(sizeof(int));
+        indices = ( int * )BJAM_MALLOC( sizeof( int ) );
         *indices = 1;
     }
 
     {
         /* Result is cached and intentionally never freed */
-        regexp *re = regex_compile( list_front( pattern ) );
+        regexp * re = regex_compile( list_front( pattern ) );
 
-        LISTITER iter = list_begin( l ), end = list_end( l );
-        for( ; iter != end; iter = list_next( iter ) )
+        LISTITER iter = list_begin( l );
+        LISTITER const end = list_end( l );
+        for ( ; iter != end; iter = list_next( iter ) )
         {
-            if( regexec( re, object_str( list_item( iter ) ) ) )
+            if ( regexec( re, object_str( list_item( iter ) ) ) )
             {
                 int i = 0;
-                for(; i < size; ++i)
+                for ( ; i < size; ++i )
                 {
-                    int index = indices[i];
-                    /* Skip empty submatches. Not sure it's right in all cases,
-                       but surely is right for the case for which this routine
-                       is optimized -- header scanning.
-                    */
-                    if (re->startp[index] != re->endp[index])
+                    int index = indices[ i ];
+                    /* Skip empty submatches. Not sure it is right in all cases,
+                     * but surely is right for the case for which this routine
+                     * is optimized -- header scanning.
+                     */
+                    if ( re->startp[ index ] != re->endp[ index ] )
                     {
-                        string_append_range( buf, re->startp[index], re->endp[index] );
-                        result = list_push_back( result, object_new( buf->value ) ); 
+                        string_append_range( buf, re->startp[ index ],
+                            re->endp[ index ] );
+                        result = list_push_back( result, object_new( buf->value
+                            ) );
                         string_truncate( buf, 0 );
                     }
                 }
@@ -84,15 +88,15 @@
         string_free( buf );
     }
 
-    BJAM_FREE(indices);
-    
+    BJAM_FREE( indices );
+
     return result;
 }
 
+
 void init_regex()
 {
-    {
-        const char* args[] = { "list", "*", ":", "pattern", ":", "indices", "*", 0 };
-        declare_native_rule("regex", "transform", args, regex_transform, 2);
-    }
+    char const * args[] = { "list", "*", ":", "pattern", ":", "indices", "*", 0
+        };
+    declare_native_rule( "regex", "transform", args, regex_transform, 2 );
 }
Modified: trunk/tools/build/v2/engine/pathsys.h
==============================================================================
--- trunk/tools/build/v2/engine/pathsys.h	(original)
+++ trunk/tools/build/v2/engine/pathsys.h	2012-07-17 04:56:49 EDT (Tue, 17 Jul 2012)
@@ -47,9 +47,7 @@
 #define f_member  part[ 5 ]
 };
 
-void path_build( PATHNAME * f, string * file, int binding );
-void path_build1( PATHNAME * f, string * file );
-
+void path_build( PATHNAME * f, string * file );
 void path_parse( char const * file, PATHNAME * f );
 void path_parent( PATHNAME * f );
 
Modified: trunk/tools/build/v2/engine/pathunix.c
==============================================================================
--- trunk/tools/build/v2/engine/pathunix.c	(original)
+++ trunk/tools/build/v2/engine/pathunix.c	2012-07-17 04:56:49 EDT (Tue, 17 Jul 2012)
@@ -169,7 +169,7 @@
  * in 'timestamp.c'.
  */
 
-void path_build( PATHNAME * f, string * file, int binding )
+void path_build( PATHNAME * f, string * file )
 {
     file_build1( f, file );
 
@@ -185,8 +185,7 @@
     {
         string_append_range( file, f->f_root.ptr, f->f_root.ptr + f->f_root.len
             );
-        /* If 'root' already ends with a path delimeter, do not add yet another
-         * one.
+        /* If 'root' already ends with a path delimeter, do not add another one.
          */
         if ( !is_path_delim( f->f_root.ptr[ f->f_root.len - 1 ] ) )
             string_push_back( file, as_path_delim( f->f_root.ptr[ f->f_root.len
Modified: trunk/tools/build/v2/engine/regexp.c
==============================================================================
--- trunk/tools/build/v2/engine/regexp.c	(original)
+++ trunk/tools/build/v2/engine/regexp.c	2012-07-17 04:56:49 EDT (Tue, 17 Jul 2012)
@@ -45,10 +45,11 @@
 
 #include "jam.h"
 #include "regexp.h"
+
 #include <stdio.h>
 #include <ctype.h>
 #ifndef ultrix
-    #include <stdlib.h>
+# include <stdlib.h>
 #endif
 #include <string.h>
 
Modified: trunk/tools/build/v2/engine/regexp.h
==============================================================================
--- trunk/tools/build/v2/engine/regexp.h	(original)
+++ trunk/tools/build/v2/engine/regexp.h	2012-07-17 04:56:49 EDT (Tue, 17 Jul 2012)
@@ -5,28 +5,30 @@
  * not the System V one.
  */
 #ifndef REGEXP_DWA20011023_H
-# define REGEXP_DWA20011023_H
+#define REGEXP_DWA20011023_H
 
 #define NSUBEXP  10
 typedef struct regexp {
-    const char *startp[NSUBEXP];
-    const char *endp[NSUBEXP];
+    char const * startp[ NSUBEXP ];
+    char const * endp[ NSUBEXP ];
     char regstart;      /* Internal use only. */
     char reganch;       /* Internal use only. */
-    char *regmust;      /* Internal use only. */
+    char * regmust;     /* Internal use only. */
     int regmlen;        /* Internal use only. */
-    char program[1];    /* Unwarranted chumminess with compiler. */
+    char program[ 1 ];  /* Unwarranted chumminess with compiler. */
 } regexp;
 
-regexp *regcomp( const char *exp );
-int regexec( regexp *prog, const char *string );
-void regerror( const char *s );
+
+regexp * regcomp( char const * exp );
+int regexec( regexp * prog, char const * string );
+void regerror( char const * s );
+
 
 /*
  * The first byte of the regexp internal "program" is actually this magic
  * number; the start node begins in the second byte.
  */
-#define MAGIC   0234
+#define MAGIC  0234
 
 #endif
 
Modified: trunk/tools/build/v2/engine/rules.c
==============================================================================
--- trunk/tools/build/v2/engine/rules.c	(original)
+++ trunk/tools/build/v2/engine/rules.c	2012-07-17 04:56:49 EDT (Tue, 17 Jul 2012)
@@ -32,17 +32,15 @@
 
 #include "hash.h"
 #include "lists.h"
-#include "modules.h"
 #include "object.h"
 #include "parse.h"
 #include "pathsys.h"
 #include "search.h"
-#include "timestamp.h"
 #include "variable.h"
 
 
 static void set_rule_actions( RULE *, rule_actions * );
-static void set_rule_body   ( RULE *, FUNCTION * procedure );
+static void set_rule_body   ( RULE *, FUNCTION * );
 
 static struct hash * targethash = 0;
 
@@ -74,9 +72,8 @@
 static RULE * enter_rule( OBJECT * rulename, module_t * target_module )
 {
     int found;
-    RULE * r;
-
-    r = (RULE *)hash_insert( demand_rules(target_module), rulename, &found );
+    RULE * const r = (RULE *)hash_insert( demand_rules( target_module ),
+        rulename, &found );
     if ( !found )
     {
         r->name = object_copy( rulename );
@@ -129,7 +126,7 @@
  * bindtarget() - return pointer to TARGET, creating it if necessary.
  */
 
-TARGET * bindtarget( OBJECT * target_name )
+TARGET * bindtarget( OBJECT * const target_name )
 {
     int found;
     TARGET * t;
@@ -187,9 +184,9 @@
  * Not entered into the hash table -- for internal nodes.
  */
 
-TARGET * copytarget( const TARGET * ot )
+TARGET * copytarget( TARGET const * ot )
 {
-    TARGET * t = (TARGET *)BJAM_MALLOC( sizeof( *t ) );
+    TARGET * const t = (TARGET *)BJAM_MALLOC( sizeof( *t ) );
     memset( (char *)t, '\0', sizeof( *t ) );
     t->name = object_copy( ot->name );
     t->boundname = object_copy( t->name );
@@ -202,7 +199,7 @@
  * touch_target() - mark a target to simulate being new.
  */
 
-void touch_target( OBJECT * t )
+void touch_target( OBJECT * const t )
 {
     bindtarget( t )->flags |= T_FLAG_TOUCHED;
 }
Modified: trunk/tools/build/v2/engine/rules.h
==============================================================================
--- trunk/tools/build/v2/engine/rules.h	(original)
+++ trunk/tools/build/v2/engine/rules.h	2012-07-17 04:56:49 EDT (Tue, 17 Jul 2012)
@@ -29,8 +29,6 @@
 #ifndef RULES_DWA_20011020_H
 #define RULES_DWA_20011020_H
 
-#include "jam.h"
-
 #include "function.h"
 #include "modules.h"
 #include "timestamp.h"
@@ -217,9 +215,14 @@
 
     int        asynccnt;              /* child deps outstanding */
     TARGETS  * parents;               /* used by make1() for completion */
-    TARGET   * scc_root;              /* used by make to resolve cyclic includes */
-    TARGET   * rescanning;            /* used by make0 to mark visited targets when rescanning */
-    int        depth;                 /* The depth of the target in the make0 stack. */
+    TARGET   * scc_root;              /* used by make to resolve cyclic includes
+                                       */
+    TARGET   * rescanning;            /* used by make0 to mark visited targets
+                                       * when rescanning
+                                       */
+    int        depth;                 /* The depth of the target in the make0
+                                       * stack.
+                                       */
     char     * cmds;                  /* type-punned command list */
 
     char const * failed;
@@ -231,8 +234,8 @@
 ACTIONS  * actionlist   ( ACTIONS *, ACTION * );
 void       freeactions  ( ACTIONS * );
 SETTINGS * addsettings  ( SETTINGS *, int flag, OBJECT * symbol, LIST * value );
-void       pushsettings ( struct module_t * module, SETTINGS * );
-void       popsettings  ( struct module_t * module, SETTINGS * );
+void       pushsettings ( module_t *, SETTINGS * );
+void       popsettings  ( module_t *, SETTINGS * );
 SETTINGS * copysettings ( SETTINGS * );
 void       freesettings ( SETTINGS * );
 void       actions_refer( rule_actions * );
@@ -248,16 +251,17 @@
 
 /* Target related functions. */
 void      bind_explicitly_located_targets();
-TARGET  * bindtarget                     ( OBJECT * target_name );
+TARGET  * bindtarget                     ( OBJECT * const );
 TARGET  * copytarget                     ( TARGET const * t );
 void      freetargets                    ( TARGETS * );
-TARGETS * targetchain                    ( TARGETS * chain, TARGETS * );
-TARGETS * targetentry                    ( TARGETS * chain, TARGET * );
-void      target_include                 ( TARGET * including, TARGET * included );
-TARGETS * targetlist                     ( TARGETS * chain, LIST * target_names );
-void      touch_target                   ( OBJECT * t );
+TARGETS * targetchain                    ( TARGETS *, TARGETS * );
+TARGETS * targetentry                    ( TARGETS *, TARGET * );
+void      target_include                 ( TARGET * including,
+                                           TARGET * included );
+TARGETS * targetlist                     ( TARGETS *, LIST * target_names );
+void      touch_target                   ( OBJECT * const );
 void      clear_includes                 ( TARGET * );
-TARGET *  target_scc                     ( TARGET * t );
+TARGET  * target_scc                     ( TARGET * );
 
 /* Final module cleanup. */
 void rules_done();
Modified: trunk/tools/build/v2/engine/search.c
==============================================================================
--- trunk/tools/build/v2/engine/search.c	(original)
+++ trunk/tools/build/v2/engine/search.c	2012-07-17 04:56:49 EDT (Tue, 17 Jul 2012)
@@ -119,7 +119,7 @@
         f->f_root.ptr = object_str( list_front( varlist ) );
         f->f_root.len = strlen( object_str( list_front( varlist ) ) );
 
-        path_build( f, buf, 1 );
+        path_build( f, buf );
 
         if ( DEBUG_SEARCH )
             printf( "locate %s: %s\n", object_str( target ), buf->value );
@@ -147,7 +147,7 @@
             f->f_root.len = strlen( object_str( list_item( iter ) ) );
 
             string_truncate( buf, 0 );
-            path_build( f, buf, 1 );
+            path_build( f, buf );
 
             if ( DEBUG_SEARCH )
                 printf( "search %s: %s\n", object_str( target ), buf->value );
@@ -194,7 +194,7 @@
         f->f_root.len = 0;
 
         string_truncate( buf, 0 );
-        path_build( f, buf, 1 );
+        path_build( f, buf );
 
         if ( DEBUG_SEARCH )
             printf( "search %s: %s\n", object_str( target ), buf->value );
Modified: trunk/tools/build/v2/engine/timestamp.c
==============================================================================
--- trunk/tools/build/v2/engine/timestamp.c	(original)
+++ trunk/tools/build/v2/engine/timestamp.c	2012-07-17 04:56:49 EDT (Tue, 17 Jul 2012)
@@ -189,7 +189,7 @@
         f2 = f1;
         f2.f_grist.len = 0;
         path_parent( &f2 );
-        path_build( &f2, buf, 0 );
+        path_build( &f2, buf );
 
         name = object_new( buf->value );
 
@@ -222,7 +222,7 @@
         f2.f_grist.len = 0;
         f2.f_member.len = 0;
         string_truncate( buf, 0 );
-        path_build( &f2, buf, 0 );
+        path_build( &f2, buf );
 
         name = object_new( buf->value );
 
Modified: trunk/tools/build/v2/test/dependency-test/foo.jam
==============================================================================
--- trunk/tools/build/v2/test/dependency-test/foo.jam	(original)
+++ trunk/tools/build/v2/test/dependency-test/foo.jam	2012-07-17 04:56:49 EDT (Tue, 17 Jul 2012)
@@ -3,10 +3,11 @@
 # Distributed under the Boost Software License, Version 1.0. 
 # (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) 
 
-import type ;
 import generators ;
+import modules ;
 import os ;
 import print ;
+import type ;
 
 type.register FOO : foo ;
 
@@ -17,16 +18,14 @@
 
 rule foo ( targets * : sources * : properties * )
 {
-    # On NT, you need an exported symbol in order to have an 
-    # import lib generated
-    # We won't really use the symbol defined here, just force
-    # lib creation.
+    # On NT, you need an exported symbol in order to have an import library
+    # generated. We will not really use the symbol defined here, just force the
+    # import library creation.
     if ( [ os.name ] = NT || [ modules.peek : OS ] in CYGWIN )
         && <main-target-type>LIB in $(properties)
     {
         .decl =  "void __declspec(dllexport) foo(){}" ;
     }
-    
     print.output $(<[1]) ;
     print.text $(.decl:E="//")$(nl) ;
     print.output $(<[2]) ;
Modified: trunk/tools/build/v2/util/print.jam
==============================================================================
--- trunk/tools/build/v2/util/print.jam	(original)
+++ trunk/tools/build/v2/util/print.jam	2012-07-17 04:56:49 EDT (Tue, 17 Jul 2012)
@@ -1,8 +1,8 @@
-# Copyright 2003 Douglas Gregor 
-# Copyright 2002, 2003, 2005 Rene Rivera 
-# Copyright 2002, 2003, 2004, 2005 Vladimir Prus 
-# Distributed under the Boost Software License, Version 1.0. 
-# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) 
+# Copyright 2003 Douglas Gregor
+# Copyright 2002, 2003, 2005 Rene Rivera
+# Copyright 2002, 2003, 2004, 2005 Vladimir Prus
+# Distributed under the Boost Software License, Version 1.0.
+# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
 
 # Utilities for generating format independent output. Using these
 # will help in generation of documentation in at minimum plain/console
@@ -242,7 +242,7 @@
         local t = "" ;
         # divide s into the first X characters and the rest
         s = [ MATCH "^($(char-match))(.*)" : $(text) ] ;
-        
+
         if $(s[2])
         {
             # split the first half at a space
@@ -252,12 +252,12 @@
         {
             t = $(s) ;
         }
-        
+
         if ! $(t[2])
         {
             t += "" ;
         }
-        
+
         text = $(t[2])$(s[2]) ;
         lines += $(t[1]) ;
     }
@@ -270,9 +270,9 @@
 # split them with <br>.
 #
 rule lines (
-    text *  # The lines of text.
-    : indent ?  # Optional indentation prepended to each line after the first one.
-    outdent ?  # Optional indentation to prepend to the first line.
+    text *      # The lines of text.
+    : indent ?  # Optional indentation prepended to each line after the first.
+    outdent ?   # Optional indentation to prepend to the first line.
 )
 {
     text ?= "" ;
@@ -307,9 +307,10 @@
 # output using this rule.
 #
 rule text (
-    strings *  # The strings of text to output.
-    : overwrite ?  # true to overwrite the output (if it is a file)
-    : prefix-body-suffix ?  # Indication to output prefix, body, or suffix (for a file).
+    strings *               # The strings of text to output.
+    : overwrite ?           # True to overwrite the output (if it is a file).
+    : prefix-body-suffix ?  # Indication to output prefix, body, or suffix (for
+                            # a file).
 )
 {
     prefix-body-suffix ?= body ;
@@ -333,7 +334,7 @@
         $(output-target).text-prefix = ;
         $(output-target).text-body = ;
         $(output-target).text-suffix = ;
-        
+
         nl on $(output-target) = "
 " ;
         text-redirect on $(output-target) = ">>" ;
@@ -342,7 +343,7 @@
             text-redirect on $(output-target) = ">" ;
         }
         text-content on $(output-target) = ;
-        
+
         text-action $(output-target) ;
 
         if $(overwrite) && $(output-target) != console
@@ -412,11 +413,10 @@
 }
 
 
-# The following code to update print targets when their contents
-# change is a horrible hack.  It basically creates a target which
-# binds to this file (print.jam) and installs a scanner on it
-# which reads the target and compares its contents to the new
-# contents that we're writing.
+# The following code to update print targets when their contents change is a
+# horrible hack. It basically creates a target which binds to this file
+# (print.jam) and installs a scanner on it which reads the target and compares
+# its contents to the new contents that we are writing.
 #
 rule check-for-update ( target )
 {
@@ -475,7 +475,7 @@
 rule __test__ ( )
 {
     import assert ;
-    
+
     assert.result one two three   : split-at-words one two three : 5 ;
     assert.result "one two" three : split-at-words one two three : 8 ;
     assert.result "one two" three : split-at-words one two three : 9 ;