|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r79672 - in trunk/tools/build/v2/engine: . modules
From: jurko.gospodnetic_at_[hidden]
Date: 2012-07-22 10:53:51
Author: jurko
Date: 2012-07-22 10:53:50 EDT (Sun, 22 Jul 2012)
New Revision: 79672
URL: http://svn.boost.org/trac/boost/changeset/79672
Log:
Boost Jam cleanup - cleaned up some header includes, minor stylistic changes.
Added:
trunk/tools/build/v2/engine/subst.h (contents, props changed)
Text files modified:
trunk/tools/build/v2/engine/builtins.c | 2
trunk/tools/build/v2/engine/compile.c | 5 -
trunk/tools/build/v2/engine/compile.h | 63 +++++++++-----------
trunk/tools/build/v2/engine/hdrmacro.c | 95 ++++++++++++++---------------
trunk/tools/build/v2/engine/hdrmacro.h | 3
trunk/tools/build/v2/engine/headers.c | 123 +++++++++++++++++----------------------
trunk/tools/build/v2/engine/modules/regex.c | 11 +--
trunk/tools/build/v2/engine/subst.c | 11 +--
8 files changed, 141 insertions(+), 172 deletions(-)
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-22 10:53:50 EDT (Sun, 22 Jul 2012)
@@ -19,11 +19,11 @@
#include "native.h"
#include "object.h"
#include "parse.h"
-#include "regexp.h"
#include "rules.h"
#include "pathsys.h"
#include "pwd.h"
#include "strings.h"
+#include "subst.h"
#include "timestamp.h"
#include "variable.h"
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-22 10:53:50 EDT (Sun, 22 Jul 2012)
@@ -45,10 +45,8 @@
#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"
@@ -132,10 +130,9 @@
if ( rule->actions )
{
TARGETS * t;
- ACTION * action;
/* The action is associated with this instance of this rule. */
- action = (ACTION *)BJAM_MALLOC( sizeof( ACTION ) );
+ ACTION * const action = (ACTION *)BJAM_MALLOC( sizeof( ACTION ) );
memset( (char *)action, '\0', sizeof( *action ) );
action->rule = rule;
Modified: trunk/tools/build/v2/engine/compile.h
==============================================================================
--- trunk/tools/build/v2/engine/compile.h (original)
+++ trunk/tools/build/v2/engine/compile.h 2012-07-22 10:53:50 EDT (Sun, 22 Jul 2012)
@@ -10,54 +10,49 @@
* (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
*/
-#ifndef COMPILE_DWA20011022_H
-# define COMPILE_DWA20011022_H
-
-# include "frames.h"
-# include "parse.h"
-# include "regexp.h"
-# include "object.h"
-
/*
* compile.h - compile parsed jam statements
*/
-void compile_builtins();
+#ifndef COMPILE_DWA20011022_H
+#define COMPILE_DWA20011022_H
+
+#include "frames.h"
+#include "lists.h"
+#include "object.h"
-LIST *evaluate_rule( OBJECT * rulename, FRAME * frame );
-LIST *call_rule( OBJECT * rulename, FRAME * caller_frame, ...);
+void compile_builtins();
-regexp* regex_compile( OBJECT * pattern );
+LIST * evaluate_rule( OBJECT * rulename, FRAME * );
+LIST * call_rule( OBJECT * rulename, FRAME * caller_frame, ... );
/* Flags for compile_set(), etc */
-# define ASSIGN_SET 0x00 /* = assign variable */
-# define ASSIGN_APPEND 0x01 /* += append variable */
-# define ASSIGN_DEFAULT 0x02 /* set only if unset */
+#define ASSIGN_SET 0x00 /* = assign variable */
+#define ASSIGN_APPEND 0x01 /* += append variable */
+#define ASSIGN_DEFAULT 0x02 /* set only if unset */
/* Flags for compile_setexec() */
-# define EXEC_UPDATED 0x01 /* executes updated */
-# define EXEC_TOGETHER 0x02 /* executes together */
-# define EXEC_IGNORE 0x04 /* executes ignore */
-# define EXEC_QUIETLY 0x08 /* executes quietly */
-# define EXEC_PIECEMEAL 0x10 /* executes piecemeal */
-# define EXEC_EXISTING 0x20 /* executes existing */
+#define EXEC_UPDATED 0x01 /* executes updated */
+#define EXEC_TOGETHER 0x02 /* executes together */
+#define EXEC_IGNORE 0x04 /* executes ignore */
+#define EXEC_QUIETLY 0x08 /* executes quietly */
+#define EXEC_PIECEMEAL 0x10 /* executes piecemeal */
+#define EXEC_EXISTING 0x20 /* executes existing */
/* Conditions for compile_if() */
-# define EXPR_NOT 0 /* ! cond */
-# define EXPR_AND 1 /* cond && cond */
-# define EXPR_OR 2 /* cond || cond */
-
-# define EXPR_EXISTS 3 /* arg */
-# define EXPR_EQUALS 4 /* arg = arg */
-# define EXPR_NOTEQ 5 /* arg != arg */
-# define EXPR_LESS 6 /* arg < arg */
-# define EXPR_LESSEQ 7 /* arg <= arg */
-# define EXPR_MORE 8 /* arg > arg */
-# define EXPR_MOREEQ 9 /* arg >= arg */
-# define EXPR_IN 10 /* arg in arg */
+#define EXPR_NOT 0 /* ! cond */
+#define EXPR_AND 1 /* cond && cond */
+#define EXPR_OR 2 /* cond || cond */
+#define EXPR_EXISTS 3 /* arg */
+#define EXPR_EQUALS 4 /* arg = arg */
+#define EXPR_NOTEQ 5 /* arg != arg */
+#define EXPR_LESS 6 /* arg < arg */
+#define EXPR_LESSEQ 7 /* arg <= arg */
+#define EXPR_MORE 8 /* arg > arg */
+#define EXPR_MOREEQ 9 /* arg >= arg */
+#define EXPR_IN 10 /* arg in arg */
#endif
-
Modified: trunk/tools/build/v2/engine/hdrmacro.c
==============================================================================
--- trunk/tools/build/v2/engine/hdrmacro.c (original)
+++ trunk/tools/build/v2/engine/hdrmacro.c 2012-07-22 10:53:50 EDT (Sun, 22 Jul 2012)
@@ -10,42 +10,37 @@
* (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 "rules.h"
-# include "variable.h"
-# include "regexp.h"
-# include "hdrmacro.h"
-# include "hash.h"
-# include "object.h"
-# include "strings.h"
-
/*
- * hdrmacro.c - handle header files that define macros used in
- * #include statements.
+ * hdrmacro.c - handle header files that define macros used in #include
+ * statements.
*
* we look for lines like "#define MACRO <....>" or '#define MACRO " "'
- * in the target file. When found, we
- *
- * we then phony up a rule invocation like:
+ * in the target file. When found, we then phony up a rule invocation like:
*
* $(HDRRULE) <target> : <resolved included files> ;
*
* External routines:
- * headers1() - scan a target for "#include MACRO" lines and try
- * to resolve them when needed
+ * headers1() - scan a target for "#include MACRO" lines and try to resolve
+ * them when needed
*
* Internal routines:
* headers1() - using regexp, scan a file and build include LIST
- *
- * 04/13/94 (seiwald) - added shorthand L0 for null list pointer
- * 09/10/00 (seiwald) - replaced call to compile_rule with evaluate_rule,
- * so that headers() doesn't have to mock up a parse structure
- * just to invoke a rule.
*/
+#include "jam.h"
+#include "hdrmacro.h"
+
+#include "compile.h"
+#include "hash.h"
+#include "lists.h"
+#include "object.h"
+#include "parse.h"
+#include "rules.h"
+#include "strings.h"
+#include "subst.h"
+#include "variable.h"
+
+
/* this type is used to store a dictionary of file header macros */
typedef struct header_macro
{
@@ -60,24 +55,24 @@
* headers() - scan a target for include files and call HDRRULE
*/
-# define MAXINC 10
+#define MAXINC 10
-void
-macro_headers( TARGET * t )
+void macro_headers( TARGET * t )
{
- static regexp *re = 0;
- FILE *f;
- char buf[ 1024 ];
+ static regexp * re = 0;
+ FILE * f;
+ char buf[ 1024 ];
if ( DEBUG_HEADER )
printf( "macro header scan for %s\n", object_str( t->name ) );
- /* this regexp is used to detect lines of the form */
- /* "#define MACRO <....>" or "#define MACRO "....." */
- /* in the header macro files.. */
- if ( re == 0 )
+ /* This regexp is used to detect lines of the form
+ * "#define MACRO <....>" or "#define MACRO "....."
+ * in the header macro files.
+ */
+ if ( !re )
{
- OBJECT * re_str = object_new(
+ OBJECT * const re_str = object_new(
"^[ ]*#[ ]*define[ ]*([A-Za-z][A-Za-z0-9_]*)[ ]*"
"[<\"]([^\">]*)[\">].*$" );
re = regex_compile( re_str );
@@ -90,35 +85,36 @@
while ( fgets( buf, sizeof( buf ), f ) )
{
HEADER_MACRO var;
- HEADER_MACRO *v = &var;
+ HEADER_MACRO * v = &var;
- if ( regexec( re, buf ) && re->startp[1] )
+ if ( regexec( re, buf ) && re->startp[ 1 ] )
{
OBJECT * symbol;
int found;
/* we detected a line that looks like "#define MACRO filename */
- ((char *)re->endp[1])[0] = '\0';
- ((char *)re->endp[2])[0] = '\0';
+ ( (char *)re->endp[ 1 ] )[ 0 ] = '\0';
+ ( (char *)re->endp[ 2 ] )[ 0 ] = '\0';
if ( DEBUG_HEADER )
printf( "macro '%s' used to define filename '%s' in '%s'\n",
- re->startp[1], re->startp[2], object_str( t->boundname ) );
+ re->startp[ 1 ], re->startp[ 2 ], object_str( t->boundname )
+ );
/* add macro definition to hash table */
if ( !header_macros_hash )
- header_macros_hash = hashinit( sizeof( HEADER_MACRO ), "hdrmacros" );
+ header_macros_hash = hashinit( sizeof( HEADER_MACRO ),
+ "hdrmacros" );
- symbol = object_new( re->startp[1] );
- v = (HEADER_MACRO *)hash_insert( header_macros_hash, symbol, &found );
+ symbol = object_new( re->startp[ 1 ] );
+ v = (HEADER_MACRO *)hash_insert( header_macros_hash, symbol, &found
+ );
if ( !found )
{
v->symbol = symbol;
- v->filename = object_new( re->startp[2] ); /* never freed */
+ v->filename = object_new( re->startp[ 2 ] ); /* never freed */
}
else
- {
object_free( symbol );
- }
/* XXXX: FOR NOW, WE IGNORE MULTIPLE MACRO DEFINITIONS !! */
/* WE MIGHT AS WELL USE A LIST TO STORE THEM.. */
}
@@ -131,11 +127,12 @@
OBJECT * macro_header_get( OBJECT * macro_name )
{
HEADER_MACRO * v;
-
- if ( header_macros_hash && ( v = (HEADER_MACRO *)hash_find( header_macros_hash, macro_name ) ) )
+ if ( header_macros_hash && ( v = (HEADER_MACRO *)hash_find(
+ header_macros_hash, macro_name ) ) )
{
if ( DEBUG_HEADER )
- printf( "### macro '%s' evaluated to '%s'\n", object_str( macro_name ), object_str( v->filename ) );
+ printf( "### macro '%s' evaluated to '%s'\n", object_str( macro_name
+ ), object_str( v->filename ) );
return v->filename;
}
return 0;
Modified: trunk/tools/build/v2/engine/hdrmacro.h
==============================================================================
--- trunk/tools/build/v2/engine/hdrmacro.h (original)
+++ trunk/tools/build/v2/engine/hdrmacro.h 2012-07-22 10:53:50 EDT (Sun, 22 Jul 2012)
@@ -15,8 +15,7 @@
#include "object.h"
#include "rules.h"
-void macro_headers( TARGET * t );
-
+void macro_headers( TARGET * );
OBJECT * macro_header_get( OBJECT * macro_name );
#endif
Modified: trunk/tools/build/v2/engine/headers.c
==============================================================================
--- trunk/tools/build/v2/engine/headers.c (original)
+++ trunk/tools/build/v2/engine/headers.c 2012-07-22 10:53:50 EDT (Sun, 22 Jul 2012)
@@ -9,64 +9,59 @@
* (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 "rules.h"
-# include "modules.h"
-# include "variable.h"
-# include "regexp.h"
-# include "headers.h"
-# include "hdrmacro.h"
-# include "object.h"
-
-#ifdef OPT_HEADER_CACHE_EXT
-# include "hcache.h"
-#endif
-
/*
* headers.c - handle #includes in source files
*
- * Using regular expressions provided as the variable $(HDRSCAN),
- * headers() searches a file for #include files and phonies up a
- * rule invocation:
- *
- * $(HDRRULE) <target> : <include files> ;
+ * Using regular expressions provided as the variable $(HDRSCAN), headers()
+ * searches a file for #include files and phonies up a rule invocation:
+ * $(HDRRULE) <target> : <include files> ;
*
* External routines:
* headers() - scan a target for include files and call HDRRULE
*
* Internal routines:
* headers1() - using regexp, scan a file and build include LIST
- *
- * 04/13/94 (seiwald) - added shorthand L0 for null list pointer
- * 09/10/00 (seiwald) - replaced call to compile_rule with evaluate_rule,
- * so that headers() doesn't have to mock up a parse structure
- * just to invoke a rule.
*/
+#include "jam.h"
+#include "headers.h"
+
+#include "compile.h"
+#include "hdrmacro.h"
+#include "lists.h"
+#include "modules.h"
+#include "object.h"
+#include "parse.h"
+#include "rules.h"
+#include "subst.h"
+#include "variable.h"
+
+#ifdef OPT_HEADER_CACHE_EXT
+# include "hcache.h"
+#endif
+
#ifndef OPT_HEADER_CACHE_EXT
-static LIST * headers1( LIST * l, OBJECT * file, int rec, regexp * re[]);
+static LIST * headers1( LIST *, OBJECT * file, int rec, regexp * re[] );
#endif
+
/*
* headers() - scan a target for include files and call HDRRULE
*/
-# define MAXINC 10
+#define MAXINC 10
-void
-headers( TARGET * t )
+void headers( TARGET * t )
{
LIST * hdrscan;
LIST * hdrrule;
- #ifndef OPT_HEADER_CACHE_EXT
+ #ifndef OPT_HEADER_CACHE_EXT
LIST * headlist = L0;
- #endif
+ #endif
regexp * re[ MAXINC ];
int rec = 0;
- LISTITER iter, end;
+ LISTITER iter;
+ LISTITER end;
hdrscan = var_get( root_module(), constant_HDRSCAN );
if ( list_empty( hdrscan ) )
@@ -80,7 +75,8 @@
printf( "header scan %s\n", object_str( t->name ) );
/* Compile all regular expressions in HDRSCAN */
- iter = list_begin( hdrscan ), end = list_end( hdrscan );
+ iter = list_begin( hdrscan );
+ end = list_end( hdrscan );
for ( ; ( rec < MAXINC ) && iter != end; iter = list_next( iter ) )
{
re[ rec++ ] = regex_compile( list_item( iter ) );
@@ -89,7 +85,7 @@
/* Doctor up call to HDRRULE rule */
/* Call headers1() to get LIST of included files. */
{
- FRAME frame[1];
+ FRAME frame[ 1 ];
frame_init( frame );
lol_add( frame->args, list_new( object_copy( t->name ) ) );
#ifdef OPT_HEADER_CACHE_EXT
@@ -100,10 +96,8 @@
if ( lol_get( frame->args, 1 ) )
{
- /* The third argument to HDRRULE is the bound name of
- * $(<) */
+ /* The third argument to HDRRULE is the bound name of $(<). */
lol_add( frame->args, list_new( object_copy( t->boundname ) ) );
-
list_free( evaluate_rule( list_front( hdrrule ), frame ) );
}
@@ -117,37 +111,32 @@
* headers1() - using regexp, scan a file and build include LIST.
*/
-#ifdef OPT_HEADER_CACHE_EXT
-LIST *
-#else
-static LIST *
+#ifndef OPT_HEADER_CACHE_EXT
+static
#endif
-headers1(
- LIST * l,
- OBJECT * file,
- int rec,
- regexp * re[] )
+LIST * headers1( LIST * l, OBJECT * file, int rec, regexp * re[] )
{
FILE * f;
char buf[ 1024 ];
- int i;
+ int i;
static regexp * re_macros = 0;
#ifdef OPT_IMPROVED_PATIENCE_EXT
static int count = 0;
++count;
- if ( ((count == 100) || !( count % 1000 )) && DEBUG_MAKE )
+ if ( ( ( count == 100 ) || !( count % 1000 ) ) && DEBUG_MAKE )
{
- printf("...patience...\n");
- fflush(stdout);
+ printf( "...patience...\n" );
+ fflush( stdout );
}
#endif
- /* the following regexp is used to detect cases where a */
- /* file is included through a line line "#include MACRO" */
+ /* The following regexp is used to detect cases where a file is included
+ * through a line line "#include MACRO".
+ */
if ( re_macros == 0 )
{
- OBJECT * re_str = object_new(
+ OBJECT * const re_str = object_new(
"^[ ]*#[ ]*include[ ]*([A-Za-z][A-Za-z0-9_]*).*$" );
re_macros = regex_compile( re_str );
object_free( re_str );
@@ -169,34 +158,33 @@
}
for ( i = 0; i < rec; ++i )
- if ( regexec( re[i], buf ) && re[i]->startp[1] )
+ if ( regexec( re[ i ], buf ) && re[ i ]->startp[ 1 ] )
{
- ((char *)re[i]->endp[1])[0] = '\0';
-
+ ( (char *)re[ i ]->endp[ 1 ] )[ 0 ] = '\0';
if ( DEBUG_HEADER )
- printf( "header found: %s\n", re[i]->startp[1] );
-
- l = list_push_back( l, object_new( re[i]->startp[1] ) );
+ printf( "header found: %s\n", re[ i ]->startp[ 1 ] );
+ l = list_push_back( l, object_new( re[ i ]->startp[ 1 ] ) );
}
/* special treatment for #include MACRO */
- if ( regexec( re_macros, buf ) && re_macros->startp[1] )
+ if ( regexec( re_macros, buf ) && re_macros->startp[ 1 ] )
{
- OBJECT * header_filename;
+ OBJECT * header_filename;
OBJECT * macro_name;
- ((char *)re_macros->endp[1])[0] = '\0';
+ ( (char *)re_macros->endp[ 1 ] )[ 0 ] = '\0';
if ( DEBUG_HEADER )
- printf( "macro header found: %s", re_macros->startp[1] );
+ printf( "macro header found: %s", re_macros->startp[ 1 ] );
- macro_name = object_new( re_macros->startp[1] );
+ macro_name = object_new( re_macros->startp[ 1 ] );
header_filename = macro_header_get( macro_name );
object_free( macro_name );
if ( header_filename )
{
if ( DEBUG_HEADER )
- printf( " resolved to '%s'\n", object_str( header_filename ) );
+ printf( " resolved to '%s'\n", object_str( header_filename )
+ );
l = list_push_back( l, object_copy( header_filename ) );
}
else
@@ -208,12 +196,11 @@
}
fclose( f );
-
return l;
}
-void regerror( const char * s )
+void regerror( char const * s )
{
printf( "re error %s\n", s );
}
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-22 10:53:50 EDT (Sun, 22 Jul 2012)
@@ -2,12 +2,10 @@
/* 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 "../object.h"
-#include "../regexp.h"
#include "../strings.h"
+#include "../subst.h"
/*
@@ -35,7 +33,7 @@
int * indices = 0;
int size;
int * p;
- LIST* result = L0;
+ LIST * result = L0;
string buf[ 1 ];
string_new( buf );
@@ -58,7 +56,7 @@
{
/* Result is cached and intentionally never freed */
- regexp * re = regex_compile( list_front( pattern ) );
+ regexp * const re = regex_compile( list_front( pattern ) );
LISTITER iter = list_begin( l );
LISTITER const end = list_end( l );
@@ -69,7 +67,7 @@
int i = 0;
for ( ; i < size; ++i )
{
- int index = indices[ i ];
+ int const 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.
@@ -89,7 +87,6 @@
}
BJAM_FREE( indices );
-
return result;
}
Modified: trunk/tools/build/v2/engine/subst.c
==============================================================================
--- trunk/tools/build/v2/engine/subst.c (original)
+++ trunk/tools/build/v2/engine/subst.c 2012-07-22 10:53:50 EDT (Sun, 22 Jul 2012)
@@ -1,22 +1,19 @@
#include "jam.h"
+#include "subst.h"
#include "builtins.h"
-#include "compile.h"
#include "frames.h"
#include "hash.h"
#include "lists.h"
-#include "object.h"
-#include "regexp.h"
#include <stddef.h>
-struct regex_entry
+typedef struct regex_entry
{
OBJECT * pattern;
regexp * regex;
-};
-typedef struct regex_entry regex_entry;
+} regex_entry;
static struct hash * regex_hash;
@@ -103,7 +100,7 @@
static void free_regex( void * xregex, void * data )
{
- regex_entry * regex = (regex_entry *)xregex;
+ regex_entry * const regex = (regex_entry *)xregex;
object_free( regex->pattern );
BJAM_FREE( regex->regex );
}
Added: trunk/tools/build/v2/engine/subst.h
==============================================================================
--- (empty file)
+++ trunk/tools/build/v2/engine/subst.h 2012-07-22 10:53:50 EDT (Sun, 22 Jul 2012)
@@ -0,0 +1,14 @@
+/* Copyright 2001-2004 David Abrahams.
+ * 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)
+ */
+
+#ifndef SUBST_JG20120722_H
+#define SUBST_JG20120722_H
+
+#include "object.h"
+#include "regexp.h"
+
+regexp * regex_compile( OBJECT * pattern );
+
+#endif
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk