|
Boost-Commit : |
From: jurko.gospodnetic_at_[hidden]
Date: 2008-08-29 08:59:56
Author: jurko
Date: 2008-08-29 08:59:49 EDT (Fri, 29 Aug 2008)
New Revision: 48445
URL: http://svn.boost.org/trac/boost/changeset/48445
Log:
Minor stylistic changes throughout Boost Jam sources. Mostly corrected indentation, removed trailing spaces and updated comments.
Binary files modified:
trunk/tools/jam/src/build_vms.com
Text files modified:
trunk/tools/jam/src/boost-jam.spec | 8
trunk/tools/jam/src/build.bat | 2
trunk/tools/jam/src/build.jam | 25
trunk/tools/jam/src/build.sh | 34
trunk/tools/jam/src/builtins.c | 132 +-
trunk/tools/jam/src/class.c | 42
trunk/tools/jam/src/command.c | 30
trunk/tools/jam/src/command.h | 38
trunk/tools/jam/src/compile.c | 594 ++++++------
trunk/tools/jam/src/compile.h | 42
trunk/tools/jam/src/debug.c | 28
trunk/tools/jam/src/execmac.c | 28
trunk/tools/jam/src/execnt.c | 273 +++--
trunk/tools/jam/src/execunix.c | 190 ++--
trunk/tools/jam/src/execvms.c | 184 +-
trunk/tools/jam/src/expand.c | 320 +++---
trunk/tools/jam/src/expand.h | 2
trunk/tools/jam/src/filemac.c | 99 +-
trunk/tools/jam/src/filent.c | 230 ++--
trunk/tools/jam/src/fileos2.c | 43
trunk/tools/jam/src/filesys.c | 16
trunk/tools/jam/src/filesys.h | 2
trunk/tools/jam/src/fileunix.c | 252 ++--
trunk/tools/jam/src/filevms.c | 206 ++--
trunk/tools/jam/src/frames.c | 2
trunk/tools/jam/src/frames.h | 2
trunk/tools/jam/src/glob.c | 188 +--
trunk/tools/jam/src/hash.c | 287 +++---
trunk/tools/jam/src/hash.h | 14
trunk/tools/jam/src/hcache.c | 429 ++++----
trunk/tools/jam/src/hdrmacro.c | 26
trunk/tools/jam/src/headers.c | 134 +-
trunk/tools/jam/src/jam.c | 158 +-
trunk/tools/jam/src/jam.h | 88
trunk/tools/jam/src/jambase.h | 2
trunk/tools/jam/src/jamgram.c | 24
trunk/tools/jam/src/jamgram.y | 34
trunk/tools/jam/src/jamgram.yy | 32
trunk/tools/jam/src/lists.c | 178 +-
trunk/tools/jam/src/lists.h | 64
trunk/tools/jam/src/make.c | 1136 +++++++++++------------
trunk/tools/jam/src/make.h | 16
trunk/tools/jam/src/make1.c | 1256 +++++++++++++-------------
trunk/tools/jam/src/mem.c | 8
trunk/tools/jam/src/mem.h | 4
trunk/tools/jam/src/mkjambase.c | 194 ++--
trunk/tools/jam/src/modules.c | 59
trunk/tools/jam/src/native.h | 4
trunk/tools/jam/src/newstr.c | 38
trunk/tools/jam/src/option.c | 117 +-
trunk/tools/jam/src/option.h | 8
trunk/tools/jam/src/output.c | 101 +-
trunk/tools/jam/src/output.h | 2
trunk/tools/jam/src/parse.c | 127 +-
trunk/tools/jam/src/parse.h | 2
trunk/tools/jam/src/pathmac.c | 256 ++--
trunk/tools/jam/src/pathsys.h | 24
trunk/tools/jam/src/pathunix.c | 180 +-
trunk/tools/jam/src/pathvms.c | 352 +++---
trunk/tools/jam/src/regexp.c | 1890 ++++++++++++++++++++--------------------
trunk/tools/jam/src/regexp.h | 16
trunk/tools/jam/src/rules.c | 305 +++---
trunk/tools/jam/src/rules.h | 190 ++-
trunk/tools/jam/src/scan.c | 484 +++++-----
trunk/tools/jam/src/scan.h | 22
trunk/tools/jam/src/search.c | 30
trunk/tools/jam/src/search.h | 2
trunk/tools/jam/src/strings.c | 14
trunk/tools/jam/src/subst.c | 16
trunk/tools/jam/src/timestamp.c | 226 ++--
trunk/tools/jam/src/variable.c | 198 ++--
trunk/tools/jam/src/variable.h | 18
trunk/tools/jam/src/w32_getreg.c | 38
trunk/tools/jam/src/yyacc.c | 8
74 files changed, 5894 insertions(+), 5929 deletions(-)
Modified: trunk/tools/jam/src/boost-jam.spec
==============================================================================
--- trunk/tools/jam/src/boost-jam.spec (original)
+++ trunk/tools/jam/src/boost-jam.spec 2008-08-29 08:59:49 EDT (Fri, 29 Aug 2008)
@@ -11,9 +11,9 @@
BuildRoot: /var/tmp/%{name}-%{version}.root
%description
-Boost Jam is a build tool based on FTJam, which in turn is based on
+Boost Jam is a build tool based on FTJam, which in turn is based on
Perforce Jam. It contains significant improvements made to facilitate
-its use in the Boost Build System, but should be backward compatible
+its use in the Boost Build System, but should be backward compatible
with Perforce Jam.
Authors:
@@ -26,7 +26,7 @@
+\ Copyright 1993-2002 Christopher Seiwald and Perforce Software, Inc.
\+/
License is hereby granted to use this software and distribute it
- freely, as long as this copyright notice is retained and modifications
+ freely, as long as this copyright notice is retained and modifications
are clearly marked.
ALL WARRANTIES ARE HEREBY DISCLAIMED.
@@ -34,7 +34,7 @@
Copyright 2001-2006 David Abrahams.
Copyright 2002-2006 Rene Rivera.
Copyright 2003-2006 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)
Modified: trunk/tools/jam/src/build.bat
==============================================================================
--- trunk/tools/jam/src/build.bat (original)
+++ trunk/tools/jam/src/build.bat 2008-08-29 08:59:49 EDT (Fri, 29 Aug 2008)
@@ -380,7 +380,7 @@
set BJAM_SOURCES=%BJAM_SOURCES% newstr.c option.c output.c parse.c pathunix.c regexp.c
set BJAM_SOURCES=%BJAM_SOURCES% rules.c scan.c search.c subst.c timestamp.c variable.c modules.c
set BJAM_SOURCES=%BJAM_SOURCES% strings.c filesys.c builtins.c pwd.c class.c w32_getreg.c native.c
-set BJAM_SOURCES=%BJAM_SOURCES% modules/set.c modules/path.c modules/regex.c
+set BJAM_SOURCES=%BJAM_SOURCES% modules/set.c modules/path.c modules/regex.c
set BJAM_SOURCES=%BJAM_SOURCES% modules/property-set.c modules/sequence.c modules/order.c
set BJAM_UPDATE=
Modified: trunk/tools/jam/src/build.jam
==============================================================================
--- trunk/tools/jam/src/build.jam (original)
+++ trunk/tools/jam/src/build.jam 2008-08-29 08:59:49 EDT (Fri, 29 Aug 2008)
@@ -10,7 +10,7 @@
else { rule .path { return "$(<:J=/)" ; } }
if $(VMS) { . = "_" ; }
else { . = "." ; }
-./ ?= "" ;
+./ ?= "" ;
# Info about what we are building.
_VERSION_ = 3 1 17 ;
@@ -341,13 +341,12 @@
toolset = [ MATCH --toolset=(.*) : $(ARGV) ] ;
if ! $(toolset)
{
- # For some reason, the following test does not catch
- # empty toolset.
+ # For some reason, the following test does not catch empty toolset.
ECHO "###" ;
ECHO "###" No toolset specified. Please use --toolset option. ;
ECHO "###" ;
ECHO "###" Known toolsets are: $(toolsets:J=", ") ;
- EXIT "###" ;
+ EXIT "###" ;
}
if ! $(toolset) in $(toolsets)
{
@@ -449,8 +448,8 @@
lists.c make.c make1.c mem.c newstr.c
option.c output.c parse.c regexp.c rules.c
scan.c search.c subst.c w32_getreg.c
- timestamp.c variable.c modules.c strings.c filesys.c
- builtins.c pwd.c class.c native.c modules/set.c
+ timestamp.c variable.c modules.c strings.c filesys.c
+ builtins.c pwd.c class.c native.c modules/set.c
modules/path.c modules/regex.c modules/property-set.c
modules/sequence.c modules/order.c
;
@@ -461,7 +460,7 @@
else if $(OS2)
{
jam.source += execunix.c fileos2.c pathunix.c ;
-}
+}
else if $(VMS)
{
jam.source += execvms.c filevms.c pathvms.c ;
@@ -770,7 +769,7 @@
{
$(>).exe = [ .exe $(>) : $(jam.source) ] ;
DEPENDS all : $($(>).exe) ;
-
+
if $(debug)
{
$(<).exe = $(<:S=$($(>).exe:S)) ;
@@ -929,14 +928,14 @@
src-files-actual += $(src-path) ;
}
}
-
+
local pack = ;
if $(NT) { pack = $(dst-dir).zip ; }
if $(UNIX) { pack = $(dst-dir).tgz ; }
-
+
DEPENDS dist : $(pack) ;
DEPENDS $(pack) : $(dst-files) ;
-
+
local dst-files-queue = $(dst-files) ;
for local src-path in $(src-files-actual)
{
@@ -944,11 +943,11 @@
dst-files-queue = $(dst-files-queue[2-]) ;
DEPENDS $(dst-file) : $(src-path) $(dst-file:D) ;
.mkdir $(dst-file:D) ;
-
+
[COPY] $(dst-file) : $(src-path) ;
.clean $(dst-file) ;
}
-
+
[PACK] $(pack) : $(dst-files) ;
.clean $(pack) ;
}
Modified: trunk/tools/jam/src/build.sh
==============================================================================
--- trunk/tools/jam/src/build.sh (original)
+++ trunk/tools/jam/src/build.sh 2008-08-29 08:59:49 EDT (Fri, 29 Aug 2008)
@@ -127,15 +127,15 @@
fi
BOOST_JAM_CC="gcc -DNT"
;;
-
+
gcc)
BOOST_JAM_CC=gcc
;;
-
+
darwin)
BOOST_JAM_CC=cc
;;
-
+
intel-linux)
if test -r /opt/intel/cc/9.0/bin/iccvars.sh ; then
BOOST_JAM_TOOLSET_ROOT=/opt/intel/cc/9.0/
@@ -164,35 +164,35 @@
fi
BOOST_JAM_CC=icc
;;
-
+
vacpp)
BOOST_JAM_CC=xlc
;;
-
+
como)
BOOST_JAM_CC="como --c"
;;
-
+
kcc)
BOOST_JAM_CC=KCC
;;
-
+
kylix)
BOOST_JAM_CC=bc++
;;
-
+
mipspro)
BOOST_JAM_CC=cc
;;
-
+
pathscale)
BOOST_JAM_CC=pathcc
;;
-
+
pgi)
BOOST_JAM_CC=pgcc
;;
-
+
sun*)
if test -z "${BOOST_JAM_TOOLSET_ROOT}" -a -r /opt/SUNWspro/bin/cc ; then
BOOST_JAM_TOOLSET_ROOT=/opt/SUNWspro/
@@ -203,15 +203,15 @@
fi
BOOST_JAM_CC=cc
;;
-
+
tru64cxx)
BOOST_JAM_CC=cc
;;
-
+
acc)
BOOST_JAM_CC="cc -Ae"
;;
-
+
cc)
if test -z "$CC" ; then CC=cc ; fi
BOOST_JAM_CC=$CC
@@ -219,11 +219,11 @@
BOOST_JAM_OPT_MKJAMBASE="$BOOST_JAM_OPT_MKJAMBASE $CFLAGS $LIBS"
BOOST_JAM_OPT_YYACC="$BOOST_JAM_OPT_YYACC $CFLAGS $LIBS"
;;
-
+
qcc)
BOOST_JAM_CC=qcc
;;
-
+
*)
error_exit "Unknown toolset: $BOOST_JAM_TOOLSET"
;;
@@ -247,7 +247,7 @@
mingw)
BJAM_SOURCES="${BJAM_SOURCES} execnt.c filent.c"
;;
-
+
*)
BJAM_SOURCES="${BJAM_SOURCES} execunix.c fileunix.c"
;;
Modified: trunk/tools/jam/src/build_vms.com
==============================================================================
Binary files. No diff available.
Modified: trunk/tools/jam/src/builtins.c
==============================================================================
--- trunk/tools/jam/src/builtins.c (original)
+++ trunk/tools/jam/src/builtins.c 2008-08-29 08:59:49 EDT (Fri, 29 Aug 2008)
@@ -31,16 +31,16 @@
*
* External routines:
*
- * load_builtin() - define builtin rules
+ * load_builtin() - define builtin rules
*
* Internal routines:
*
- * builtin_depends() - DEPENDS/INCLUDES rule
- * builtin_echo() - ECHO rule
- * builtin_exit() - EXIT rule
- * builtin_flags() - NOCARE, NOTFILE, TEMPORARY rule
- * builtin_glob() - GLOB rule
- * builtin_match() - MATCH rule
+ * builtin_depends() - DEPENDS/INCLUDES rule
+ * builtin_echo() - ECHO rule
+ * builtin_exit() - EXIT rule
+ * builtin_flags() - NOCARE, NOTFILE, TEMPORARY rule
+ * builtin_glob() - GLOB rule
+ * builtin_match() - MATCH rule
*
* 01/10/01 (seiwald) - split from compile.c
*/
@@ -417,43 +417,45 @@
LIST *
builtin_depends(
- PARSE *parse,
- FRAME *frame )
+ PARSE *parse,
+ FRAME *frame )
{
- LIST *targets = lol_get( frame->args, 0 );
- LIST *sources = lol_get( frame->args, 1 );
- LIST *l;
-
- for( l = targets; l; l = list_next( l ) )
- {
- TARGET *t = bindtarget( l->string );
-
- /* If doing INCLUDES, switch to the TARGET's include */
- /* TARGET, creating it if needed. The internal include */
- /* TARGET shares the name of its parent. */
-
- if( parse->num )
- {
- if( !t->includes ) {
+ LIST *targets = lol_get( frame->args, 0 );
+ LIST *sources = lol_get( frame->args, 1 );
+ LIST *l;
+
+ for ( l = targets; l; l = list_next( l ) )
+ {
+ TARGET * t = bindtarget( l->string );
+
+ /* If doing INCLUDES, switch to the TARGET's include */
+ /* TARGET, creating it if needed. The internal include */
+ /* TARGET shares the name of its parent. */
+
+ if ( parse->num )
+ {
+ if ( !t->includes )
+ {
t->includes = copytarget( t );
t->includes->original_target = t;
}
t = t->includes;
- }
+ }
- t->depends = targetlist( t->depends, sources );
- }
+ t->depends = targetlist( t->depends, sources );
+ }
/* Enter reverse links */
- for( l = sources; l; l = list_next( l ) )
- {
- TARGET *s = bindtarget( l->string );
+ for ( l = sources; l; l = list_next( l ) )
+ {
+ TARGET * s = bindtarget( l->string );
s->dependents = targetlist( s->dependents, targets );
}
- return L0;
+ return L0;
}
+
/*
* builtin_rebuilds() - REBUILDS rule
*
@@ -464,22 +466,23 @@
LIST *
builtin_rebuilds(
- PARSE *parse,
- FRAME *frame )
+ PARSE *parse,
+ FRAME *frame )
{
- LIST *targets = lol_get( frame->args, 0 );
- LIST *rebuilds = lol_get( frame->args, 1 );
- LIST *l;
-
- for( l = targets; l; l = list_next( l ) )
- {
- TARGET *t = bindtarget( l->string );
- t->rebuilds = targetlist( t->rebuilds, rebuilds );
- }
+ LIST *targets = lol_get( frame->args, 0 );
+ LIST *rebuilds = lol_get( frame->args, 1 );
+ LIST *l;
+
+ for( l = targets; l; l = list_next( l ) )
+ {
+ TARGET *t = bindtarget( l->string );
+ t->rebuilds = targetlist( t->rebuilds, rebuilds );
+ }
- return L0;
+ return L0;
}
+
/*
* builtin_echo() - ECHO rule
*
@@ -489,15 +492,16 @@
LIST *
builtin_echo(
- PARSE *parse,
- FRAME *frame )
+ PARSE *parse,
+ FRAME *frame )
{
- list_print( lol_get( frame->args, 0 ) );
- printf( "\n" );
+ list_print( lol_get( frame->args, 0 ) );
+ printf( "\n" );
fflush( stdout );
- return L0;
+ return L0;
}
+
/*
* builtin_exit() - EXIT rule
*
@@ -532,15 +536,15 @@
LIST *
builtin_flags(
- PARSE *parse,
- FRAME *frame )
+ PARSE *parse,
+ FRAME *frame )
{
- LIST *l = lol_get( frame->args, 0 );
+ LIST *l = lol_get( frame->args, 0 );
- for( ; l; l = list_next( l ) )
- bindtarget( l->string )->flags |= parse->num;
+ for( ; l; l = list_next( l ) )
+ bindtarget( l->string )->flags |= parse->num;
- return L0;
+ return L0;
}
/*
@@ -832,23 +836,23 @@
LIST *
builtin_match(
- PARSE *parse,
- FRAME *frame )
+ PARSE *parse,
+ FRAME *frame )
{
- LIST *l, *r;
- LIST *result = 0;
+ LIST *l, *r;
+ LIST *result = 0;
string buf[1];
string_new(buf);
- /* For each pattern */
+ /* For each pattern */
- for( l = lol_get( frame->args, 0 ); l; l = l->next )
- {
+ for( l = lol_get( frame->args, 0 ); l; l = l->next )
+ {
/* Result is cached and intentionally never freed */
- regexp *re = regex_compile( l->string );
+ regexp *re = regex_compile( l->string );
- /* For each string to match against */
+ /* For each string to match against */
for( r = lol_get( frame->args, 1 ); r; r = r->next )
{
if( regexec( re, r->string ) )
@@ -1170,7 +1174,7 @@
*/
void backtrace( FRAME *frame )
{
- if ( !frame ) return;
+ if ( !frame ) return;
while ( frame = frame->prev )
{
backtrace_line( frame );
Modified: trunk/tools/jam/src/class.c
==============================================================================
--- trunk/tools/jam/src/class.c (original)
+++ trunk/tools/jam/src/class.c 2008-08-29 08:59:49 EDT (Fri, 29 Aug 2008)
@@ -1,4 +1,4 @@
-/* Copyright Vladiir Prus 2003. Distributed under the Boost */
+/* Copyright Vladimir Prus 2003. Distributed under the Boost */
/* Software License, Version 1.0. (See accompanying */
/* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) */
@@ -24,18 +24,19 @@
}
}
-static char* class_module_name(char* declared_name)
+
+static char * class_module_name( char * declared_name )
{
string name[1];
- char* result;
-
+ char * result;
+
string_new(name);
string_append(name, "class@");
string_append(name, declared_name);
result = newstr(name->value);
string_free(name);
-
+
return result;
}
@@ -57,7 +58,7 @@
string_new(qualified_name);
string_append(qualified_name, d->base_name);
string_push_back(qualified_name, '.');
- string_append(qualified_name, r->name);
+ string_append(qualified_name, r->name);
ir1 = import_rule(r, d->class_module, r->name);
ir2 = import_rule(r, d->class_module, qualified_name->value);
@@ -66,11 +67,11 @@
ir1->exported = ir2->exported = r->exported;
/* If we're importing class method, localize it. */
- if (r->module == d->base_module
+ if (r->module == d->base_module
|| r->module->class_module && r->module->class_module == d->base_module) {
- ir1->module = ir2->module = d->class_module;
+ ir1->module = ir2->module = d->class_module;
}
-
+
string_free(qualified_name);
}
@@ -92,25 +93,28 @@
import_module( imported_modules(base_module), class );
}
-char* make_class_module(LIST* xname, LIST* bases, FRAME* frame)
+
+char * make_class_module( LIST * xname, LIST * bases, FRAME * frame )
{
char* name = class_module_name(xname->string);
char** pp = &xname->string;
module_t* class_module = 0;
- module_t* outer_module = frame->module;
+ module_t* outer_module = frame->module;
- if (!classes)
+ if ( !classes )
classes = hashinit(sizeof(char*), "classes");
-
- if (hashcheck(classes, (HASHDATA**)&pp)) {
+ if ( hashcheck( classes, (HASHDATA**)&pp ) )
+ {
printf("Class %s already defined\n", xname->string);
abort();
- } else {
+ }
+ else
+ {
hashenter(classes, (HASHDATA**)&pp);
}
check_defined(bases);
-
+
class_module = bindmodule(name);
exit_module( outer_module );
@@ -118,14 +122,12 @@
var_set("__name__", xname, VAR_SET);
var_set("__bases__", bases, VAR_SET);
-
+
exit_module( class_module );
enter_module( outer_module );
-
+
for(; bases; bases = bases->next)
import_base_rules(class_module, bases->string);
-
-
return name;
}
Modified: trunk/tools/jam/src/command.c
==============================================================================
--- trunk/tools/jam/src/command.c (original)
+++ trunk/tools/jam/src/command.c 2008-08-29 08:59:49 EDT (Fri, 29 Aug 2008)
@@ -31,10 +31,10 @@
CMD *
cmd_new(
- RULE *rule,
- LIST *targets,
- LIST *sources,
- LIST *shell )
+ RULE *rule,
+ LIST *targets,
+ LIST *sources,
+ LIST *shell )
{
CMD *cmd = (CMD *)BJAM_MALLOC( sizeof( CMD ) );
/* lift line-length limitation entirely when JAMSHELL is just "%" */
@@ -54,14 +54,14 @@
do
{
BJAM_FREE(cmd->buf); /* free any buffer from previous iteration */
-
+
cmd->buf = (char*)BJAM_MALLOC_ATOMIC(max_line + 1);
-
- if (cmd->buf == 0)
+
+ if ( cmd->buf == 0 )
break;
-
+
allocated = var_string( rule->actions->command, cmd->buf, max_line, &cmd->args );
-
+
max_line = max_line * 2;
}
while( allocated < 0 && max_line < INT_MAX / 2 );
@@ -69,18 +69,18 @@
if ( !no_limit )
{
/* Bail if the result won't fit in MAXLINE */
- char *s = cmd->buf;
+ char * s = cmd->buf;
while ( *s )
{
size_t l = strcspn( s, "\n" );
-
+
if ( l > MAXLINE )
{
/* We don't free targets/sources/shell if bailing. */
cmd_free( cmd );
return 0;
}
-
+
s += l;
if ( *s )
++s;
@@ -97,8 +97,8 @@
void
cmd_free( CMD *cmd )
{
- lol_free( &cmd->args );
- list_free( cmd->shell );
+ lol_free( &cmd->args );
+ list_free( cmd->shell );
BJAM_FREE( cmd->buf );
- BJAM_FREE( (char *)cmd );
+ BJAM_FREE( (char *)cmd );
}
Modified: trunk/tools/jam/src/command.h
==============================================================================
--- trunk/tools/jam/src/command.h (original)
+++ trunk/tools/jam/src/command.h 2008-08-29 08:59:49 EDT (Fri, 29 Aug 2008)
@@ -12,23 +12,23 @@
* sources; a CMD is what actually gets executed by the shell. The
* differences are due to:
*
- * ACTIONS must be combined if 'actions together' is given.
- * ACTIONS must be split if 'actions piecemeal' is given.
- * ACTIONS must have current sources omitted for 'actions updated'.
+ * ACTIONS must be combined if 'actions together' is given.
+ * ACTIONS must be split if 'actions piecemeal' is given.
+ * ACTIONS must have current sources omitted for 'actions updated'.
*
- * The CMD datatype holds a single command that is to be executed
- * against a target, and they can chain together to represent the
+ * The CMD datatype holds a single command that is to be executed
+ * against a target, and they can chain together to represent the
* full collection of commands used to update a target.
*
* Structures:
*
- * CMD - an action, ready to be formatted into a buffer and executed
+ * CMD - an action, ready to be formatted into a buffer and executed
*
* External routines:
*
- * cmd_new() - return a new CMD or 0 if too many args
- * cmd_free() - delete CMD and its parts
- * cmd_next() - walk the CMD chain
+ * cmd_new() - return a new CMD or 0 if too many args
+ * cmd_free() - delete CMD and its parts
+ * cmd_next() - walk the CMD chain
*/
/*
@@ -39,19 +39,19 @@
struct _cmd
{
- CMD *next;
- CMD *tail; /* valid on in head */
- RULE *rule; /* rule->actions contains shell script */
- LIST *shell; /* $(SHELL) value */
- LOL args; /* LISTs for $(<), $(>) */
- char* buf; /* actual commands */
+ CMD *next;
+ CMD *tail; /* valid on in head */
+ RULE *rule; /* rule->actions contains shell script */
+ LIST *shell; /* $(SHELL) value */
+ LOL args; /* LISTs for $(<), $(>) */
+ char* buf; /* actual commands */
} ;
CMD *cmd_new(
- RULE *rule, /* rule (referenced) */
- LIST *targets, /* $(<) (freed) */
- LIST *sources, /* $(>) (freed) */
- LIST *shell ); /* $(SHELL) (freed) */
+ RULE *rule, /* rule (referenced) */
+ LIST *targets, /* $(<) (freed) */
+ LIST *sources, /* $(>) (freed) */
+ LIST *shell ); /* $(SHELL) (freed) */
void cmd_free( CMD *cmd );
Modified: trunk/tools/jam/src/compile.c
==============================================================================
--- trunk/tools/jam/src/compile.c (original)
+++ trunk/tools/jam/src/compile.c 2008-08-29 08:59:49 EDT (Fri, 29 Aug 2008)
@@ -38,20 +38,20 @@
* External routines:
*
* compile_append() - append list results of two statements
- * compile_eval() - evaluate if to determine which leg to compile
+ * compile_eval() - evaluate if to determine which leg to compile
* compile_foreach() - compile the "for x in y" statement
* compile_if() - compile 'if' rule
* compile_while() - compile 'while' rule
* compile_include() - support for 'include' - call include() on file
- * compile_list() - expand and return a list
+ * compile_list() - expand and return a list
* compile_local() - declare (and set) local variables
* compile_null() - do nothing -- a stub for parsing
* compile_on() - run rule under influence of on-target variables
* compile_rule() - compile a single user defined rule
* compile_rules() - compile a chain of rules
* compile_set() - compile the "set variable" statement
- * compile_setcomp() - support for `rule` - save parse tree
- * compile_setexec() - support for `actions` - save execution string
+ * compile_setcomp() - support for `rule` - save parse tree
+ * compile_setexec() - support for `actions` - save execution string
* compile_settings() - compile the "on =" (set variable on exec) statement
* compile_switch() - compile 'switch' rule
*
@@ -65,7 +65,7 @@
* builtin_exit() - EXIT rule
* builtin_flags() - NOCARE, NOTFILE, TEMPORARY rule
*
- * 02/03/94 (seiwald) - Changed trace output to read "setting" instead of
+ * 02/03/94 (seiwald) - Changed trace output to read "setting" instead of
* the awkward sounding "settings".
* 04/12/94 (seiwald) - Combined build_depends() with build_includes().
* 04/12/94 (seiwald) - actionlist() now just appends a single action.
@@ -93,8 +93,7 @@
void backtrace_line( FRAME *frame );
void print_source_line( PARSE* p );
-
-struct frame *frame_before_python_call;
+struct frame * frame_before_python_call;
void frame_init( FRAME* frame )
{
@@ -106,11 +105,13 @@
frame->procedure = 0;
}
+
void frame_free( FRAME* frame )
{
lol_free( frame->args );
}
+
/*
* compile_append() - append list results of two statements
*
@@ -118,131 +119,127 @@
* parse->right single rule
*/
-LIST *
-compile_append(
- PARSE *parse,
- FRAME *frame )
+LIST * compile_append( PARSE * parse, FRAME * frame )
{
/* Append right to left. */
-
- return list_append(
+ return list_append(
parse_evaluate( parse->left, frame ),
parse_evaluate( parse->right, frame ) );
}
+
/*
* compile_eval() - evaluate if to determine which leg to compile
*
* Returns:
- * list if expression true - compile 'then' clause
- * L0 if expression false - compile 'else' clause
+ * list if expression true - compile 'then' clause
+ * L0 if expression false - compile 'else' clause
*/
-static int
-lcmp( LIST *t, LIST *s )
+static int lcmp( LIST * t, LIST * s )
{
- int status = 0;
+ int status = 0;
- while( !status && ( t || s ) )
- {
- char *st = t ? t->string : "";
- char *ss = s ? s->string : "";
+ while ( !status && ( t || s ) )
+ {
+ char *st = t ? t->string : "";
+ char *ss = s ? s->string : "";
- status = strcmp( st, ss );
+ status = strcmp( st, ss );
- t = t ? list_next( t ) : t;
- s = s ? list_next( s ) : s;
- }
+ t = t ? list_next( t ) : t;
+ s = s ? list_next( s ) : s;
+ }
- return status;
+ return status;
}
-LIST *
-compile_eval(
- PARSE *parse,
- FRAME *frame )
-{
- LIST *ll, *lr, *s, *t;
- int status = 0;
-
- /* Short circuit lr eval for &&, ||, and 'in' */
-
- ll = parse_evaluate( parse->left, frame );
- lr = 0;
-
- switch( parse->num )
- {
- case EXPR_AND:
- case EXPR_IN: if( ll ) goto eval; break;
- case EXPR_OR: if( !ll ) goto eval; break;
- default: eval: lr = parse_evaluate( parse->right, frame );
- }
-
- /* Now eval */
-
- switch( parse->num )
- {
- case EXPR_NOT:
- if( !ll ) status = 1;
- break;
-
- case EXPR_AND:
- if( ll && lr ) status = 1;
- break;
-
- case EXPR_OR:
- if( ll || lr ) status = 1;
- break;
-
- case EXPR_IN:
- /* "a in b": make sure each of */
- /* ll is equal to something in lr. */
-
- for( t = ll; t; t = list_next( t ) )
- {
- for( s = lr; s; s = list_next( s ) )
- if( !strcmp( t->string, s->string ) )
- break;
- if( !s ) break;
- }
-
- /* No more ll? Success */
-
- if( !t ) status = 1;
-
- break;
-
- case EXPR_EXISTS: if( lcmp( ll, L0 ) != 0 ) status = 1; break;
- case EXPR_EQUALS: if( lcmp( ll, lr ) == 0 ) status = 1; break;
- case EXPR_NOTEQ: if( lcmp( ll, lr ) != 0 ) status = 1; break;
- case EXPR_LESS: if( lcmp( ll, lr ) < 0 ) status = 1; break;
- case EXPR_LESSEQ: if( lcmp( ll, lr ) <= 0 ) status = 1; break;
- case EXPR_MORE: if( lcmp( ll, lr ) > 0 ) status = 1; break;
- case EXPR_MOREEQ: if( lcmp( ll, lr ) >= 0 ) status = 1; break;
-
- }
-
- if( DEBUG_IF )
- {
- debug_compile( 0, "if", frame );
- list_print( ll );
- printf( "(%d) ", status );
- list_print( lr );
- printf( "\n" );
- }
-
- /* Find something to return. */
- /* In odd circumstances (like "" = "") */
- /* we'll have to return a new string. */
-
- if( !status ) t = 0;
- else if( ll ) t = ll, ll = 0;
- else if( lr ) t = lr, lr = 0;
- else t = list_new( L0, newstr( "1" ) );
-
- if( ll ) list_free( ll );
- if( lr ) list_free( lr );
- return t;
+LIST * compile_eval( PARSE * parse, FRAME * frame )
+{
+ LIST * ll;
+ LIST * lr;
+ LIST * s;
+ LIST * t;
+ int status = 0;
+
+ /* Short circuit lr eval for &&, ||, and 'in'. */
+
+ ll = parse_evaluate( parse->left, frame );
+ lr = 0;
+
+ switch( parse->num )
+ {
+ case EXPR_AND:
+ case EXPR_IN: if( ll ) goto eval; break;
+ case EXPR_OR: if( !ll ) goto eval; break;
+ default: eval: lr = parse_evaluate( parse->right, frame );
+ }
+
+ /* Now eval */
+
+ switch( parse->num )
+ {
+ case EXPR_NOT:
+ if( !ll ) status = 1;
+ break;
+
+ case EXPR_AND:
+ if( ll && lr ) status = 1;
+ break;
+
+ case EXPR_OR:
+ if( ll || lr ) status = 1;
+ break;
+
+ case EXPR_IN:
+ /* "a in b": make sure each of */
+ /* ll is equal to something in lr. */
+
+ for( t = ll; t; t = list_next( t ) )
+ {
+ for( s = lr; s; s = list_next( s ) )
+ if( !strcmp( t->string, s->string ) )
+ break;
+ if( !s ) break;
+ }
+
+ /* No more ll? Success */
+
+ if( !t ) status = 1;
+
+ break;
+
+ case EXPR_EXISTS: if( lcmp( ll, L0 ) != 0 ) status = 1; break;
+ case EXPR_EQUALS: if( lcmp( ll, lr ) == 0 ) status = 1; break;
+ case EXPR_NOTEQ: if( lcmp( ll, lr ) != 0 ) status = 1; break;
+ case EXPR_LESS: if( lcmp( ll, lr ) < 0 ) status = 1; break;
+ case EXPR_LESSEQ: if( lcmp( ll, lr ) <= 0 ) status = 1; break;
+ case EXPR_MORE: if( lcmp( ll, lr ) > 0 ) status = 1; break;
+ case EXPR_MOREEQ: if( lcmp( ll, lr ) >= 0 ) status = 1; break;
+
+ }
+
+ if( DEBUG_IF )
+ {
+ debug_compile( 0, "if", frame );
+ list_print( ll );
+ printf( "(%d) ", status );
+ list_print( lr );
+ printf( "\n" );
+ }
+
+ /* Find something to return. */
+ /* In odd circumstances (like "" = "") */
+ /* we'll have to return a new string. */
+
+ if( !status ) t = 0;
+ else if( ll ) t = ll, ll = 0;
+ else if( lr ) t = lr, lr = 0;
+ else t = list_new( L0, newstr( "1" ) );
+
+ if( ll ) list_free( ll );
+ if( lr ) list_free( lr );
+ return t;
}
@@ -257,37 +254,32 @@
* parse->right rule to compile
*/
-LIST *
-compile_foreach(
- PARSE *parse,
- FRAME *frame )
+LIST * compile_foreach( PARSE * parse, FRAME * frame )
{
- LIST *nv = parse_evaluate( parse->left, frame );
- LIST *l;
- SETTINGS *s = 0;
-
- if ( parse->num )
- {
- s = addsettings( s, VAR_SET, parse->string, L0 );
- pushsettings( s );
- }
+ LIST * nv = parse_evaluate( parse->left, frame );
+ LIST * l;
+ SETTINGS * s = 0;
+
+ if ( parse->num )
+ {
+ s = addsettings( s, VAR_SET, parse->string, L0 );
+ pushsettings( s );
+ }
/* Call var_set to reset $(parse->string) for each val. */
- for( l = nv; l; l = list_next( l ) )
+ for ( l = nv; l; l = list_next( l ) )
{
- LIST *val = list_new( L0, copystr( l->string ) );
-
+ LIST * val = list_new( L0, copystr( l->string ) );
var_set( parse->string, val, VAR_SET );
-
list_free( parse_evaluate( parse->right, frame ) );
}
- if ( parse->num )
- {
- popsettings( s );
- freesettings( s );
- }
+ if ( parse->num )
+ {
+ popsettings( s );
+ freesettings( s );
+ }
list_free( nv );
@@ -358,21 +350,21 @@
if( nt )
{
- TARGET *t = bindtarget( nt->string );
+ TARGET * t = bindtarget( nt->string );
+
+ /* DWA 2001/10/22 - Perforce Jam cleared the arguments here, which
+ * prevents an included file from being treated as part of the body of a
+ * rule. I did not see any reason to do that, so I lifted the
+ * restriction.
+ */
- /* DWA 2001/10/22 - Perforce Jam clears the arguments here, which
- * prevents an included file from being treated as part of the body
- * of a rule. I didn't see any reason to do that, so I lifted the
- * restriction.
- */
-
/* Bind the include file under the influence of */
/* "on-target" variables. Though they are targets, */
/* include files are not built with make(). */
pushsettings( t->settings );
/* We don't expect that file to be included is generated by some
- action. Therefore, pass 0 as third argument.
+ action. Therefore, pass 0 as third argument.
If the name resolves to directory, let it error out. */
t->boundname = search( t->name, &t->time, 0, 0 );
popsettings( t->settings );
@@ -397,9 +389,9 @@
exit_module( outer_module );
enter_module( frame->module );
}
-
+
result = parse_evaluate( p, frame );
-
+
if ( outer_module != frame->module )
{
exit_module( frame->module );
@@ -410,46 +402,40 @@
return result;
}
-LIST *
-compile_module(
- PARSE *p,
- FRAME *frame )
+
+LIST * compile_module( PARSE * p, FRAME * frame )
{
- /* Here we are entering a module declaration block.
- */
- LIST* module_name = parse_evaluate( p->left, frame );
- LIST* result = evaluate_in_module( module_name ? module_name->string : 0,
+ /* Here we are entering a module declaration block. */
+ LIST * module_name = parse_evaluate( p->left, frame );
+ LIST * result = evaluate_in_module( module_name ? module_name->string : 0,
p->right, frame );
-
list_free( module_name );
return result;
}
-LIST *
-compile_class(
- PARSE *p,
- FRAME *frame )
+
+LIST * compile_class( PARSE * p, FRAME * frame )
{
/** Todo: check for empty class name.
Check for class redeclaration. */
- char* class_module = 0;
+ char * class_module = 0;
- LIST* name = parse_evaluate( p->left->right, frame );
- LIST* bases = 0;
+ LIST * name = parse_evaluate( p->left->right, frame );
+ LIST * bases = 0;
- if (p->left->left)
+ if ( p->left->left )
bases = parse_evaluate( p->left->left->right, frame );
- class_module = make_class_module(name, bases, frame);
+ class_module = make_class_module( name, bases, frame );
evaluate_in_module( class_module, p->right, frame );
- return L0;
+ return L0;
}
/*
- * compile_list() - expand and return a list
+ * compile_list() - expand and return a list
*
* parse->string - character string to expand
*/
@@ -527,40 +513,40 @@
/*
* compile_on() - run rule under influence of on-target variables
*
- * parse->left list of files to include (can only do 1)
- * parse->right rule to run
+ * parse->left list of files to include (can only do 1)
+ * parse->right rule to run
*
* EXPERIMENTAL!
*/
LIST *
compile_on(
- PARSE *parse,
- FRAME *frame )
+ PARSE *parse,
+ FRAME *frame )
{
- LIST *nt = parse_evaluate( parse->left, frame );
- LIST *result = 0;
+ LIST *nt = parse_evaluate( parse->left, frame );
+ LIST *result = 0;
- if( DEBUG_COMPILE )
- {
- debug_compile( 0, "on", frame );
- list_print( nt );
- printf( "\n" );
- }
+ if( DEBUG_COMPILE )
+ {
+ debug_compile( 0, "on", frame );
+ list_print( nt );
+ printf( "\n" );
+ }
- if( nt )
- {
- TARGET *t = bindtarget( nt->string );
- pushsettings( t->settings );
+ if( nt )
+ {
+ TARGET *t = bindtarget( nt->string );
+ pushsettings( t->settings );
- result = parse_evaluate( parse->right, frame );
+ result = parse_evaluate( parse->right, frame );
- popsettings( t->settings );
- }
+ popsettings( t->settings );
+ }
- list_free( nt );
+ list_free( nt );
- return result;
+ return result;
}
@@ -573,33 +559,24 @@
* Wrapped around evaluate_rule() so that headers() can share it.
*/
-LIST *
-compile_rule(
- PARSE *parse,
- FRAME *frame )
+LIST * compile_rule( PARSE * parse, FRAME * frame )
{
- FRAME inner[1];
- LIST *result;
- PARSE *p;
-
-
- /* Build up the list of arg lists */
+ FRAME inner[1];
+ LIST * result;
+ PARSE * p;
+ /* Build up the list of arg lists. */
frame_init( inner );
inner->prev = frame;
inner->prev_user = frame->module->user_module ? frame : frame->prev_user;
inner->module = frame->module; /* This gets fixed up in evaluate_rule(), below */
inner->procedure = parse;
-
for( p = parse->left; p; p = p->left )
lol_add( inner->args, parse_evaluate( p->right, frame ) );
- /* And invoke rule */
-
+ /* And invoke the rule. */
result = evaluate_rule( parse->string, inner );
-
frame_free( inner );
-
return result;
}
@@ -684,9 +661,9 @@
if ( !typecheck->rules || !hashcheck( typecheck->rules, (HASHDATA**)&checker ) )
return;
}
-
+
exit_module( caller->module );
-
+
while ( values != 0 )
{
LIST *error;
@@ -700,14 +677,14 @@
/* Prepare the argument list */
lol_add( frame->args, list_new( L0, values->string ) );
error = evaluate_rule( type_name, frame );
-
+
exit_module( typecheck );
-
+
if ( error )
argument_error( error->string, called, caller, arg_name );
frame_free( frame );
- values = values->next;
+ values = values->next;
}
enter_module( caller->module );
@@ -720,21 +697,21 @@
collect_arguments( RULE* rule, FRAME* frame )
{
SETTINGS *locals = 0;
-
- LOL* all_actual = frame->args;
- LOL *all_formal = rule->arguments ? rule->arguments->data : 0;
+
+ LOL * all_actual = frame->args;
+ LOL * all_formal = rule->arguments ? rule->arguments->data : 0;
if ( all_formal ) /* Nothing to set; nothing to check */
{
int max = all_formal->count > all_actual->count
? all_formal->count
: all_actual->count;
-
+
int n;
for ( n = 0; n < max ; ++n )
{
LIST *actual = lol_get( all_actual, n );
char *type_name = 0;
-
+
LIST *formal;
for ( formal = lol_get( all_formal, n ); formal; formal = formal->next )
{
@@ -744,7 +721,7 @@
{
if ( type_name )
argument_error( "missing argument name before type name:", rule, frame, formal );
-
+
if ( !formal->next )
argument_error( "missing argument name after type name:", rule, frame, formal );
@@ -755,13 +732,13 @@
LIST* value = 0;
char modifier;
LIST* arg_name = formal; /* hold the argument name for type checking */
-
+
/* Stop now if a variable number of arguments are specified */
if ( name[0] == '*' && name[1] == 0 )
return locals;
modifier = arg_modifier( formal );
-
+
if ( !actual && modifier != '?' && modifier != '*' )
argument_error( "missing argument", rule, frame, formal );
@@ -772,11 +749,11 @@
value = list_copy( 0, actual );
actual = 0;
/* skip an extra element for the modifier */
- formal = formal->next;
+ formal = formal->next;
break;
case '?':
/* skip an extra element for the modifier */
- formal = formal->next;
+ formal = formal->next;
/* fall through */
default:
if ( actual ) /* in case actual is missing */
@@ -785,13 +762,13 @@
actual = actual->next;
}
}
-
+
locals = addsettings( locals, VAR_SET, name, value );
type_check( type_name, value, frame, rule, arg_name );
type_name = 0;
}
}
-
+
if ( actual )
{
argument_error( "extra argument", rule, frame, actual );
@@ -824,7 +801,7 @@
{
PyObject* v = PyString_FromString(l->string);
/* Steals reference to 'v' */
- PyList_Append(arg, v);
+ PyList_Append(arg, v);
}
/* Steals reference to 'arg' */
PyTuple_SetItem(arguments, i, arg);
@@ -833,33 +810,34 @@
frame_before_python_call = frame;
py_result = PyObject_CallObject(r->python_function, arguments);
Py_DECREF(arguments);
- if (py_result != NULL) {
-
- if (PyList_Check(py_result)) {
+ if ( py_result != NULL )
+ {
+ if ( PyList_Check(py_result) )
+ {
int size = PyList_Size(py_result);
int i;
- for(i = 0; i < size; ++i)
+ for( i = 0; i < size; ++i )
{
- PyObject* item = PyList_GetItem(py_result, i);
- if (PyString_Check(item))
+ PyObject * item = PyList_GetItem( py_result, i );
+ if ( PyString_Check( item ) )
{
- result = list_new(result,
- newstr(PyString_AsString(item)));
+ result = list_new( result,
+ newstr( PyString_AsString( item ) ) );
}
else
{
- fprintf(stderr, "Non-string object returned by Python call\n");
+ fprintf( stderr, "Non-string object returned by Python call.\n" );
}
}
}
- else if (PyInstance_Check(py_result))
+ else if ( PyInstance_Check( py_result ) )
{
static char instance_name[1000];
static char imported_method_name[1000];
- module_t* m;
- PyObject* method;
- PyObject* method_name = PyString_FromString("foo");
- RULE* r;
+ module_t * m;
+ PyObject * method;
+ PyObject * method_name = PyString_FromString("foo");
+ RULE * r;
fprintf(stderr, "Got instance!\n");
@@ -868,21 +846,21 @@
snprintf(imported_method_name, 1000,
"pyinstance%d.foo", python_instance_number);
++python_instance_number;
-
+
m = bindmodule(instance_name);
/* This is expected to get bound method. */
method = PyObject_GetAttr(py_result, method_name);
-
+
r = bindrule( imported_method_name, root_module() );
r->python_function = method;
- result = list_new(0, newstr(instance_name));
+ result = list_new(0, newstr(instance_name));
- Py_DECREF(method_name);
+ Py_DECREF( method_name );
}
- else if (py_result == Py_None)
+ else if ( py_result == Py_None )
{
result = L0;
}
@@ -891,48 +869,49 @@
fprintf(stderr, "Non-list object returned by Python call\n");
}
- Py_DECREF(py_result);
+ Py_DECREF( py_result );
}
- else {
+ else
+ {
PyErr_Print();
fprintf(stderr,"Call failed\n");
}
-
+
return result;
}
-module_t* python_module()
+
+module_t * python_module()
{
- static module_t* python = 0;
+ static module_t * python = 0;
if ( !python )
python = bindmodule("__python__");
return python;
}
-
#endif
+
/*
- * evaluate_rule() - execute a rule invocation
+ * evaluate_rule() - execute a rule invocation.
*/
LIST *
evaluate_rule(
- char *rulename,
- FRAME *frame )
+ char * rulename,
+ FRAME * frame )
{
- LIST *result = L0;
- RULE *rule;
- profile_frame prof[1];
- module_t *prev_module = frame->module;
-
- LIST *l;
+ LIST * result = L0;
+ RULE * rule;
+ profile_frame prof[1];
+ module_t * prev_module = frame->module;
+
+ LIST * l;
{
- LOL arg_context_, *arg_context = &arg_context_;
+ LOL arg_context_, * arg_context = &arg_context_;
if ( !frame->prev )
lol_init(arg_context);
else
arg_context = frame->prev->args;
-
l = var_expand( L0, rulename, rulename+strlen(rulename), arg_context, 0 );
}
@@ -951,7 +930,7 @@
if (rule->python_function)
{
/* The below messing with modules is due to the
- way modules are implemented in jam.
+ way modules are implemented in jam.
Suppose we're in module M1 now. The global
variable map actually holds 'M1' variables,
and M1->variables hold global variables.
@@ -961,7 +940,7 @@
module M1 { }
- then jam will try to swap current global
+ then jam will try to swap current global
variables with M1->variables. The result will
be that global variables map will hold
global variables, and any variables settings
@@ -970,12 +949,12 @@
By restoring basic state, where global
variable map hold global variable, we make
sure any fugure 'module M1' will work OK. */
-
+
LIST *result;
module_t *m = python_module();
frame->module = m;
-
+
exit_module( prev_module );
enter_module( m );
@@ -988,15 +967,15 @@
}
#endif
- /* drop the rule name */
+ /* Drop the rule name. */
l = list_pop_front( l );
- /* tack the rest of the expansion onto the front of the first argument */
+ /* Tack the rest of the expansion onto the front of the first argument. */
frame->args->list[0] = list_append( l, lol_get( frame->args, 0 ) );
if ( DEBUG_COMPILE )
{
- /* Try hard to indicate in which module the rule is going to execute */
+ /* Try hard to indicate in which module the rule is going to execute. */
if ( rule->module != frame->module
&& rule->procedure != 0 && strcmp(rulename, rule->procedure->rulename) )
{
@@ -1013,28 +992,27 @@
lol_print( frame->args );
printf( "\n" );
}
-
+
if ( rule->procedure && rule->module != prev_module )
{
- /* propagate current module to nested rule invocations */
+ /* Propagate current module to nested rule invocations. */
frame->module = rule->module;
-
- /* swap variables */
+
+ /* Swap variables. */
exit_module( prev_module );
enter_module( rule->module );
}
-
- /* record current rule name in frame */
+
+ /* Record current rule name in frame. */
if ( rule->procedure )
{
frame->rulename = rulename;
- /* and enter record profile info */
+ /* And enter record profile info. */
if ( DEBUG_PROFILE )
profile_enter( rule->procedure->rulename, prof );
}
- /* Check traditional targets $(<) and sources $(>) */
-
+ /* Check traditional targets $(<) and sources $(>). */
if( !rule->actions && !rule->procedure )
{
backtrace_line( frame->prev );
@@ -1043,8 +1021,8 @@
exit(1);
}
- /* If this rule will be executed for updating the targets */
- /* then construct the action for make(). */
+ /* If this rule will be executed for updating the targets then construct */
+ /* the action for make(). */
if( rule->actions )
{
@@ -1059,7 +1037,7 @@
action->rule = rule;
action->targets = targetlist( (TARGETS *)0, lol_get( frame->args, 0 ) );
action->sources = targetlist( (TARGETS *)0, lol_get( frame->args, 1 ) );
-
+
/* 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
@@ -1102,26 +1080,25 @@
}
}
- /* Append this action to the actions of each target */
-
+ /* Append this action to the actions of each target. */
for( t = action->targets; t; t = t->next )
t->target->actions = actionlist( t->target->actions, action );
}
/* Now recursively compile any parse tree associated with this rule */
- /* refer/free to ensure rule not freed during use */
+ /* refer/free to ensure rule not freed during use. */
if( rule->procedure )
{
SETTINGS *local_args = collect_arguments( rule, frame );
PARSE *parse = rule->procedure;
parse_refer( parse );
-
+
pushsettings( local_args );
result = parse_evaluate( parse, frame );
popsettings( local_args );
freesettings( local_args );
-
+
parse_free( parse );
}
@@ -1156,12 +1133,12 @@
FRAME inner[1];
frame_init( inner );
inner->prev = caller_frame;
- inner->prev_user = caller_frame->module->user_module ?
+ inner->prev_user = caller_frame->module->user_module ?
caller_frame : caller_frame->prev_user;
- inner->module = caller_frame->module;
+ inner->module = caller_frame->module;
inner->procedure = 0;
- va_start(va, caller_frame);
+ va_start(va, caller_frame);
for(;;)
{
LIST* l = va_arg(va, LIST*);
@@ -1170,8 +1147,8 @@
lol_add(inner->args, l);
}
va_end(va);
-
- result = evaluate_rule(rulename, inner);
+
+ result = evaluate_rule(rulename, inner);
frame_free(inner);
@@ -1181,8 +1158,8 @@
/*
* compile_rules() - compile a chain of rules
*
- * parse->left single rule
- * parse->right more compile_rules() by right-recursion
+ * parse->left single rule
+ * parse->right more compile_rules() by right-recursion
*/
LIST *
@@ -1191,7 +1168,7 @@
FRAME *frame )
{
/* Ignore result from first statement; return the 2nd. */
- /* Optimize recursion on the right by looping. */
+ /* Optimize recursion on the right by looping. */
do list_free( parse_evaluate( parse->left, frame ) );
while( (parse = parse->right)->func == compile_rules );
@@ -1223,7 +1200,7 @@
* compile_set() - compile the "set variable" statement
*
* parse->left variable names
- * parse->right variable values
+ * parse->right variable values
* parse->num ASSIGN_SET/APPEND/DEFAULT
*/
@@ -1259,7 +1236,7 @@
}
/*
- * compile_setcomp() - support for `rule` - save parse tree
+ * compile_setcomp() - support for `rule` - save parse tree
*
* parse->string rule name
* parse->left rules for rule
@@ -1272,7 +1249,7 @@
FRAME *frame)
{
argument_list* arg_list = 0;
-
+
/* Create new LOL describing argument requirements if supplied */
if ( parse->right )
{
@@ -1281,13 +1258,13 @@
for( p = parse->right; p; p = p->left )
lol_add( arg_list->data, parse_evaluate( p->right, frame ) );
}
-
+
new_rule_body( frame->module, parse->string, arg_list, parse->left, !parse->num );
return L0;
}
/*
- * compile_setexec() - support for `actions` - save execution string
+ * compile_setexec() - support for `actions` - save execution string
*
* parse->string rule name
* parse->string1 OS command string
@@ -1314,9 +1291,9 @@
* compile_settings() - compile the "on =" (set variable on exec) statement
*
* parse->left variable names
- * parse->right target name
- * parse->third variable value
- * parse->num ASSIGN_SET/APPEND
+ * parse->right target name
+ * parse->third variable value
+ * parse->num ASSIGN_SET/APPEND
*/
LIST *
@@ -1352,7 +1329,7 @@
LIST *l;
for( l = nt; l; l = list_next( l ) )
- t->settings = addsettings( t->settings, setflag,
+ t->settings = addsettings( t->settings, setflag,
l->string, list_copy( (LIST*)0, ns ) );
}
@@ -1412,26 +1389,25 @@
* debug_compile() - printf with indent to show rule expansion.
*/
-static void
-debug_compile( int which, char *s, FRAME* frame )
+static void debug_compile( int which, char * s, FRAME * frame )
{
static int level = 0;
static char indent[36] = ">>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|";
if ( which >= 0 )
{
- int i;
-
- print_source_line( frame->procedure );
-
- i = (level+1)*2;
- while ( i > 35 )
- {
- printf( indent );
- i -= 35;
- }
+ int i;
+
+ print_source_line( frame->procedure );
+
+ i = (level+1)*2;
+ while ( i > 35 )
+ {
+ printf( indent );
+ i -= 35;
+ }
- printf( "%*.*s ", i, i, indent );
+ printf( "%*.*s ", i, i, indent );
}
if( s )
Modified: trunk/tools/jam/src/compile.h
==============================================================================
--- trunk/tools/jam/src/compile.h (original)
+++ trunk/tools/jam/src/compile.h 2008-08-29 08:59:49 EDT (Fri, 29 Aug 2008)
@@ -50,33 +50,33 @@
/* 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/jam/src/debug.c
==============================================================================
--- trunk/tools/jam/src/debug.c (original)
+++ trunk/tools/jam/src/debug.c 2008-08-29 08:59:49 EDT (Fri, 29 Aug 2008)
@@ -59,18 +59,16 @@
}
}
+
void profile_memory( long mem )
{
if ( DEBUG_PROFILE )
- {
if ( profile_stack && profile_stack->info )
- {
profile_stack->info->memory += mem;
- }
- }
}
-
-void profile_exit(profile_frame* frame)
+
+
+void profile_exit( profile_frame * frame )
{
if ( DEBUG_PROFILE )
{
@@ -78,12 +76,12 @@
clock_t t = clock() - frame->entry_time - frame->overhead;
/* If this rule is already present on the stack, don't add the time for
this instance. */
- if (frame->info->stack_count == 1)
+ if ( frame->info->stack_count == 1 )
frame->info->cumulative += t;
/* Net time does not depend on presense of the same rule in call stack. */
frame->info->net += t - frame->subrules;
- if (frame->caller)
+ if ( frame->caller )
{
/* caller's cumulative time must account for this overhead */
frame->caller->overhead += frame->overhead;
@@ -95,9 +93,10 @@
}
}
-static void dump_profile_entry(void* p_, void* ignored)
+
+static void dump_profile_entry( void * p_, void * ignored )
{
- profile_info* p = (profile_info*)p_;
+ profile_info * p = (profile_info *)p_;
unsigned long mem_each = (p->memory/(p->num_entries ? p->num_entries : 1));
double cumulative = p->cumulative;
double net = p->net;
@@ -118,16 +117,17 @@
p->name);
}
+
void profile_dump()
{
if ( profile_hash )
{
- printf("%10s %12s %12s %12s %10s %10s %s\n",
+ printf( "%10s %12s %12s %12s %10s %10s %s\n",
"--count--", "--gross--", "--net--", "--each--",
"--mem--", "--each--",
- "--name--");
+ "--name--" );
hashenumerate( profile_hash, dump_profile_entry, 0 );
- dump_profile_entry(&profile_other,0);
- dump_profile_entry(&profile_total,(void*)1);
+ dump_profile_entry( &profile_other, 0 );
+ dump_profile_entry( &profile_total, (void *)1 );
}
}
Modified: trunk/tools/jam/src/execmac.c
==============================================================================
--- trunk/tools/jam/src/execmac.c (original)
+++ trunk/tools/jam/src/execmac.c 2008-08-29 08:59:49 EDT (Fri, 29 Aug 2008)
@@ -17,11 +17,11 @@
* If $(JAMSHELL) is defined, uses that to formulate execvp().
* The default is:
*
- * /bin/sh -c %
+ * /bin/sh -c %
*
* Each word must be an individual element in a jam variable value.
*
- * In $(JAMSHELL), % expands to the command string and ! expands to
+ * In $(JAMSHELL), % expands to the command string and ! expands to
* the slot number (starting at 1) for multiprocess (-j) invocations.
* If $(JAMSHELL) doesn't include a %, it is tacked on as the last
* argument.
@@ -29,11 +29,11 @@
* Don't just set JAMSHELL to /bin/sh - it won't work!
*
* External routines:
- * execcmd() - launch an async command execution
- * execwait() - wait and drive at most one execution completion
+ * execcmd() - launch an async command execution
+ * execwait() - wait and drive at most one execution completion
*
* Internal routines:
- * onintr() - bump intr to note command interruption
+ * onintr() - bump intr to note command interruption
*
* 04/08/94 (seiwald) - Coherent/386 support added.
* 05/04/94 (seiwald) - async multiprocess interface
@@ -44,16 +44,14 @@
* execcmd() - launch an async command execution
*/
-void
-execcmd(
- char *string,
- void (*func)( void *closure, int status, timing_info*, char *, char * ),
- void *closure,
- LIST *shell )
+void execcmd(
+ char *string,
+ void (*func)( void *closure, int status, timing_info*, char *, char * ),
+ void *closure,
+ LIST *shell )
{
-
- printf( "%s", string );
- (*func)( closure, EXEC_CMD_OK );
+ printf( "%s", string );
+ (*func)( closure, EXEC_CMD_OK );
}
/*
@@ -63,7 +61,7 @@
int
execwait()
{
- return 0;
+ return 0;
}
# endif /* OS_MAC */
Modified: trunk/tools/jam/src/execnt.c
==============================================================================
--- trunk/tools/jam/src/execnt.c (original)
+++ trunk/tools/jam/src/execnt.c 2008-08-29 08:59:49 EDT (Fri, 29 Aug 2008)
@@ -41,7 +41,7 @@
*
* Each word must be an individual element in a jam variable value.
*
- * In $(JAMSHELL), % expands to the command string and ! expands to
+ * In $(JAMSHELL), % expands to the command string and ! expands to
* the slot number (starting at 1) for multiprocess (-j) invocations.
* If $(JAMSHELL) doesn't include a %, it is tacked on as the last
* argument.
@@ -96,7 +96,7 @@
static int try_kill_one();
/* */
static double creation_time(HANDLE);
-/* Recursive check if first process is parent (directly or indirectly) of
+/* Recursive check if first process is parent (directly or indirectly) of
the second one. */
static int is_parent_child(DWORD, DWORD);
/* */
@@ -142,7 +142,7 @@
/* execution unit tests */
void execnt_unit_test()
{
-#if !defined(NDEBUG)
+#if !defined(NDEBUG)
/* vc6 preprocessor is broken, so assert with these strings gets
* confused. Use a table instead.
*/
@@ -178,18 +178,22 @@
/* Work around vc6 bug; it doesn't like escaped string
* literals inside assert
*/
- char** argv = string_to_args("\"g++\" -c -I\"Foobar\"");
- char const expected[] = "-c -I\"Foobar\"";
-
- assert(!strcmp(argv[0], "g++"));
- assert(!strcmp(argv[1], expected));
- free_argv(argv);
+ char * * argv = string_to_args(" \"g++\" -c -I\"Foobar\"" );
+ char const expected[] = "-c -I\"Foobar\"";
+
+ assert( !strcmp( argv[0], "g++" ) );
+ assert( !strcmp( argv[1], expected ) );
+ free_argv( argv );
}
-#endif
+#endif
}
-/* execcmd() - launch an async command execution */
-void execcmd(
+
+/*
+ * execcmd() - launch an async command execution.
+ */
+
+void execcmd(
char *command,
void (*func)( void *closure, int status, timing_info*, char *invoked_command, char *command_output),
void *closure,
@@ -203,7 +207,7 @@
char **argv = argv_static;
char *p;
char* command_orig = command;
-
+
/* Check to see if we need to hack around the line-length limitation. */
/* Look for a JAMSHELL setting of "%", indicating that the command
* should be invoked directly */
@@ -223,17 +227,17 @@
exit( EXITBAD );
}
- /* compute the name of a temp batch file, for possible use */
+ /* Compute the name of a temp batch file, for possible use. */
if( !cmdtab[ slot ].tempfile_bat )
{
const char *tempdir = path_tmpdir();
DWORD procID = GetCurrentProcessId();
-
- /* SVA - allocate 64 other just to be safe */
+
+ /* SVA - allocate 64 bytes extra just to be safe. */
cmdtab[ slot ].tempfile_bat = BJAM_MALLOC_ATOMIC( strlen( tempdir ) + 64 );
-
+
sprintf(
- cmdtab[ slot ].tempfile_bat, "%s\\jam%d-%02d.bat",
+ cmdtab[ slot ].tempfile_bat, "%s\\jam%d-%02d.bat",
tempdir, procID, slot );
}
@@ -241,25 +245,26 @@
while( *(command+1) && isspace( *command ) )
++command;
- /* Write to .BAT file unless the line would be too long and it
- * meets the other spawnability criteria.
+ /* Write to .BAT file unless the line would be too long and it meets the
+ * other spawnability criteria.
*/
if( raw_cmd && can_spawn( command ) >= MAXLINE )
{
if( DEBUG_EXECCMD )
- printf("Executing raw command directly\n");
+ printf("Executing raw command directly\n");
}
else
{
FILE *f = 0;
int tries = 0;
raw_cmd = 0;
-
- /* Write command to bat file. For some reason this open can
- fails intermitently. But doing some retries works. Most likely
- this is due to a previously existing file of the same name that
- happens to be opened by an active virus scanner. Pointed out,
- and fix by Bronek Kozicki. */
+
+ /* Write command to bat file. For some reason this open can fail
+ * intermitently. But doing some retries works. Most likely this is due
+ * to a previously existing file of the same name that happens to be
+ * opened by an active virus scanner. Pointed out and fixed by Bronek
+ * Kozicki.
+ */
for (; !f && tries < 4; ++tries)
{
f = fopen( cmdtab[ slot ].tempfile_bat, "w" );
@@ -274,7 +279,7 @@
fclose( f );
command = cmdtab[ slot ].tempfile_bat;
-
+
if( DEBUG_EXECCMD )
{
if (shell)
@@ -327,8 +332,8 @@
if( !cmdsrunning++ )
istat = signal( SIGINT, onintr );
-
- /* Start the command */
+
+ /* Start the command. */
{
SECURITY_ATTRIBUTES sa
= { sizeof(SECURITY_ATTRIBUTES), 0, 0 };
@@ -367,26 +372,26 @@
SetHandleInformation( cmdtab[ slot ].pipe_err[0], HANDLE_FLAG_INHERIT, 0 );
}
- /* hide the child window, if any */
+ /* Hide the child window, if any. */
si.dwFlags |= STARTF_USESHOWWINDOW;
si.wShowWindow = SW_HIDE;
- /* set the child outputs to the pipes */
+ /* Set the child outputs to the pipes. */
si.dwFlags |= STARTF_USESTDHANDLES;
si.hStdOutput = cmdtab[ slot ].pipe_out[1];
if ( globs.pipe_action == 2 )
{
- /* pipe stderr to the action error output */
+ /* Pipe stderr to the action error output. */
si.hStdError = cmdtab[ slot ].pipe_err[1];
}
else if ( globs.pipe_action == 1 )
{
- /* pipe stderr to the console error output */
+ /* Pipe stderr to the console error output. */
si.hStdError = GetStdHandle(STD_ERROR_HANDLE);
}
else
{
- /* pipe stderr to the action merged output */
+ /* Pipe stderr to the action merged output. */
si.hStdError = cmdtab[ slot ].pipe_out[1];
}
@@ -406,8 +411,8 @@
string_new( &cmdtab[ slot ].target );
}
string_copy( &cmdtab[ slot ].command, command_orig );
-
- /* put together the comman we run */
+
+ /* Put together the command we run. */
{
char ** argp = argv;
string_new(&cmd);
@@ -418,64 +423,64 @@
string_append(&cmd,*(argp++));
}
}
-
- /* create the output buffers */
+
+ /* Create output buffers. */
string_new( &cmdtab[ slot ].buffer_out );
string_new( &cmdtab[ slot ].buffer_err );
- /* run the command, by creating a sub-process for it */
+ /* Run the command by creating a sub-process for it. */
if (
! CreateProcess(
- NULL, /* application name */
- cmd.value, /* command line */
- NULL, /* process attributes */
- NULL, /* thread attributes */
- TRUE, /* inherit handles */
- CREATE_NEW_PROCESS_GROUP, /* create flags */
- NULL, /* env vars, null inherits env */
- NULL, /* current dir, null is our current dir */
- &si, /* startup info */
- &cmdtab[ slot ].pi /* the child process info, if created */
+ NULL , /* application name */
+ cmd.value , /* command line */
+ NULL , /* process attributes */
+ NULL , /* thread attributes */
+ TRUE , /* inherit handles */
+ CREATE_NEW_PROCESS_GROUP, /* create flags */
+ NULL , /* env vars, null inherits env */
+ NULL , /* current dir, null is our */
+ /* current dir */
+ &si , /* startup info */
+ &cmdtab[ slot ].pi /* child process info, if created */
)
)
{
perror( "CreateProcess" );
exit( EXITBAD );
}
-
- /* clean up temporary stuff */
+
+ /* Clean up temporary stuff. */
string_free(&cmd);
}
- /* Wait until we're under the limit of concurrent commands. */
- /* Don't trust globs.jobs alone. */
-
- while( cmdsrunning >= MAXJOBS || cmdsrunning >= globs.jobs )
+ /* Wait until we are under the limit of concurrent commands. Do not trust
+ * globs.jobs alone.
+ */
+ while( ( cmdsrunning >= MAXJOBS ) || ( cmdsrunning >= globs.jobs ) )
if( !execwait() )
break;
-
+
if (argv != argv_static)
- {
free_argv(argv);
- }
}
-
/* execwait()
- - wait and drive at most one execution completion
+ * wait and drive at most one execution completion
* waits for one command to complete, while processing the io
for all ongoing commands.
+
+ Returns 0 if called when there were no more commands being executed or 1
+ otherwise.
*/
int execwait()
{
int i = -1;
- /* Handle naive make1() which doesn't know if cmds are running. */
-
+ /* Handle naive make1() which does not know if cmds are running. */
if( !cmdsrunning )
return 0;
-
+
/* wait for a command to complete, while snarfing up any output */
do
{
@@ -489,13 +494,13 @@
if ( i < 0 ) i = try_kill_one();
}
while ( i < 0 );
-
- /* we have a command... process it */
+
+ /* We have a command... process it. */
--cmdsrunning;
{
timing_info time;
int rstat;
-
+
/* the time data for the command */
record_times(cmdtab[i].pi.hProcess, &time);
@@ -536,7 +541,7 @@
&time,
cmdtab[i].command.value,
cmdtab[i].buffer_out.value );
-
+
/* clean up the command data, process, etc. */
string_free(&cmdtab[i].action); string_new(&cmdtab[i].action);
string_free(&cmdtab[i].target); string_new(&cmdtab[i].target);
@@ -556,6 +561,7 @@
return 1;
}
+
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
static void free_argv( char** args )
@@ -566,7 +572,7 @@
/* For more details on Windows cmd.exe shell command-line length limitations see
* the following MSDN article:
- *
+ *
* http://support.microsoft.com/default.aspx?scid=kb;en-us;830473
*/
int maxline()
@@ -574,7 +580,7 @@
OSVERSIONINFO os_info;
os_info.dwOSVersionInfoSize = sizeof(os_info);
GetVersionEx(&os_info);
-
+
if (os_info.dwMajorVersion >= 5) return 8191; /* XP > */
if (os_info.dwMajorVersion == 4) return 2047; /* NT 4.x */
return 996; /* NT 3.5.1 */
@@ -602,7 +608,7 @@
/* drop leading and trailing whitespace if any */
while (isspace(*string))
++string;
-
+
src_len = strlen( string );
while ( src_len > 0 && isspace( string[src_len - 1] ) )
--src_len;
@@ -624,7 +630,7 @@
BJAM_FREE( line );
return 0;
}
-
+
/* Strip quotes from the first command-line argument and find
* where it ends. Quotes are illegal in Win32 pathnames, so we
* don't need to worry about preserving escaped quotes here.
@@ -644,31 +650,32 @@
*dst++ = 0;
argv[0] = line;
- /* skip whitespace in src */
+ /* Skip whitespace in src. */
while (isspace(*src))
++src;
argv[1] = dst;
- /* Copy the rest of the arguments verbatim */
-
+ /* Copy the rest of the arguments verbatim. */
src_len -= src - string;
- /* Use strncat because it appends a trailing nul */
+ /* Use strncat because it appends a trailing nul. */
*dst = 0;
strncat(dst, src, src_len);
argv[2] = 0;
-
+
return argv;
}
+
static void onintr( int disp )
{
intr++;
printf( "...interrupted\n" );
}
+
/*
* can_spawn() - If the command is suitable for execution via spawnvp,
* return a number >= the number of characters it would occupy on the
@@ -676,15 +683,15 @@
*/
long can_spawn(char* command)
{
- char *p;
-
+ char * p;
+
char inquote = 0;
/* Move to the first non-whitespace */
command += strspn( command, " \t" );
p = command;
-
+
/* Look for newlines and unquoted i/o redirection */
do
{
@@ -702,7 +709,7 @@
if (*p)
return 0;
break;
-
+
case '"':
case '\'':
if (p > command && p[-1] != '\\')
@@ -712,10 +719,10 @@
else if (inquote == 0)
inquote = *p;
}
-
+
++p;
break;
-
+
case '<':
case '>':
case '|':
@@ -798,11 +805,11 @@
return ceil(filetime_seconds(t_utc)-time_diff);
}
+
static void record_times(HANDLE process, timing_info* time)
{
FILETIME creation, exit, kernel, user;
-
- if (GetProcessTimes(process, &creation, &exit, &kernel, &user))
+ if ( GetProcessTimes( process, &creation, &exit, &kernel, &user ) )
{
time->system = filetime_seconds(kernel);
time->user = filetime_seconds(user);
@@ -811,10 +818,12 @@
}
}
+
#define IO_BUFFER_SIZE (16*1024)
static char ioBuffer[IO_BUFFER_SIZE+1];
+
static void read_pipe(
HANDLE in, /* the pipe to read from */
string * out
@@ -822,7 +831,7 @@
{
DWORD bytesInBuffer = 0;
DWORD bytesAvailable = 0;
-
+
do
{
/* check if we have any data to read */
@@ -830,7 +839,7 @@
{
bytesAvailable = 0;
}
-
+
/* read in the available data */
if ( bytesAvailable > 0 )
{
@@ -879,7 +888,7 @@
static void read_output()
{
int i;
-
+
for ( i = 0; i < globs.jobs && i < MAXJOBS; ++i )
{
/* read stdout data */
@@ -933,7 +942,7 @@
if ( globs.timeout > 0 )
{
int i;
-
+
for ( i = 0; i < globs.jobs; ++i )
{
double t = running_time(cmdtab[i].pi.hProcess);
@@ -1041,7 +1050,7 @@
pid = get_process_id(process);
}
process_snapshot_h = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
-
+
if (INVALID_HANDLE_VALUE != process_snapshot_h)
{
BOOL ok = TRUE;
@@ -1079,61 +1088,65 @@
return 0.0;
}
-/* Recursive check if first process is parent (directly or indirectly) of
-the second one. Both processes are passed as process ids, not handles.
-Special return value 2 means that the second process is smss.exe and its
-parent process is System (first argument is ignored) */
-static int is_parent_child(DWORD parent, DWORD child)
+
+/* Recursive check if first process is parent (directly or indirectly) of the
+ * second one. Both processes are passed as process ids, not handles. Special
+ * return value 2 means that the second process is smss.exe and its parent
+ * process is System (first argument is ignored).
+ */
+
+static int is_parent_child( DWORD parent, DWORD child )
{
HANDLE process_snapshot_h = INVALID_HANDLE_VALUE;
- if (!child)
+ if ( !child )
return 0;
- if (parent == child)
+ if ( parent == child )
return 1;
- process_snapshot_h = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
- if (INVALID_HANDLE_VALUE != process_snapshot_h)
+ process_snapshot_h = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 );
+ if ( INVALID_HANDLE_VALUE != process_snapshot_h )
{
BOOL ok = TRUE;
PROCESSENTRY32 pinfo;
pinfo.dwSize = sizeof(PROCESSENTRY32);
for (
- ok = Process32First(process_snapshot_h, &pinfo);
- ok == TRUE;
+ ok = Process32First(process_snapshot_h, &pinfo);
+ ok == TRUE;
ok = Process32Next(process_snapshot_h, &pinfo) )
{
if (pinfo.th32ProcessID == child)
{
- /*
- Unfortunately, process ids are not really unique. There might
- be spurious "parent and child" relationship match between
- two non-related processes if real parent process of a given
- process has exited (while child process kept running as an
- "orphan") and the process id of such parent process has been
- reused by internals of the operating system when creating
- another process. Thus additional check is needed - process
- creation time. This check may fail (ie. return 0) for system
- processes due to insufficient privileges, and that's OK. */
+ /* Unfortunately, process ids are not really unique. There might
+ * be spurious "parent and child" relationship match between two
+ * non-related processes if real parent process of a given
+ * process has exited (while child process kept running as an
+ * "orphan") and the process id of such parent process has been
+ * reused by internals of the operating system when creating
+ * another process.
+ *
+ * Thus additional check is needed - process creation time. This
+ * check may fail (i.e. return 0) for system processes due to
+ * insufficient privileges, and that is OK.
+ */
double tchild = 0.0;
double tparent = 0.0;
- HANDLE hchild = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pinfo.th32ProcessID);
-
- CloseHandle(process_snapshot_h);
+ HANDLE hchild = OpenProcess( PROCESS_QUERY_INFORMATION, FALSE, pinfo.th32ProcessID );
+ CloseHandle( process_snapshot_h );
/* csrss.exe may display message box like following:
xyz.exe - Unable To Locate Component
- This application has failed to start because
- boost_foo-bar.dll was not found. Re-installing the
+ This application has failed to start because
+ boost_foo-bar.dll was not found. Re-installing the
application may fix the problem
This actually happens when starting test process that depends
- on a dynamic library which failed to build. We want to
+ on a dynamic library which failed to build. We want to
automatically close these message boxes even though csrss.exe
is not our child process. We may depend on the fact that (in
- all current versions of Windows) csrss.exe is directly
+ all current versions of Windows) csrss.exe is directly
child of smss.exe process, which in turn is directly child of
System process, which always has process id == 4 .
- This check must be performed before comparison of process
+ This check must be performed before comparison of process
creation time */
if (stricmp(pinfo.szExeFile, "csrss.exe") == 0
&& is_parent_child(parent, pinfo.th32ParentProcessID) == 2)
@@ -1153,7 +1166,7 @@
{
tchild = creation_time(hchild);
tparent = creation_time(hparent);
-
+
CloseHandle(hparent);
}
CloseHandle(hchild);
@@ -1194,14 +1207,14 @@
if (!GetClassNameA(hwnd, buf, sizeof(buf)))
return TRUE; /* failed to read class name; presume it's not a dialog */
-
+
if (strcmp(buf, "#32770") != 0)
return TRUE; /* not a dialog */
/* GetWindowThreadProcessId returns 0 on error, otherwise thread id
of window message pump thread */
tid = GetWindowThreadProcessId(hwnd, &pid);
-
+
if (tid && is_parent_child(p.pid, pid))
{
/* ask really nice */
@@ -1212,7 +1225,7 @@
PostThreadMessageA(tid, WM_QUIT, 0, 0);
WaitForSingleObject(p.h, 300);
}
-
+
/* done, we do not want to check any other window now */
return FALSE;
}
@@ -1220,17 +1233,19 @@
return TRUE;
}
-static void close_alert(HANDLE process)
+
+static void close_alert( HANDLE process )
{
DWORD pid = get_process_id(process);
- /* If process already exited or we just cannot get its process id, do not
- go any further */
- if (pid)
+ /* If process already exited or we just cannot get its process id, do not go
+ * go any further.
+ */
+ if ( pid )
{
PROCESS_HANDLE_ID p;
p.h = process;
- p.pid = pid;
- EnumWindows(&close_alert_window_enum, (LPARAM) &p);
+ p.pid = pid;
+ EnumWindows( &close_alert_window_enum, (LPARAM)&p );
}
}
Modified: trunk/tools/jam/src/execunix.c
==============================================================================
--- trunk/tools/jam/src/execunix.c (original)
+++ trunk/tools/jam/src/execunix.c 2008-08-29 08:59:49 EDT (Fri, 29 Aug 2008)
@@ -39,12 +39,12 @@
* If $(JAMSHELL) is defined, uses that to formulate execvp()/spawnvp().
* The default is:
*
- * /bin/sh -c % [ on UNIX/AmigaOS ]
- * cmd.exe /c % [ on OS2/WinNT ]
+ * /bin/sh -c % [ on UNIX/AmigaOS ]
+ * cmd.exe /c % [ on OS2/WinNT ]
*
* Each word must be an individual element in a jam variable value.
*
- * In $(JAMSHELL), % expands to the command string and ! expands to
+ * In $(JAMSHELL), % expands to the command string and ! expands to
* the slot number (starting at 1) for multiprocess (-j) invocations.
* If $(JAMSHELL) doesn't include a %, it is tacked on as the last
* argument.
@@ -52,11 +52,11 @@
* Don't just set JAMSHELL to /bin/sh or cmd.exe - it won't work!
*
* External routines:
- * execcmd() - launch an async command execution
- * execwait() - wait and drive at most one execution completion
+ * execcmd() - launch an async command execution
+ * execwait() - wait and drive at most one execution completion
*
* Internal routines:
- * onintr() - bump intr to note command interruption
+ * onintr() - bump intr to note command interruption
*
* 04/08/94 (seiwald) - Coherent/386 support added.
* 05/04/94 (seiwald) - async multiprocess interface
@@ -76,7 +76,7 @@
static struct
{
- int pid; /* on win32, a real process handle */
+ int pid; /* on win32, a real process handle */
int fd[2]; /* file descriptors for stdout and stderr */
FILE *stream[2]; /* child's stdout (0) and stderr (1) file stream */
clock_t start_time; /* start time of child process */
@@ -99,8 +99,8 @@
void
onintr( int disp )
{
- intr++;
- printf( "...interrupted\n" );
+ intr++;
+ printf( "...interrupted\n" );
}
/*
@@ -108,70 +108,70 @@
*/
void
-execcmd(
- char *string,
- void (*func)( void *closure, int status, timing_info*, char *, char * ),
- void *closure,
- LIST *shell,
+execcmd(
+ char *string,
+ void (*func)( void *closure, int status, timing_info*, char *, char * ),
+ void *closure,
+ LIST *shell,
char *action,
char *target )
{
static int initialized = 0;
int out[2], err[2];
- int slot, len;
- char *argv[ MAXARGC + 1 ]; /* +1 for NULL */
+ int slot, len;
+ char *argv[ MAXARGC + 1 ]; /* +1 for NULL */
- /* Find a slot in the running commands table for this one. */
+ /* Find a slot in the running commands table for this one. */
- for( slot = 0; slot < MAXJOBS; slot++ )
- if( !cmdtab[ slot ].pid )
- break;
-
- if( slot == MAXJOBS )
- {
- printf( "no slots for child!\n" );
- exit( EXITBAD );
- }
-
- /* Forumulate argv */
- /* If shell was defined, be prepared for % and ! subs. */
- /* Otherwise, use stock /bin/sh (on unix) or cmd.exe (on NT). */
-
- if( shell )
- {
- int i;
- char jobno[4];
- int gotpercent = 0;
-
- sprintf( jobno, "%d", slot + 1 );
-
- for( i = 0; shell && i < MAXARGC; i++, shell = list_next( shell ) )
- {
- switch( shell->string[0] )
- {
- case '%': argv[i] = string; gotpercent++; break;
- case '!': argv[i] = jobno; break;
- default: argv[i] = shell->string;
- }
- if( DEBUG_EXECCMD )
- printf( "argv[%d] = '%s'\n", i, argv[i] );
- }
-
- if( !gotpercent )
- argv[i++] = string;
-
- argv[i] = 0;
- }
- else
- {
- argv[0] = "/bin/sh";
- argv[1] = "-c";
- argv[2] = string;
- argv[3] = 0;
- }
+ for( slot = 0; slot < MAXJOBS; slot++ )
+ if( !cmdtab[ slot ].pid )
+ break;
- /* increment jobs running */
- ++cmdsrunning;
+ if( slot == MAXJOBS )
+ {
+ printf( "no slots for child!\n" );
+ exit( EXITBAD );
+ }
+
+ /* Forumulate argv */
+ /* If shell was defined, be prepared for % and ! subs. */
+ /* Otherwise, use stock /bin/sh (on unix) or cmd.exe (on NT). */
+
+ if( shell )
+ {
+ int i;
+ char jobno[4];
+ int gotpercent = 0;
+
+ sprintf( jobno, "%d", slot + 1 );
+
+ for( i = 0; shell && i < MAXARGC; i++, shell = list_next( shell ) )
+ {
+ switch( shell->string[0] )
+ {
+ case '%': argv[i] = string; gotpercent++; break;
+ case '!': argv[i] = jobno; break;
+ default: argv[i] = shell->string;
+ }
+ if( DEBUG_EXECCMD )
+ printf( "argv[%d] = '%s'\n", i, argv[i] );
+ }
+
+ if( !gotpercent )
+ argv[i++] = string;
+
+ argv[i] = 0;
+ }
+ else
+ {
+ argv[0] = "/bin/sh";
+ argv[1] = "-c";
+ argv[2] = string;
+ argv[3] = 0;
+ }
+
+ /* increment jobs running */
+ ++cmdsrunning;
/* save off actual command string */
cmdtab[ slot ].command = BJAM_MALLOC_ATOMIC(strlen(string)+1);
@@ -197,24 +197,24 @@
fcntl(err[0], F_SETFL, O_NONBLOCK);
fcntl(err[1], F_SETFL, O_NONBLOCK);
- /* Start the command */
+ /* Start the command */
cmdtab[ slot ].start_dt = time(0);
if (0 < globs.timeout) {
- /*
- * handle hung processes by manually tracking elapsed
+ /*
+ * handle hung processes by manually tracking elapsed
* time and signal process when time limit expires
*/
struct tms buf;
cmdtab[ slot ].start_time = times(&buf);
/* make a global, only do this once */
- if (tps == 0) tps = sysconf(_SC_CLK_TCK);
+ if (tps == 0) tps = sysconf(_SC_CLK_TCK);
}
- if ((cmdtab[slot].pid = vfork()) == 0)
- {
+ if ((cmdtab[slot].pid = vfork()) == 0)
+ {
int pid = getpid();
close(out[0]);
@@ -251,20 +251,20 @@
_exit(127);
}
else if( cmdtab[slot].pid == -1 )
- {
- perror( "vfork" );
- exit( EXITBAD );
- }
+ {
+ perror( "vfork" );
+ exit( EXITBAD );
+ }
setpgid(cmdtab[slot].pid, cmdtab[slot].pid);
/* close write end of pipes */
- close(out[1]);
- close(err[1]);
+ close(out[1]);
+ close(err[1]);
/* child writes stdout to out[1], parent reads from out[0] */
- cmdtab[slot].fd[OUT] = out[0];
- cmdtab[slot].stream[OUT] = fdopen(cmdtab[slot].fd[OUT], "rb");
+ cmdtab[slot].fd[OUT] = out[0];
+ cmdtab[slot].stream[OUT] = fdopen(cmdtab[slot].fd[OUT], "rb");
if (cmdtab[slot].stream[OUT] == NULL) {
perror( "fdopen" );
exit( EXITBAD );
@@ -277,8 +277,8 @@
}
else
{
- cmdtab[slot].fd[ERR] = err[0];
- cmdtab[slot].stream[ERR] = fdopen(cmdtab[slot].fd[ERR], "rb");
+ cmdtab[slot].fd[ERR] = err[0];
+ cmdtab[slot].stream[ERR] = fdopen(cmdtab[slot].fd[ERR], "rb");
if (cmdtab[slot].stream[ERR] == NULL) {
perror( "fdopen" );
exit( EXITBAD );
@@ -290,7 +290,7 @@
if (action && target)
{
len = strlen(action) + 1;
- if (cmdtab[slot].action_length < len)
+ if (cmdtab[slot].action_length < len)
{
BJAM_FREE(cmdtab[ slot ].action);
cmdtab[ slot ].action = BJAM_MALLOC_ATOMIC(len);
@@ -298,7 +298,7 @@
}
strcpy(cmdtab[ slot ].action, action);
len = strlen(target) + 1;
- if (cmdtab[slot].target_length < len)
+ if (cmdtab[slot].target_length < len)
{
BJAM_FREE(cmdtab[ slot ].target);
cmdtab[ slot ].target = BJAM_MALLOC_ATOMIC(len);
@@ -316,13 +316,13 @@
cmdtab[ slot ].target_length = 0;
}
- /* Save the operation for execwait() to find. */
+ /* Save the operation for execwait() to find. */
- cmdtab[ slot ].func = func;
- cmdtab[ slot ].closure = closure;
+ cmdtab[ slot ].func = func;
+ cmdtab[ slot ].closure = closure;
- /* Wait until we're under the limit of concurrent commands. */
- /* Don't trust globs.jobs alone. */
+ /* Wait until we're under the limit of concurrent commands. */
+ /* Don't trust globs.jobs alone. */
while( cmdsrunning >= MAXJOBS || cmdsrunning >= globs.jobs )
if( !execwait() )
@@ -333,10 +333,10 @@
*
* i is index into cmdtab
*
- * s (stream) indexes
+ * s (stream) indexes
*
- * cmdtab[i].stream[s]
- * cmdtab[i].buffer[s] and
+ * cmdtab[i].stream[s]
+ * cmdtab[i].buffer[s] and
* cmdtab[i].fd[s]
*/
@@ -374,7 +374,7 @@
/* close the stream and pipe descriptor */
fclose(cmdtab[i].stream[s]);
cmdtab[i].stream[s] = 0;
-
+
close(cmdtab[i].fd[s]);
cmdtab[i].fd[s] = 0;
}
@@ -487,9 +487,9 @@
cmdtab[i].pid = 0;
/* set reason for exit if not timed out */
- if (WIFEXITED(status))
+ if (WIFEXITED(status))
{
- if (0 == WEXITSTATUS(status))
+ if (0 == WEXITSTATUS(status))
cmdtab[i].exit_reason = EXIT_OK;
else
cmdtab[i].exit_reason = EXIT_FAIL;
@@ -506,7 +506,7 @@
time_info.user = (double)(new_time.tms_cutime - old_time.tms_cutime) / CLOCKS_PER_SEC;
time_info.start = cmdtab[i].start_dt;
time_info.end = time(0);
-
+
old_time = new_time;
/* Drive the completion */
Modified: trunk/tools/jam/src/execvms.c
==============================================================================
--- trunk/tools/jam/src/execvms.c (original)
+++ trunk/tools/jam/src/execvms.c 2008-08-29 08:59:49 EDT (Fri, 29 Aug 2008)
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright 1993, 1995 Christopher Seiwald.
*
* This file is part of Jam - see jam.c for Copyright information.
@@ -24,14 +24,14 @@
*
* The approach is this:
*
- * If the command is a single line, and shorter than WRTLEN (what we
- * believe to be the maximum line length), we just system() it.
+ * If the command is a single line, and shorter than WRTLEN (what we
+ * believe to be the maximum line length), we just system() it.
*
- * If the command is multi-line, or longer than WRTLEN, we write the
- * command block to a temp file, splitting long lines (using "-" at
- * the end of the line to indicate contiuation), and then source that
- * temp file. We use special logic to make sure we don't continue in
- * the middle of a quoted string.
+ * If the command is multi-line, or longer than WRTLEN, we write the
+ * command block to a temp file, splitting long lines (using "-" at
+ * the end of the line to indicate contiuation), and then source that
+ * temp file. We use special logic to make sure we don't continue in
+ * the middle of a quoted string.
*
* 05/04/94 (seiwald) - async multiprocess interface; noop on VMS
* 12/20/96 (seiwald) - rewritten to handle multi-line commands well
@@ -40,130 +40,130 @@
#define WRTLEN 240
-#define MIN( a, b ) ((a) < (b) ? (a) : (b))
+#define MIN( a, b ) ((a) < (b) ? (a) : (b))
/* 1 for the @ and 4 for the .com */
char tempnambuf[ L_tmpnam + 1 + 4 ] = {0};
void
-execcmd(
- char *string,
+execcmd(
+ char *string,
void (*func)( void *closure, int status, timing_info*, char *, char * ),
- void *closure,
- LIST *shell,
+ void *closure,
+ LIST *shell,
char *rule_name,
char *target )
{
- char *s, *e, *p;
- int rstat = EXEC_CMD_OK;
- int status;
+ char *s, *e, *p;
+ int rstat = EXEC_CMD_OK;
+ int status;
+
+ /* See if string is more than one line */
+ /* discounting leading/trailing white space */
- /* See if string is more than one line */
- /* discounting leading/trailing white space */
+ for( s = string; *s && isspace( *s ); s++ )
+ ;
- for( s = string; *s && isspace( *s ); s++ )
- ;
+ e = p = strchr( s, '\n' );
- e = p = strchr( s, '\n' );
+ while( p && isspace( *p ) )
+ ++p;
- while( p && isspace( *p ) )
- ++p;
+ /* If multi line or long, write to com file. */
+ /* Otherwise, exec directly. */
- /* If multi line or long, write to com file. */
- /* Otherwise, exec directly. */
+ if( p && *p || e - s > WRTLEN )
+ {
+ FILE *f;
- if( p && *p || e - s > WRTLEN )
- {
- FILE *f;
+ /* Create temp file invocation "@sys$scratch:tempfile.com" */
- /* Create temp file invocation "@sys$scratch:tempfile.com" */
+ if( !*tempnambuf )
+ {
+ tempnambuf[0] = '@';
+ (void)tmpnam( tempnambuf + 1 );
+ strcat( tempnambuf, ".com" );
+ }
- if( !*tempnambuf )
- {
- tempnambuf[0] = '@';
- (void)tmpnam( tempnambuf + 1 );
- strcat( tempnambuf, ".com" );
- }
-
- /* Open tempfile */
+ /* Open tempfile */
- if( !( f = fopen( tempnambuf + 1, "w" ) ) )
- {
- printf( "can't open command file\n" );
- (*func)( closure, EXEC_CMD_FAIL );
- return;
- }
+ if( !( f = fopen( tempnambuf + 1, "w" ) ) )
+ {
+ printf( "can't open command file\n" );
+ (*func)( closure, EXEC_CMD_FAIL );
+ return;
+ }
- /* For each line of the string */
+ /* For each line of the string */
- while( *string )
- {
- char *s = strchr( string, '\n' );
- int len = s ? s + 1 - string : strlen( string );
+ while( *string )
+ {
+ char *s = strchr( string, '\n' );
+ int len = s ? s + 1 - string : strlen( string );
- fputc( '$', f );
+ fputc( '$', f );
- /* For each chunk of a line that needs to be split */
+ /* For each chunk of a line that needs to be split */
- while( len > 0 )
- {
- char *q = string;
- char *qe = string + MIN( len, WRTLEN );
- char *qq = q;
- int quote = 0;
+ while( len > 0 )
+ {
+ char *q = string;
+ char *qe = string + MIN( len, WRTLEN );
+ char *qq = q;
+ int quote = 0;
- /* Look for matching "'s */
+ /* Look for matching "'s */
- for( ; q < qe; q++ )
- if( *q == '"' && ( quote = !quote ) )
- qq = q;
+ for( ; q < qe; q++ )
+ if( *q == '"' && ( quote = !quote ) )
+ qq = q;
- /* Back up to opening quote, if in one */
+ /* Back up to opening quote, if in one */
- if( quote )
- q = qq;
+ if( quote )
+ q = qq;
- fwrite( string, ( q - string ), 1, f );
+ fwrite( string, ( q - string ), 1, f );
- len -= ( q - string );
- string = q;
+ len -= ( q - string );
+ string = q;
- if( len )
- {
- fputc( '-', f );
- fputc( '\n', f );
- }
- }
- }
+ if( len )
+ {
+ fputc( '-', f );
+ fputc( '\n', f );
+ }
+ }
+ }
- fclose( f );
+ fclose( f );
- status = system( tempnambuf ) & 0x07;
+ status = system( tempnambuf ) & 0x07;
- unlink( tempnambuf + 1 );
- }
- else
- {
- /* Execute single line command */
- /* Strip trailing newline before execing */
- if( e ) *e = 0;
- status = system( s ) & 0x07;
- }
+ unlink( tempnambuf + 1 );
+ }
+ else
+ {
+ /* Execute single line command */
+ /* Strip trailing newline before execing */
+ if( e ) *e = 0;
+ status = system( s ) & 0x07;
+ }
- /* Fail for error or fatal error */
- /* OK on OK, warning, or info exit */
+ /* Fail for error or fatal error */
+ /* OK on OK, warning, or info exit */
- if( status == 2 || status == 4 )
- rstat = EXEC_CMD_FAIL;
+ if( status == 2 || status == 4 )
+ rstat = EXEC_CMD_FAIL;
- (*func)( closure, rstat );
+ (*func)( closure, rstat );
}
-int
-execwait()
+
+int execwait()
{
- return 0;
+ return 0;
}
# endif /* VMS */
Modified: trunk/tools/jam/src/expand.c
==============================================================================
--- trunk/tools/jam/src/expand.c (original)
+++ trunk/tools/jam/src/expand.c 2008-08-29 08:59:49 EDT (Fri, 29 Aug 2008)
@@ -24,13 +24,13 @@
*
* External routines:
*
- * var_expand() - variable-expand input string into list of strings
+ * var_expand() - variable-expand input string into list of strings
*
* Internal routines:
*
- * var_edit_parse() - parse : modifiers into PATHNAME structure
- * var_edit_file() - copy input target name to output, modifying filename
- * var_edit_shift() - do upshift/downshift mods
+ * var_edit_parse() - parse : modifiers into PATHNAME structure
+ * var_edit_file() - copy input target name to output, modifying filename
+ * var_edit_shift() - do upshift/downshift mods
*
* 01/25/94 (seiwald) - $(X)$(UNDEF) was expanding like plain $(X)
* 04/13/94 (seiwald) - added shorthand L0 for null list pointer
@@ -38,29 +38,29 @@
*/
typedef struct {
- PATHNAME f; /* :GDBSMR -- pieces */
- char parent; /* :P -- go to parent directory */
- char filemods; /* one of the above applied */
- char downshift; /* :L -- downshift result */
- char upshift; /* :U -- upshift result */
+ PATHNAME f; /* :GDBSMR -- pieces */
+ char parent; /* :P -- go to parent directory */
+ char filemods; /* one of the above applied */
+ char downshift; /* :L -- downshift result */
+ char upshift; /* :U -- upshift result */
char to_slashes; /* :T -- convert "\" to "/" */
char to_windows; /* :W -- convert cygwin to native paths */
- PATHPART empty; /* :E -- default for empties */
- PATHPART join; /* :J -- join list with char */
+ PATHPART empty; /* :E -- default for empties */
+ PATHPART join; /* :J -- join list with char */
} VAR_EDITS ;
static void var_edit_parse( char *mods, VAR_EDITS *edits );
static void var_edit_file( char *in, string *out, VAR_EDITS *edits );
static void var_edit_shift( string *out, VAR_EDITS *edits );
-# define MAGIC_COLON '\001'
-# define MAGIC_LEFT '\002'
-# define MAGIC_RIGHT '\003'
+# define MAGIC_COLON '\001'
+# define MAGIC_LEFT '\002'
+# define MAGIC_RIGHT '\003'
/*
* var_expand() - variable-expand input string into list of strings
*
- * Would just copy input to output, performing variable expansion,
+ * Would just copy input to output, performing variable expansion,
* except that since variables can contain multiple values the result
* of variable expansion may contain multiple values (a list). Properly
* performs "product" operations that occur in "$(var1)xxx$(var2)" or
@@ -70,12 +70,12 @@
*/
LIST *
-var_expand(
- LIST *l,
- char *in,
- char *end,
- LOL *lol,
- int cancopyin )
+var_expand(
+ LIST *l,
+ char *in,
+ char *end,
+ LOL *lol,
+ int cancopyin )
{
char out_buf[ MAXSYM ];
string buf[1];
@@ -83,7 +83,7 @@
size_t prefix_length;
char *out;
char *inp = in;
- char *ov; /* for temp copy of variable in outbuf */
+ char *ov; /* for temp copy of variable in outbuf */
int depth;
if( DEBUG_VAREXP )
@@ -100,7 +100,7 @@
case '>':
return list_copy( l, lol_get( lol, 1 ) );
-
+
case '1':
case '2':
case '3':
@@ -113,9 +113,9 @@
return list_copy( l, lol_get( lol, in[2]-'1' ) );
}
}
-
+
/* Expand @() files, to single item plus accompanying file. */
-
+
if ( in[0] == '@' && in[1] == '(' && *(end-1) == ')' )
{
/* We try the expansion until it fits within the propspective output buffer. */
@@ -144,8 +144,8 @@
/* Just try simple copy of in to out. */
- while( in < end )
- if( *in++ == '$' && *in == '(' )
+ while ( in < end )
+ if ( *in++ == '$' && *in == '(' )
goto expand;
/* No variables expanded - just add copy of input string to list. */
@@ -154,7 +154,7 @@
/* item, we can use the copystr() to put it on the new list. */
/* Otherwise, we use the slower newstr(). */
- if( cancopyin )
+ if( cancopyin )
{
return list_new( l, copystr( inp ) );
}
@@ -239,7 +239,7 @@
* out_buf out ov
*
* Later we will overwrite 'variable' in out_buf, but we'll be
- * done with it by then. 'variable' may be a multi-element list,
+ * done with it by then. 'variable' may be a multi-element list,
* so may each value for '$(variable element)', and so may 'remainder'.
* Thus we produce a product of three lists.
*/
@@ -339,7 +339,7 @@
}
/* First, compute the index of the last element. */
- sub2 = atoi(s);
+ sub2 = atoi(s);
s++;
while ( isdigit( *s ) ) s++;
@@ -353,7 +353,7 @@
** introducing a modifier is a syntax error.
*/
- s++;
+ s++;
if (*s && *s != MAGIC_COLON)
sub2 = 0;
@@ -361,14 +361,14 @@
}
/* Get variable value, specially handling $(<), $(>), $(n) */
-
+
if( varname[0] == '<' && !varname[1] )
value = lol_get( lol, 0 );
else if( varname[0] == '>' && !varname[1] )
value = lol_get( lol, 1 );
else if( varname[0] >= '1' && varname[0] <= '9' && !varname[1] )
value = lol_get( lol, varname[0] - '1' );
- else
+ else
value = var_get( varname );
/* Handle negitive indexes: part two. */
@@ -444,7 +444,7 @@
/* keep appending them (with the join value) */
/* rather than creating separate LIST elements. */
- if( colon && edits.join.ptr &&
+ if( colon && edits.join.ptr &&
( list_next( value ) || list_next( vars ) ) )
{
string_append( out1, edits.join.ptr );
@@ -511,160 +511,160 @@
* var_edit_parse() - parse : modifiers into PATHNAME structure
*
* The : modifiers in a $(varname:modifier) currently support replacing
- * or omitting elements of a filename, and so they are parsed into a
+ * or omitting elements of a filename, and so they are parsed into a
* PATHNAME structure (which contains pointers into the original string).
*
* Modifiers of the form "X=value" replace the component X with
- * the given value. Modifiers without the "=value" cause everything
+ * the given value. Modifiers without the "=value" cause everything
* but the component X to be omitted. X is one of:
*
- * G <grist>
- * D directory name
- * B base name
- * S .suffix
- * M (member)
- * R root directory - prepended to whole path
+ * G <grist>
+ * D directory name
+ * B base name
+ * S .suffix
+ * M (member)
+ * R root directory - prepended to whole path
*
* This routine sets:
*
- * f->f_xxx.ptr = 0
- * f->f_xxx.len = 0
- * -> leave the original component xxx
- *
- * f->f_xxx.ptr = string
- * f->f_xxx.len = strlen( string )
- * -> replace component xxx with string
- *
- * f->f_xxx.ptr = ""
- * f->f_xxx.len = 0
- * -> omit component xxx
+ * f->f_xxx.ptr = 0
+ * f->f_xxx.len = 0
+ * -> leave the original component xxx
+ *
+ * f->f_xxx.ptr = string
+ * f->f_xxx.len = strlen( string )
+ * -> replace component xxx with string
+ *
+ * f->f_xxx.ptr = ""
+ * f->f_xxx.len = 0
+ * -> omit component xxx
*
* var_edit_file() below and path_build() obligingly follow this convention.
*/
static void
var_edit_parse(
- char *mods,
- VAR_EDITS *edits )
+ char *mods,
+ VAR_EDITS *edits )
{
- int havezeroed = 0;
- memset( (char *)edits, 0, sizeof( *edits ) );
+ int havezeroed = 0;
+ memset( (char *)edits, 0, sizeof( *edits ) );
- while( *mods )
- {
- char *p;
- PATHPART *fp;
-
- switch( *mods++ )
- {
- case 'L': edits->downshift = 1; continue;
- case 'U': edits->upshift = 1; continue;
- case 'P': edits->parent = edits->filemods = 1; continue;
- case 'E': fp = &edits->empty; goto strval;
- case 'J': fp = &edits->join; goto strval;
- case 'G': fp = &edits->f.f_grist; goto fileval;
- case 'R': fp = &edits->f.f_root; goto fileval;
- case 'D': fp = &edits->f.f_dir; goto fileval;
- case 'B': fp = &edits->f.f_base; goto fileval;
- case 'S': fp = &edits->f.f_suffix; goto fileval;
- case 'M': fp = &edits->f.f_member; goto fileval;
+ while( *mods )
+ {
+ char *p;
+ PATHPART *fp;
+
+ switch( *mods++ )
+ {
+ case 'L': edits->downshift = 1; continue;
+ case 'U': edits->upshift = 1; continue;
+ case 'P': edits->parent = edits->filemods = 1; continue;
+ case 'E': fp = &edits->empty; goto strval;
+ case 'J': fp = &edits->join; goto strval;
+ case 'G': fp = &edits->f.f_grist; goto fileval;
+ case 'R': fp = &edits->f.f_root; goto fileval;
+ case 'D': fp = &edits->f.f_dir; goto fileval;
+ case 'B': fp = &edits->f.f_base; goto fileval;
+ case 'S': fp = &edits->f.f_suffix; goto fileval;
+ case 'M': fp = &edits->f.f_member; goto fileval;
case 'T': edits->to_slashes = 1; continue;
case 'W': edits->to_windows = 1; continue;
- default: return; /* should complain, but so what... */
- }
+ default: return; /* should complain, but so what... */
+ }
+
+ fileval:
+
+ /* Handle :CHARS, where each char (without a following =) */
+ /* selects a particular file path element. On the first such */
+ /* char, we deselect all others (by setting ptr = "", len = 0) */
+ /* and for each char we select that element (by setting ptr = 0) */
+
+ edits->filemods = 1;
+
+ if( *mods != '=' )
+ {
+ int i;
+
+ if( !havezeroed++ )
+ for( i = 0; i < 6; i++ )
+ {
+ edits->f.part[ i ].len = 0;
+ edits->f.part[ i ].ptr = "";
+ }
+
+ fp->ptr = 0;
+ continue;
+ }
+
+ strval:
- fileval:
+ /* Handle :X=value, or :X */
- /* Handle :CHARS, where each char (without a following =) */
- /* selects a particular file path element. On the first such */
- /* char, we deselect all others (by setting ptr = "", len = 0) */
- /* and for each char we select that element (by setting ptr = 0) */
-
- edits->filemods = 1;
-
- if( *mods != '=' )
- {
- int i;
-
- if( !havezeroed++ )
- for( i = 0; i < 6; i++ )
- {
- edits->f.part[ i ].len = 0;
- edits->f.part[ i ].ptr = "";
- }
-
- fp->ptr = 0;
- continue;
- }
-
- strval:
-
- /* Handle :X=value, or :X */
-
- if( *mods != '=' )
- {
- fp->ptr = "";
- fp->len = 0;
- }
- else if( p = strchr( mods, MAGIC_COLON ) )
- {
- *p = 0;
- fp->ptr = ++mods;
- fp->len = p - mods;
- mods = p + 1;
- }
- else
- {
- fp->ptr = ++mods;
- fp->len = strlen( mods );
- mods += fp->len;
- }
- }
+ if( *mods != '=' )
+ {
+ fp->ptr = "";
+ fp->len = 0;
+ }
+ else if( p = strchr( mods, MAGIC_COLON ) )
+ {
+ *p = 0;
+ fp->ptr = ++mods;
+ fp->len = p - mods;
+ mods = p + 1;
+ }
+ else
+ {
+ fp->ptr = ++mods;
+ fp->len = strlen( mods );
+ mods += fp->len;
+ }
+ }
}
/*
* var_edit_file() - copy input target name to output, modifying filename
*/
-
+
static void
-var_edit_file(
- char *in,
- string *out,
- VAR_EDITS *edits )
+var_edit_file(
+ char *in,
+ string *out,
+ VAR_EDITS *edits )
{
- PATHNAME pathname;
+ PATHNAME pathname;
- /* Parse apart original filename, putting parts into "pathname" */
+ /* Parse apart original filename, putting parts into "pathname" */
- path_parse( in, &pathname );
+ path_parse( in, &pathname );
- /* Replace any pathname with edits->f */
+ /* Replace any pathname with edits->f */
- if( edits->f.f_grist.ptr )
- pathname.f_grist = edits->f.f_grist;
+ if( edits->f.f_grist.ptr )
+ pathname.f_grist = edits->f.f_grist;
- if( edits->f.f_root.ptr )
- pathname.f_root = edits->f.f_root;
+ if( edits->f.f_root.ptr )
+ pathname.f_root = edits->f.f_root;
- if( edits->f.f_dir.ptr )
- pathname.f_dir = edits->f.f_dir;
+ if( edits->f.f_dir.ptr )
+ pathname.f_dir = edits->f.f_dir;
- if( edits->f.f_base.ptr )
- pathname.f_base = edits->f.f_base;
+ if( edits->f.f_base.ptr )
+ pathname.f_base = edits->f.f_base;
- if( edits->f.f_suffix.ptr )
- pathname.f_suffix = edits->f.f_suffix;
+ if( edits->f.f_suffix.ptr )
+ pathname.f_suffix = edits->f.f_suffix;
- if( edits->f.f_member.ptr )
- pathname.f_member = edits->f.f_member;
+ if( edits->f.f_member.ptr )
+ pathname.f_member = edits->f.f_member;
- /* If requested, modify pathname to point to parent */
+ /* If requested, modify pathname to point to parent */
- if( edits->parent )
- path_parent( &pathname );
+ if( edits->parent )
+ path_parent( &pathname );
- /* Put filename back together */
+ /* Put filename back together */
path_build( &pathname, out, 0 );
}
@@ -674,11 +674,11 @@
*/
static void
-var_edit_shift(
- string *out,
- VAR_EDITS *edits )
+var_edit_shift(
+ string *out,
+ VAR_EDITS *edits )
{
- /* Handle upshifting, downshifting and slash translation now */
+ /* Handle upshifting, downshifting and slash translation now */
char *p;
for ( p = out->value; *p; ++p)
@@ -690,7 +690,7 @@
else if ( edits->downshift )
{
*p = tolower( *p );
- }
+ }
if ( edits->to_slashes )
{
if ( *p == '\\')
@@ -720,14 +720,14 @@
char axyb[] = "a$(xy)b";
char azb[] = "a$($(z))b";
char path[] = "$(p:W)";
-
+
# ifdef OS_CYGWIN
char cygpath[256];
cygwin_conv_to_posix_path("c:\\foo\\bar", cygpath);
# else
char cygpath[] = "/cygdrive/c/foo/bar";
# endif
-
+
lol_init(lol);
var_set("xy", list_new( list_new( L0, newstr( "x" ) ), newstr( "y" ) ), VAR_SET );
var_set("z", list_new( L0, newstr( "xy" ) ), VAR_SET );
@@ -738,7 +738,7 @@
assert( !strcmp( e2->string, l2->string ) );
assert(l2 == 0 && e2 == 0);
list_free(l);
-
+
l = var_expand( 0, azb, azb + sizeof(azb) - 1, lol, 0 );
for ( l2 = l, e2 = expected; l2 && e2; l2 = list_next(l2), e2 = list_next(e2) )
assert( !strcmp( e2->string, l2->string ) );
@@ -753,15 +753,15 @@
/* This has been reported to be the case if cygwin has been installed to C:\ */
/* as opposed to C:\cygwin */
/* Since case of the drive letter will not matter, we allow for both. */
- assert( 0 == strcmp( l->string, "c:\\foo\\bar" )
+ assert( 0 == strcmp( l->string, "c:\\foo\\bar" )
|| 0 == strcmp( l->string, "C:\\foo\\bar") );
- # else
+ # else
assert( !strcmp( l->string, cygpath ) );
- # endif
+ # endif
list_free(l);
list_free(expected);
-
+
lol_free(lol);
}
#endif
Modified: trunk/tools/jam/src/expand.h
==============================================================================
--- trunk/tools/jam/src/expand.h (original)
+++ trunk/tools/jam/src/expand.h 2008-08-29 08:59:49 EDT (Fri, 29 Aug 2008)
@@ -10,5 +10,5 @@
#include "lists.h"
-LIST *var_expand( LIST *l, char *in, char *end, LOL *lol, int cancopyin );
+LIST *var_expand( LIST *l, char *in, char *end, LOL *lol, int cancopyin );
void var_expand_unit_test();
Modified: trunk/tools/jam/src/filemac.c
==============================================================================
--- trunk/tools/jam/src/filemac.c (original)
+++ trunk/tools/jam/src/filemac.c 2008-08-29 08:59:49 EDT (Fri, 29 Aug 2008)
@@ -3,7 +3,7 @@
*
* This file is part of Jam - see jam.c for Copyright information.
*/
-
+
/* This file is ALSO:
* Copyright 2001-2004 David Abrahams.
* Distributed under the Boost Software License, Version 1.0.
@@ -26,9 +26,9 @@
*
* External routines:
*
- * file_dirscan() - scan a directory for files
- * file_time() - get timestamp of file, if not done by file_dirscan()
- * file_archscan() - scan an archive for files
+ * file_dirscan() - scan a directory for files
+ * file_time() - get timestamp of file, if not done by file_dirscan()
+ * file_archscan() - scan an archive for files
*
* File_dirscan() and file_archscan() call back a caller provided function
* for each file found. A flag to this callback function lets file_dirscan()
@@ -45,23 +45,21 @@
void CopyC2PStr(const char * cstr, StringPtr pstr)
{
- int len;
-
- for (len = 0; *cstr && len<255; pstr[++len] = *cstr++)
- ;
-
- pstr[0] = len;
+ int len;
+ for ( len = 0; *cstr && len < 255; pstr[++len] = *cstr++ );
+ pstr[0] = len;
}
+
/*
* file_dirscan() - scan a directory for files
*/
void
-file_dirscan(
- char *dir,
- scanback func,
- void *closure )
+file_dirscan(
+ char *dir,
+ scanback func,
+ void *closure )
{
PATHNAME f;
string filename[1];
@@ -69,10 +67,10 @@
FSSpec spec;
WDPBRec vol;
- Str63 volName;
+ Str63 volName;
CInfoPBRec lastInfo;
int index = 1;
-
+
/* First enter directory itself */
memset( (char *)&f, '\0', sizeof( f ) );
@@ -82,30 +80,30 @@
if( DEBUG_BINDSCAN )
printf( "scan directory %s\n", dir );
-
+
/* Special case ":" - enter it */
if( f.f_dir.len == 1 && f.f_dir.ptr[0] == ':' )
- (*func)( closure, dir, 0 /* not stat()'ed */, (time_t)0 );
+ (*func)( closure, dir, 0 /* not stat()'ed */, (time_t)0 );
/* Now enter contents of directory */
vol.ioNamePtr = volName;
-
+
if( PBHGetVolSync( &vol ) )
return;
CopyC2PStr( dir, fullPath );
-
+
if( FSMakeFSSpec( vol.ioWDVRefNum, vol.ioWDDirID, fullPath, &spec ) )
return;
-
- lastInfo.dirInfo.ioVRefNum = spec.vRefNum;
- lastInfo.dirInfo.ioDrDirID = spec.parID;
- lastInfo.dirInfo.ioNamePtr = spec.name;
- lastInfo.dirInfo.ioFDirIndex = 0;
- lastInfo.dirInfo.ioACUser = 0;
-
+
+ lastInfo.dirInfo.ioVRefNum = spec.vRefNum;
+ lastInfo.dirInfo.ioDrDirID = spec.parID;
+ lastInfo.dirInfo.ioNamePtr = spec.name;
+ lastInfo.dirInfo.ioFDirIndex = 0;
+ lastInfo.dirInfo.ioACUser = 0;
+
if( PBGetCatInfoSync(&lastInfo) )
return;
@@ -113,20 +111,20 @@
return;
// ioDrDirID must be reset each time.
-
+
spec.parID = lastInfo.dirInfo.ioDrDirID;
string_new( filename );
for( ;; )
{
- lastInfo.dirInfo.ioVRefNum = spec.vRefNum;
- lastInfo.dirInfo.ioDrDirID = spec.parID;
- lastInfo.dirInfo.ioNamePtr = fullPath;
+ lastInfo.dirInfo.ioVRefNum = spec.vRefNum;
+ lastInfo.dirInfo.ioDrDirID = spec.parID;
+ lastInfo.dirInfo.ioNamePtr = fullPath;
lastInfo.dirInfo.ioFDirIndex = index++;
-
+
if( PBGetCatInfoSync(&lastInfo) )
return;
-
+
f.f_base.ptr = (char *)fullPath + 1;
f.f_base.len = *fullPath;
@@ -142,31 +140,32 @@
*/
int
-file_time(
- char *filename,
- time_t *time )
+file_time(
+ char *filename,
+ time_t *time )
{
- struct stat statbuf;
+ struct stat statbuf;
+
+ if( stat( filename, &statbuf ) < 0 )
+ return -1;
- if( stat( filename, &statbuf ) < 0 )
- return -1;
+ *time = statbuf.st_mtime;
- *time = statbuf.st_mtime;
-
- return 0;
+ return 0;
}
+
int file_is_file(char* filename)
{
- struct stat statbuf;
+ struct stat statbuf;
- if( stat( filename, &statbuf ) < 0 )
- return -1;
+ if( stat( filename, &statbuf ) < 0 )
+ return -1;
- if (S_ISREG(statbuf.st_mode))
+ if ( S_ISREG( statbuf.st_mode ) )
return 1;
else
- return 0;
+ return 0;
}
@@ -176,9 +175,9 @@
void
file_archscan(
- char *archive,
- scanback func,
- void *closure )
+ char *archive,
+ scanback func,
+ void *closure )
{
}
Modified: trunk/tools/jam/src/filent.c
==============================================================================
--- trunk/tools/jam/src/filent.c (original)
+++ trunk/tools/jam/src/filent.c 2008-08-29 08:59:49 EDT (Fri, 29 Aug 2008)
@@ -25,7 +25,7 @@
# include <dir.h>
# include <dos.h>
# endif
-# undef FILENAME /* cpp namespace collision */
+# undef FILENAME /* cpp namespace collision */
# define _finddata_t ffblk
# endif
@@ -38,9 +38,9 @@
*
* External routines:
*
- * file_dirscan() - scan a directory for files
- * file_time() - get timestamp of file, if not done by file_dirscan()
- * file_archscan() - scan an archive for files
+ * file_dirscan() - scan a directory for files
+ * file_time() - get timestamp of file, if not done by file_dirscan()
+ * file_archscan() - scan an archive for files
*
* File_dirscan() and file_archscan() call back a caller provided function
* for each file found. A flag to this callback function lets file_dirscan()
@@ -58,12 +58,12 @@
void
file_dirscan(
- char *dir,
- scanback func,
- void *closure )
+ char *dir,
+ scanback func,
+ void *closure )
{
PROFILE_ENTER(FILE_DIRSCAN);
-
+
file_info_t * d = 0;
dir = short_path_to_long_path( dir );
@@ -71,7 +71,7 @@
/* First enter directory itself */
d = file_query( dir );
-
+
if ( ! d || ! d->is_dir )
{
PROFILE_EXIT(FILE_DIRSCAN);
@@ -90,7 +90,7 @@
int d_length = strlen( d->name );
memset( (char *)&f, '\0', sizeof( f ) );
-
+
f.f_dir.ptr = d->name;
f.f_dir.len = d_length;
@@ -128,7 +128,7 @@
while( !ret )
{
file_info_t * ff = 0;
-
+
f.f_base.ptr = finfo->ff_name;
f.f_base.len = strlen( finfo->ff_name );
@@ -179,7 +179,7 @@
# endif
string_free( filename );
string_free( filespec );
-
+
d->files = files;
}
@@ -203,7 +203,7 @@
files = list_next( files );
}
}
-
+
PROFILE_EXIT(FILE_DIRSCAN);
}
@@ -231,8 +231,8 @@
int
file_time(
- char *filename,
- time_t *time )
+ char *filename,
+ time_t *time )
{
file_info_t * ff = file_query( filename );
if ( !ff ) return -1;
@@ -254,19 +254,19 @@
/* Straight from SunOS */
-#define ARMAG "!<arch>\n"
-#define SARMAG 8
+#define ARMAG "!<arch>\n"
+#define SARMAG 8
-#define ARFMAG "`\n"
+#define ARFMAG "`\n"
struct ar_hdr {
- char ar_name[16];
- char ar_date[12];
- char ar_uid[6];
- char ar_gid[6];
- char ar_mode[8];
- char ar_size[10];
- char ar_fmag[2];
+ char ar_name[16];
+ char ar_date[12];
+ char ar_uid[6];
+ char ar_gid[6];
+ char ar_mode[8];
+ char ar_size[10];
+ char ar_fmag[2];
};
# define SARFMAG 2
@@ -274,98 +274,98 @@
void
file_archscan(
- char *archive,
- scanback func,
- void *closure )
+ char *archive,
+ scanback func,
+ void *closure )
{
- struct ar_hdr ar_hdr;
- char *string_table = 0;
- char buf[ MAXJPATH ];
- long offset;
- int fd;
-
- if( ( fd = open( archive, O_RDONLY | O_BINARY, 0 ) ) < 0 )
- return;
-
- if( read( fd, buf, SARMAG ) != SARMAG ||
- strncmp( ARMAG, buf, SARMAG ) )
- {
- close( fd );
- return;
- }
-
- offset = SARMAG;
-
- if( DEBUG_BINDSCAN )
- printf( "scan archive %s\n", archive );
-
- while( read( fd, &ar_hdr, SARHDR ) == SARHDR &&
- !memcmp( ar_hdr.ar_fmag, ARFMAG, SARFMAG ) )
- {
- long lar_date;
- long lar_size;
- char *name = 0;
- char *endname;
- char *c;
-
- sscanf( ar_hdr.ar_date, "%ld", &lar_date );
- sscanf( ar_hdr.ar_size, "%ld", &lar_size );
-
- lar_size = ( lar_size + 1 ) & ~1;
-
- if (ar_hdr.ar_name[0] == '/' && ar_hdr.ar_name[1] == '/' )
- {
- /* this is the "string table" entry of the symbol table,
- ** which holds strings of filenames that are longer than
- ** 15 characters (ie. don't fit into a ar_name
- */
-
- string_table = BJAM_MALLOC_ATOMIC(lar_size+1);
- if (read(fd, string_table, lar_size) != lar_size)
- printf("error reading string table\n");
- string_table[lar_size] = '\0';
- offset += SARHDR + lar_size;
- continue;
- }
- else if (ar_hdr.ar_name[0] == '/' && ar_hdr.ar_name[1] != ' ')
- {
- /* Long filenames are recognized by "/nnnn" where nnnn is
- ** the offset of the string in the string table represented
- ** in ASCII decimals.
- */
-
- name = string_table + atoi( ar_hdr.ar_name + 1 );
- for ( endname = name; *endname && *endname != '\n'; ++endname) {}
- }
- else
- {
- /* normal name */
- name = ar_hdr.ar_name;
- endname = name + sizeof( ar_hdr.ar_name );
- }
-
- /* strip trailing white-space, slashes, and backslashes */
-
- while( endname-- > name )
- if( !isspace(*endname) && *endname != '\\' && *endname != '/' )
- break;
- *++endname = 0;
-
- /* strip leading directory names, an NT specialty */
-
- if( c = strrchr( name, '/' ) )
- name = c + 1;
- if( c = strrchr( name, '\\' ) )
- name = c + 1;
-
- sprintf( buf, "%s(%.*s)", archive, endname - name, name );
- (*func)( closure, buf, 1 /* time valid */, (time_t)lar_date );
-
- offset += SARHDR + lar_size;
- lseek( fd, offset, 0 );
- }
+ struct ar_hdr ar_hdr;
+ char *string_table = 0;
+ char buf[ MAXJPATH ];
+ long offset;
+ int fd;
+
+ if( ( fd = open( archive, O_RDONLY | O_BINARY, 0 ) ) < 0 )
+ return;
+
+ if( read( fd, buf, SARMAG ) != SARMAG ||
+ strncmp( ARMAG, buf, SARMAG ) )
+ {
+ close( fd );
+ return;
+ }
+
+ offset = SARMAG;
+
+ if( DEBUG_BINDSCAN )
+ printf( "scan archive %s\n", archive );
+
+ while( read( fd, &ar_hdr, SARHDR ) == SARHDR &&
+ !memcmp( ar_hdr.ar_fmag, ARFMAG, SARFMAG ) )
+ {
+ long lar_date;
+ long lar_size;
+ char *name = 0;
+ char *endname;
+ char *c;
+
+ sscanf( ar_hdr.ar_date, "%ld", &lar_date );
+ sscanf( ar_hdr.ar_size, "%ld", &lar_size );
+
+ lar_size = ( lar_size + 1 ) & ~1;
+
+ if (ar_hdr.ar_name[0] == '/' && ar_hdr.ar_name[1] == '/' )
+ {
+ /* this is the "string table" entry of the symbol table,
+ ** which holds strings of filenames that are longer than
+ ** 15 characters (ie. don't fit into a ar_name
+ */
+
+ string_table = BJAM_MALLOC_ATOMIC(lar_size+1);
+ if (read(fd, string_table, lar_size) != lar_size)
+ printf("error reading string table\n");
+ string_table[lar_size] = '\0';
+ offset += SARHDR + lar_size;
+ continue;
+ }
+ else if (ar_hdr.ar_name[0] == '/' && ar_hdr.ar_name[1] != ' ')
+ {
+ /* Long filenames are recognized by "/nnnn" where nnnn is
+ ** the offset of the string in the string table represented
+ ** in ASCII decimals.
+ */
+
+ name = string_table + atoi( ar_hdr.ar_name + 1 );
+ for ( endname = name; *endname && *endname != '\n'; ++endname) {}
+ }
+ else
+ {
+ /* normal name */
+ name = ar_hdr.ar_name;
+ endname = name + sizeof( ar_hdr.ar_name );
+ }
+
+ /* strip trailing white-space, slashes, and backslashes */
+
+ while( endname-- > name )
+ if( !isspace(*endname) && *endname != '\\' && *endname != '/' )
+ break;
+ *++endname = 0;
+
+ /* strip leading directory names, an NT specialty */
+
+ if( c = strrchr( name, '/' ) )
+ name = c + 1;
+ if( c = strrchr( name, '\\' ) )
+ name = c + 1;
+
+ sprintf( buf, "%s(%.*s)", archive, endname - name, name );
+ (*func)( closure, buf, 1 /* time valid */, (time_t)lar_date );
+
+ offset += SARHDR + lar_size;
+ lseek( fd, offset, 0 );
+ }
- close( fd );
+ close( fd );
}
# endif /* NT */
Modified: trunk/tools/jam/src/fileos2.c
==============================================================================
--- trunk/tools/jam/src/fileos2.c (original)
+++ trunk/tools/jam/src/fileos2.c 2008-08-29 08:59:49 EDT (Fri, 29 Aug 2008)
@@ -25,9 +25,9 @@
*
* External routines:
*
- * file_dirscan() - scan a directory for files
- * file_time() - get timestamp of file, if not done by file_dirscan()
- * file_archscan() - scan an archive for files
+ * file_dirscan() - scan a directory for files
+ * file_time() - get timestamp of file, if not done by file_dirscan()
+ * file_archscan() - scan an archive for files
*
* File_dirscan() and file_archscan() call back a caller provided function
* for each file found. A flag to this callback function lets file_dirscan()
@@ -45,10 +45,10 @@
*/
void
-file_dirscan(
- char *dir,
- scanback func,
- void *closure )
+file_dirscan(
+ char *dir,
+ scanback func,
+ void *closure )
{
PATHNAME f;
string filespec[1];
@@ -69,9 +69,9 @@
string_copy( filespec, dir );
if( f.f_dir.len == 1 && f.f_dir.ptr[0] == '\\' )
- (*func)( closure, dir, 0 /* not stat()'ed */, (time_t)0 );
+ (*func)( closure, dir, 0 /* not stat()'ed */, (time_t)0 );
else if( f.f_dir.len == 3 && f.f_dir.ptr[1] == ':' )
- (*func)( closure, dir, 0 /* not stat()'ed */, (time_t)0 );
+ (*func)( closure, dir, 0 /* not stat()'ed */, (time_t)0 );
else
string_push_back( filespec, '/' );
@@ -92,7 +92,6 @@
string_new( filename );
do
{
-
f.f_base.ptr = finfo->name;
f.f_base.len = strlen( finfo->name );
@@ -111,27 +110,27 @@
int
file_time(
- char *filename,
- time_t *time )
+ char *filename,
+ time_t *time )
{
- /* This is called on OS2, not NT. */
- /* NT fills in the time in the dirscan. */
+ /* This is called on OS2, not NT. */
+ /* NT fills in the time in the dirscan. */
- struct stat statbuf;
+ struct stat statbuf;
- if( stat( filename, &statbuf ) < 0 )
- return -1;
+ if( stat( filename, &statbuf ) < 0 )
+ return -1;
- *time = statbuf.st_mtime;
+ *time = statbuf.st_mtime;
- return 0;
+ return 0;
}
void
file_archscan(
- char *archive,
- scanback func,
- void *closure )
+ char *archive,
+ scanback func,
+ void *closure )
{
}
Modified: trunk/tools/jam/src/filesys.c
==============================================================================
--- trunk/tools/jam/src/filesys.c (original)
+++ trunk/tools/jam/src/filesys.c 2008-08-29 08:59:49 EDT (Fri, 29 Aug 2008)
@@ -12,16 +12,16 @@
{
if( DEBUG_SEARCH )
{
- printf("build file: ");
- if( f->f_root.len )
+ printf("build file: ");
+ if( f->f_root.len )
printf( "root = '%.*s' ", f->f_root.len, f->f_root.ptr );
- if( f->f_dir.len )
+ if( f->f_dir.len )
printf( "dir = '%.*s' ", f->f_dir.len, f->f_dir.ptr );
- if( f->f_base.len )
+ if( f->f_base.len )
printf( "base = '%.*s' ", f->f_base.len, f->f_base.ptr );
printf( "\n" );
}
-
+
/* Start with the grist. If the current grist isn't */
/* surrounded by <>'s, add them. */
@@ -41,10 +41,10 @@
file_info_t * file_info(char * filename)
{
file_info_t finfo_, *finfo = &finfo_;
-
+
if ( !filecache_hash )
filecache_hash = hashinit( sizeof( file_info_t ), "file_info" );
-
+
finfo->name = filename;
if ( hashenter( filecache_hash, (HASHDATA**)&finfo ) )
{
@@ -56,7 +56,7 @@
finfo->time = 0;
finfo->files = 0;
}
-
+
return finfo;
}
Modified: trunk/tools/jam/src/filesys.h
==============================================================================
--- trunk/tools/jam/src/filesys.h (original)
+++ trunk/tools/jam/src/filesys.h 2008-08-29 08:59:49 EDT (Fri, 29 Aug 2008)
@@ -11,7 +11,7 @@
*/
/*
- * filesys.h - OS specific file routines
+ * filesys.h - OS specific file routines
*/
#ifndef FILESYS_DWA20011025_H
Modified: trunk/tools/jam/src/fileunix.c
==============================================================================
--- trunk/tools/jam/src/fileunix.c (original)
+++ trunk/tools/jam/src/fileunix.c 2008-08-29 08:59:49 EDT (Fri, 29 Aug 2008)
@@ -31,7 +31,7 @@
# if defined( OS_SEQUENT ) || \
defined( OS_DGUX ) || \
defined( OS_SCO ) || \
- defined( OS_ISC )
+ defined( OS_ISC )
# define PORTAR 1
# endif
@@ -46,10 +46,10 @@
/* need unistd for rhapsody's proper lseek */
# include <sys/dir.h>
# include <unistd.h>
-# define STRUCT_DIRENT struct direct
+# define STRUCT_DIRENT struct direct
# else
# include <dirent.h>
-# define STRUCT_DIRENT struct dirent
+# define STRUCT_DIRENT struct dirent
# endif
# ifdef OS_COHERENT
@@ -58,21 +58,21 @@
# endif
# if defined( OS_MVS ) || \
- defined( OS_INTERIX )
+ defined( OS_INTERIX )
-#define ARMAG "!<arch>\n"
-#define SARMAG 8
-#define ARFMAG "`\n"
+#define ARMAG "!<arch>\n"
+#define SARMAG 8
+#define ARFMAG "`\n"
-struct ar_hdr /* archive file member header - printable ascii */
+struct ar_hdr /* archive file member header - printable ascii */
{
- char ar_name[16]; /* file member name - `/' terminated */
- char ar_date[12]; /* file member date - decimal */
- char ar_uid[6]; /* file member user id - decimal */
- char ar_gid[6]; /* file member group id - decimal */
- char ar_mode[8]; /* file member mode - octal */
- char ar_size[10]; /* file member size - decimal */
- char ar_fmag[2]; /* ARFMAG - string to end header */
+ char ar_name[16]; /* file member name - `/' terminated */
+ char ar_date[12]; /* file member date - decimal */
+ char ar_uid[6]; /* file member user id - decimal */
+ char ar_gid[6]; /* file member group id - decimal */
+ char ar_mode[8]; /* file member mode - octal */
+ char ar_size[10]; /* file member size - decimal */
+ char ar_fmag[2]; /* ARFMAG - string to end header */
};
# define HAVE_AR
@@ -90,21 +90,21 @@
# ifdef OS_AIX
/* Define those for AIX to get the definitions for both the small and the
* big variant of the archive file format. */
-# define __AR_SMALL__
-# define __AR_BIG__
+# define __AR_SMALL__
+# define __AR_BIG__
# endif
# include <ar.h>
-# endif
+# endif
/*
* fileunix.c - manipulate file names and scan directories on UNIX/AmigaOS
*
* External routines:
*
- * file_dirscan() - scan a directory for files
- * file_time() - get timestamp of file, if not done by file_dirscan()
- * file_archscan() - scan an archive for files
+ * file_dirscan() - scan a directory for files
+ * file_time() - get timestamp of file, if not done by file_dirscan()
+ * file_archscan() - scan an archive for files
*
* File_dirscan() and file_archscan() call back a caller provided function
* for each file found. A flag to this callback function lets file_dirscan()
@@ -124,17 +124,17 @@
*/
void
-file_dirscan(
- char *dir,
- scanback func,
- void *closure )
+file_dirscan(
+ char *dir,
+ scanback func,
+ void *closure )
{
PROFILE_ENTER(FILE_DIRSCAN);
-
+
file_info_t * d = 0;
d = file_query( dir );
-
+
if ( ! d || ! d->is_dir )
{
PROFILE_EXIT(FILE_DIRSCAN);
@@ -173,7 +173,7 @@
while( dirent = readdir( dd ) )
{
file_info_t * ff = 0;
-
+
# ifdef old_sinix
/* Broken structure definition on sinix. */
f.f_base.ptr = dirent->d_name - 2;
@@ -191,7 +191,7 @@
string_free( filename );
closedir( dd );
-
+
d->files = files;
}
@@ -213,7 +213,7 @@
files = list_next( files );
}
}
-
+
PROFILE_EXIT(FILE_DIRSCAN);
}
@@ -241,8 +241,8 @@
int
file_time(
- char *filename,
- time_t *time )
+ char *filename,
+ time_t *time )
{
file_info_t * ff = file_query( filename );
if ( !ff ) return -1;
@@ -262,109 +262,109 @@
* file_archscan() - scan an archive for files
*/
-# ifndef AIAMAG /* God-fearing UNIX */
+# ifndef AIAMAG /* God-fearing UNIX */
# define SARFMAG 2
# define SARHDR sizeof( struct ar_hdr )
void
file_archscan(
- char *archive,
- scanback func,
- void *closure )
+ char *archive,
+ scanback func,
+ void *closure )
{
# ifndef NO_AR
- struct ar_hdr ar_hdr;
- char buf[ MAXJPATH ];
- long offset;
- char *string_table = 0;
- int fd;
-
- if( ( fd = open( archive, O_RDONLY, 0 ) ) < 0 )
- return;
-
- if( read( fd, buf, SARMAG ) != SARMAG ||
- strncmp( ARMAG, buf, SARMAG ) )
- {
- close( fd );
- return;
- }
+ struct ar_hdr ar_hdr;
+ char buf[ MAXJPATH ];
+ long offset;
+ char *string_table = 0;
+ int fd;
+
+ if( ( fd = open( archive, O_RDONLY, 0 ) ) < 0 )
+ return;
- offset = SARMAG;
+ if( read( fd, buf, SARMAG ) != SARMAG ||
+ strncmp( ARMAG, buf, SARMAG ) )
+ {
+ close( fd );
+ return;
+ }
- if( DEBUG_BINDSCAN )
- printf( "scan archive %s\n", archive );
+ offset = SARMAG;
+
+ if( DEBUG_BINDSCAN )
+ printf( "scan archive %s\n", archive );
- while( read( fd, &ar_hdr, SARHDR ) == SARHDR
- && ! ( memcmp( ar_hdr.ar_fmag, ARFMAG, SARFMAG )
+ while( read( fd, &ar_hdr, SARHDR ) == SARHDR
+ && ! ( memcmp( ar_hdr.ar_fmag, ARFMAG, SARFMAG )
#ifdef ARFZMAG
- /* OSF also has a compressed format */
- && memcmp( ar_hdr.ar_fmag, ARFZMAG, SARFMAG )
+ /* OSF also has a compressed format */
+ && memcmp( ar_hdr.ar_fmag, ARFZMAG, SARFMAG )
#endif
- ) )
- {
- char lar_name_[257];
+ ) )
+ {
+ char lar_name_[257];
char* lar_name = lar_name_ + 1;
- long lar_date;
- long lar_size;
- long lar_offset;
- char *c;
- char *src, *dest;
-
- strncpy( lar_name, ar_hdr.ar_name, sizeof(ar_hdr.ar_name) );
-
- sscanf( ar_hdr.ar_date, "%ld", &lar_date );
- sscanf( ar_hdr.ar_size, "%ld", &lar_size );
-
- if (ar_hdr.ar_name[0] == '/')
- {
- if (ar_hdr.ar_name[1] == '/')
- {
- /* this is the "string table" entry of the symbol table,
- ** which holds strings of filenames that are longer than
- ** 15 characters (ie. don't fit into a ar_name
- */
-
- string_table = (char *)BJAM_MALLOC_ATOMIC(lar_size);
- lseek(fd, offset + SARHDR, 0);
- if (read(fd, string_table, lar_size) != lar_size)
- printf("error reading string table\n");
- }
- else if (string_table && ar_hdr.ar_name[1] != ' ')
- {
- /* Long filenames are recognized by "/nnnn" where nnnn is
- ** the offset of the string in the string table represented
- ** in ASCII decimals.
- */
- dest = lar_name;
- lar_offset = atoi(lar_name + 1);
- src = &string_table[lar_offset];
- while (*src != '/')
- *dest++ = *src++;
- *dest = '/';
- }
- }
-
- c = lar_name - 1;
- while( *++c != ' ' && *c != '/' )
- ;
- *c = '\0';
-
- if ( DEBUG_BINDSCAN )
- printf( "archive name %s found\n", lar_name );
-
- sprintf( buf, "%s(%s)", archive, lar_name );
-
- (*func)( closure, buf, 1 /* time valid */, (time_t)lar_date );
-
- offset += SARHDR + ( ( lar_size + 1 ) & ~1 );
- lseek( fd, offset, 0 );
- }
+ long lar_date;
+ long lar_size;
+ long lar_offset;
+ char *c;
+ char *src, *dest;
- if (string_table)
- BJAM_FREE(string_table);
+ strncpy( lar_name, ar_hdr.ar_name, sizeof(ar_hdr.ar_name) );
- close( fd );
+ sscanf( ar_hdr.ar_date, "%ld", &lar_date );
+ sscanf( ar_hdr.ar_size, "%ld", &lar_size );
+
+ if (ar_hdr.ar_name[0] == '/')
+ {
+ if (ar_hdr.ar_name[1] == '/')
+ {
+ /* this is the "string table" entry of the symbol table,
+ ** which holds strings of filenames that are longer than
+ ** 15 characters (ie. don't fit into a ar_name
+ */
+
+ string_table = (char *)BJAM_MALLOC_ATOMIC(lar_size);
+ lseek(fd, offset + SARHDR, 0);
+ if (read(fd, string_table, lar_size) != lar_size)
+ printf("error reading string table\n");
+ }
+ else if (string_table && ar_hdr.ar_name[1] != ' ')
+ {
+ /* Long filenames are recognized by "/nnnn" where nnnn is
+ ** the offset of the string in the string table represented
+ ** in ASCII decimals.
+ */
+ dest = lar_name;
+ lar_offset = atoi(lar_name + 1);
+ src = &string_table[lar_offset];
+ while (*src != '/')
+ *dest++ = *src++;
+ *dest = '/';
+ }
+ }
+
+ c = lar_name - 1;
+ while( *++c != ' ' && *c != '/' )
+ ;
+ *c = '\0';
+
+ if ( DEBUG_BINDSCAN )
+ printf( "archive name %s found\n", lar_name );
+
+ sprintf( buf, "%s(%s)", archive, lar_name );
+
+ (*func)( closure, buf, 1 /* time valid */, (time_t)lar_date );
+
+ offset += SARHDR + ( ( lar_size + 1 ) & ~1 );
+ lseek( fd, offset, 0 );
+ }
+
+ if (string_table)
+ BJAM_FREE(string_table);
+
+ close( fd );
# endif /* NO_AR */
@@ -389,24 +389,24 @@
return;
sscanf( fl_hdr.fl_fstmoff, "%ld", &offset );
-
+
if( DEBUG_BINDSCAN )
printf( "scan archive %s\n", archive );
-
+
while( offset > 0
&& lseek( fd, offset, 0 ) >= 0
&& read( fd, &ar_hdr, sizeof( ar_hdr ) ) >= sizeof( ar_hdr.hdr ) )
{
long lar_date;
int lar_namlen;
-
+
sscanf( ar_hdr.hdr.ar_namlen, "%d", &lar_namlen );
sscanf( ar_hdr.hdr.ar_date, "%ld", &lar_date );
sscanf( ar_hdr.hdr.ar_nxtmem, "%ld", &offset );
-
+
if( !lar_namlen )
continue;
-
+
ar_hdr.hdr._ar_name.ar_name[ lar_namlen ] = '\0';
sprintf( buf, "%s(%s)", archive, ar_hdr.hdr._ar_name.ar_name );
@@ -471,7 +471,7 @@
if(( fd = open(archive, O_RDONLY, 0)) < 0)
return;
-
+
if(read( fd, fl_magic, SAIAMAG) != SAIAMAG
|| lseek(fd, 0, SEEK_SET) == -1)
{
@@ -491,7 +491,7 @@
file_archscan_big(fd, archive, func, closure);
}
#endif
-
+
close( fd );
}
Modified: trunk/tools/jam/src/filevms.c
==============================================================================
--- trunk/tools/jam/src/filevms.c (original)
+++ trunk/tools/jam/src/filevms.c 2008-08-29 08:59:49 EDT (Fri, 29 Aug 2008)
@@ -21,9 +21,9 @@
*
* External routines:
*
- * file_dirscan() - scan a directory for files
- * file_time() - get timestamp of file, if not done by file_dirscan()
- * file_archscan() - scan an archive for files
+ * file_dirscan() - scan a directory for files
+ * file_time() - get timestamp of file, if not done by file_dirscan()
+ * file_archscan() - scan an archive for files
*
* File_dirscan() and file_archscan() call back a caller provided function
* for each file found. A flag to this callback function lets file_dirscan()
@@ -53,45 +53,45 @@
/* Supply missing prototypes for lbr$-routines*/
#ifdef __cplusplus
-extern "C" {
+extern "C" {
#endif /* __cplusplus */
-int lbr$set_module(
- void **,
- unsigned long *,
- struct dsc$descriptor_s *,
- unsigned short *,
- void * );
+int lbr$set_module(
+ void **,
+ unsigned long *,
+ struct dsc$descriptor_s *,
+ unsigned short *,
+ void * );
int lbr$open( void **,
- struct dsc$descriptor_s *,
- void *,
- void *,
- void *,
- void *,
- void * );
+ struct dsc$descriptor_s *,
+ void *,
+ void *,
+ void *,
+ void *,
+ void * );
int lbr$ini_control(
- void **,
- unsigned long *,
- unsigned long *,
- void * );
+ void **,
+ unsigned long *,
+ unsigned long *,
+ void * );
int lbr$get_index(
- void **,
- unsigned long *,
- int (*func)( struct dsc$descriptor_s *, unsigned long *),
- void * );
+ void **,
+ unsigned long *,
+ int (*func)( struct dsc$descriptor_s *, unsigned long *),
+ void * );
int lbr$close(
- void ** );
+ void ** );
#ifdef __cplusplus
}
#endif /* __cplusplus */
static void
-file_cvttime(
+file_cvttime(
unsigned int *curtime,
time_t *unixtime )
{
@@ -108,10 +108,10 @@
# define min( a,b ) ((a)<(b)?(a):(b))
void
-file_dirscan(
- char *dir,
- scanback func,
- void *closure )
+file_dirscan(
+ char *dir,
+ scanback func,
+ void *closure )
{
struct FAB xfab;
@@ -129,8 +129,8 @@
f.f_root.ptr = dir;
f.f_root.len = strlen( dir );
- /* get the input file specification
- */
+ /* get the input file specification
+ */
xnam = cc$rms_nam;
xnam.nam$l_esa = esa;
xnam.nam$b_ess = sizeof( esa ) - 1;
@@ -138,26 +138,26 @@
xnam.nam$b_rss = min( sizeof( filename ) - 1, NAM$C_MAXRSS );
xab = cc$rms_xabdat; /* initialize extended attributes */
- xab.xab$b_cod = XAB$C_DAT; /* ask for date */
+ xab.xab$b_cod = XAB$C_DAT; /* ask for date */
xab.xab$l_nxt = NULL; /* terminate XAB chain */
xfab = cc$rms_fab;
xfab.fab$l_dna = DEFAULT_FILE_SPECIFICATION;
xfab.fab$b_dns = sizeof( DEFAULT_FILE_SPECIFICATION ) - 1;
xfab.fab$l_fop = FAB$M_NAM;
- xfab.fab$l_fna = dir; /* address of file name */
- xfab.fab$b_fns = strlen( dir ); /* length of file name */
- xfab.fab$l_nam = &xnam; /* address of NAB block */
+ xfab.fab$l_fna = dir; /* address of file name */
+ xfab.fab$b_fns = strlen( dir ); /* length of file name */
+ xfab.fab$l_nam = &xnam; /* address of NAB block */
xfab.fab$l_xab = (char *)&xab; /* address of XAB block */
status = sys$parse( &xfab );
if( DEBUG_BINDSCAN )
- printf( "scan directory %s\n", dir );
+ printf( "scan directory %s\n", dir );
if ( !( status & 1 ) )
- return;
+ return;
@@ -165,84 +165,84 @@
if( !strcmp( dir, "[000000]" ) )
{
- (*func)( closure, "[000000]", 1 /* time valid */, 1 /* old but true */ );
+ (*func)( closure, "[000000]", 1 /* time valid */, 1 /* old but true */ );
}
/* Add bogus directory for [] */
if( !strcmp( dir, "[]" ) )
{
- (*func)( closure, "[]", 1 /* time valid */, 1 /* old but true */ );
- (*func)( closure, "[-]", 1 /* time valid */, 1 /* old but true */ );
+ (*func)( closure, "[]", 1 /* time valid */, 1 /* old but true */ );
+ (*func)( closure, "[-]", 1 /* time valid */, 1 /* old but true */ );
}
string_new( filename2 );
while ( (status = sys$search( &xfab )) & 1 )
{
- char *s;
- time_t time;
+ char *s;
+ time_t time;
- /* "I think that might work" - eml */
+ /* "I think that might work" - eml */
- sys$open( &xfab );
- sys$close( &xfab );
+ sys$open( &xfab );
+ sys$close( &xfab );
- file_cvttime( (unsigned int *)&xab.xab$q_rdt, &time );
-
- filename[xnam.nam$b_rsl] = '\0';
-
- /* What we do with the name depends on the suffix: */
- /* .dir is a directory */
- /* .xxx is a file with a suffix */
- /* . is no suffix at all */
-
- if( xnam.nam$b_type == 4 && !strncmp( xnam.nam$l_type, ".DIR", 4 ) )
- {
- /* directory */
- sprintf( dirname, "[.%.*s]", xnam.nam$b_name, xnam.nam$l_name );
- f.f_dir.ptr = dirname;
- f.f_dir.len = strlen( dirname );
- f.f_base.ptr = 0;
- f.f_base.len = 0;
- f.f_suffix.ptr = 0;
- f.f_suffix.len = 0;
- }
- else
- {
- /* normal file with a suffix */
- f.f_dir.ptr = 0;
- f.f_dir.len = 0;
- f.f_base.ptr = xnam.nam$l_name;
- f.f_base.len = xnam.nam$b_name;
- f.f_suffix.ptr = xnam.nam$l_type;
- f.f_suffix.len = xnam.nam$b_type;
- }
+ file_cvttime( (unsigned int *)&xab.xab$q_rdt, &time );
+
+ filename[xnam.nam$b_rsl] = '\0';
+
+ /* What we do with the name depends on the suffix: */
+ /* .dir is a directory */
+ /* .xxx is a file with a suffix */
+ /* . is no suffix at all */
+
+ if( xnam.nam$b_type == 4 && !strncmp( xnam.nam$l_type, ".DIR", 4 ) )
+ {
+ /* directory */
+ sprintf( dirname, "[.%.*s]", xnam.nam$b_name, xnam.nam$l_name );
+ f.f_dir.ptr = dirname;
+ f.f_dir.len = strlen( dirname );
+ f.f_base.ptr = 0;
+ f.f_base.len = 0;
+ f.f_suffix.ptr = 0;
+ f.f_suffix.len = 0;
+ }
+ else
+ {
+ /* normal file with a suffix */
+ f.f_dir.ptr = 0;
+ f.f_dir.len = 0;
+ f.f_base.ptr = xnam.nam$l_name;
+ f.f_base.len = xnam.nam$b_name;
+ f.f_suffix.ptr = xnam.nam$l_type;
+ f.f_suffix.len = xnam.nam$b_type;
+ }
string_truncate( filename2, 0 );
- path_build( &f, filename2, 0 );
+ path_build( &f, filename2, 0 );
- /*
- if( DEBUG_SEARCH )
- printf("root '%s' base %.*s suf %.*s = %s\n",
- dir,
- xnam.nam$b_name, xnam.nam$l_name,
- xnam.nam$b_type, xnam.nam$l_type,
- filename2);
- */
+ /*
+ if( DEBUG_SEARCH )
+ printf("root '%s' base %.*s suf %.*s = %s\n",
+ dir,
+ xnam.nam$b_name, xnam.nam$l_name,
+ xnam.nam$b_type, xnam.nam$l_type,
+ filename2);
+ */
- (*func)( closure, filename2->value, 1 /* time valid */, time );
+ (*func)( closure, filename2->value, 1 /* time valid */, time );
}
string_free( filename2 );
-}
+}
int
file_time(
- char *filename,
- time_t *time )
+ char *filename,
+ time_t *time )
{
- /* This should never be called, as all files are */
- /* timestampped in file_dirscan() and file_archscan() */
- return -1;
+ /* This should never be called, as all files are */
+ /* timestampped in file_dirscan() and file_archscan() */
+ return -1;
}
static char *VMS_archive = 0;
@@ -251,12 +251,12 @@
static void *context;
static int
-file_archmember(
+file_archmember(
struct dsc$descriptor_s *module,
unsigned long *rfa )
{
static struct dsc$descriptor_s bufdsc =
- {0, DSC$K_DTYPE_T, DSC$K_CLASS_S, NULL};
+ {0, DSC$K_DTYPE_T, DSC$K_CLASS_S, NULL};
struct mhddef *mhd;
char filename[128];
@@ -271,17 +271,17 @@
bufdsc.dsc$a_pointer = filename;
bufdsc.dsc$w_length = sizeof( filename );
status = lbr$set_module( &context, rfa, &bufdsc,
- &bufdsc.dsc$w_length, NULL );
+ &bufdsc.dsc$w_length, NULL );
if ( !(status & 1) )
- return ( 1 );
+ return ( 1 );
mhd = (struct mhddef *)filename;
file_cvttime( &mhd->mhd$l_datim, &library_date );
for ( i = 0, p = module->dsc$a_pointer; i < module->dsc$w_length; i++, p++ )
- filename[i] = *p;
+ filename[i] = *p;
filename[i] = '\0';
@@ -294,12 +294,12 @@
void
file_archscan(
- char *archive,
- scanback func,
- void *closure )
+ char *archive,
+ scanback func,
+ void *closure )
{
static struct dsc$descriptor_s library =
- {0, DSC$K_DTYPE_T, DSC$K_CLASS_S, NULL};
+ {0, DSC$K_DTYPE_T, DSC$K_CLASS_S, NULL};
unsigned long lfunc = LBR$C_READ;
unsigned long typ = LBR$C_TYP_UNK;
@@ -313,14 +313,14 @@
status = lbr$ini_control( &context, &lfunc, &typ, NULL );
if ( !( status & 1 ) )
- return;
+ return;
library.dsc$a_pointer = archive;
library.dsc$w_length = strlen( archive );
status = lbr$open( &context, &library, NULL, NULL, NULL, NULL, NULL );
if ( !( status & 1 ) )
- return;
+ return;
(void) lbr$get_index( &context, &index, file_archmember, NULL );
Modified: trunk/tools/jam/src/frames.c
==============================================================================
--- trunk/tools/jam/src/frames.c (original)
+++ trunk/tools/jam/src/frames.c 2008-08-29 08:59:49 EDT (Fri, 29 Aug 2008)
@@ -1,4 +1,4 @@
-/*
+/*
* 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)
Modified: trunk/tools/jam/src/frames.h
==============================================================================
--- trunk/tools/jam/src/frames.h (original)
+++ trunk/tools/jam/src/frames.h 2008-08-29 08:59:49 EDT (Fri, 29 Aug 2008)
@@ -1,4 +1,4 @@
-/*
+/*
* 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)
Modified: trunk/tools/jam/src/glob.c
==============================================================================
--- trunk/tools/jam/src/glob.c (original)
+++ trunk/tools/jam/src/glob.c 2008-08-29 08:59:49 EDT (Fri, 29 Aug 2008)
@@ -1,5 +1,5 @@
/*
- * Copyright 1994 Christopher Seiwald. All rights reserved.
+ * Copyright 1994 Christopher Seiwald. All rights reserved.
*
* This file is part of Jam - see jam.c for Copyright information.
*/
@@ -9,25 +9,25 @@
*
* Understands the following patterns:
*
- * * any number of characters
- * ? any single character
- * [a-z] any single character in the range a-z
- * [^a-z] any single character not in the range a-z
- * \x match x
- *
+ * * any number of characters
+ * ? any single character
+ * [a-z] any single character in the range a-z
+ * [^a-z] any single character not in the range a-z
+ * \x match x
+ *
* External functions:
*
- * glob() - match a string against a simple pattern
+ * glob() - match a string against a simple pattern
*
* Internal functions:
*
- * globchars() - build a bitlist to check for character group match
+ * globchars() - build a bitlist to check for character group match
*/
# include "jam.h"
# define CHECK_BIT( tab, bit ) ( tab[ (bit)/8 ] & (1<<( (bit)%8 )) )
-# define BITLISTSIZE 16 /* bytes used for [chars] in compiled expr */
+# define BITLISTSIZE 16 /* bytes used for [chars] in compiled expr */
static void globchars( char *s, char *e, char *b );
@@ -37,121 +37,117 @@
int
glob(
- register char *c,
- register char *s )
+ register char *c,
+ register char *s )
{
- char bitlist[ BITLISTSIZE ];
- char *here;
+ char bitlist[ BITLISTSIZE ];
+ char *here;
- for( ;; )
- switch( *c++ )
- {
- case '\0':
- return *s ? -1 : 0;
+ for( ;; )
+ switch( *c++ )
+ {
+ case '\0':
+ return *s ? -1 : 0;
- case '?':
- if( !*s++ )
- return 1;
- break;
+ case '?':
+ if( !*s++ )
+ return 1;
+ break;
- case '[':
- /* scan for matching ] */
+ case '[':
+ /* scan for matching ] */
- here = c;
- do if( !*c++ )
- return 1;
- while( here == c || *c != ']' );
- c++;
+ here = c;
+ do if( !*c++ )
+ return 1;
+ while( here == c || *c != ']' );
+ c++;
- /* build character class bitlist */
+ /* build character class bitlist */
- globchars( here, c, bitlist );
+ globchars( here, c, bitlist );
- if( !CHECK_BIT( bitlist, *(unsigned char *)s ) )
- return 1;
- s++;
- break;
+ if( !CHECK_BIT( bitlist, *(unsigned char *)s ) )
+ return 1;
+ s++;
+ break;
- case '*':
- here = s;
+ case '*':
+ here = s;
- while( *s )
- s++;
+ while ( *s )
+ s++;
- /* Try to match the rest of the pattern in a recursive */
- /* call. If the match fails we'll back up chars, retrying. */
+ /* Try to match the rest of the pattern in a recursive */
+ /* call. If the match fails we'll back up chars, retrying. */
- while( s != here )
- {
- int r;
+ while( s != here )
+ {
+ int r;
- /* A fast path for the last token in a pattern */
+ /* A fast path for the last token in a pattern */
- r = *c ? glob( c, s ) : *s ? -1 : 0;
+ r = *c ? glob( c, s ) : *s ? -1 : 0;
- if( !r )
- return 0;
- else if( r < 0 )
- return 1;
+ if( !r )
+ return 0;
+ else if( r < 0 )
+ return 1;
- --s;
- }
- break;
+ --s;
+ }
+ break;
- case '\\':
- /* Force literal match of next char. */
+ case '\\':
+ /* Force literal match of next char. */
- if( !*c || *s++ != *c++ )
- return 1;
- break;
+ if( !*c || *s++ != *c++ )
+ return 1;
+ break;
- default:
- if( *s++ != c[-1] )
- return 1;
- break;
- }
+ default:
+ if( *s++ != c[-1] )
+ return 1;
+ break;
+ }
}
/*
* globchars() - build a bitlist to check for character group match
*/
-static void
-globchars(
- char *s,
- char *e,
- char *b )
+static void globchars( char * s, char * e, char * b )
{
- int neg = 0;
+ int neg = 0;
- memset( b, '\0', BITLISTSIZE );
+ memset( b, '\0', BITLISTSIZE );
- if( *s == '^')
- neg++, s++;
+ if( *s == '^')
+ neg++, s++;
- while( s < e )
- {
- int c;
-
- if( s+2 < e && s[1] == '-' )
- {
- for( c = s[0]; c <= s[2]; c++ )
- b[ c/8 ] |= (1<<(c%8));
- s += 3;
- } else {
- c = *s++;
- b[ c/8 ] |= (1<<(c%8));
- }
- }
-
- if( neg )
- {
- int i;
- for( i = 0; i < BITLISTSIZE; i++ )
- b[ i ] ^= 0377;
- }
+ while( s < e )
+ {
+ int c;
+
+ if( s+2 < e && s[1] == '-' )
+ {
+ for( c = s[0]; c <= s[2]; c++ )
+ b[ c/8 ] |= (1<<(c%8));
+ s += 3;
+ } else {
+ c = *s++;
+ b[ c/8 ] |= (1<<(c%8));
+ }
+ }
+
+ if ( neg )
+ {
+ int i;
+ for ( i = 0; i < BITLISTSIZE; ++i )
+ b[ i ] ^= 0377;
+ }
- /* Don't include \0 in either $[chars] or $[^chars] */
+ /* Don't include \0 in either $[chars] or $[^chars] */
- b[0] &= 0376;
+ b[0] &= 0376;
}
Modified: trunk/tools/jam/src/hash.c
==============================================================================
--- trunk/tools/jam/src/hash.c (original)
+++ trunk/tools/jam/src/hash.c 2008-08-29 08:59:49 EDT (Fri, 29 Aug 2008)
@@ -9,8 +9,8 @@
# include "compile.h"
# include <assert.h>
-/*
- * hash.c - simple in-memory hashing routines
+/*
+ * hash.c - simple in-memory hashing routines
*
* External routines:
*
@@ -29,63 +29,63 @@
#define HASH_DEBUG_PROFILE 1
/* */
-char *hashsccssid="@(#)hash.c 1.14 () 6/20/88";
+char *hashsccssid="@(#)hash.c 1.14 () 6/20/88";
/* Header attached to all data items entered into a hash table. */
struct hashhdr {
- struct item *next;
- unsigned int keyval; /* for quick comparisons */
+ struct item *next;
+ unsigned int keyval; /* for quick comparisons */
} ;
/* This structure overlays the one handed to hashenter(). */
/* It's actual size is given to hashinit(). */
struct hashdata {
- char *key;
- /* rest of user data */
+ char *key;
+ /* rest of user data */
} ;
typedef struct item {
- struct hashhdr hdr;
- struct hashdata data;
+ struct hashhdr hdr;
+ struct hashdata data;
} ITEM ;
# define MAX_LISTS 32
-struct hash
+struct hash
{
- /*
- * the hash table, just an array of item pointers
- */
- struct {
- int nel;
- ITEM **base;
- } tab;
-
- int bloat; /* tab.nel / items.nel */
- int inel; /* initial number of elements */
-
- /*
- * the array of records, maintained by these routines
- * essentially a microallocator
- */
- struct {
- int more; /* how many more ITEMs fit in lists[ list ] */
+ /*
+ * the hash table, just an array of item pointers
+ */
+ struct {
+ int nel;
+ ITEM **base;
+ } tab;
+
+ int bloat; /* tab.nel / items.nel */
+ int inel; /* initial number of elements */
+
+ /*
+ * the array of records, maintained by these routines
+ * essentially a microallocator
+ */
+ struct {
+ int more; /* how many more ITEMs fit in lists[ list ] */
ITEM *free; /* free list of items */
- char *next; /* where to put more ITEMs in lists[ list ] */
- int datalen; /* length of records in this hash table */
- int size; /* sizeof( ITEM ) + aligned datalen */
- int nel; /* total ITEMs held by all lists[] */
- int list; /* index into lists[] */
-
- struct {
- int nel; /* total ITEMs held by this list */
- char *base; /* base of ITEMs array */
- } lists[ MAX_LISTS ];
- } items;
+ char *next; /* where to put more ITEMs in lists[ list ] */
+ int datalen; /* length of records in this hash table */
+ int size; /* sizeof( ITEM ) + aligned datalen */
+ int nel; /* total ITEMs held by all lists[] */
+ int list; /* index into lists[] */
+
+ struct {
+ int nel; /* total ITEMs held by this list */
+ char *base; /* base of ITEMs array */
+ } lists[ MAX_LISTS ];
+ } items;
- char *name; /* just for hashstats() */
+ char *name; /* just for hashstats() */
} ;
static void hashrehash( struct hash *hp );
@@ -134,7 +134,7 @@
}
p = i;
}
-
+
return 0;
}
@@ -152,7 +152,7 @@
ITEM * i = 0;
ITEM * prev = 0;
unsigned int keyval = hash_keyval(data->key);
-
+
i = hash_search( hp, keyval, data->key, &prev );
if (i)
{
@@ -166,7 +166,7 @@
hp->items.free = i;
/* we have another item */
hp->items.more++;
-
+
return 1;
}
return 0;
@@ -178,32 +178,32 @@
int
hashitem(
- register struct hash *hp,
- HASHDATA **data,
- int enter )
-{
- register ITEM *i;
- char *b = (*data)->key;
- unsigned int keyval = hash_keyval(b);
-
+ register struct hash *hp,
+ HASHDATA **data,
+ int enter )
+{
+ register ITEM *i;
+ char *b = (*data)->key;
+ unsigned int keyval = hash_keyval(b);
+
#ifdef HASH_DEBUG_PROFILE
profile_frame prof[1];
if ( DEBUG_PROFILE )
profile_enter( 0, prof );
#endif
- if( enter && !hp->items.more )
- hashrehash( hp );
+ if( enter && !hp->items.more )
+ hashrehash( hp );
- if( !enter && !hp->items.nel )
+ if( !enter && !hp->items.nel )
{
#ifdef HASH_DEBUG_PROFILE
if ( DEBUG_PROFILE )
profile_exit( prof );
#endif
- return 0;
+ return 0;
}
-
+
i = hash_search( hp, keyval, (*data)->key, 0 );
if (i)
{
@@ -214,10 +214,10 @@
return !0;
}
- if( enter )
+ if ( enter )
{
- ITEM **base = hash_bucket(hp,keyval);
-
+ ITEM * * base = hash_bucket(hp,keyval);
+
/* try to grab one from the free list */
if ( hp->items.free )
{
@@ -248,7 +248,7 @@
if ( DEBUG_PROFILE )
profile_exit( prof );
#endif
- return 0;
+ return 0;
}
/*
@@ -257,39 +257,39 @@
static void hashrehash( register struct hash *hp )
{
- int i = ++hp->items.list;
- hp->items.more = i ? 2 * hp->items.nel : hp->inel;
- hp->items.next = (char *)hash_mem_alloc( hp->items.datalen, hp->items.more * hp->items.size );
+ int i = ++hp->items.list;
+ hp->items.more = i ? 2 * hp->items.nel : hp->inel;
+ hp->items.next = (char *)hash_mem_alloc( hp->items.datalen, hp->items.more * hp->items.size );
hp->items.free = 0;
-
- hp->items.lists[i].nel = hp->items.more;
- hp->items.lists[i].base = hp->items.next;
- hp->items.nel += hp->items.more;
-
- if( hp->tab.base )
- hash_mem_free( hp->items.datalen, (char *)hp->tab.base );
-
- hp->tab.nel = hp->items.nel * hp->bloat;
- hp->tab.base = (ITEM **)hash_mem_alloc( hp->items.datalen, hp->tab.nel * sizeof(ITEM **) );
-
- memset( (char *)hp->tab.base, '\0', hp->tab.nel * sizeof( ITEM * ) );
-
- for( i = 0; i < hp->items.list; i++ )
- {
- int nel = hp->items.lists[i].nel;
- char *next = hp->items.lists[i].base;
-
- for( ; nel--; next += hp->items.size )
- {
- register ITEM *i = (ITEM *)next;
- ITEM **ip = hp->tab.base + i->hdr.keyval % hp->tab.nel;
+
+ hp->items.lists[i].nel = hp->items.more;
+ hp->items.lists[i].base = hp->items.next;
+ hp->items.nel += hp->items.more;
+
+ if( hp->tab.base )
+ hash_mem_free( hp->items.datalen, (char *)hp->tab.base );
+
+ hp->tab.nel = hp->items.nel * hp->bloat;
+ hp->tab.base = (ITEM **)hash_mem_alloc( hp->items.datalen, hp->tab.nel * sizeof(ITEM **) );
+
+ memset( (char *)hp->tab.base, '\0', hp->tab.nel * sizeof( ITEM * ) );
+
+ for( i = 0; i < hp->items.list; i++ )
+ {
+ int nel = hp->items.lists[i].nel;
+ char *next = hp->items.lists[i].base;
+
+ for( ; nel--; next += hp->items.size )
+ {
+ register ITEM *i = (ITEM *)next;
+ ITEM **ip = hp->tab.base + i->hdr.keyval % hp->tab.nel;
/* code currently assumes rehashing only when there are no free items */
- assert( i->data.key != 0 );
-
- i->hdr.next = *ip;
- *ip = i;
- }
- }
+ assert( i->data.key != 0 );
+
+ i->hdr.next = *ip;
+ *ip = i;
+ }
+ }
}
void hashenumerate( struct hash *hp, void (*f)(void*,void*), void* data )
@@ -304,10 +304,9 @@
for( ; nel--; next += hp->items.size )
{
- register ITEM *i = (ITEM *)next;
-
+ register ITEM * i = (ITEM *)next;
if ( i->data.key != 0 ) /* don't enumerate freed items */
- f(&i->data, data);
+ f( &i->data, data );
}
}
}
@@ -321,25 +320,25 @@
*/
struct hash *
-hashinit(
- int datalen,
- char *name )
-{
- struct hash *hp = (struct hash *)hash_mem_alloc( datalen, sizeof( *hp ) );
-
- hp->bloat = 3;
- hp->tab.nel = 0;
- hp->tab.base = (ITEM **)0;
- hp->items.more = 0;
+hashinit(
+ int datalen,
+ char *name )
+{
+ struct hash *hp = (struct hash *)hash_mem_alloc( datalen, sizeof( *hp ) );
+
+ hp->bloat = 3;
+ hp->tab.nel = 0;
+ hp->tab.base = (ITEM **)0;
+ hp->items.more = 0;
hp->items.free = 0;
- hp->items.datalen = datalen;
- hp->items.size = sizeof( struct hashhdr ) + ALIGNED( datalen );
- hp->items.list = -1;
- hp->items.nel = 0;
- hp->inel = /* */ 11 /*/ 47 /* */;
- hp->name = name;
+ hp->items.datalen = datalen;
+ hp->items.size = sizeof( struct hashhdr ) + ALIGNED( datalen );
+ hp->items.list = -1;
+ hp->items.nel = 0;
+ hp->inel = /* */ 11 /*/ 47 /* */;
+ hp->name = name;
- return hp;
+ return hp;
}
/*
@@ -349,19 +348,19 @@
void
hashdone( struct hash *hp )
{
- int i;
+ int i;
- if( !hp )
- return;
+ if( !hp )
+ return;
- if( DEBUG_MEM || DEBUG_PROFILE )
- hashstat( hp );
+ if( DEBUG_MEM || DEBUG_PROFILE )
+ hashstat( hp );
- if( hp->tab.base )
- hash_mem_free( hp->items.datalen, (char *)hp->tab.base );
- for( i = 0; i <= hp->items.list; i++ )
- hash_mem_free( hp->items.datalen, hp->items.lists[i].base );
- hash_mem_free( hp->items.datalen, (char *)hp );
+ if( hp->tab.base )
+ hash_mem_free( hp->items.datalen, (char *)hp->tab.base );
+ for( i = 0; i <= hp->items.list; i++ )
+ hash_mem_free( hp->items.datalen, hp->items.lists[i].base );
+ hash_mem_free( hp->items.datalen, (char *)hp );
}
static void * hash_mem_alloc(size_t datalen, size_t size)
@@ -403,28 +402,28 @@
static void
hashstat( struct hash *hp )
{
- ITEM **tab = hp->tab.base;
- int nel = hp->tab.nel;
- int count = 0;
- int sets = 0;
- int run = ( tab[ nel - 1 ] != (ITEM *)0 );
- int i, here;
-
- for( i = nel; i > 0; i-- )
- {
- if( here = ( *tab++ != (ITEM *)0 ) )
- count++;
- if( here && !run )
- sets++;
- run = here;
- }
-
- printf( "%s table: %d+%d+%d (%dK+%dK) items+table+hash, %f density\n",
- hp->name,
- count,
- hp->items.nel,
- hp->tab.nel,
- hp->items.nel * hp->items.size / 1024,
- hp->tab.nel * sizeof( ITEM ** ) / 1024,
- (float)count / (float)sets );
+ ITEM **tab = hp->tab.base;
+ int nel = hp->tab.nel;
+ int count = 0;
+ int sets = 0;
+ int run = ( tab[ nel - 1 ] != (ITEM *)0 );
+ int i, here;
+
+ for( i = nel; i > 0; i-- )
+ {
+ if( here = ( *tab++ != (ITEM *)0 ) )
+ count++;
+ if( here && !run )
+ sets++;
+ run = here;
+ }
+
+ printf( "%s table: %d+%d+%d (%dK+%dK) items+table+hash, %f density\n",
+ hp->name,
+ count,
+ hp->items.nel,
+ hp->tab.nel,
+ hp->items.nel * hp->items.size / 1024,
+ hp->tab.nel * sizeof( ITEM ** ) / 1024,
+ (float)count / (float)sets );
}
Modified: trunk/tools/jam/src/hash.h
==============================================================================
--- trunk/tools/jam/src/hash.h (original)
+++ trunk/tools/jam/src/hash.h 2008-08-29 08:59:49 EDT (Fri, 29 Aug 2008)
@@ -5,21 +5,21 @@
*/
/*
- * hash.h - simple in-memory hashing routines
+ * hash.h - simple in-memory hashing routines
*/
-
+
#ifndef BOOST_JAM_HASH_H
#define BOOST_JAM_HASH_H
typedef struct hashdata HASHDATA;
-struct hash * hashinit( int datalen, char *name );
-int hashitem( struct hash *hp, HASHDATA **data, int enter );
-void hashdone( struct hash *hp );
+struct hash * hashinit( int datalen, char *name );
+int hashitem( struct hash *hp, HASHDATA **data, int enter );
+void hashdone( struct hash *hp );
void hashenumerate( struct hash *hp, void (*f)(void*,void*), void* data );
int hash_free( struct hash *hp, HASHDATA *data);
-# define hashenter( hp, data ) (!hashitem( hp, data, !0 ))
-# define hashcheck( hp, data ) hashitem( hp, data, 0 )
+# define hashenter( hp, data ) (!hashitem( hp, data, !0 ))
+# define hashcheck( hp, data ) hashitem( hp, data, 0 )
#endif
Modified: trunk/tools/jam/src/hcache.c
==============================================================================
--- trunk/tools/jam/src/hcache.c (original)
+++ trunk/tools/jam/src/hcache.c 2008-08-29 08:59:49 EDT (Fri, 29 Aug 2008)
@@ -34,26 +34,26 @@
* hcache_init() - read and parse the local .jamdeps file.
* hcache_done() - write a new .jamdeps file
* hcache() - return list of headers on target. Use cache or do a scan.
- *
+ *
* The dependency file format is an ascii file with 1 line per target.
* Each line has the following fields:
* @boundname@ timestamp @file@ @file@ @file@ ... \n
* */
struct hcachedata {
- char *boundname;
- time_t time;
- LIST *includes;
- LIST *hdrscan; /* the HDRSCAN value for this target */
- int age; /* if too old, we'll remove it from cache */
- struct hcachedata *next;
+ char *boundname;
+ time_t time;
+ LIST *includes;
+ LIST *hdrscan; /* the HDRSCAN value for this target */
+ int age; /* if too old, we'll remove it from cache */
+ struct hcachedata *next;
} ;
typedef struct hcachedata HCACHEDATA ;
static struct hash *hcachehash = 0;
-static HCACHEDATA *hcachelist = 0;
+static HCACHEDATA *hcachelist = 0;
static int queries = 0;
static int hits = 0;
@@ -74,23 +74,23 @@
{
static char* name = 0;
if (!name) {
- LIST *hcachevar = var_get("HCACHEFILE");
+ LIST *hcachevar = var_get("HCACHEFILE");
- if (hcachevar) {
- TARGET *t = bindtarget( hcachevar->string );
+ if (hcachevar) {
+ TARGET *t = bindtarget( hcachevar->string );
- pushsettings( t->settings );
+ pushsettings( t->settings );
/* Don't expect cache file to be generated, so pass 0
- as third argument to search.
+ as third argument to search.
Expect the location to be specified via LOCATE,
so pass 0 as fourth arugment. */
- t->boundname = search( t->name, &t->time, 0, 0 );
- popsettings( t->settings );
+ t->boundname = search( t->name, &t->time, 0, 0 );
+ popsettings( t->settings );
- if (hcachevar) {
- name = copystr(t->boundname);
- }
- }
+ if (hcachevar) {
+ name = copystr(t->boundname);
+ }
+ }
}
return name;
}
@@ -106,9 +106,9 @@
LIST *var = var_get("HCACHEMAXAGE");
if (var) {
- age = atoi(var->string);
- if (age < 0)
- age = 0;
+ age = atoi(var->string);
+ if (age < 0)
+ age = 0;
}
return age;
@@ -127,35 +127,36 @@
static unsigned long buf_len = 0;
if (fscanf(f, " %9lu", &len) != 1)
- return NULL;
+ return NULL;
if (fgetc(f) != (int)'\t')
- return NULL;
+ return NULL;
if (len > 1024 * 64)
- return NULL; /* sanity check */
+ return NULL; /* sanity check */
if (len > buf_len)
{
- unsigned long new_len = buf_len * 2;
- if (new_len < len)
- new_len = len;
- buf = (char*)BJAM_REALLOC(buf, new_len + 1);
- if (buf)
- buf_len = new_len;
+ unsigned long new_len = buf_len * 2;
+ if (new_len < len)
+ new_len = len;
+ buf = (char*)BJAM_REALLOC(buf, new_len + 1);
+ if (buf)
+ buf_len = new_len;
}
if (!buf)
- return NULL;
+ return NULL;
if (fread(buf, 1, len, f) != len)
- return NULL;
+ return NULL;
if (fgetc(f) != (int)'\n')
- return NULL;
+ return NULL;
buf[len] = 0;
return newstr(buf);
}
+
/*
* Write a netstring.
*/
@@ -163,119 +164,121 @@
write_netstring(FILE* f, const char* s)
{
if (!s)
- s = "";
+ s = "";
fprintf(f, "%lu\t%s\n", strlen(s), s);
}
+
void
hcache_init()
{
- HCACHEDATA cachedata, *c;
- FILE *f;
- char *version;
- int header_count = 0;
- char* hcachename;
+ HCACHEDATA cachedata;
+ HCACHEDATA * c;
+ FILE * f;
+ char * version;
+ int header_count = 0;
+ char * hcachename;
hcachehash = hashinit (sizeof (HCACHEDATA), "hcache");
if (! (hcachename = cache_name()))
- return;
+ return;
if (! (f = fopen (hcachename, "rb" )))
- return;
-
+ return;
+
version = read_netstring(f);
if (!version || strcmp(version, CACHE_FILE_VERSION)) {
- fclose(f);
- return;
+ fclose(f);
+ return;
}
while (1)
{
- char* record_type;
- char *time_str;
- char *age_str;
- char *includes_count_str;
- char *hdrscan_count_str;
- int i, count;
- LIST *l;
-
- record_type = read_netstring(f);
- if (!record_type) {
- fprintf(stderr, "invalid %s\n", hcachename);
- goto bail;
- }
- if (!strcmp(record_type, CACHE_RECORD_END)) {
- break;
- }
- if (strcmp(record_type, CACHE_RECORD_HEADER)) {
- fprintf(stderr, "invalid %s with record separator <%s>\n",
- hcachename, record_type ? record_type : "<null>");
- goto bail;
- }
-
- c = &cachedata;
-
- c->boundname = read_netstring(f);
- time_str = read_netstring(f);
- age_str = read_netstring(f);
- includes_count_str = read_netstring(f);
-
- if (!c->boundname || !time_str || !age_str
- || !includes_count_str)
- {
- fprintf(stderr, "invalid %s\n", hcachename);
- goto bail;
- }
-
- c->time = atoi(time_str);
- c->age = atoi(age_str) + 1;
-
- count = atoi(includes_count_str);
- for (l = 0, i = 0; i < count; i++) {
- char* s = read_netstring(f);
- if (!s) {
- fprintf(stderr, "invalid %s\n", hcachename);
- goto bail;
- }
- l = list_new(l, s);
- }
- c->includes = l;
-
- hdrscan_count_str = read_netstring(f);
- if (!includes_count_str) {
- list_free(c->includes);
- fprintf(stderr, "invalid %s\n", hcachename);
- goto bail;
- }
-
- count = atoi(hdrscan_count_str);
- for (l = 0, i = 0; i < count; i++) {
- char* s = read_netstring(f);
- if (!s) {
- fprintf(stderr, "invalid %s\n", hcachename);
- goto bail;
- }
- l = list_new(l, s);
- }
- c->hdrscan = l;
-
- if (!hashenter(hcachehash, (HASHDATA **)&c)) {
- fprintf(stderr, "can't insert header cache item, bailing on %s\n",
- hcachename);
- goto bail;
- }
+ char* record_type;
+ char *time_str;
+ char *age_str;
+ char *includes_count_str;
+ char *hdrscan_count_str;
+ int i, count;
+ LIST *l;
+
+ record_type = read_netstring(f);
+ if (!record_type) {
+ fprintf(stderr, "invalid %s\n", hcachename);
+ goto bail;
+ }
+ if (!strcmp(record_type, CACHE_RECORD_END)) {
+ break;
+ }
+ if (strcmp(record_type, CACHE_RECORD_HEADER)) {
+ fprintf(stderr, "invalid %s with record separator <%s>\n",
+ hcachename, record_type ? record_type : "<null>");
+ goto bail;
+ }
+
+ c = &cachedata;
+
+ c->boundname = read_netstring(f);
+ time_str = read_netstring(f);
+ age_str = read_netstring(f);
+ includes_count_str = read_netstring(f);
+
+ if (!c->boundname || !time_str || !age_str
+ || !includes_count_str)
+ {
+ fprintf(stderr, "invalid %s\n", hcachename);
+ goto bail;
+ }
- c->next = hcachelist;
- hcachelist = c;
+ c->time = atoi(time_str);
+ c->age = atoi(age_str) + 1;
+
+ count = atoi(includes_count_str);
+ for (l = 0, i = 0; i < count; i++) {
+ char* s = read_netstring(f);
+ if (!s) {
+ fprintf(stderr, "invalid %s\n", hcachename);
+ goto bail;
+ }
+ l = list_new(l, s);
+ }
+ c->includes = l;
- header_count++;
+ hdrscan_count_str = read_netstring(f);
+ if (!includes_count_str) {
+ list_free(c->includes);
+ fprintf(stderr, "invalid %s\n", hcachename);
+ goto bail;
+ }
+
+ count = atoi(hdrscan_count_str);
+ for (l = 0, i = 0; i < count; i++) {
+ char* s = read_netstring(f);
+ if (!s) {
+ fprintf(stderr, "invalid %s\n", hcachename);
+ goto bail;
+ }
+ l = list_new(l, s);
+ }
+ c->hdrscan = l;
+
+ if (!hashenter(hcachehash, (HASHDATA **)&c)) {
+ fprintf(stderr, "can't insert header cache item, bailing on %s\n",
+ hcachename);
+ goto bail;
+ }
+
+ c->next = hcachelist;
+ hcachelist = c;
+
+ header_count++;
}
if (DEBUG_HEADER) {
- printf("hcache read from file %s\n", hcachename);
+ printf("hcache read from file %s\n", hcachename);
}
-
+
bail:
fclose(f);
}
@@ -283,20 +286,20 @@
void
hcache_done()
{
- FILE *f;
+ FILE *f;
HCACHEDATA *c;
- int header_count = 0;
- char* hcachename;
- int maxage;
-
+ int header_count = 0;
+ char* hcachename;
+ int maxage;
+
if (!hcachehash)
- return;
+ return;
if (! (hcachename = cache_name()))
- return;
+ return;
if (! (f = fopen (hcachename, "wb" )))
- return;
+ return;
maxage = cache_maxage();
@@ -305,43 +308,43 @@
c = hcachelist;
for (c = hcachelist; c; c = c->next) {
- LIST *l;
- char time_str[30];
- char age_str[30];
- char includes_count_str[30];
- char hdrscan_count_str[30];
-
- if (maxage == 0)
- c->age = 0;
- else if (c->age > maxage)
- continue;
-
- sprintf(includes_count_str, "%lu", list_length(c->includes));
- sprintf(hdrscan_count_str, "%lu", list_length(c->hdrscan));
- sprintf(time_str, "%lu", c->time);
- sprintf(age_str, "%lu", c->age);
-
- write_netstring(f, CACHE_RECORD_HEADER);
- write_netstring(f, c->boundname);
- write_netstring(f, time_str);
- write_netstring(f, age_str);
- write_netstring(f, includes_count_str);
- for (l = c->includes; l; l = list_next(l)) {
- write_netstring(f, l->string);
- }
- write_netstring(f, hdrscan_count_str);
- for (l = c->hdrscan; l; l = list_next(l)) {
- write_netstring(f, l->string);
- }
- fputs("\n", f);
- header_count++;
+ LIST *l;
+ char time_str[30];
+ char age_str[30];
+ char includes_count_str[30];
+ char hdrscan_count_str[30];
+
+ if (maxage == 0)
+ c->age = 0;
+ else if (c->age > maxage)
+ continue;
+
+ sprintf(includes_count_str, "%lu", list_length(c->includes));
+ sprintf(hdrscan_count_str, "%lu", list_length(c->hdrscan));
+ sprintf(time_str, "%lu", c->time);
+ sprintf(age_str, "%lu", c->age);
+
+ write_netstring(f, CACHE_RECORD_HEADER);
+ write_netstring(f, c->boundname);
+ write_netstring(f, time_str);
+ write_netstring(f, age_str);
+ write_netstring(f, includes_count_str);
+ for (l = c->includes; l; l = list_next(l)) {
+ write_netstring(f, l->string);
+ }
+ write_netstring(f, hdrscan_count_str);
+ for (l = c->hdrscan; l; l = list_next(l)) {
+ write_netstring(f, l->string);
+ }
+ fputs("\n", f);
+ header_count++;
}
write_netstring(f, CACHE_RECORD_END);
if (DEBUG_HEADER) {
- printf("hcache written to %s. %d dependencies, %.0f%% hit rate\n",
- hcachename, header_count,
- queries ? 100.0 * hits / queries : 0);
+ printf("hcache written to %s. %d dependencies, %.0f%% hit rate\n",
+ hcachename, header_count,
+ queries ? 100.0 * hits / queries : 0);
}
fclose (f);
@@ -351,7 +354,7 @@
hcache (TARGET *t, int rec, regexp *re[], LIST *hdrscan)
{
HCACHEDATA cachedata, *c = &cachedata;
- LIST *l = 0;
+ LIST *l = 0;
++queries;
@@ -359,55 +362,55 @@
if (hashcheck (hcachehash, (HASHDATA **) &c))
{
- if (c->time == t->time)
- {
- LIST *l1 = hdrscan, *l2 = c->hdrscan;
- while (l1 && l2) {
- if (l1->string != l2->string) {
- l1 = NULL;
- } else {
- l1 = list_next(l1);
- l2 = list_next(l2);
- }
- }
- if (l1 || l2) {
- if (DEBUG_HEADER)
- printf("HDRSCAN out of date in cache for %s\n",
- t->boundname);
-
- printf("HDRSCAN out of date for %s\n", t->boundname);
- printf(" real : ");
- list_print(hdrscan);
- printf("\n cached: ");
- list_print(c->hdrscan);
- printf("\n");
-
- list_free(c->includes);
- list_free(c->hdrscan);
- c->includes = 0;
- c->hdrscan = 0;
- } else {
- if (DEBUG_HEADER)
- printf ("using header cache for %s\n", t->boundname);
- c->age = 0;
- ++hits;
- l = list_copy (0, c->includes);
- return l;
- }
- } else {
- if (DEBUG_HEADER)
- printf ("header cache out of date for %s\n", t->boundname);
- list_free (c->includes);
- list_free(c->hdrscan);
- c->includes = 0;
- c->hdrscan = 0;
- }
+ if (c->time == t->time)
+ {
+ LIST *l1 = hdrscan, *l2 = c->hdrscan;
+ while (l1 && l2) {
+ if (l1->string != l2->string) {
+ l1 = NULL;
+ } else {
+ l1 = list_next(l1);
+ l2 = list_next(l2);
+ }
+ }
+ if (l1 || l2) {
+ if (DEBUG_HEADER)
+ printf("HDRSCAN out of date in cache for %s\n",
+ t->boundname);
+
+ printf("HDRSCAN out of date for %s\n", t->boundname);
+ printf(" real : ");
+ list_print(hdrscan);
+ printf("\n cached: ");
+ list_print(c->hdrscan);
+ printf("\n");
+
+ list_free(c->includes);
+ list_free(c->hdrscan);
+ c->includes = 0;
+ c->hdrscan = 0;
+ } else {
+ if (DEBUG_HEADER)
+ printf ("using header cache for %s\n", t->boundname);
+ c->age = 0;
+ ++hits;
+ l = list_copy (0, c->includes);
+ return l;
+ }
} else {
- if (hashenter (hcachehash, (HASHDATA **)&c)) {
- c->boundname = newstr (c->boundname);
- c->next = hcachelist;
- hcachelist = c;
- }
+ if (DEBUG_HEADER)
+ printf ("header cache out of date for %s\n", t->boundname);
+ list_free (c->includes);
+ list_free(c->hdrscan);
+ c->includes = 0;
+ c->hdrscan = 0;
+ }
+ } else {
+ if (hashenter (hcachehash, (HASHDATA **)&c)) {
+ c->boundname = newstr (c->boundname);
+ c->next = hcachelist;
+ hcachelist = c;
+ }
}
/* 'c' points at the cache entry. Its out of date. */
Modified: trunk/tools/jam/src/hdrmacro.c
==============================================================================
--- trunk/tools/jam/src/hdrmacro.c (original)
+++ trunk/tools/jam/src/hdrmacro.c 2008-08-29 08:59:49 EDT (Fri, 29 Aug 2008)
@@ -27,11 +27,11 @@
* #include statements.
*
* we look for lines like "#define MACRO <....>" or '#define MACRO " "'
- * in the target file. When found, we
+ * in the target file. When found, we
*
* we then phony up a rule invocation like:
*
- * $(HDRRULE) <target> : <resolved included files> ;
+ * $(HDRRULE) <target> : <resolved included files> ;
*
* External routines:
* headers1() - scan a target for "#include MACRO" lines and try
@@ -42,8 +42,8 @@
*
* 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.
+ * so that headers() doesn't have to mock up a parse structure
+ * just to invoke a rule.
*/
static LIST *header_macros1( LIST *l, char *file, int rec, regexp *re[] );
@@ -53,9 +53,9 @@
{
char* symbol;
char* filename; /* we could maybe use a LIST here ?? */
-
+
} HEADER_MACRO;
-
+
static struct hash* header_macros_hash = 0;
/*
@@ -68,9 +68,9 @@
macro_headers( TARGET *t )
{
static regexp *re = 0;
- FILE *f;
- char buf[ 1024 ];
-
+ FILE *f;
+ char buf[ 1024 ];
+
if ( DEBUG_HEADER )
printf( "macro header scan for %s\n", t->name );
@@ -80,10 +80,10 @@
if ( re == 0 )
{
re = regex_compile(
- "^[ ]*#[ ]*define[ ]*([A-Za-z][A-Za-z0-9_]*)[ ]*"
+ "^[ ]*#[ ]*define[ ]*([A-Za-z][A-Za-z0-9_]*)[ ]*"
"[<\"]([^\">]*)[\">].*$" );
}
-
+
if( !( f = fopen( t->boundname, "r" ) ) )
return;
@@ -96,7 +96,7 @@
/* we detected a line that looks like "#define MACRO filename */
re->endp[1][0] = '\0';
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], t->boundname );
@@ -134,6 +134,6 @@
printf( "### macro '%s' evaluated to '%s'\n", macro_name, v->filename );
return v->filename;
}
- return 0;
+ return 0;
}
Modified: trunk/tools/jam/src/headers.c
==============================================================================
--- trunk/tools/jam/src/headers.c (original)
+++ trunk/tools/jam/src/headers.c 2008-08-29 08:59:49 EDT (Fri, 29 Aug 2008)
@@ -27,11 +27,11 @@
/*
* headers.c - handle #includes in source files
*
- * Using regular expressions provided as the variable $(HDRSCAN),
+ * 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> ;
+ *
+ * $(HDRRULE) <target> : <include files> ;
*
* External routines:
* headers() - scan a target for include files and call HDRRULE
@@ -41,8 +41,8 @@
*
* 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.
+ * so that headers() doesn't have to mock up a parse structure
+ * just to invoke a rule.
*/
#ifndef OPT_HEADER_CACHE_EXT
@@ -58,13 +58,13 @@
void
headers( TARGET *t )
{
- LIST *hdrscan;
- LIST *hdrrule;
- LIST *headlist = 0;
- regexp *re[ MAXINC ];
- int rec = 0;
-
- if( !( hdrscan = var_get( "HDRSCAN" ) ) ||
+ LIST *hdrscan;
+ LIST *hdrrule;
+ LIST *headlist = 0;
+ regexp *re[ MAXINC ];
+ int rec = 0;
+
+ if( !( hdrscan = var_get( "HDRSCAN" ) ) ||
!( hdrrule = var_get( "HDRRULE" ) ) )
return;
@@ -82,7 +82,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( L0, t->name ) );
#ifdef OPT_HEADER_CACHE_EXT
@@ -115,91 +115,91 @@
#else
static LIST *
#endif
-headers1(
- LIST *l,
- char *file,
- int rec,
- regexp *re[] )
+headers1(
+ LIST *l,
+ char *file,
+ int rec,
+ regexp *re[] )
{
- FILE *f;
- char buf[ 1024 ];
- int i;
+ FILE *f;
+ char buf[ 1024 ];
+ int i;
static regexp *re_macros = 0;
-
+
#ifdef OPT_IMPROVED_PATIENCE_EXT
- static int count = 0;
- ++count;
- if ( ((count == 100) || !( count % 1000 )) && DEBUG_MAKE )
- printf("...patience...\n");
+ static int count = 0;
+ ++count;
+ if ( ((count == 100) || !( count % 1000 )) && DEBUG_MAKE )
+ printf("...patience...\n");
#endif
-
+
/* the following regexp is used to detect cases where a */
/* file is included through a line line "#include MACRO" */
if ( re_macros == 0 )
{
re_macros = regex_compile(
- "^[ ]*#[ ]*include[ ]*([A-Za-z][A-Za-z0-9_]*).*$" );
+ "^[ ]*#[ ]*include[ ]*([A-Za-z][A-Za-z0-9_]*).*$" );
}
- if( !( f = fopen( file, "r" ) ) )
- return l;
+ if( !( f = fopen( file, "r" ) ) )
+ return l;
- while( fgets( buf, sizeof( buf ), f ) )
- {
+ while( fgets( buf, sizeof( buf ), f ) )
+ {
int size = strlen (buf);
/* Remove trailing \r and \n, if any. */
- while (size > 0
+ while (size > 0
&& (buf[size-1] == '\n' && buf[size-1] == '\r'))
{
buf[size-1] = '\0';
--size;
}
- for( i = 0; i < rec; i++ )
- if( regexec( re[i], buf ) && re[i]->startp[1] )
- {
- re[i]->endp[1][0] = '\0';
-
- if( DEBUG_HEADER )
- printf( "header found: %s\n", re[i]->startp[1] );
-
- l = list_new( l, newstr( re[i]->startp[1] ) );
- }
-
+ for( i = 0; i < rec; i++ )
+ if( regexec( re[i], buf ) && re[i]->startp[1] )
+ {
+ re[i]->endp[1][0] = '\0';
+
+ if( DEBUG_HEADER )
+ printf( "header found: %s\n", re[i]->startp[1] );
+
+ l = list_new( l, newstr( re[i]->startp[1] ) );
+ }
+
/* special treatment for #include MACRO */
if ( regexec( re_macros, buf ) && re_macros->startp[1] )
{
- char* header_filename;
-
- re_macros->endp[1][0] = '\0';
-
- if ( DEBUG_HEADER )
- printf( "macro header found: %s", re_macros->startp[1] );
-
- header_filename = macro_header_get( re_macros->startp[1] );
- if (header_filename)
- {
- if ( DEBUG_HEADER )
- printf( " resolved to '%s'\n", header_filename );
- l = list_new( l, newstr( header_filename ) );
- }
- else
- {
- if ( DEBUG_HEADER )
- printf( " ignored !!\n" );
- }
+ char* header_filename;
+
+ re_macros->endp[1][0] = '\0';
+
+ if ( DEBUG_HEADER )
+ printf( "macro header found: %s", re_macros->startp[1] );
+
+ header_filename = macro_header_get( re_macros->startp[1] );
+ if ( header_filename )
+ {
+ if ( DEBUG_HEADER )
+ printf( " resolved to '%s'\n", header_filename );
+ l = list_new( l, newstr( header_filename ) );
+ }
+ else
+ {
+ if ( DEBUG_HEADER )
+ printf( " ignored !!\n" );
+ }
}
- }
+ }
- fclose( f );
+ fclose( f );
- return l;
+ return l;
}
void
regerror( char *s )
{
- printf( "re error %s\n", s );
+ printf( "re error %s\n", s );
}
Modified: trunk/tools/jam/src/jam.c
==============================================================================
--- trunk/tools/jam/src/jam.c (original)
+++ trunk/tools/jam/src/jam.c 2008-08-29 08:59:49 EDT (Fri, 29 Aug 2008)
@@ -1,12 +1,12 @@
/*
* /+\
- * +\ Copyright 1993-2002 Christopher Seiwald and Perforce Software, Inc.
+ * +\ Copyright 1993-2002 Christopher Seiwald and Perforce Software, Inc.
* \+/
*
* This file is part of jam.
*
* License is hereby granted to use this software and distribute it
- * freely, as long as this copyright notice is retained and modifications
+ * freely, as long as this copyright notice is retained and modifications
* are clearly marked.
*
* ALL WARRANTIES ARE HEREBY DISCLAIMED.
@@ -27,11 +27,11 @@
*
* The top half of the code is structured such:
*
- * jam
- * / | \
+ * jam
+ * / | \
* +---+ | \
- * / | \
- * jamgram option \
+ * / | \
+ * jamgram option \
* / | \ \
* / | \ \
* / | \ |
@@ -69,32 +69,32 @@
*
* Roughly, the modules are:
*
- * builtins.c - jam's built-in rules
- * command.c - maintain lists of commands
- * compile.c - compile parsed jam statements
- * execunix.c - execute a shell script on UNIX
- * execvms.c - execute a shell script, ala VMS
- * expand.c - expand a buffer, given variable values
- * file*.c - scan directories and archives on *
- * hash.c - simple in-memory hashing routines
+ * builtins.c - jam's built-in rules
+ * command.c - maintain lists of commands
+ * compile.c - compile parsed jam statements
+ * execunix.c - execute a shell script on UNIX
+ * execvms.c - execute a shell script, ala VMS
+ * expand.c - expand a buffer, given variable values
+ * file*.c - scan directories and archives on *
+ * hash.c - simple in-memory hashing routines
* hdrmacro.c - handle header file parsing for filename macro definitions
- * headers.c - handle #includes in source files
- * jambase.c - compilable copy of Jambase
- * jamgram.y - jam grammar
- * lists.c - maintain lists of strings
- * make.c - bring a target up to date, once rules are in place
- * make1.c - execute command to bring targets up to date
- * newstr.c - string manipulation routines
- * option.c - command line option processing
- * parse.c - make and destroy parse trees as driven by the parser
- * path*.c - manipulate file names on *
- * hash.c - simple in-memory hashing routines
- * regexp.c - Henry Spencer's regexp
- * rules.c - access to RULEs, TARGETs, and ACTIONs
- * scan.c - the jam yacc scanner
- * search.c - find a target along $(SEARCH) or $(LOCATE)
- * timestamp.c - get the timestamp of a file or archive member
- * variable.c - handle jam multi-element variables
+ * headers.c - handle #includes in source files
+ * jambase.c - compilable copy of Jambase
+ * jamgram.y - jam grammar
+ * lists.c - maintain lists of strings
+ * make.c - bring a target up to date, once rules are in place
+ * make1.c - execute command to bring targets up to date
+ * newstr.c - string manipulation routines
+ * option.c - command line option processing
+ * parse.c - make and destroy parse trees as driven by the parser
+ * path*.c - manipulate file names on *
+ * hash.c - simple in-memory hashing routines
+ * regexp.c - Henry Spencer's regexp
+ * rules.c - access to RULEs, TARGETs, and ACTIONs
+ * scan.c - the jam yacc scanner
+ * search.c - find a target along $(SEARCH) or $(LOCATE)
+ * timestamp.c - get the timestamp of a file or archive member
+ * variable.c - handle jam multi-element variables
*
* 05/04/94 (seiwald) - async multiprocess (-j) support
* 02/08/95 (seiwald) - -n implies -d2.
@@ -138,17 +138,17 @@
# endif
struct globs globs = {
- 0, /* noexec */
- 1, /* jobs */
- 0, /* quitquick */
- 0, /* newestfirst */
+ 0, /* noexec */
+ 1, /* jobs */
+ 0, /* quitquick */
+ 0, /* newestfirst */
0, /* pipes action stdout and stderr merged to action output */
# ifdef OS_MAC
- { 0, 0 }, /* debug - suppress tracing output */
+ { 0, 0 }, /* debug - suppress tracing output */
# else
- { 0, 1 }, /* debug ... */
+ { 0, 1 }, /* debug ... */
# endif
- 0, /* output commands, not run them */
+ 0, /* output commands, not run them */
0 /* action timeout */
} ;
@@ -156,9 +156,9 @@
static char *othersyms[] = { OSMAJOR, OSMINOR, OSPLAT, JAMVERSYM, 0 } ;
-/* Known for sure:
- * mac needs arg_enviro
- * OS2 needs extern environ
+/* Known for sure:
+ * mac needs arg_enviro
+ * OS2 needs extern environ
*/
# ifdef OS_MAC
@@ -180,7 +180,7 @@
# ifndef use_environ
# define use_environ environ
-# if !defined( __WATCOM__ ) && !defined( OS_OS2 ) && !defined( OS_NT )
+# if !defined( __WATCOM__ ) && !defined( OS_OS2 ) && !defined( OS_NT )
extern char **environ;
# endif
# endif
@@ -195,7 +195,7 @@
# if defined( USE_EXECNT )
extern void execnt_unit_test();
execnt_unit_test();
-# endif
+# endif
string_unit_test();
var_expand_unit_test();
}
@@ -204,7 +204,7 @@
#ifdef HAVE_PYTHON
extern PyObject*
bjam_call(PyObject *self, PyObject *args);
-
+
extern PyObject*
bjam_import_rule(PyObject* self, PyObject* args);
@@ -220,12 +220,12 @@
int main( int argc, char **argv, char **arg_environ )
{
- int n;
- char *s;
- struct option optv[N_OPTS];
- const char *all = "all";
- int anyhow = 0;
- int status;
+ int n;
+ char *s;
+ struct option optv[N_OPTS];
+ const char *all = "all";
+ int anyhow = 0;
+ int status;
int arg_c = argc;
char ** arg_v = argv;
const char *progname = argv[0];
@@ -292,7 +292,7 @@
}
if( ( s = getoptval( optv, 'q', 0 ) ) )
- globs.quitquick = 1;
+ globs.quitquick = 1;
if( ( s = getoptval( optv, 'a', 0 ) ) )
anyhow++;
@@ -341,7 +341,7 @@
{
PROFILE_ENTER(MAIN_PYTHON);
Py_Initialize();
-
+
{
static PyMethodDef BjamMethods[] = {
{"call", bjam_call, METH_VARARGS,
@@ -356,13 +356,13 @@
"Returns bjam backtrace from the last call into Python."},
{NULL, NULL, 0, NULL}
};
-
- Py_InitModule("bjam", BjamMethods);
+
+ Py_InitModule( "bjam", BjamMethods );
}
PROFILE_EXIT(MAIN_PYTHON);
}
#endif
-
+
#ifndef NDEBUG
run_unit_tests();
#endif
@@ -375,10 +375,9 @@
var_set( "JAMDATE", list_new( L0, outf_time(time(0)) ), VAR_SET );
-
var_set( "JAM_VERSION",
- list_new( list_new( list_new( L0, newstr( VERSION_MAJOR_SYM ) ),
- newstr( VERSION_MINOR_SYM ) ),
+ list_new( list_new( list_new( L0, newstr( VERSION_MAJOR_SYM ) ),
+ newstr( VERSION_MINOR_SYM ) ),
newstr( VERSION_PATCH_SYM ) ),
VAR_SET );
@@ -389,12 +388,12 @@
if( uname( &u ) >= 0 )
{
- var_set( "JAMUNAME",
- list_new(
+ var_set( "JAMUNAME",
+ list_new(
list_new(
list_new(
list_new(
- list_new( L0,
+ list_new( L0,
newstr( u.sysname ) ),
newstr( u.nodename ) ),
newstr( u.release ) ),
@@ -408,18 +407,18 @@
/* first into global module, with splitting, for backward compatibility */
var_defines( use_environ, 1 );
-
+
/* then into .ENVIRON, without splitting */
enter_module( bindmodule(".ENVIRON") );
var_defines( use_environ, 0 );
exit_module( bindmodule(".ENVIRON") );
- /*
- * Jam defined variables OS, OSPLAT
+ /*
+ * Jam defined variables OS, OSPLAT
* We load them after environment, so that
- * setting OS in environment does not
+ * setting OS in environment does not
* change Jam notion of the current platform.
- */
+ */
var_defines( othersyms, 1 );
@@ -444,9 +443,9 @@
var_set( "ARGV", list_new( L0, newstr( arg_v[n] ) ), VAR_APPEND );
}
- /* Initialize built-in rules */
+ /* Initialize built-in rules */
- load_builtins();
+ load_builtins();
/* Add the targets in the command line to update list */
@@ -469,11 +468,11 @@
{
FRAME frame[1];
frame_init( frame );
- for( n = 0; s = getoptval( optv, 'f', n ); n++ )
- parse_file( s, frame );
+ for( n = 0; s = getoptval( optv, 'f', n ); n++ )
+ parse_file( s, frame );
- if( !n )
- parse_file( "+", frame );
+ if( !n )
+ parse_file( "+", frame );
}
status = yyanyerrors();
@@ -499,13 +498,13 @@
{
PROFILE_ENTER(MAIN_MAKE);
-
- LIST* targets = targets_to_update();
+
+ LIST * targets = targets_to_update();
if ( !targets )
{
status |= make( 1, &all, anyhow );
}
- else
+ else
{
int targets_count = list_length(targets);
const char **targets2 = (const char **)BJAM_MALLOC(targets_count * sizeof(char *));
@@ -514,16 +513,16 @@
{
targets2[n++] = targets->string;
}
- status |= make( targets_count, targets2, anyhow );
+ status |= make( targets_count, targets2, anyhow );
free(targets);
}
-
+
PROFILE_EXIT(MAIN_MAKE);
}
PROFILE_EXIT(MAIN); }
-
+
if ( DEBUG_PROFILE )
profile_dump();
@@ -543,9 +542,8 @@
#ifdef HAVE_PYTHON
Py_Finalize();
#endif
-
- BJAM_MEM_CLOSE();
+ BJAM_MEM_CLOSE();
return status ? EXITBAD : EXITOK;
}
Modified: trunk/tools/jam/src/jam.h
==============================================================================
--- trunk/tools/jam/src/jam.h (original)
+++ trunk/tools/jam/src/jam.h 2008-08-29 08:59:49 EDT (Fri, 29 Aug 2008)
@@ -75,7 +75,7 @@
/* This may be inaccurate */
# ifndef __DECC
# define OSPLAT "OSPLAT=VAX"
-# endif
+# endif
# endif
@@ -103,7 +103,7 @@
# define SPLITPATH ';'
/* Windows NT 3.51 only allows 996 chars per line, but we deal */
/* with problem in "execnt.c". */
-# define MAXLINE (maxline()) /* longest 'together' actions */
+# define MAXLINE (maxline()) /* longest 'together' actions */
# define USE_EXECNT
# define USE_PATHUNIX
# define PATH_DELIM '\\'
@@ -147,7 +147,7 @@
# define OSMINOR "OS=MINGW"
# define OS_NT
# define SPLITPATH ';'
-# define MAXLINE 996 /* longest 'together' actions */
+# define MAXLINE 996 /* longest 'together' actions */
# define USE_EXECUNIX
# define USE_PATHUNIX
# define PATH_DELIM '\\'
@@ -174,7 +174,7 @@
# define OSMINOR "OS=OS2"
# define OS_OS2
# define SPLITPATH ';'
-# define MAXLINE 996 /* longest 'together' actions */
+# define MAXLINE 996 /* longest 'together' actions */
# define USE_EXECUNIX
# define USE_PATHUNIX
# define PATH_DELIM '\\'
@@ -430,9 +430,9 @@
# include <malloc.h>
# endif
-# endif
+# endif
-/*
+/*
* OSPLAT definitions - suppressed when it's a one-of-a-kind
*/
@@ -453,7 +453,7 @@
defined( __i386__ ) || \
defined( _M_IX86 )
# define OSPLAT "OSPLAT=X86"
-# endif
+# endif
# if defined( __ia64__ ) || defined( __IA64__ ) || defined( __ia64 )
# define OSPLAT "OSPLAT=IA64"
@@ -496,7 +496,7 @@
*/
# ifndef MAXLINE
-# define MAXLINE 102400 /* longest 'together' actions' */
+# define MAXLINE 102400 /* longest 'together' actions' */
# endif
# ifndef EXITOK
@@ -510,55 +510,55 @@
/* You probably don't need to muck with these. */
-# define MAXSYM 1024 /* longest symbol in the environment */
-# define MAXJPATH 1024 /* longest filename */
+# define MAXSYM 1024 /* longest symbol in the environment */
+# define MAXJPATH 1024 /* longest filename */
-# define MAXJOBS 64 /* silently enforce -j limit */
-# define MAXARGC 32 /* words in $(JAMSHELL) */
+# define MAXJOBS 64 /* silently enforce -j limit */
+# define MAXARGC 32 /* words in $(JAMSHELL) */
/* Jam private definitions below. */
-# define DEBUG_MAX 14
+# define DEBUG_MAX 14
struct globs {
- int noexec;
- int jobs;
- int quitquick;
- int newestfirst; /* build newest sources first */
+ int noexec;
+ int jobs;
+ int quitquick;
+ int newestfirst; /* build newest sources first */
int pipe_action;
- char debug[DEBUG_MAX];
- FILE *cmdout; /* print cmds, not run them */
+ char debug[DEBUG_MAX];
+ FILE *cmdout; /* print cmds, not run them */
long timeout; /* number of seconds to limit actions to, default 0 for no limit. */
int dart; /* output build and test results formatted for Dart */
} ;
extern struct globs globs;
-# define DEBUG_MAKE ( globs.debug[ 1 ] ) /* show actions when executed */
-# define DEBUG_MAKEQ ( globs.debug[ 2 ] ) /* show even quiet actions */
-# define DEBUG_EXEC ( globs.debug[ 2 ] ) /* show text of actons */
-# define DEBUG_MAKEPROG ( globs.debug[ 3 ] ) /* show progress of make0 */
-# define DEBUG_BIND ( globs.debug[ 3 ] ) /* show when files bound */
-
-# define DEBUG_EXECCMD ( globs.debug[ 4 ] ) /* show execcmds()'s work */
-
-# define DEBUG_COMPILE ( globs.debug[ 5 ] ) /* show rule invocations */
-
-# define DEBUG_HEADER ( globs.debug[ 6 ] ) /* show result of header scan */
-# define DEBUG_BINDSCAN ( globs.debug[ 6 ] ) /* show result of dir scan */
-# define DEBUG_SEARCH ( globs.debug[ 6 ] ) /* show attempts at binding */
-
-# define DEBUG_VARSET ( globs.debug[ 7 ] ) /* show variable settings */
-# define DEBUG_VARGET ( globs.debug[ 8 ] ) /* show variable fetches */
-# define DEBUG_VAREXP ( globs.debug[ 8 ] ) /* show variable expansions */
-# define DEBUG_IF ( globs.debug[ 8 ] ) /* show 'if' calculations */
-# define DEBUG_LISTS ( globs.debug[ 9 ] ) /* show list manipulation */
-# define DEBUG_SCAN ( globs.debug[ 9 ] ) /* show scanner tokens */
-# define DEBUG_MEM ( globs.debug[ 9 ] ) /* show memory use */
-
-# define DEBUG_PROFILE ( globs.debug[ 10 ] ) /* dump rule execution times */
-# define DEBUG_PARSE ( globs.debug[ 11 ] ) /* debug parsing */
-# define DEBUG_GRAPH ( globs.debug[ 12 ] ) /* debug dependencies */
+# define DEBUG_MAKE ( globs.debug[ 1 ] ) /* show actions when executed */
+# define DEBUG_MAKEQ ( globs.debug[ 2 ] ) /* show even quiet actions */
+# define DEBUG_EXEC ( globs.debug[ 2 ] ) /* show text of actons */
+# define DEBUG_MAKEPROG ( globs.debug[ 3 ] ) /* show progress of make0 */
+# define DEBUG_BIND ( globs.debug[ 3 ] ) /* show when files bound */
+
+# define DEBUG_EXECCMD ( globs.debug[ 4 ] ) /* show execcmds()'s work */
+
+# define DEBUG_COMPILE ( globs.debug[ 5 ] ) /* show rule invocations */
+
+# define DEBUG_HEADER ( globs.debug[ 6 ] ) /* show result of header scan */
+# define DEBUG_BINDSCAN ( globs.debug[ 6 ] ) /* show result of dir scan */
+# define DEBUG_SEARCH ( globs.debug[ 6 ] ) /* show attempts at binding */
+
+# define DEBUG_VARSET ( globs.debug[ 7 ] ) /* show variable settings */
+# define DEBUG_VARGET ( globs.debug[ 8 ] ) /* show variable fetches */
+# define DEBUG_VAREXP ( globs.debug[ 8 ] ) /* show variable expansions */
+# define DEBUG_IF ( globs.debug[ 8 ] ) /* show 'if' calculations */
+# define DEBUG_LISTS ( globs.debug[ 9 ] ) /* show list manipulation */
+# define DEBUG_SCAN ( globs.debug[ 9 ] ) /* show scanner tokens */
+# define DEBUG_MEM ( globs.debug[ 9 ] ) /* show memory use */
+
+# define DEBUG_PROFILE ( globs.debug[ 10 ] ) /* dump rule execution times */
+# define DEBUG_PARSE ( globs.debug[ 11 ] ) /* debug parsing */
+# define DEBUG_GRAPH ( globs.debug[ 12 ] ) /* debug dependencies */
# define DEBUG_FATE ( globs.debug[ 13 ] ) /* show changes to fate in make0() */
/* Everyone gets the memory definitions. */
Modified: trunk/tools/jam/src/jambase.h
==============================================================================
--- trunk/tools/jam/src/jambase.h (original)
+++ trunk/tools/jam/src/jambase.h 2008-08-29 08:59:49 EDT (Fri, 29 Aug 2008)
@@ -8,7 +8,7 @@
* jambase.h - declaration for the internal jambase
*
* The file Jambase is turned into a C array of strings in jambase.c
- * so that it can be built in to the executable. This is the
+ * so that it can be built in to the executable. This is the
* declaration for that array.
*/
Modified: trunk/tools/jam/src/jamgram.c
==============================================================================
--- trunk/tools/jam/src/jamgram.c (original)
+++ trunk/tools/jam/src/jamgram.c 2008-08-29 08:59:49 EDT (Fri, 29 Aug 2008)
@@ -438,17 +438,17 @@
First, the terminals, then, starting at YYNTOKENS, nonterminals. */
static const char *const yytname[] =
{
- "$end", "error", "$undefined", "_BANG_t", "_BANG_EQUALS_t", "_AMPER_t",
- "_AMPERAMPER_t", "_LPAREN_t", "_RPAREN_t", "_PLUS_EQUALS_t", "_COLON_t",
- "_SEMIC_t", "_LANGLE_t", "_LANGLE_EQUALS_t", "_EQUALS_t", "_RANGLE_t",
- "_RANGLE_EQUALS_t", "_QUESTION_EQUALS_t", "_LBRACKET_t", "_RBRACKET_t",
- "ACTIONS_t", "BIND_t", "CASE_t", "CLASS_t", "DEFAULT_t", "ELSE_t",
- "EXISTING_t", "FOR_t", "IF_t", "IGNORE_t", "IN_t", "INCLUDE_t",
- "LOCAL_t", "MODULE_t", "ON_t", "PIECEMEAL_t", "QUIETLY_t", "RETURN_t",
- "RULE_t", "SWITCH_t", "TOGETHER_t", "UPDATED_t", "WHILE_t", "_LBRACE_t",
- "_BAR_t", "_BARBAR_t", "_RBRACE_t", "ARG", "STRING", "$accept", "run",
- "block", "rules", "null", "assign_list_opt", "arglist_opt", "local_opt",
- "rule", "@1", "@2", "assign", "expr", "cases", "case", "lol", "list",
+ "$end", "error", "$undefined", "_BANG_t", "_BANG_EQUALS_t", "_AMPER_t",
+ "_AMPERAMPER_t", "_LPAREN_t", "_RPAREN_t", "_PLUS_EQUALS_t", "_COLON_t",
+ "_SEMIC_t", "_LANGLE_t", "_LANGLE_EQUALS_t", "_EQUALS_t", "_RANGLE_t",
+ "_RANGLE_EQUALS_t", "_QUESTION_EQUALS_t", "_LBRACKET_t", "_RBRACKET_t",
+ "ACTIONS_t", "BIND_t", "CASE_t", "CLASS_t", "DEFAULT_t", "ELSE_t",
+ "EXISTING_t", "FOR_t", "IF_t", "IGNORE_t", "IN_t", "INCLUDE_t",
+ "LOCAL_t", "MODULE_t", "ON_t", "PIECEMEAL_t", "QUIETLY_t", "RETURN_t",
+ "RULE_t", "SWITCH_t", "TOGETHER_t", "UPDATED_t", "WHILE_t", "_LBRACE_t",
+ "_BAR_t", "_BARBAR_t", "_RBRACE_t", "ARG", "STRING", "$accept", "run",
+ "block", "rules", "null", "assign_list_opt", "arglist_opt", "local_opt",
+ "rule", "@1", "@2", "assign", "expr", "cases", "case", "lol", "list",
"listp", "arg", "@3", "func", "eflags", "eflag", "bindlist", 0
};
#endif
@@ -1007,7 +1007,7 @@
#endif
#endif
{
-
+
register int yystate;
register int yyn;
int yyresult;
Modified: trunk/tools/jam/src/jamgram.y
==============================================================================
--- trunk/tools/jam/src/jamgram.y (original)
+++ trunk/tools/jam/src/jamgram.y 2008-08-29 08:59:49 EDT (Fri, 29 Aug 2008)
@@ -73,7 +73,7 @@
*
* New "[ rule ]" syntax evals rule into a LIST.
*
- * Lists are now generated by compile_list() and
+ * Lists are now generated by compile_list() and
* compile_append(), and any other rule that indirectly
* makes a list, rather than being built directly here,
* so that lists values can contain rule evaluations.
@@ -81,7 +81,7 @@
* New 'return' rule sets the return value, though
* other statements also may have return values.
*
- * 'run' production split from 'block' production so
+ * 'run' production split from 'block' production so
* that empty blocks can be handled separately.
*/
@@ -201,13 +201,13 @@
{ $$.parse = pfor( $3.string, $5.parse, $7.parse, $2.number ); }
| SWITCH_t list _LBRACE_t cases _RBRACE_t
{ $$.parse = pswitch( $2.parse, $4.parse ); }
- | IF_t expr _LBRACE_t block _RBRACE_t
+ | IF_t expr _LBRACE_t block _RBRACE_t
{ $$.parse = pif( $2.parse, $4.parse, pnull() ); }
- | MODULE_t list _LBRACE_t block _RBRACE_t
+ | MODULE_t list _LBRACE_t block _RBRACE_t
{ $$.parse = pmodule( $2.parse, $4.parse ); }
- | CLASS_t lol _LBRACE_t block _RBRACE_t
+ | CLASS_t lol _LBRACE_t block _RBRACE_t
{ $$.parse = pclass( $2.parse, $4.parse ); }
- | WHILE_t expr _LBRACE_t block _RBRACE_t
+ | WHILE_t expr _LBRACE_t block _RBRACE_t
{ $$.parse = pwhile( $2.parse, $4.parse ); }
| IF_t expr _LBRACE_t block _RBRACE_t ELSE_t rule
{ $$.parse = pif( $2.parse, $4.parse, $7.parse ); }
@@ -217,7 +217,7 @@
{ $$.parse = pon( $2.parse, $3.parse ); }
| ACTIONS_t eflags ARG bindlist _LBRACE_t
{ yymode( SCAN_STRING ); }
- STRING
+ STRING
{ yymode( SCAN_NORMAL ); }
_RBRACE_t
{ $$.parse = psete( $3.string,$4.parse,$7.string,$2.number ); }
@@ -240,23 +240,23 @@
/*
* expr - an expression for if
*/
-expr : arg
+expr : arg
{ $$.parse = peval( EXPR_EXISTS, $1.parse, pnull() ); }
- | expr _EQUALS_t expr
+ | expr _EQUALS_t expr
{ $$.parse = peval( EXPR_EQUALS, $1.parse, $3.parse ); }
| expr _BANG_EQUALS_t expr
{ $$.parse = peval( EXPR_NOTEQ, $1.parse, $3.parse ); }
| expr _LANGLE_t expr
{ $$.parse = peval( EXPR_LESS, $1.parse, $3.parse ); }
- | expr _LANGLE_EQUALS_t expr
+ | expr _LANGLE_EQUALS_t expr
{ $$.parse = peval( EXPR_LESSEQ, $1.parse, $3.parse ); }
- | expr _RANGLE_t expr
+ | expr _RANGLE_t expr
{ $$.parse = peval( EXPR_MORE, $1.parse, $3.parse ); }
- | expr _RANGLE_EQUALS_t expr
+ | expr _RANGLE_EQUALS_t expr
{ $$.parse = peval( EXPR_MOREEQ, $1.parse, $3.parse ); }
- | expr _AMPER_t expr
+ | expr _AMPER_t expr
{ $$.parse = peval( EXPR_AND, $1.parse, $3.parse ); }
- | expr _AMPERAMPER_t expr
+ | expr _AMPERAMPER_t expr
{ $$.parse = peval( EXPR_AND, $1.parse, $3.parse ); }
| expr _BAR_t expr
{ $$.parse = peval( EXPR_OR, $1.parse, $3.parse ); }
@@ -314,7 +314,7 @@
{ $$.parse = pappend( $1.parse, $2.parse ); }
;
-arg : ARG
+arg : ARG
{ $$.parse = plist( $1.string ); }
| _LBRACKET_t { yymode( SCAN_NORMAL ); } func _RBRACKET_t
{ $$.parse = $3.parse; }
@@ -329,7 +329,7 @@
{ $$.parse = prule( $1.string, $2.parse ); }
| ON_t arg arg lol
{ $$.parse = pon( $2.parse, prule( $3.string, $4.parse ) ); }
- | ON_t arg RETURN_t list
+ | ON_t arg RETURN_t list
{ $$.parse = pon( $2.parse, $4.parse ); }
;
@@ -369,5 +369,3 @@
| BIND_t list
{ $$.parse = $2.parse; }
;
-
-
Modified: trunk/tools/jam/src/jamgram.yy
==============================================================================
--- trunk/tools/jam/src/jamgram.yy (original)
+++ trunk/tools/jam/src/jamgram.yy 2008-08-29 08:59:49 EDT (Fri, 29 Aug 2008)
@@ -29,7 +29,7 @@
*
* New "[ rule ]" syntax evals rule into a LIST.
*
- * Lists are now generated by compile_list() and
+ * Lists are now generated by compile_list() and
* compile_append(), and any other rule that indirectly
* makes a list, rather than being built directly here,
* so that lists values can contain rule evaluations.
@@ -37,7 +37,7 @@
* New 'return' rule sets the return value, though
* other statements also may have return values.
*
- * 'run' production split from 'block' production so
+ * 'run' production split from 'block' production so
* that empty blocks can be handled separately.
*/
@@ -157,13 +157,13 @@
{ $$.parse = pfor( $3.string, $5.parse, $7.parse, $2.number ); }
| `switch` list `{` cases `}`
{ $$.parse = pswitch( $2.parse, $4.parse ); }
- | `if` expr `{` block `}`
+ | `if` expr `{` block `}`
{ $$.parse = pif( $2.parse, $4.parse, pnull() ); }
- | `module` list `{` block `}`
+ | `module` list `{` block `}`
{ $$.parse = pmodule( $2.parse, $4.parse ); }
- | `class` lol `{` block `}`
+ | `class` lol `{` block `}`
{ $$.parse = pclass( $2.parse, $4.parse ); }
- | `while` expr `{` block `}`
+ | `while` expr `{` block `}`
{ $$.parse = pwhile( $2.parse, $4.parse ); }
| `if` expr `{` block `}` `else` rule
{ $$.parse = pif( $2.parse, $4.parse, $7.parse ); }
@@ -173,7 +173,7 @@
{ $$.parse = pon( $2.parse, $3.parse ); }
| `actions` eflags ARG bindlist `{`
{ yymode( SCAN_STRING ); }
- STRING
+ STRING
{ yymode( SCAN_NORMAL ); }
`}`
{ $$.parse = psete( $3.string,$4.parse,$7.string,$2.number ); }
@@ -196,23 +196,23 @@
/*
* expr - an expression for if
*/
-expr : arg
+expr : arg
{ $$.parse = peval( EXPR_EXISTS, $1.parse, pnull() ); }
- | expr `=` expr
+ | expr `=` expr
{ $$.parse = peval( EXPR_EQUALS, $1.parse, $3.parse ); }
| expr `!=` expr
{ $$.parse = peval( EXPR_NOTEQ, $1.parse, $3.parse ); }
| expr `<` expr
{ $$.parse = peval( EXPR_LESS, $1.parse, $3.parse ); }
- | expr `<=` expr
+ | expr `<=` expr
{ $$.parse = peval( EXPR_LESSEQ, $1.parse, $3.parse ); }
- | expr `>` expr
+ | expr `>` expr
{ $$.parse = peval( EXPR_MORE, $1.parse, $3.parse ); }
- | expr `>=` expr
+ | expr `>=` expr
{ $$.parse = peval( EXPR_MOREEQ, $1.parse, $3.parse ); }
- | expr `&` expr
+ | expr `&` expr
{ $$.parse = peval( EXPR_AND, $1.parse, $3.parse ); }
- | expr `&&` expr
+ | expr `&&` expr
{ $$.parse = peval( EXPR_AND, $1.parse, $3.parse ); }
| expr `|` expr
{ $$.parse = peval( EXPR_OR, $1.parse, $3.parse ); }
@@ -270,7 +270,7 @@
{ $$.parse = pappend( $1.parse, $2.parse ); }
;
-arg : ARG
+arg : ARG
{ $$.parse = plist( $1.string ); }
| `[` { yymode( SCAN_NORMAL ); } func `]`
{ $$.parse = $3.parse; }
@@ -285,7 +285,7 @@
{ $$.parse = prule( $1.string, $2.parse ); }
| `on` arg arg lol
{ $$.parse = pon( $2.parse, prule( $3.string, $4.parse ) ); }
- | `on` arg `return` list
+ | `on` arg `return` list
{ $$.parse = pon( $2.parse, $4.parse ); }
;
Modified: trunk/tools/jam/src/lists.c
==============================================================================
--- trunk/tools/jam/src/lists.c (original)
+++ trunk/tools/jam/src/lists.c 2008-08-29 08:59:49 EDT (Fri, 29 Aug 2008)
@@ -25,7 +25,7 @@
* 09/07/00 (seiwald) - documented lol_*() functions
*/
-static LIST *freelist = 0; /* junkpile for list_free() */
+static LIST *freelist = 0; /* junkpile for list_free() */
/*
* list_append() - append a list onto another one, returning total
@@ -33,25 +33,25 @@
LIST *
list_append(
- LIST *l,
- LIST *nl )
+ LIST *l,
+ LIST *nl )
{
- if( !nl )
- {
- /* Just return l */
- }
- else if( !l )
- {
- l = nl;
- }
- else
- {
- /* Graft two non-empty lists. */
- l->tail->next = nl;
- l->tail = nl->tail;
- }
+ if( !nl )
+ {
+ /* Just return l */
+ }
+ else if( !l )
+ {
+ l = nl;
+ }
+ else
+ {
+ /* Graft two non-empty lists. */
+ l->tail->next = nl;
+ l->tail = nl->tail;
+ }
- return l;
+ return l;
}
/*
@@ -60,41 +60,41 @@
LIST *
list_new(
- LIST *head,
- char *string )
+ LIST *head,
+ char *string )
{
- LIST *l;
+ LIST *l;
- if( DEBUG_LISTS )
- printf( "list > %s <\n", string );
+ if( DEBUG_LISTS )
+ printf( "list > %s <\n", string );
- /* Get list struct from freelist, if one available. */
- /* Otherwise allocate. */
- /* If from freelist, must free string first */
-
- if( freelist )
- {
- l = freelist;
- freestr( l->string );
- freelist = freelist->next;
- }
- else
- {
- l = (LIST *)BJAM_MALLOC( sizeof( LIST ) );
- }
+ /* Get list struct from freelist, if one available. */
+ /* Otherwise allocate. */
+ /* If from freelist, must free string first */
- /* If first on chain, head points here. */
- /* If adding to chain, tack us on. */
- /* Tail must point to this new, last element. */
+ if( freelist )
+ {
+ l = freelist;
+ freestr( l->string );
+ freelist = freelist->next;
+ }
+ else
+ {
+ l = (LIST *)BJAM_MALLOC( sizeof( LIST ) );
+ }
- if( !head ) head = l;
- else head->tail->next = l;
- head->tail = l;
- l->next = 0;
+ /* If first on chain, head points here. */
+ /* If adding to chain, tack us on. */
+ /* Tail must point to this new, last element. */
+
+ if( !head ) head = l;
+ else head->tail->next = l;
+ head->tail = l;
+ l->next = 0;
- l->string = string;
+ l->string = string;
- return head;
+ return head;
}
/*
@@ -103,13 +103,13 @@
LIST *
list_copy(
- LIST *l,
- LIST *nl )
+ LIST *l,
+ LIST *nl )
{
- for( ; nl; nl = list_next( nl ) )
- l = list_new( l, copystr( nl->string ) );
+ for( ; nl; nl = list_next( nl ) )
+ l = list_new( l, copystr( nl->string ) );
- return l;
+ return l;
}
/*
@@ -118,19 +118,19 @@
LIST *
list_sublist(
- LIST *l,
- int start,
- int count )
+ LIST *l,
+ int start,
+ int count )
{
- LIST *nl = 0;
+ LIST *nl = 0;
- for( ; l && start--; l = list_next( l ) )
- ;
+ for( ; l && start--; l = list_next( l ) )
+ ;
- for( ; l && count--; l = list_next( l ) )
- nl = list_new( nl, copystr( l->string ) );
+ for( ; l && count--; l = list_next( l ) )
+ nl = list_new( nl, copystr( l->string ) );
- return nl;
+ return nl;
}
static int str_ptr_compare(const void *va, const void *vb)
@@ -177,15 +177,15 @@
*/
void
-list_free( LIST *head )
+list_free( LIST *head )
{
- /* Just tack onto freelist. */
+ /* Just tack onto freelist. */
- if( head )
- {
- head->tail->next = freelist;
- freelist = head;
- }
+ if( head )
+ {
+ head->tail->next = freelist;
+ freelist = head;
+ }
}
/*
@@ -226,12 +226,12 @@
int
list_length( LIST *l )
{
- int n = 0;
+ int n = 0;
- for( ; l; l = list_next( l ), ++n )
- ;
+ for( ; l; l = list_next( l ), ++n )
+ ;
- return n;
+ return n;
}
int
@@ -277,11 +277,11 @@
void
lol_add(
- LOL *lol,
- LIST *l )
+ LOL *lol,
+ LIST *l )
{
- if( lol->count < LOL_MAX )
- lol->list[ lol->count++ ] = l;
+ if( lol->count < LOL_MAX )
+ lol->list[ lol->count++ ] = l;
}
/*
@@ -291,12 +291,12 @@
void
lol_free( LOL *lol )
{
- int i;
+ int i;
- for( i = 0; i < lol->count; i++ )
- list_free( lol->list[i] );
+ for( i = 0; i < lol->count; i++ )
+ list_free( lol->list[i] );
- lol->count = 0;
+ lol->count = 0;
}
/*
@@ -305,10 +305,10 @@
LIST *
lol_get(
- LOL *lol,
- int i )
+ LOL *lol,
+ int i )
{
- return i < lol->count ? lol->list[i] : 0;
+ return i < lol->count ? lol->list[i] : 0;
}
/*
@@ -318,12 +318,12 @@
void
lol_print( LOL *lol )
{
- int i;
+ int i;
- for( i = 0; i < lol->count; i++ )
- {
- if( i )
- printf( " : " );
- list_print( lol->list[i] );
- }
+ for( i = 0; i < lol->count; i++ )
+ {
+ if( i )
+ printf( " : " );
+ list_print( lol->list[i] );
+ }
}
Modified: trunk/tools/jam/src/lists.h
==============================================================================
--- trunk/tools/jam/src/lists.h (original)
+++ trunk/tools/jam/src/lists.h 2008-08-29 08:59:49 EDT (Fri, 29 Aug 2008)
@@ -19,24 +19,24 @@
*
* Structures defined:
*
- * LIST - list of strings
- * LOL - list of LISTs
+ * LIST - list of strings
+ * LOL - list of LISTs
*
* External routines:
*
- * list_append() - append a list onto another one, returning total
- * list_new() - tack a string onto the end of a list of strings
- * list_copy() - copy a whole list of strings
- * list_sublist() - copy a subset of a list of strings
- * list_free() - free a list of strings
- * list_print() - print a list of strings to stdout
- * list_length() - return the number of items in the list
- *
- * lol_init() - initialize a LOL (list of lists)
- * lol_add() - append a LIST onto an LOL
- * lol_free() - free the LOL and its LISTs
- * lol_get() - return one of the LISTs in the LOL
- * lol_print() - debug print LISTS separated by ":"
+ * list_append() - append a list onto another one, returning total
+ * list_new() - tack a string onto the end of a list of strings
+ * list_copy() - copy a whole list of strings
+ * list_sublist() - copy a subset of a list of strings
+ * list_free() - free a list of strings
+ * list_print() - print a list of strings to stdout
+ * list_length() - return the number of items in the list
+ *
+ * lol_init() - initialize a LOL (list of lists)
+ * lol_add() - append a LIST onto an LOL
+ * lol_free() - free the LOL and its LISTs
+ * lol_get() - return one of the LISTs in the LOL
+ * lol_print() - debug print LISTS separated by ":"
*
* 04/13/94 (seiwald) - added shorthand L0 for null list pointer
* 08/23/94 (seiwald) - new list_append()
@@ -52,9 +52,9 @@
typedef struct _list LIST;
struct _list {
- LIST *next;
- LIST *tail; /* only valid in head node */
- char *string; /* private copy */
+ LIST *next;
+ LIST *tail; /* only valid in head node */
+ char *string; /* private copy */
} ;
/*
@@ -66,17 +66,17 @@
# define LOL_MAX 9
struct _lol {
- int count;
- LIST *list[ LOL_MAX ];
+ int count;
+ LIST *list[ LOL_MAX ];
} ;
-LIST * list_append( LIST *l, LIST *nl );
-LIST * list_copy( LIST *l, LIST *nl );
-void list_free( LIST *head );
-LIST * list_new( LIST *head, char *string );
-void list_print( LIST *l );
-int list_length( LIST *l );
-LIST * list_sublist( LIST *l, int start, int count );
+LIST * list_append( LIST *l, LIST *nl );
+LIST * list_copy( LIST *l, LIST *nl );
+void list_free( LIST *head );
+LIST * list_new( LIST *head, char *string );
+void list_print( LIST *l );
+int list_length( LIST *l );
+LIST * list_sublist( LIST *l, int start, int count );
LIST * list_pop_front( LIST *l );
LIST * list_sort( LIST *l);
LIST * list_unique( LIST *sorted_list);
@@ -86,11 +86,11 @@
# define L0 ((LIST *)0)
-void lol_add( LOL *lol, LIST *l );
-void lol_init( LOL *lol );
-void lol_free( LOL *lol );
-LIST * lol_get( LOL *lol, int i );
-void lol_print( LOL *lol );
+void lol_add( LOL *lol, LIST *l );
+void lol_init( LOL *lol );
+void lol_free( LOL *lol );
+LIST * lol_get( LOL *lol, int i );
+void lol_print( LOL *lol );
void lol_build( LOL* lol, char** elements );
#endif
Modified: trunk/tools/jam/src/make.c
==============================================================================
--- trunk/tools/jam/src/make.c (original)
+++ trunk/tools/jam/src/make.c 2008-08-29 08:59:49 EDT (Fri, 29 Aug 2008)
@@ -23,19 +23,19 @@
* execution, is in make1.c.
*
* External routines:
- * make() - make a target, given its name
+ * make() - make a target, given its name
*
* Internal routines:
- * make0() - bind and scan everything to make a TARGET
- * make0sort() - reorder TARGETS chain by their time (newest to oldest)
+ * make0() - bind and scan everything to make a TARGET
+ * make0sort() - reorder TARGETS chain by their time (newest to oldest)
*
* 12/26/93 (seiwald) - allow NOTIME targets to be expanded via $(<), $(>)
* 01/04/94 (seiwald) - print all targets, bounded, when tracing commands
* 04/08/94 (seiwald) - progress report now reflects only targets with actions
* 04/11/94 (seiwald) - Combined deps & headers into deps[2] in TARGET.
* 12/20/94 (seiwald) - NOTIME renamed NOTFILE.
- * 12/20/94 (seiwald) - make0() headers after determining fate of target, so
- * that headers aren't seen as dependents on themselves.
+ * 12/20/94 (seiwald) - make0() headers after determining fate of target, so
+ * that headers aren't seen as dependents on themselves.
* 01/19/95 (seiwald) - distinguish between CANTFIND/CANTMAKE targets.
* 02/02/95 (seiwald) - propagate leaf source time for new LEAVES rule.
* 02/14/95 (seiwald) - NOUPDATE rule means don't update existing target.
@@ -74,29 +74,29 @@
static void dependGraphOutput( TARGET *t, int depth );
#endif
-static const char *target_fate[] =
+static const char *target_fate[] =
{
- "init", /* T_FATE_INIT */
- "making", /* T_FATE_MAKING */
- "stable", /* T_FATE_STABLE */
- "newer", /* T_FATE_NEWER */
- "temp", /* T_FATE_ISTMP */
- "touched", /* T_FATE_TOUCHED */
- "rebuild", /* T_FATE_REBUILD */
- "missing", /* T_FATE_MISSING */
- "needtmp", /* T_FATE_NEEDTMP */
- "old", /* T_FATE_OUTDATED */
- "update", /* T_FATE_UPDATE */
- "nofind", /* T_FATE_CANTFIND */
- "nomake" /* T_FATE_CANTMAKE */
+ "init", /* T_FATE_INIT */
+ "making", /* T_FATE_MAKING */
+ "stable", /* T_FATE_STABLE */
+ "newer", /* T_FATE_NEWER */
+ "temp", /* T_FATE_ISTMP */
+ "touched", /* T_FATE_TOUCHED */
+ "rebuild", /* T_FATE_REBUILD */
+ "missing", /* T_FATE_MISSING */
+ "needtmp", /* T_FATE_NEEDTMP */
+ "old", /* T_FATE_OUTDATED */
+ "update", /* T_FATE_UPDATE */
+ "nofind", /* T_FATE_CANTFIND */
+ "nomake" /* T_FATE_CANTMAKE */
} ;
-static const char *target_bind[] =
+static const char *target_bind[] =
{
- "unbound",
- "missing",
- "parents",
- "exists",
+ "unbound",
+ "missing",
+ "parents",
+ "exists",
} ;
# define spaces(x) ( " " + ( x > 20 ? 0 : 20-x ) )
@@ -106,77 +106,77 @@
*/
int
-make(
- int n_targets,
- const char **targets,
- int anyhow )
-{
- int i;
- COUNTS counts[1];
- int status = 0; /* 1 if anything fails */
+make(
+ int n_targets,
+ const char **targets,
+ int anyhow )
+{
+ int i;
+ COUNTS counts[1];
+ int status = 0; /* 1 if anything fails */
#ifdef OPT_HEADER_CACHE_EXT
- hcache_init();
+ hcache_init();
#endif
- memset( (char *)counts, 0, sizeof( *counts ) );
+ memset( (char *)counts, 0, sizeof( *counts ) );
/* First bind all targets with LOCATE_TARGET setting. This is
- needed to correctly handle dependencies to generated headers.
+ needed to correctly handle dependencies to generated headers.
*/
bind_explicitly_located_targets();
{ PROFILE_ENTER(MAKE_MAKE0);
- for( i = 0; i < n_targets; i++ )
- {
- TARGET *t = bindtarget( targets[i] );
+ for( i = 0; i < n_targets; i++ )
+ {
+ TARGET *t = bindtarget( targets[i] );
- make0( t, 0, 0, counts, anyhow );
- }
+ make0( t, 0, 0, counts, anyhow );
+ }
PROFILE_EXIT(MAKE_MAKE0); }
-
+
#ifdef OPT_GRAPH_DEBUG_EXT
- if( DEBUG_GRAPH )
- {
- for( i = 0; i < n_targets; i++ )
- {
- TARGET *t = bindtarget( targets[i] );
- dependGraphOutput( t, 0 );
- }
- }
-#endif
-
- if( DEBUG_MAKE )
- {
- if( counts->targets )
- printf( "...found %d target%s...\n", counts->targets,
- counts->targets > 1 ? "s" : "" );
- if( counts->temp )
- printf( "...using %d temp target%s...\n", counts->temp,
- counts->temp > 1 ? "s" : "" );
- if( counts->updating )
- printf( "...updating %d target%s...\n", counts->updating,
- counts->updating > 1 ? "s" : "" );
- if( counts->cantfind )
- printf( "...can't find %d target%s...\n", counts->cantfind,
- counts->cantfind > 1 ? "s" : "" );
- if( counts->cantmake )
- printf( "...can't make %d target%s...\n", counts->cantmake,
- counts->cantmake > 1 ? "s" : "" );
- }
+ if ( DEBUG_GRAPH )
+ {
+ for( i = 0; i < n_targets; i++ )
+ {
+ TARGET *t = bindtarget( targets[i] );
+ dependGraphOutput( t, 0 );
+ }
+ }
+#endif
+
+ if ( DEBUG_MAKE )
+ {
+ if ( counts->targets )
+ printf( "...found %d target%s...\n", counts->targets,
+ counts->targets > 1 ? "s" : "" );
+ if ( counts->temp )
+ printf( "...using %d temp target%s...\n", counts->temp,
+ counts->temp > 1 ? "s" : "" );
+ if ( counts->updating )
+ printf( "...updating %d target%s...\n", counts->updating,
+ counts->updating > 1 ? "s" : "" );
+ if ( counts->cantfind )
+ printf( "...can't find %d target%s...\n", counts->cantfind,
+ counts->cantfind > 1 ? "s" : "" );
+ if ( counts->cantmake )
+ printf( "...can't make %d target%s...\n", counts->cantmake,
+ counts->cantmake > 1 ? "s" : "" );
+ }
#ifdef OPT_HEADER_CACHE_EXT
- hcache_done();
+ hcache_done();
#endif
- status = counts->cantfind || counts->cantmake;
+ status = counts->cantfind || counts->cantmake;
{ PROFILE_ENTER(MAKE_MAKE1);
- for( i = 0; i < n_targets; i++ )
- status |= make1( bindtarget( targets[i] ) );
+ for( i = 0; i < n_targets; i++ )
+ status |= make1( bindtarget( targets[i] ) );
PROFILE_EXIT(MAKE_MAKE1); }
- return status;
+ return status;
}
/* Force any dependents of t that have already at least begun being
@@ -185,7 +185,7 @@
static void update_dependents(TARGET* t)
{
TARGETS *q;
-
+
for (q = t->dependents; q; q = q->next)
{
TARGET* p = q->target;
@@ -197,13 +197,13 @@
if (fate0 != T_FATE_INIT && fate0 < T_FATE_BUILD)
{
p->fate = T_FATE_UPDATE;
-
+
if (DEBUG_FATE)
{
printf( "fate change %s from %s to %s (as dependent of %s)\n",
p->name, target_fate[fate0], target_fate[p->fate], t->name);
}
-
+
/* If we're done visiting it, go back and make sure its
* dependents get rebuilt.
*/
@@ -227,7 +227,7 @@
if (DEBUG_FATE)
printf( "fate change %s from %s to %s (by rebuild)\n",
r->name, target_fate[r->fate], target_fate[T_FATE_REBUILD]);
-
+
/* Force rebuild it */
r->fate = T_FATE_REBUILD;
@@ -244,376 +244,359 @@
*/
void
-make0(
- TARGET *t,
- TARGET *p, /* parent */
- int depth, /* for display purposes */
- COUNTS *counts, /* for reporting */
- int anyhow ) /* forcibly touch all (real) targets */
-{
- TARGETS *c, *d, *incs;
- TARGET *ptime = t;
- time_t last, leaf, hlast;
- int fate;
- const char *flag = "";
- SETTINGS *s;
-
-#ifdef OPT_GRAPH_DEBUG_EXT
- int savedFate, oldTimeStamp;
-#endif
-
- if( DEBUG_MAKEPROG )
- printf( "make\t--\t%s%s\n", spaces( depth ), t->name );
-
- /*
- * Step 1: initialize
- */
-
- if( DEBUG_MAKEPROG )
- printf( "make\t--\t%s%s\n", spaces( depth ), t->name );
-
- t->fate = T_FATE_MAKING;
-
- /*
- * Step 2: under the influence of "on target" variables,
- * bind the target and search for headers.
- */
-
- /* Step 2a: set "on target" variables. */
-
- s = copysettings( t->settings );
- pushsettings( s );
-
- /* Step 2b: find and timestamp the target file (if it's a file). */
-
- if( t->binding == T_BIND_UNBOUND && !( t->flags & T_FLAG_NOTFILE ) )
- {
- char* another_target;
- t->boundname = search( t->name, &t->time, &another_target,
- (t->flags & T_FLAG_ISFILE));
- /* If it was detected that this target refers to an already
- existing and bound one, we add include dependency, so that
- every target which depends on us will depend on that other
- target. */
- if( another_target )
- {
- TARGET* includes;
- if (!t->includes) {
- t->includes = copytarget(t);
- t->includes->original_target = t;
- }
- includes = t->includes;
- includes->depends = targetlist( includes->depends,
- list_new( L0, another_target ) );
- }
-
- t->binding = t->time ? T_BIND_EXISTS : T_BIND_MISSING;
- }
-
- /* INTERNAL, NOTFILE header nodes have the time of their parents */
-
- if( p && t->flags & T_FLAG_INTERNAL )
- ptime = p;
-
- /* If temp file doesn't exist but parent does, use parent */
- if( p && t->flags & T_FLAG_TEMP &&
- t->binding == T_BIND_MISSING &&
- p->binding != T_BIND_MISSING )
+make0(
+ TARGET *t,
+ TARGET *p, /* parent */
+ int depth, /* for display purposes */
+ COUNTS *counts, /* for reporting */
+ int anyhow ) /* forcibly touch all (real) targets */
+{
+ TARGETS *c, *d, *incs;
+ TARGET *ptime = t;
+ time_t last;
+ time_t leaf;
+ time_t hlast;
+ int fate;
+ const char *flag = "";
+ SETTINGS *s;
+
+#ifdef OPT_GRAPH_DEBUG_EXT
+ int savedFate, oldTimeStamp;
+#endif
+
+ if ( DEBUG_MAKEPROG )
+ printf( "make\t--\t%s%s\n", spaces( depth ), t->name );
+
+ /*
+ * Step 1: initialize
+ */
+
+ if ( DEBUG_MAKEPROG )
+ printf( "make\t--\t%s%s\n", spaces( depth ), t->name );
+
+ t->fate = T_FATE_MAKING;
+
+ /*
+ * Step 2: under the influence of "on target" variables,
+ * bind the target and search for headers.
+ */
+
+ /* Step 2a: set "on target" variables. */
+ s = copysettings( t->settings );
+ pushsettings( s );
+
+ /* Step 2b: find and timestamp the target file (if it is a file). */
+ if ( t->binding == T_BIND_UNBOUND && !( t->flags & T_FLAG_NOTFILE ) )
+ {
+ char * another_target;
+ t->boundname = search( t->name, &t->time, &another_target,
+ t->flags & T_FLAG_ISFILE );
+ /* If it was detected that this target refers to an already existing and
+ * bound one, we add an include dependency, so that every target
+ * depending on us will depend on that other target as well.
+ */
+ if ( another_target )
+ add_include( t, bindtarget( another_target ) );
+
+ t->binding = t->time ? T_BIND_EXISTS : T_BIND_MISSING;
+ }
+
+ /* INTERNAL, NOTFILE header nodes have the time of their parents. */
+ if ( p && t->flags & T_FLAG_INTERNAL )
+ ptime = p;
+
+ /* If temp file doesn't exist but parent does, use parent */
+ if ( p && t->flags & T_FLAG_TEMP &&
+ t->binding == T_BIND_MISSING &&
+ p->binding != T_BIND_MISSING )
{
- t->binding = T_BIND_PARENTS;
- ptime = p;
+ t->binding = T_BIND_PARENTS;
+ ptime = p;
}
#ifdef OPT_SEMAPHORE
- {
- LIST *var = var_get( "JAM_SEMAPHORE" );
- if( var )
- {
- TARGET *semaphore = bindtarget( var->string );
-
- semaphore->progress = T_MAKE_SEMAPHORE;
- t->semaphore = semaphore;
- }
- }
-#endif
-
- /* Step 2c: If its a file, search for headers. */
-
- if( t->binding == T_BIND_EXISTS )
- headers( t );
-
- /* Step 2d: reset "on target" variables */
-
- popsettings( s );
- freesettings( s );
-
- /*
- * Pause for a little progress reporting
- */
-
- if( DEBUG_BIND )
-
- {
- if( strcmp( t->name, t->boundname ) )
- {
- printf( "bind\t--\t%s%s: %s\n",
- spaces( depth ), t->name, t->boundname );
- }
-
- switch( t->binding )
- {
- case T_BIND_UNBOUND:
- case T_BIND_MISSING:
- case T_BIND_PARENTS:
- printf( "time\t--\t%s%s: %s\n",
- spaces( depth ), t->name, target_bind[ t->binding ] );
- break;
-
- case T_BIND_EXISTS:
- printf( "time\t--\t%s%s: %s",
- spaces( depth ), t->name, ctime( &t->time ) );
- break;
- }
- }
-
- /*
- * Step 3: recursively make0() dependents & headers
- */
-
- /* Step 3a: recursively make0() dependents */
-
- for( c = t->depends; c; c = c->next )
- {
- int internal = t->flags & T_FLAG_INTERNAL;
+ {
+ LIST * var = var_get( "JAM_SEMAPHORE" );
+ if ( var )
+ {
+ TARGET * semaphore = bindtarget( var->string );
+ semaphore->progress = T_MAKE_SEMAPHORE;
+ t->semaphore = semaphore;
+ }
+ }
+#endif
+
+ /* Step 2c: If its a file, search for headers. */
+ if ( t->binding == T_BIND_EXISTS )
+ headers( t );
+
+ /* Step 2d: reset "on target" variables */
+ popsettings( s );
+ freesettings( s );
+
+ /*
+ * Pause for a little progress reporting .
+ */
+
+ if ( DEBUG_BIND )
+ {
+ if ( strcmp( t->name, t->boundname ) )
+ {
+ printf( "bind\t--\t%s%s: %s\n",
+ spaces( depth ), t->name, t->boundname );
+ }
+
+ switch( t->binding )
+ {
+ case T_BIND_UNBOUND:
+ case T_BIND_MISSING:
+ case T_BIND_PARENTS:
+ printf( "time\t--\t%s%s: %s\n",
+ spaces( depth ), t->name, target_bind[ t->binding ] );
+ break;
+
+ case T_BIND_EXISTS:
+ printf( "time\t--\t%s%s: %s",
+ spaces( depth ), t->name, ctime( &t->time ) );
+ break;
+ }
+ }
+
+ /*
+ * Step 3: recursively make0() dependants & headers.
+ */
+
+ /* Step 3a: recursively make0() dependants. */
+
+ for( c = t->depends; c; c = c->next )
+ {
+ int internal = t->flags & T_FLAG_INTERNAL;
/* Seems like it's not relevant for us....
- if( DEBUG_DEPENDS )
- printf( "%s \"%s\" : \"%s\" ;\n",
- internal ? "Includes" : "Depends",
- t->name, c->target->name );
+ if ( DEBUG_DEPENDS )
+ printf( "%s \"%s\" : \"%s\" ;\n",
+ internal ? "Includes" : "Depends",
+ t->name, c->target->name );
*/
- /* Warn about circular deps, except for includes, */
- /* which include each other alot. */
-
- if( c->target->fate == T_FATE_INIT )
- make0( c->target, ptime, depth + 1, counts, anyhow );
- else if( c->target->fate == T_FATE_MAKING && !internal )
- printf( "warning: %s depends on itself\n", c->target->name );
- }
+ /* Warn about circular deps, except for includes, */
+ /* which include each other alot. */
- /* Step 3b: recursively make0() internal includes node */
+ if ( c->target->fate == T_FATE_INIT )
+ make0( c->target, ptime, depth + 1, counts, anyhow );
+ else if ( c->target->fate == T_FATE_MAKING && !internal )
+ printf( "warning: %s depends on itself\n", c->target->name );
+ }
- if( t->includes )
- make0( t->includes, p, depth + 1, counts, anyhow );
+ /* Step 3b: recursively make0() internal includes node */
- /* Step 3c: add dependents' includes to our direct dependencies */
+ if ( t->includes )
+ make0( t->includes, p, depth + 1, counts, anyhow );
- incs = 0;
+ /* Step 3c: add dependents' includes to our direct dependencies */
- for( c = t->depends; c; c = c->next )
- if( c->target->includes )
- incs = targetentry( incs, c->target->includes );
+ incs = 0;
- t->depends = targetchain( t->depends, incs );
+ for( c = t->depends; c; c = c->next )
+ if ( c->target->includes )
+ incs = targetentry( incs, c->target->includes );
- /*
- * Step 4: compute time & fate
- */
+ t->depends = targetchain( t->depends, incs );
- /* Step 4a: pick up dependents' time and fate */
+ /*
+ * Step 4: compute time & fate
+ */
+ /* Step 4a: pick up dependants' time and fate */
- last = 0;
- leaf = 0;
+ last = 0;
+ leaf = 0;
fate = T_FATE_STABLE;
- for( c = t->depends; c; c = c->next )
- {
- /* If LEAVES has been applied, we only heed the timestamps of */
- /* the leaf source nodes. */
-
- leaf = max( leaf, c->target->leaf );
-
- if( t->flags & T_FLAG_LEAVES )
- {
- last = leaf;
- continue;
- }
-
- last = max( last, c->target->time );
- fate = max( fate, c->target->fate );
-
-#ifdef OPT_GRAPH_DEBUG_EXT
- if( DEBUG_FATE )
- if( fate < c->target->fate )
- printf( "fate change %s from %s to %s by dependency %s\n",
- t->name,
- target_fate[fate], target_fate[c->target->fate],
- c->target->name);
-#endif
-
- }
-
- /* Step 4b: pick up included headers time */
-
- /*
- * If a header is newer than a temp source that includes it,
- * the temp source will need building.
- */
-
- hlast = t->includes ? t->includes->time : 0;
-
- /* Step 4c: handle NOUPDATE oddity */
-
- /*
- * If a NOUPDATE file exists, make dependents eternally old.
- * Don't inherit our fate from our dependents. Decide fate
- * based only upon other flags and our binding (done later).
- */
-
- if( t->flags & T_FLAG_NOUPDATE )
- {
-#ifdef OPT_GRAPH_DEBUG_EXT
- if( DEBUG_FATE )
- if( fate != T_FATE_STABLE )
- printf( "fate change %s back to stable, NOUPDATE.\n",
- t->name);
-#endif
-
- last = 0;
- t->time = 0;
-
-
- /*
- * Don't inherit our fate from our dependents. Decide fate
- * based only upon other flags and our binding (done later).
- */
-
- fate = T_FATE_STABLE;
- }
-
- /* Step 4d: determine fate: rebuild target or what? */
-
- /*
- In English:
- If can't find or make child, can't make target.
- If children changed, make target.
- If target missing, make it.
- If children newer, make target.
- If temp's children newer than parent, make temp.
- If temp's headers newer than parent, make temp.
- If deliberately touched, make it.
- If up-to-date temp file present, use it.
- If target newer than non-notfile parent, mark target newer.
- Otherwise, stable!
-
- Note this block runs from least to most stable:
- as we make it further down the list, the target's
- fate is getting stabler.
- */
-
-#ifdef OPT_GRAPH_DEBUG_EXT
- savedFate = fate;
- oldTimeStamp = 0;
-#endif
-
- if( fate >= T_FATE_BROKEN )
- {
- fate = T_FATE_CANTMAKE;
- }
- else if( fate >= T_FATE_SPOIL )
- {
- fate = T_FATE_UPDATE;
- }
- else if( t->binding == T_BIND_MISSING )
- {
- fate = T_FATE_MISSING;
- }
- else if( t->binding == T_BIND_EXISTS && last > t->time )
- {
-#ifdef OPT_GRAPH_DEBUG_EXT
- oldTimeStamp = 1;
-#endif
- fate = T_FATE_OUTDATED;
- }
- else if( t->binding == T_BIND_PARENTS && last > p->time )
- {
-#ifdef OPT_GRAPH_DEBUG_EXT
- oldTimeStamp = 1;
-#endif
- fate = T_FATE_NEEDTMP;
- }
- else if( t->binding == T_BIND_PARENTS && hlast > p->time )
- {
- fate = T_FATE_NEEDTMP;
- }
- else if( t->flags & T_FLAG_TOUCHED )
- {
- fate = T_FATE_TOUCHED;
- }
- else if( anyhow && !( t->flags & T_FLAG_NOUPDATE ) )
- {
- fate = T_FATE_TOUCHED;
- }
- else if( t->binding == T_BIND_EXISTS && t->flags & T_FLAG_TEMP )
- {
- fate = T_FATE_ISTMP;
- }
- else if( t->binding == T_BIND_EXISTS && p &&
- p->binding != T_BIND_UNBOUND && t->time > p->time )
- {
-#ifdef OPT_GRAPH_DEBUG_EXT
- oldTimeStamp = 1;
-#endif
- fate = T_FATE_NEWER;
- }
- else
- {
- fate = T_FATE_STABLE;
- }
-#ifdef OPT_GRAPH_DEBUG_EXT
- if( DEBUG_FATE && fate != savedFate )
- if( savedFate == T_FATE_STABLE )
- printf( "fate change %s set to %s%s\n",
- t->name, target_fate[fate],
- oldTimeStamp ? " (by timestamp)" : "" );
- else
- printf( "fate change %s from %s to %s%s\n",
- t->name, target_fate[savedFate], target_fate[fate],
- oldTimeStamp ? " (by timestamp)" : "" );
-#endif
-
- /* Step 4e: handle missing files */
- /* If it's missing and there are no actions to create it, boom. */
- /* If we can't make a target we don't care about, 'sokay */
- /* We could insist that there are updating actions for all missing */
- /* files, but if they have dependents we just pretend it's NOTFILE. */
-
- if( fate == T_FATE_MISSING && !t->actions && !t->depends )
- {
- if( t->flags & T_FLAG_NOCARE )
- {
-#ifdef OPT_GRAPH_DEBUG_EXT
- if( DEBUG_FATE )
- printf( "fate change %s to STABLE from %s, "
- "no actions, no dependents and don't care\n",
- t->name, target_fate[fate]);
-#endif
- fate = T_FATE_STABLE;
- }
- else
- {
- printf( "don't know how to make %s\n", t->name );
-
- fate = T_FATE_CANTFIND;
- }
- }
+ for ( c = t->depends; c; c = c->next )
+ {
+ /* If LEAVES has been applied, we only heed the timestamps of */
+ /* the leaf source nodes. */
+
+ leaf = max( leaf, c->target->leaf );
+
+ if ( t->flags & T_FLAG_LEAVES )
+ {
+ last = leaf;
+ continue;
+ }
+
+ last = max( last, c->target->time );
+ fate = max( fate, c->target->fate );
+
+#ifdef OPT_GRAPH_DEBUG_EXT
+ if ( DEBUG_FATE )
+ if ( fate < c->target->fate )
+ printf( "fate change %s from %s to %s by dependency %s\n",
+ t->name,
+ target_fate[fate], target_fate[c->target->fate],
+ c->target->name);
+#endif
+
+ }
+
+ /* Step 4b: pick up included headers time */
+
+ /*
+ * If a header is newer than a temp source that includes it,
+ * the temp source will need building.
+ */
+
+ hlast = t->includes ? t->includes->time : 0;
+
+ /* Step 4c: handle NOUPDATE oddity */
+
+ /*
+ * If a NOUPDATE file exists, make dependents eternally old.
+ * Don't inherit our fate from our dependents. Decide fate
+ * based only upon other flags and our binding (done later).
+ */
+
+ if ( t->flags & T_FLAG_NOUPDATE )
+ {
+#ifdef OPT_GRAPH_DEBUG_EXT
+ if ( DEBUG_FATE )
+ if ( fate != T_FATE_STABLE )
+ printf( "fate change %s back to stable, NOUPDATE.\n",
+ t->name);
+#endif
+
+ last = 0;
+ t->time = 0;
+
+ /*
+ * Don't inherit our fate from our dependents. Decide fate
+ * based only upon other flags and our binding (done later).
+ */
+ fate = T_FATE_STABLE;
+ }
+
+ /* Step 4d: determine fate: rebuild target or what? */
+
+ /*
+ In English:
+ If can't find or make child, can't make target.
+ If children changed, make target.
+ If target missing, make it.
+ If children newer, make target.
+ If temp's children newer than parent, make temp.
+ If temp's headers newer than parent, make temp.
+ If deliberately touched, make it.
+ If up-to-date temp file present, use it.
+ If target newer than non-notfile parent, mark target newer.
+ Otherwise, stable!
+
+ Note this block runs from least to most stable:
+ as we make it further down the list, the target's
+ fate is getting stabler.
+ */
- /* Step 4f: propagate dependents' time & fate. */
- /* Set leaf time to be our time only if this is a leaf. */
+#ifdef OPT_GRAPH_DEBUG_EXT
+ savedFate = fate;
+ oldTimeStamp = 0;
+#endif
- t->time = max( t->time, last );
- t->leaf = leaf ? leaf : t->time ;
+ if ( fate >= T_FATE_BROKEN )
+ {
+ fate = T_FATE_CANTMAKE;
+ }
+ else if ( fate >= T_FATE_SPOIL )
+ {
+ fate = T_FATE_UPDATE;
+ }
+ else if ( t->binding == T_BIND_MISSING )
+ {
+ fate = T_FATE_MISSING;
+ }
+ else if ( t->binding == T_BIND_EXISTS && last > t->time )
+ {
+#ifdef OPT_GRAPH_DEBUG_EXT
+ oldTimeStamp = 1;
+#endif
+ fate = T_FATE_OUTDATED;
+ }
+ else if ( t->binding == T_BIND_PARENTS && last > p->time )
+ {
+#ifdef OPT_GRAPH_DEBUG_EXT
+ oldTimeStamp = 1;
+#endif
+ fate = T_FATE_NEEDTMP;
+ }
+ else if ( t->binding == T_BIND_PARENTS && hlast > p->time )
+ {
+ fate = T_FATE_NEEDTMP;
+ }
+ else if ( t->flags & T_FLAG_TOUCHED )
+ {
+ fate = T_FATE_TOUCHED;
+ }
+ else if ( anyhow && !( t->flags & T_FLAG_NOUPDATE ) )
+ {
+ fate = T_FATE_TOUCHED;
+ }
+ else if ( t->binding == T_BIND_EXISTS && t->flags & T_FLAG_TEMP )
+ {
+ fate = T_FATE_ISTMP;
+ }
+ else if ( t->binding == T_BIND_EXISTS && p &&
+ p->binding != T_BIND_UNBOUND && t->time > p->time )
+ {
+#ifdef OPT_GRAPH_DEBUG_EXT
+ oldTimeStamp = 1;
+#endif
+ fate = T_FATE_NEWER;
+ }
+ else
+ {
+ fate = T_FATE_STABLE;
+ }
+#ifdef OPT_GRAPH_DEBUG_EXT
+ if ( DEBUG_FATE && fate != savedFate )
+ if ( savedFate == T_FATE_STABLE )
+ printf( "fate change %s set to %s%s\n",
+ t->name, target_fate[fate],
+ oldTimeStamp ? " (by timestamp)" : "" );
+ else
+ printf( "fate change %s from %s to %s%s\n",
+ t->name, target_fate[savedFate], target_fate[fate],
+ oldTimeStamp ? " (by timestamp)" : "" );
+#endif
+
+ /* Step 4e: handle missing files */
+ /* If it's missing and there are no actions to create it, boom. */
+ /* If we can't make a target we don't care about, 'sokay */
+ /* We could insist that there are updating actions for all missing */
+ /* files, but if they have dependents we just pretend it's NOTFILE. */
+
+ if ( fate == T_FATE_MISSING && !t->actions && !t->depends )
+ {
+ if ( t->flags & T_FLAG_NOCARE )
+ {
+#ifdef OPT_GRAPH_DEBUG_EXT
+ if ( DEBUG_FATE )
+ printf( "fate change %s to STABLE from %s, "
+ "no actions, no dependents and don't care\n",
+ t->name, target_fate[fate]);
+#endif
+ fate = T_FATE_STABLE;
+ }
+ else
+ {
+ printf( "don't know how to make %s\n", t->name );
+
+ fate = T_FATE_CANTFIND;
+ }
+ }
+
+ /* Step 4f: propagate dependents' time & fate. */
+ /* Set leaf time to be our time only if this is a leaf. */
+
+ t->time = max( t->time, last );
+ t->leaf = leaf ? leaf : t->time ;
/* This target's fate may have been updated by virtue of following
* some target's rebuilds list, so only allow it to be increased
* to the fate we've calculated. Otherwise, grab its new fate.
@@ -627,61 +610,55 @@
* everything in this target's rebuilds list */
if (fate >= T_FATE_BUILD && fate < T_FATE_BROKEN)
force_rebuilds(t);
- /*
- * Step 5: sort dependents by their update time.
- */
+ /*
+ * Step 5: sort dependents by their update time.
+ */
- if( globs.newestfirst )
- t->depends = make0sort( t->depends );
+ if ( globs.newestfirst )
+ t->depends = make0sort( t->depends );
- /*
- * Step 6: a little harmless tabulating for tracing purposes
- */
+ /*
+ * Step 6: a little harmless tabulating for tracing purposes
+ */
- /* Don't count or report interal includes nodes. */
+ /* Don't count or report interal includes nodes. */
- if( t->flags & T_FLAG_INTERNAL )
- return;
+ if ( t->flags & T_FLAG_INTERNAL )
+ return;
if (counts) {
#ifdef OPT_IMPROVED_PATIENCE_EXT
++counts->targets;
-#else
- if( !( ++counts->targets % 1000 ) && DEBUG_MAKE )
+#else
+ if ( !( ++counts->targets % 1000 ) && DEBUG_MAKE )
printf( "...patience...\n" );
#endif
- if( fate == T_FATE_ISTMP )
+ if ( fate == T_FATE_ISTMP )
counts->temp++;
- else if( fate == T_FATE_CANTFIND )
+ else if ( fate == T_FATE_CANTFIND )
counts->cantfind++;
- else if( fate == T_FATE_CANTMAKE && t->actions )
+ else if ( fate == T_FATE_CANTMAKE && t->actions )
counts->cantmake++;
- else if( fate >= T_FATE_BUILD && fate < T_FATE_BROKEN && t->actions )
+ else if ( fate >= T_FATE_BUILD && fate < T_FATE_BROKEN && t->actions )
counts->updating++;
}
- if( !( t->flags & T_FLAG_NOTFILE ) && fate >= T_FATE_SPOIL )
- flag = "+";
- else if( t->binding == T_BIND_EXISTS && p && t->time > p->time )
- flag = "*";
-
- if( DEBUG_MAKEPROG )
- printf( "made%s\t%s\t%s%s\n",
- flag, target_fate[ t->fate ],
- spaces( depth ), t->name );
-
-/* We don't have DEBUG_CAUSES.
- if( DEBUG_CAUSES &&
- t->fate >= T_FATE_NEWER &&
- t->fate <= T_FATE_MISSING )
- printf( "%s %s\n", target_fate[ t->fate ], t->name );
-*/
+ if ( !( t->flags & T_FLAG_NOTFILE ) && fate >= T_FATE_SPOIL )
+ flag = "+";
+ else if ( t->binding == T_BIND_EXISTS && p && t->time > p->time )
+ flag = "*";
+
+ if ( DEBUG_MAKEPROG )
+ printf( "made%s\t%s\t%s%s\n",
+ flag, target_fate[ t->fate ],
+ spaces( depth ), t->name );
}
+
#ifdef OPT_GRAPH_DEBUG_EXT
-static const char* target_name( TARGET* t )
+static const char * target_name( TARGET * t )
{
static char buf[1000];
if (t->flags & T_FLAG_INTERNAL) {
@@ -692,168 +669,161 @@
}
}
+
/*
- * dependGraphOutput() - output the DG after make0 has run
+ * dependGraphOutput() - output the DG after make0 has run.
*/
-static void
-dependGraphOutput( TARGET *t, int depth )
+static void dependGraphOutput( TARGET * t, int depth )
{
- TARGETS *c;
+ TARGETS * c;
- if ( (t->flags & T_FLAG_VISITED) != 0
- || !t->name
- || !t->boundname)
- return;
+ if ( ( t->flags & T_FLAG_VISITED ) || !t->name || !t->boundname )
+ return;
t->flags |= T_FLAG_VISITED;
- switch (t->fate)
+ switch ( t->fate )
{
- case T_FATE_TOUCHED:
- case T_FATE_MISSING:
- case T_FATE_OUTDATED:
- case T_FATE_UPDATE:
- printf( "->%s%2d Name: %s\n", spaces(depth), depth, target_name(t) );
- break;
- default:
- printf( " %s%2d Name: %s\n", spaces(depth), depth, target_name(t) );
- break;
- }
-
- if( strcmp (t->name, t->boundname) )
- {
- printf( " %s Loc: %s\n", spaces(depth), t->boundname );
- }
-
- switch( t->fate )
- {
- case T_FATE_STABLE:
- printf( " %s : Stable\n", spaces(depth) );
- break;
- case T_FATE_NEWER:
- printf( " %s : Newer\n", spaces(depth) );
- break;
- case T_FATE_ISTMP:
- printf( " %s : Up to date temp file\n", spaces(depth) );
- break;
- case T_FATE_NEEDTMP:
- printf( " %s : Temporary file, to be updated\n", spaces(depth) );
- break;
- case T_FATE_TOUCHED:
- printf( " %s : Been touched, updating it\n", spaces(depth) );
- break;
- case T_FATE_MISSING:
- printf( " %s : Missing, creating it\n", spaces(depth) );
- break;
- case T_FATE_OUTDATED:
- printf( " %s : Outdated, updating it\n", spaces(depth) );
- break;
- case T_FATE_REBUILD:
- printf( " %s : Rebuild, updating it\n", spaces(depth) );
- break;
- case T_FATE_UPDATE:
- printf( " %s : Updating it\n", spaces(depth) );
- break;
- case T_FATE_CANTFIND:
- printf( " %s : Can not find it\n", spaces(depth) );
- break;
- case T_FATE_CANTMAKE:
- printf( " %s : Can not make it\n", spaces(depth) );
- break;
- }
-
- if( t->flags & ~T_FLAG_VISITED )
- {
- printf( " %s : ", spaces(depth) );
- if( t->flags & T_FLAG_TEMP ) printf ("TEMPORARY ");
- if( t->flags & T_FLAG_NOCARE ) printf ("NOCARE ");
- if( t->flags & T_FLAG_NOTFILE ) printf ("NOTFILE ");
- if( t->flags & T_FLAG_TOUCHED ) printf ("TOUCHED ");
- if( t->flags & T_FLAG_LEAVES ) printf ("LEAVES ");
- if( t->flags & T_FLAG_NOUPDATE ) printf ("NOUPDATE ");
- printf( "\n" );
+ case T_FATE_TOUCHED:
+ case T_FATE_MISSING:
+ case T_FATE_OUTDATED:
+ case T_FATE_UPDATE:
+ printf( "->%s%2d Name: %s\n", spaces(depth), depth, target_name(t) );
+ break;
+ default:
+ printf( " %s%2d Name: %s\n", spaces(depth), depth, target_name(t) );
+ break;
}
- for( c = t->depends; c; c = c->next )
+ if ( strcmp( t->name, t->boundname ) )
+ printf( " %s Loc: %s\n", spaces(depth), t->boundname );
+
+ switch ( t->fate )
{
- printf( " %s : Depends on %s (%s)", spaces(depth),
- target_name(c->target), target_fate[ c->target->fate ] );
- if (c->target->time == t->time)
- printf( " (max time)");
- printf("\n");
-
+ case T_FATE_STABLE:
+ printf( " %s : Stable\n", spaces(depth) );
+ break;
+ case T_FATE_NEWER:
+ printf( " %s : Newer\n", spaces(depth) );
+ break;
+ case T_FATE_ISTMP:
+ printf( " %s : Up to date temp file\n", spaces(depth) );
+ break;
+ case T_FATE_NEEDTMP:
+ printf( " %s : Temporary file, to be updated\n", spaces(depth) );
+ break;
+ case T_FATE_TOUCHED:
+ printf( " %s : Been touched, updating it\n", spaces(depth) );
+ break;
+ case T_FATE_MISSING:
+ printf( " %s : Missing, creating it\n", spaces(depth) );
+ break;
+ case T_FATE_OUTDATED:
+ printf( " %s : Outdated, updating it\n", spaces(depth) );
+ break;
+ case T_FATE_REBUILD:
+ printf( " %s : Rebuild, updating it\n", spaces(depth) );
+ break;
+ case T_FATE_UPDATE:
+ printf( " %s : Updating it\n", spaces(depth) );
+ break;
+ case T_FATE_CANTFIND:
+ printf( " %s : Can not find it\n", spaces(depth) );
+ break;
+ case T_FATE_CANTMAKE:
+ printf( " %s : Can make it\n", spaces(depth) );
+ break;
}
-
- for( c = t->depends; c; c = c->next )
+ if ( t->flags & ~T_FLAG_VISITED )
{
+ printf( " %s : ", spaces(depth) );
+ if ( t->flags & T_FLAG_TEMP ) printf( "TEMPORARY " );
+ if ( t->flags & T_FLAG_NOCARE ) printf( "NOCARE " );
+ if ( t->flags & T_FLAG_NOTFILE ) printf( "NOTFILE " );
+ if ( t->flags & T_FLAG_TOUCHED ) printf( "TOUCHED " );
+ if ( t->flags & T_FLAG_LEAVES ) printf( "LEAVES " );
+ if ( t->flags & T_FLAG_NOUPDATE ) printf( "NOUPDATE " );
+ printf( "\n" );
+ }
- dependGraphOutput( c->target, depth + 1 );
+ for ( c = t->depends; c; c = c->next )
+ {
+ printf( " %s : Depends on %s (%s)", spaces(depth),
+ target_name(c->target), target_fate[ c->target->fate ] );
+ if ( c->target->time == t->time )
+ printf( " (max time)");
+ printf("\n");
}
-}
+ for ( c = t->depends; c; c = c->next )
+ dependGraphOutput( c->target, depth + 1 );
+}
#endif
+
+
/*
* make0sort() - reorder TARGETS chain by their time (newest to oldest)
*/
-static TARGETS *
-make0sort( TARGETS *chain )
+static TARGETS * make0sort( TARGETS * chain )
{
PROFILE_ENTER(MAKE_MAKE0SORT);
- TARGETS *result = 0;
+ TARGETS * result = 0;
+
+ /* We walk chain, taking each item and inserting it on the sorted result, */
+ /* with newest items at the front. This involves updating each of the */
+ /* TARGETS' c->next and c->tail. Note that we make c->tail a valid prev */
+ /* pointer for every entry. Normally, it is only valid at the head, where */
+ /* prev == tail. Note also that while tail is a loop, next ends at the */
+ /* end of the chain. */
- /* We walk chain, taking each item and inserting it on the */
- /* sorted result, with newest items at the front. This involves */
- /* updating each TARGETS' c->next and c->tail. Note that we */
- /* make c->tail a valid prev pointer for every entry. Normally, */
- /* it is only valid at the head, where prev == tail. Note also */
- /* that while tail is a loop, next ends at the end of the chain. */
-
- /* Walk current target list */
-
- while( chain )
- {
- TARGETS *c = chain;
- TARGETS *s = result;
-
- chain = chain->next;
-
- /* Find point s in result for c */
-
- while( s && s->target->time > c->target->time )
- s = s->next;
-
- /* Insert c in front of s (might be 0). */
- /* Don't even think of deciphering this. */
-
- c->next = s; /* good even if s = 0 */
- if( result == s ) result = c; /* new head of chain? */
- if( !s ) s = result; /* wrap to ensure a next */
- if( result != c ) s->tail->next = c; /* not head? be prev's next */
- c->tail = s->tail; /* take on next's prev */
- s->tail = c; /* make next's prev us */
- }
+ /* Walk the current target list. */
+
+ while( chain )
+ {
+ TARGETS *c = chain;
+ TARGETS *s = result;
+
+ chain = chain->next;
+
+ /* Find point s in result for c. */
+ while( s && s->target->time > c->target->time )
+ s = s->next;
+
+ /* Insert c in front of s (might be 0). */
+ /* Do not even think of deciphering this. */
+ c->next = s; /* good even if s = 0 */
+ if ( result == s ) result = c; /* new head of chain? */
+ if ( !s ) s = result; /* wrap to ensure a next */
+ if ( result != c ) s->tail->next = c; /* not head? be prev's next */
+ c->tail = s->tail; /* take on next's prev */
+ s->tail = c; /* make next's prev us */
+ }
PROFILE_EXIT(MAKE_MAKE0SORT);
- return result;
+ return result;
}
-static LIST *targets_to_update_ = 0;
-void mark_target_for_updating(char *target)
+static LIST * targets_to_update_ = 0;
+
+
+void mark_target_for_updating( char * target )
{
targets_to_update_ = list_new( targets_to_update_, target );
}
-LIST *targets_to_update()
+
+LIST * targets_to_update()
{
return targets_to_update_;
}
+
void clear_targets_to_update()
{
- list_free(targets_to_update_);
+ list_free( targets_to_update_ );
targets_to_update_ = 0;
}
Modified: trunk/tools/jam/src/make.h
==============================================================================
--- trunk/tools/jam/src/make.h (original)
+++ trunk/tools/jam/src/make.h 2008-08-29 08:59:49 EDT (Fri, 29 Aug 2008)
@@ -14,16 +14,16 @@
int make1( TARGET *t );
typedef struct {
- int temp;
- int updating;
- int cantfind;
- int cantmake;
- int targets;
- int made;
+ int temp;
+ int updating;
+ int cantfind;
+ int cantmake;
+ int targets;
+ int made;
} COUNTS ;
-void make0( TARGET *t, TARGET *p, int depth,
+void make0( TARGET *t, TARGET *p, int depth,
COUNTS *counts, int anyhow );
@@ -31,7 +31,7 @@
* Specifies that the target should be updated.
*/
void mark_target_for_updating(char *target);
-/*
+/*
* Returns the list of all the target previously passed to 'mark_target_for_updating'.
*/
LIST *targets_to_update();
Modified: trunk/tools/jam/src/make1.c
==============================================================================
--- trunk/tools/jam/src/make1.c (original)
+++ trunk/tools/jam/src/make1.c 2008-08-29 08:59:49 EDT (Fri, 29 Aug 2008)
@@ -13,27 +13,27 @@
/*
* make1.c - execute command to bring targets up to date
*
- * This module contains make1(), the entry point called by make() to
+ * This module contains make1(), the entry point called by make() to
* recursively decend the dependency graph executing update actions as
* marked by make0().
*
* External routines:
*
- * make1() - execute commands to update a TARGET and all its dependents
+ * make1() - execute commands to update a TARGET and all its dependents
*
* Internal routines, the recursive/asynchronous command executors:
*
- * make1a() - recursively traverse target tree, calling make1b()
- * make1b() - dependents of target built, now build target with make1c()
- * make1c() - launch target's next command, call make1b() when done
- * make1d() - handle command execution completion and call back make1c()
+ * make1a() - recursively traverse target tree, calling make1b()
+ * make1b() - dependents of target built, now build target with make1c()
+ * make1c() - launch target's next command, call make1b() when done
+ * make1d() - handle command execution completion and call back make1c()
*
* Internal support routines:
*
- * make1cmds() - turn ACTIONS into CMDs, grouping, splitting, etc
- * make1list() - turn a list of targets into a LIST, for $(<) and $(>)
- * make1settings() - for vars that get bound values, build up replacement lists
- * make1bind() - bind targets that weren't bound in dependency analysis
+ * make1cmds() - turn ACTIONS into CMDs, grouping, splitting, etc
+ * make1list() - turn a list of targets into a LIST, for $(<) and $(>)
+ * make1settings() - for vars that get bound values, build up replacement lists
+ * make1bind() - bind targets that weren't bound in dependency analysis
*
* 04/16/94 (seiwald) - Split from make.c.
* 04/21/94 (seiwald) - Handle empty "updated" actions.
@@ -77,10 +77,10 @@
/* Ugly static - it's too hard to carry it through the callbacks. */
static struct {
- int failed;
- int skipped;
- int total;
- int made;
+ int failed;
+ int skipped;
+ int total;
+ int made;
} counts[1] ;
/*
@@ -109,95 +109,104 @@
typedef struct _stack
{
- state *stack;
+ state * stack;
} stack;
static stack state_stack = { NULL };
static state *state_freelist = NULL;
+
static state *alloc_state()
{
- if(state_freelist != NULL)
- {
- state *pState;
-
- pState = state_freelist;
- state_freelist = pState->prev;
- memset(pState, 0, sizeof(state));
- return pState;
- }
- else
- {
- return (state *)BJAM_MALLOC(sizeof(state));
- }
+ if(state_freelist != NULL)
+ {
+ state *pState;
+
+ pState = state_freelist;
+ state_freelist = pState->prev;
+ memset(pState, 0, sizeof(state));
+ return pState;
+ }
+ else
+ {
+ return (state *)BJAM_MALLOC(sizeof(state));
+ }
}
+
static void free_state(state *pState)
{
- pState->prev = state_freelist;
- state_freelist = pState;
+ pState->prev = state_freelist;
+ state_freelist = pState;
}
+
static void clear_state_freelist()
{
- while(state_freelist != NULL)
- {
- state *pState = state_freelist;
- state_freelist = state_freelist->prev;
- BJAM_FREE(pState);
- }
+ while(state_freelist != NULL)
+ {
+ state *pState = state_freelist;
+ state_freelist = state_freelist->prev;
+ BJAM_FREE(pState);
+ }
}
+
static state *current_state(stack *pStack)
{
- return pStack->stack;
+ return pStack->stack;
}
-static void pop_state(stack *pStack)
+
+static void pop_state( stack * pStack )
{
- state *pState;
+ state * pState;
- if(pStack->stack != NULL)
- {
- pState = pStack->stack->prev;
- free_state(pStack->stack);
- pStack->stack = pState;
- }
+ if ( pStack->stack != NULL )
+ {
+ pState = pStack->stack->prev;
+ free_state(pStack->stack);
+ pStack->stack = pState;
+ }
}
+
static state *push_state(stack *pStack, TARGET *t, TARGET *parent, int curstate)
{
- state *pState;
+ state *pState;
- pState = alloc_state();
+ pState = alloc_state();
- pState->t = t;
- pState->parent = parent;
- pState->prev = pStack->stack;
- pState->curstate = curstate;
+ pState->t = t;
+ pState->parent = parent;
+ pState->prev = pStack->stack;
+ pState->curstate = curstate;
- pStack->stack = pState;
+ pStack->stack = pState;
- return pStack->stack;
+ return pStack->stack;
}
-/* pushes a stack onto another stack, effectively reversing the order */
+
+/*
+ * Pushes a stack onto another stack, effectively reversing the order.
+ */
+
static void push_stack_on_stack(stack *pDest, stack *pSrc)
{
- while(pSrc->stack != NULL)
- {
- state *pState;
-
- pState = pSrc->stack;
- pSrc->stack = pSrc->stack->prev;
- pState->prev = pDest->stack;
- pDest->stack = pState;
- }
+ while ( pSrc->stack != NULL )
+ {
+ state * pState = pSrc->stack;
+ pSrc->stack = pSrc->stack->prev;
+ pState->prev = pDest->stack;
+ pDest->stack = pState;
+ }
}
+
/*
- * make1() - execute commands to update a TARGET and all its dependents
+ * make1() - execute commands to update a TARGET and all its dependants.
*/
static int intr = 0;
@@ -205,137 +214,137 @@
int
make1( TARGET *t )
{
- state *pState;
+ state *pState;
- memset( (char *)counts, 0, sizeof( *counts ) );
+ memset( (char *)counts, 0, sizeof( *counts ) );
- /* Recursively make the target and its dependents */
- push_state(&state_stack, t, NULL, T_STATE_MAKE1A);
+ /* Recursively make the target and its dependants. */
+ push_state(&state_stack, t, NULL, T_STATE_MAKE1A);
- do
- {
- while((pState = current_state(&state_stack)) != NULL)
- {
- if (intr)
+ do
+ {
+ while((pState = current_state(&state_stack)) != NULL)
+ {
+ if (intr)
pop_state(&state_stack);
- switch(pState->curstate)
- {
- case T_STATE_MAKE1A:
- make1a(pState);
- break;
- case T_STATE_MAKE1ATAIL:
- make1atail(pState);
- break;
- case T_STATE_MAKE1B:
- make1b(pState);
- break;
- case T_STATE_MAKE1C:
- make1c(pState);
- break;
- case T_STATE_MAKE1D:
- make1d(pState);
- break;
- default:
- break;
- }
- }
-
-
- /* Wait for any outstanding commands to finish running. */
- } while( execwait() );
-
- clear_state_freelist();
-
- /* Talk about it */
- if( counts->failed )
- printf( "...failed updating %d target%s...\n", counts->failed,
- counts->failed > 1 ? "s" : "" );
-
- if( DEBUG_MAKE && counts->skipped )
- printf( "...skipped %d target%s...\n", counts->skipped,
- counts->skipped > 1 ? "s" : "" );
-
- if( DEBUG_MAKE && counts->made )
- printf( "...updated %d target%s...\n", counts->made,
- counts->made > 1 ? "s" : "" );
+ switch(pState->curstate)
+ {
+ case T_STATE_MAKE1A:
+ make1a(pState);
+ break;
+ case T_STATE_MAKE1ATAIL:
+ make1atail(pState);
+ break;
+ case T_STATE_MAKE1B:
+ make1b(pState);
+ break;
+ case T_STATE_MAKE1C:
+ make1c(pState);
+ break;
+ case T_STATE_MAKE1D:
+ make1d(pState);
+ break;
+ default:
+ break;
+ }
+ }
+ /* Wait for any outstanding commands to finish running. */
+ } while( execwait() );
+
+ clear_state_freelist();
- return counts->total != counts->made;
+ /* Talk about it */
+ if( counts->failed )
+ printf( "...failed updating %d target%s...\n", counts->failed,
+ counts->failed > 1 ? "s" : "" );
+
+ if( DEBUG_MAKE && counts->skipped )
+ printf( "...skipped %d target%s...\n", counts->skipped,
+ counts->skipped > 1 ? "s" : "" );
+
+ if( DEBUG_MAKE && counts->made )
+ printf( "...updated %d target%s...\n", counts->made,
+ counts->made > 1 ? "s" : "" );
+
+ return counts->total != counts->made;
}
+
/*
- * make1a() - recursively traverse target tree, calling make1b()
+ * make1a() - recursively traverse target tree, calling make1b().
*/
static void
-make1a( state *pState)
+make1a( state *pState )
{
- TARGET* t = pState->t;
- TARGETS *c;
- TARGETS *inc;
-
- /* If the parent is the first to try to build this target */
- /* or this target is in the make1c() quagmire, arrange for the */
- /* parent to be notified when this target is built. */
-
- if( pState->parent )
- switch( pState->t->progress )
- {
- case T_MAKE_INIT:
- case T_MAKE_ACTIVE:
- case T_MAKE_RUNNING:
- pState->t->parents = targetentry( pState->t->parents, pState->parent );
- pState->parent->asynccnt++;
- }
-
- if( pState->t->progress != T_MAKE_INIT )
- {
- pop_state(&state_stack);
- return;
- }
-
- /* Asynccnt counts the dependents preventing this target from */
- /* proceeding to make1b() for actual building. We start off with */
- /* a count of 1 to prevent anything from happening until we can */
- /* call all dependents. This 1 is accounted for when we call */
- /* make1b() ourselves, below. */
-
- pState->t->asynccnt = 1;
-
- /* Add header node that was created during building process. */
-
- inc = 0;
- for (c = t->depends; c; c = c->next) {
- if (c->target->rescanned && c->target->includes)
- inc = targetentry(inc, c->target->includes);
- }
- t->depends = targetchain(t->depends, inc);
-
- /* against circular dependency. */
-
- pState->t->progress = T_MAKE_ONSTACK;
-
- {
- stack temp_stack = { NULL };
- for( c = t->depends; c && !intr; c = c->next )
+ TARGET *t = pState->t;
+ TARGETS *c;
+
+ /* If the parent is the first to try to build this target */
+ /* or this target is in the make1c() quagmire, arrange for the */
+ /* parent to be notified when this target is built. */
+
+ if( pState->parent )
+ switch( pState->t->progress )
+ {
+ case T_MAKE_INIT:
+ case T_MAKE_ACTIVE:
+ case T_MAKE_RUNNING:
+ pState->t->parents = targetentry( pState->t->parents, pState->parent );
+ pState->parent->asynccnt++;
+ }
+
+ if( pState->t->progress != T_MAKE_INIT )
+ {
+ pop_state(&state_stack);
+ return;
+ }
+
+ /* Asynccnt counts the dependants preventing this target from proceeding to
+ * make1b() for actual building. We start off with a count of 1 to prevent
+ * anything from happening until we can call all dependents. This 1 is
+ * accounted for when we call make1b() ourselves, below. Without this if a
+ * a dependant gets built before we finish processing all of our other
+ * dependants our build would be triggerred prematurely.
+ */
+ pState->t->asynccnt = 1;
+
+ /* Add header nodes created during the building process. */
+ {
+ TARGETS *inc = 0;
+ for ( c = t->depends; c; c = c->next )
+ if (c->target->rescanned && c->target->includes)
+ inc = targetentry(inc, c->target->includes);
+ t->depends = targetchain(t->depends, inc);
+ }
+
+ /* Guard against circular dependency. */
+ pState->t->progress = T_MAKE_ONSTACK;
+
+ {
+ stack temp_stack = { NULL };
+ for( c = t->depends; c && !intr; c = c->next )
push_state(&temp_stack, c->target, pState->t, T_STATE_MAKE1A);
- /* using stacks reverses the order of execution. Reverse it back */
- push_stack_on_stack(&state_stack, &temp_stack);
- }
+ /* Using stacks reverses the order of execution. Reverse it back. */
+ push_stack_on_stack(&state_stack, &temp_stack);
+ }
- pState->curstate = T_STATE_MAKE1ATAIL;
+ pState->curstate = T_STATE_MAKE1ATAIL;
}
+
static void make1atail(state *pState)
{
- pState->t->progress = T_MAKE_ACTIVE;
+ pState->t->progress = T_MAKE_ACTIVE;
- /* Now that all dependents have bumped asynccnt, we now allow */
- /* decrement our reference to asynccnt. */
- pState->curstate = T_STATE_MAKE1B;
+ /* Now that all dependents have bumped asynccnt, we now allow */
+ /* decrement our reference to asynccnt. */
+ pState->curstate = T_STATE_MAKE1B;
}
+
/*
* make1b() - dependents of target built, now build target with make1c()
*/
@@ -343,42 +352,39 @@
static void
make1b( state *pState )
{
- TARGET *t = pState->t;
- TARGETS *c;
- TARGET *failed = 0;
- char* failed_name = "dependencies";
-
- /* If any dependents are still outstanding, wait until they */
- /* call make1b() to signal their completion. */
+ TARGET *t = pState->t;
+ TARGETS *c;
+ TARGET *failed = 0;
+ char *failed_name = "dependencies";
+ /* If any dependents are still outstanding, wait until they call make1b() */
+ /* to signal their completion. */
if( --(pState->t->asynccnt) )
- {
- pop_state(&state_stack);
- return;
- }
-
+ {
+ pop_state(&state_stack);
+ return;
+ }
+
/* Try to aquire a semaphore. If it's locked, wait until the target
that locked it is build and signals completition. */
#ifdef OPT_SEMAPHORE
- if( t->semaphore && t->semaphore->asynccnt )
- {
+ if( t->semaphore && t->semaphore->asynccnt )
+ {
/* Append 't' to the list of targets waiting on semaphore. */
- t->semaphore->parents = targetentry( t->semaphore->parents, t );
- t->asynccnt++;
+ t->semaphore->parents = targetentry( t->semaphore->parents, t );
+ t->asynccnt++;
- if( DEBUG_EXECCMD )
- printf( "SEM: %s is busy, delaying launch of %s\n",
- t->semaphore->name, t->name);
- pop_state(&state_stack);
- return;
- }
+ if( DEBUG_EXECCMD )
+ printf( "SEM: %s is busy, delaying launch of %s\n",
+ t->semaphore->name, t->name);
+ pop_state(&state_stack);
+ return;
+ }
#endif
+ /* Now ready to build target 't'... if dependants built OK. */
- /* Now ready to build target 't'... if dependents built ok. */
-
- /* Collect status from dependents */
-
+ /* Collect status from dependants. */
for( c = t->depends; c; c = c->next )
if( c->target->status > t->status && !( c->target->flags & T_FLAG_NOCARE ))
@@ -386,19 +392,20 @@
failed = c->target;
pState->t->status = c->target->status;
}
- /* If a internal header node failed to build, we'd want to output the
- target that it failed on. */
- if (failed && (failed->flags & T_FLAG_INTERNAL)) {
- failed_name = failed->failed;
- } else if (failed) {
- failed_name = failed->name;
+ /* If an internal header node failed to build, we want to output the target
+ that it failed on. */
+ if ( failed )
+ {
+ failed_name = failed->flags & T_FLAG_INTERNAL
+ ? failed->failed
+ : failed->name;
}
t->failed = failed_name;
- /* If actions on deps have failed, bail. */
- /* Otherwise, execute all actions to make target */
+ /* If actions on any of the dependants have failed, bail. */
+ /* Otherwise, execute all actions to make the current target. */
- if( pState->t->status == EXEC_CMD_FAIL && pState->t->actions )
+ if( ( pState->t->status == EXEC_CMD_FAIL ) && pState->t->actions )
{
++counts->skipped;
if ( ( pState->t->flags & ( T_FLAG_RMOLD | T_FLAG_NOTFILE ) ) == T_FLAG_RMOLD )
@@ -455,223 +462,218 @@
}
break;
-
- /* All possible fates should have been accounted for by now */
+
+ /* All possible fates should have been accounted for by now. */
default:
printf("ERROR: %s has bad fate %d", pState->t->name, pState->t->fate);
abort();
}
- /* Call make1c() to begin the execution of the chain of commands */
- /* needed to build target. If we're not going to build target */
- /* (because of dependency failures or because no commands need to */
- /* be run) the chain will be empty and make1c() will directly */
- /* signal the completion of target. */
+ /* Call make1c() to begin the execution of the chain of commands */
+ /* needed to build target. If we're not going to build target */
+ /* (because of dependency failures or because no commands need to */
+ /* be run) the chain will be empty and make1c() will directly */
+ /* signal the completion of target. */
- /* Recurse on our dependents, manipulating progress to guard */
+ /* Recurse on our dependents, manipulating progress to guard. */
#ifdef OPT_SEMAPHORE
- /* If there is a semaphore, indicate that its in use */
- if( pState->t->semaphore )
- {
- ++(pState->t->semaphore->asynccnt);
-
- if( DEBUG_EXECCMD )
- printf( "SEM: %s now used by %s\n", pState->t->semaphore->name,
- pState->t->name );
- }
+ /* If there is a semaphore, indicate that it is in use. */
+ if ( pState->t->semaphore )
+ {
+ ++(pState->t->semaphore->asynccnt);
+
+ if ( DEBUG_EXECCMD )
+ printf( "SEM: %s now used by %s\n", pState->t->semaphore->name,
+ pState->t->name );
+ }
#endif
- pState->curstate = T_STATE_MAKE1C;
+ pState->curstate = T_STATE_MAKE1C;
}
+
/*
- * make1c() - launch target's next command, call make1b() when done
+ * make1c() - launch target's next command, call make1b() when done.
*/
static void
make1c( state *pState )
{
- CMD *cmd = (CMD *)pState->t->cmds;
+ CMD *cmd = (CMD *)pState->t->cmds;
+
+ /* If there are (more) commands to run to build this target */
+ /* (and we haven't hit an error running earlier comands) we */
+ /* launch the command with execcmd(). */
- /* If there are (more) commands to run to build this target */
- /* (and we haven't hit an error running earlier comands) we */
- /* launch the command with execcmd(). */
-
- /* If there are no more commands to run, we collect the status */
- /* from all the actions then report our completion to all the */
- /* parents. */
+ /* If there are no more commands to run, we collect the status */
+ /* from all the actions then report our completion to all the */
+ /* parents. */
- if( cmd && pState->t->status == EXEC_CMD_OK )
- {
+ if( cmd && pState->t->status == EXEC_CMD_OK )
+ {
char *rule_name = 0;
char *target = 0;
- if( DEBUG_MAKEQ ||
+ if( DEBUG_MAKEQ ||
! ( cmd->rule->actions->flags & RULE_QUIETLY ) && DEBUG_MAKE)
- {
+ {
rule_name = cmd->rule->name;
target = lol_get(&cmd->args, 0)->string;
if ( globs.noexec )
{
out_action(rule_name,target,cmd->buf,"","",EXIT_OK);
}
- }
+ }
- if( globs.noexec )
- {
- pState->curstate = T_STATE_MAKE1D;
- pState->status = EXEC_CMD_OK;
- }
- else
- {
- TARGET *t = pState->t;
-
- pop_state(&state_stack); /* pop state first because execcmd could push state */
- execcmd( cmd->buf, make_closure, t, cmd->shell, rule_name, target );
- }
- }
- else
- {
- TARGETS *c;
- ACTIONS *actions;
-
- /* Collect status from actions, and distribute it as well */
-
- for( actions = pState->t->actions; actions; actions = actions->next )
- if( actions->action->status > pState->t->status )
- pState->t->status = actions->action->status;
-
- for( actions = pState->t->actions; actions; actions = actions->next )
- if( pState->t->status > actions->action->status )
- actions->action->status = pState->t->status;
-
- /* Tally success/failure for those we tried to update. */
-
- if( pState->t->progress == T_MAKE_RUNNING )
- switch( pState->t->status )
- {
- case EXEC_CMD_OK:
- ++counts->made;
- break;
- case EXEC_CMD_FAIL:
- ++counts->failed;
- break;
- }
-
- /* Tell parents dependent has been built */
- {
- stack temp_stack = { NULL };
- TARGET *t = pState->t;
- TARGET* additional_includes = NULL;
-
- t->progress = T_MAKE_DONE;
-
- /* Target was updated. Rescan dependencies. */
- if (t->fate >= T_FATE_MISSING &&
- t->status == EXEC_CMD_OK &&
- !t->rescanned) {
+ if( globs.noexec )
+ {
+ pState->curstate = T_STATE_MAKE1D;
+ pState->status = EXEC_CMD_OK;
+ }
+ else
+ {
+ TARGET *t = pState->t;
+
+ pop_state(&state_stack); /* pop state first because execcmd could push state */
+ execcmd( cmd->buf, make_closure, t, cmd->shell, rule_name, target );
+ }
+ }
+ else
+ {
+ TARGETS *c;
+ ACTIONS *actions;
+
+ /* Collect status from actions, and distribute it as well */
+
+ for( actions = pState->t->actions; actions; actions = actions->next )
+ if( actions->action->status > pState->t->status )
+ pState->t->status = actions->action->status;
+
+ for( actions = pState->t->actions; actions; actions = actions->next )
+ if( pState->t->status > actions->action->status )
+ actions->action->status = pState->t->status;
+ /* Tally success/failure for those we tried to update. */
+
+ if( pState->t->progress == T_MAKE_RUNNING )
+ switch( pState->t->status )
+ {
+ case EXEC_CMD_OK:
+ ++counts->made;
+ break;
+ case EXEC_CMD_FAIL:
+ ++counts->failed;
+ break;
+ }
+
+ /* Tell parents their dependant has been built. */
+ {
+ stack temp_stack = { NULL };
+ TARGET * t = pState->t;
+ TARGET * additional_includes = NULL;
+
+ t->progress = T_MAKE_DONE;
+
+ /* Target has been updated. Rescan dependencies. */
+ if ( ( t->fate >= T_FATE_MISSING ) &&
+ ( t->status == EXEC_CMD_OK ) &&
+ !t->rescanned )
+ {
TARGET *target_to_rescan = t;
- SETTINGS *s;
+ SETTINGS *s;
target_to_rescan->rescanned = 1;
- if (target_to_rescan->flags & T_FLAG_INTERNAL) {
- target_to_rescan = t->original_target;
- }
+ if ( target_to_rescan->flags & T_FLAG_INTERNAL )
+ target_to_rescan = t->original_target;
- /* Clean current includes */
- if (target_to_rescan->includes) {
- target_to_rescan->includes = 0;
- }
+ /* Clean current includes. */
+ target_to_rescan->includes = 0;
s = copysettings( target_to_rescan->settings );
pushsettings( s );
- headers(target_to_rescan);
+ headers( target_to_rescan );
popsettings( s );
freesettings( s );
- if (target_to_rescan->includes) {
+ if ( target_to_rescan->includes )
+ {
target_to_rescan->includes->rescanned = 1;
- /* Tricky. The parents were already processed, but they
- did not seen the internal node, because it was just
- created. We need to make the calls to make1a that would
- have been done by parents here, and also make sure all
- unprocessed parents will pick up the includes. We must
- make sure processing of the additional make1a invocations
- is done before make1b which means this target is built,
- otherwise the parent will be considered built before this
- make1a processing is even started.
- */
- make0(target_to_rescan->includes, target_to_rescan->parents->target, 0, 0, 0);
- for( c = target_to_rescan->parents; c; c = c->next) {
- c->target->depends = targetentry( c->target->depends,
+ /* Tricky. The parents have already been processed, but they
+ * have not seen the internal node, because it was just
+ * created. We need to make the calls to make1a() that would
+ * have been made by the parents here, and also make sure
+ * all unprocessed parents will pick up the includes. We
+ * must make sure processing of the additional make1a()
+ * invocations is done before make1b() which means this
+ * target is built, otherwise the parent would be considered
+ * built before this make1a() processing has even started.
+ */
+ make0( target_to_rescan->includes, target_to_rescan->parents->target, 0, 0, 0 );
+ for ( c = target_to_rescan->parents; c; c = c->next )
+ {
+ c->target->depends = targetentry( c->target->depends,
target_to_rescan->includes );
}
/* Will be processed below. */
additional_includes = target_to_rescan->includes;
- }
+ }
}
- if (additional_includes)
- for ( c = t->parents; c; c = c->next ) {
+ if ( additional_includes )
+ for ( c = t->parents; c; c = c->next )
push_state(&temp_stack, additional_includes, c->target, T_STATE_MAKE1A);
-
- }
-
- for( c = t->parents; c; c = c->next ) {
- push_state(&temp_stack, c->target, NULL, T_STATE_MAKE1B);
- }
-
+ for ( c = t->parents; c; c = c->next )
+ push_state(&temp_stack, c->target, NULL, T_STATE_MAKE1B);
#ifdef OPT_SEMAPHORE
- /* If there is a semaphore, its now free */
- if( t->semaphore )
- {
- assert( t->semaphore->asynccnt == 1 );
- --(t->semaphore->asynccnt);
-
- if( DEBUG_EXECCMD )
- printf( "SEM: %s is now free\n", t->semaphore->name);
-
- /* If anything is waiting, notify the next target. There's no
- point in notifying all waiting targets, since they'll be
- serialized again. */
- if( t->semaphore->parents )
- {
- TARGETS *first = t->semaphore->parents;
- if( first->next )
- first->next->tail = first->tail;
- t->semaphore->parents = first->next;
-
- if( DEBUG_EXECCMD )
- printf( "SEM: placing %s on stack\n", first->target->name);
- push_state(&temp_stack, first->target, NULL, T_STATE_MAKE1B);
- BJAM_FREE( first );
- }
- }
+ /* If there is a semaphore, it is now free. */
+ if ( t->semaphore )
+ {
+ assert( t->semaphore->asynccnt == 1 );
+ --(t->semaphore->asynccnt);
+
+ if ( DEBUG_EXECCMD )
+ printf( "SEM: %s is now free\n", t->semaphore->name);
+
+ /* If anything is waiting, notify the next target. There is no
+ * point in notifying waiting targets, since they will be
+ * notified again.
+ */
+ if ( t->semaphore->parents )
+ {
+ TARGETS * first = t->semaphore->parents;
+ if ( first->next )
+ first->next->tail = first->tail;
+ t->semaphore->parents = first->next;
+
+ if ( DEBUG_EXECCMD )
+ printf( "SEM: placing %s on stack\n", first->target->name);
+ push_state( &temp_stack, first->target, NULL, T_STATE_MAKE1B );
+ BJAM_FREE( first );
+ }
+ }
#endif
-
- /* must pop state before pushing any more */
- pop_state(&state_stack);
-
- /* using stacks reverses the order of execution. Reverse it back */
- push_stack_on_stack(&state_stack, &temp_stack);
-
- }
- }
+ /* Must pop state before pushing any more. */
+ pop_state(&state_stack);
+
+ /* Using stacks reverses the order of execution. Reverse it back. */
+ push_stack_on_stack(&state_stack, &temp_stack);
+ }
+ }
}
-/* Look up the __TIMING_RULE__ variable on the given target, and if
- * non-empty, invoke the rule it names, passing the given
- * timing_info
+
+/* Look up the __TIMING_RULE__ variable on the given target, and if non-empty,
+ * invoke the rule it names, passing the given timing_info.
*/
-static void call_timing_rule(TARGET* target, timing_info* time)
+
+static void call_timing_rule( TARGET * target, timing_info * time )
{
- LIST* timing_rule;
-
+ LIST * timing_rule;
+
pushsettings(target->settings);
timing_rule = var_get( "__TIMING_RULE__" );
popsettings(target->settings);
@@ -709,10 +711,12 @@
}
}
-/* Look up the __ACTION_RULE__ variable on the given target, and if
- * non-empty, invoke the rule it names, passing the given info,
- * timing_info, executed command and command output
+
+/* Look up the __ACTION_RULE__ variable on the given target, and if non-empty,
+ * invoke the rule it names, passing the given info, timing_info, executed
+ * command and command output.
*/
+
static void call_action_rule(TARGET* target, int status, timing_info* time,
char *executed_command, char *command_output)
{
@@ -776,10 +780,11 @@
printf("%f sec system; %f sec user\n", time->system, time->user);
call_action_rule(built, status, time, executed_command, command_output);
-
+
push_state(&state_stack, built, NULL, T_STATE_MAKE1D)->status = status;
}
+
/*
* make1d() - handle command execution completion and call back make1c()
*/
@@ -787,75 +792,74 @@
static void
make1d(state *pState)
{
- TARGET *t = pState->t;
- CMD *cmd = (CMD *)t->cmds;
- int status = pState->status;
-
- /* Execcmd() has completed. All we need to do is fiddle with the */
- /* status and signal our completion so make1c() can run the next */
- /* command. On interrupts, we bail heavily. */
-
- if ( t->flags & T_FLAG_FAIL_EXPECTED )
- {
- /* invert execution result when FAIL_EXPECTED was applied */
- switch (status)
- {
+ TARGET * t = pState->t;
+ CMD * cmd = (CMD *)t->cmds;
+ int status = pState->status;
+
+ /* Execcmd() has completed. All we need to do is fiddle with the */
+ /* status and signal our completion so make1c() can run the next */
+ /* command. On interrupts, we bail heavily. */
+
+ if ( t->flags & T_FLAG_FAIL_EXPECTED )
+ {
+ /* Invert execution result when FAIL_EXPECTED has been applied. */
+ switch ( status )
+ {
case EXEC_CMD_FAIL: status = EXEC_CMD_OK; break;
case EXEC_CMD_OK: status = EXEC_CMD_FAIL; break;
- default:
- ;
- }
}
-
- if( status == EXEC_CMD_FAIL && ( cmd->rule->actions->flags & RULE_IGNORE ) )
- status = EXEC_CMD_OK;
+ }
- /* On interrupt, set intr so _everything_ fails */
+ if( status == EXEC_CMD_FAIL && ( cmd->rule->actions->flags & RULE_IGNORE ) )
+ status = EXEC_CMD_OK;
- if( status == EXEC_CMD_INTR )
- ++intr;
+ /* On interrupt, set intr so _everything_ fails. */
+ if( status == EXEC_CMD_INTR )
+ ++intr;
- if( status == EXEC_CMD_FAIL && DEBUG_MAKE )
- {
- /* Print command text on failure */
+ if( status == EXEC_CMD_FAIL && DEBUG_MAKE )
+ {
+ /* Print command text on failure */
- if( !DEBUG_EXEC )
- printf( "%s\n", cmd->buf );
+ if( !DEBUG_EXEC )
+ printf( "%s\n", cmd->buf );
- printf( "...failed %s ", cmd->rule->name );
- list_print( lol_get( &cmd->args, 0 ) );
- printf( "...\n" );
- }
+ printf( "...failed %s ", cmd->rule->name );
+ list_print( lol_get( &cmd->args, 0 ) );
+ printf( "...\n" );
+ }
- if (status == EXEC_CMD_FAIL)
- if( globs.quitquick ) ++intr;
+ if (status == EXEC_CMD_FAIL)
+ if( globs.quitquick ) ++intr;
- /* If the command was interrupted or failed and the target */
- /* is not "precious", remove the targets */
+ /* If the command was interrupted or failed and the target */
+ /* is not "precious", remove the targets */
- if( status != EXEC_CMD_OK && !( cmd->rule->actions->flags & RULE_TOGETHER ) )
- {
- LIST *targets = lol_get( &cmd->args, 0 );
+ if( status != EXEC_CMD_OK && !( cmd->rule->actions->flags & RULE_TOGETHER ) )
+ {
+ LIST *targets = lol_get( &cmd->args, 0 );
- for( ; targets; targets = list_next( targets ) )
- if( !unlink( targets->string ) )
- printf( "...removing %s\n", targets->string );
- }
+ for( ; targets; targets = list_next( targets ) )
+ if( !unlink( targets->string ) )
+ printf( "...removing %s\n", targets->string );
+ }
- /* Free this command and call make1c() to move onto next command. */
+ /* Free this command and call make1c() to move onto next command. */
- t->status = status;
- t->cmds = (char *)cmd_next( cmd );
+ t->status = status;
+ t->cmds = (char *)cmd_next( cmd );
- cmd_free( cmd );
+ cmd_free( cmd );
- pState->curstate = T_STATE_MAKE1C;
+ pState->curstate = T_STATE_MAKE1C;
}
+
/*
* swap_settings() - replace the settings from the current module and
* target with those from the new module and target
*/
+
static void swap_settings(
module_t** current_module
, TARGET** current_target
@@ -864,20 +868,20 @@
{
if (new_module == root_module())
new_module = 0;
-
+
if (new_target == *current_target && new_module == *current_module)
return;
if (*current_target)
popsettings( (*current_target)->settings );
-
+
if (new_module != *current_module)
{
if (*current_module)
exit_module( *current_module );
*current_module = new_module;
-
+
if (new_module)
enter_module( new_module );
}
@@ -887,266 +891,256 @@
pushsettings( new_target->settings );
}
+
/*
- * make1cmds() - turn ACTIONS into CMDs, grouping, splitting, etc
+ * make1cmds() - turn ACTIONS into CMDs, grouping, splitting, etc.
*
- * Essentially copies a chain of ACTIONs to a chain of CMDs,
- * grouping RULE_TOGETHER actions, splitting RULE_PIECEMEAL actions,
- * and handling RULE_NEWSRCS actions. The result is a chain of
- * CMDs which can be expanded by var_string() and executed with
- * execcmd().
+ * Essentially copies a chain of ACTIONs to a chain of CMDs, grouping
+ * RULE_TOGETHER actions, splitting RULE_PIECEMEAL actions, and handling
+ * RULE_NEWSRCS actions. The result is a chain of CMDs which can be expanded by
+ * var_string() and executed using execcmd().
*/
-static CMD *
-make1cmds( TARGET *t )
+static CMD * make1cmds( TARGET * t )
{
- CMD *cmds = 0;
- LIST *shell = 0;
-
- module_t *settings_module = 0;
- TARGET *settings_target = 0;
-
- /* Step through actions */
- /* Actions may be shared with other targets or grouped with */
- /* RULE_TOGETHER, so actions already seen are skipped. */
-
- ACTIONS* a0;
- for(a0 = t->actions ; a0; a0 = a0->next )
- {
- RULE *rule = a0->action->rule;
- rule_actions *actions = rule->actions;
- SETTINGS *boundvars;
- LIST *nt, *ns;
- ACTIONS *a1;
- int start, chunk, length;
-
- /* Only do rules with commands to execute. */
- /* If this action has already been executed, use saved status */
-
- if( !actions || a0->action->running )
- continue;
-
- a0->action->running = 1;
-
- /* Make LISTS of targets and sources */
- /* If `execute together` has been specified for this rule, tack */
- /* on sources from each instance of this rule for this target. */
-
- nt = make1list( L0, a0->action->targets, 0 );
- ns = make1list( L0, a0->action->sources, actions->flags );
-
- if( actions->flags & RULE_TOGETHER )
- for( a1 = a0->next; a1; a1 = a1->next )
- if( a1->action->rule == rule && !a1->action->running )
- {
- ns = make1list( ns, a1->action->sources, actions->flags );
- a1->action->running = 1;
- }
-
- /* If doing only updated (or existing) sources, but none have */
- /* been updated (or exist), skip this action. */
-
- if( !ns && ( actions->flags & ( RULE_NEWSRCS | RULE_EXISTING ) ) )
- {
- list_free( nt );
- continue;
- }
-
- swap_settings( &settings_module, &settings_target, rule->module, t );
- if (!shell)
- shell = var_get( "JAMSHELL" ); /* shell is per-target */
-
- /* If we had 'actions xxx bind vars' we bind the vars now */
-
- boundvars = make1settings( actions->bindlist );
- pushsettings( boundvars );
-
- /*
- * Build command, starting with all source args.
- *
- * If cmd_new returns 0, it's because the resulting command
- * length is > MAXLINE. In this case, we'll slowly reduce
- * the number of source arguments presented until it does
- * fit. This only applies to actions that allow PIECEMEAL
- * commands.
- *
- * While reducing slowly takes a bit of compute time to get
- * things just right, it's worth it to get as close to MAXLINE
- * as possible, because launching the commands we're executing
- * is likely to be much more compute intensive!
- *
- * Note we loop through at least once, for sourceless actions.
- */
-
- start = 0;
- chunk = length = list_length( ns );
-
- do
- {
- /* Build cmd: cmd_new consumes its lists. */
-
- CMD *cmd = cmd_new( rule,
- list_copy( L0, nt ),
- list_sublist( ns, start, chunk ),
- list_copy( L0, shell ) );
-
- if( cmd )
- {
- /* It fit: chain it up. */
-
- if( !cmds ) cmds = cmd;
- else cmds->tail->next = cmd;
- cmds->tail = cmd;
- start += chunk;
- }
- else if( ( actions->flags & RULE_PIECEMEAL ) && chunk > 1 )
- {
- /* Reduce chunk size slowly. */
-
- chunk = chunk * 9 / 10;
- }
- else
- {
- /* Too long and not splittable. */
+ CMD * cmds = 0;
+ LIST * shell = 0;
+ module_t * settings_module = 0;
+ TARGET * settings_target = 0;
+ ACTIONS * a0;
+
+ /* Step through actions. Actions may be shared with other targets or grouped
+ /* using RULE_TOGETHER, so actions already seen are skipped.
+ */
+ for ( a0 = t->actions ; a0; a0 = a0->next )
+ {
+ RULE * rule = a0->action->rule;
+ rule_actions * actions = rule->actions;
+ SETTINGS * boundvars;
+ LIST * nt;
+ LIST * ns;
+ ACTIONS * a1;
+ int start;
+ int chunk;
+ int length;
+
+ /* Only do rules with commands to execute. */
+ /* If this action has already been executed, use saved status */
+
+ if ( !actions || a0->action->running )
+ continue;
+
+ a0->action->running = 1;
+
+ /* Make LISTS of targets and sources */
+ /* If `execute together` has been specified for this rule, tack */
+ /* on sources from each instance of this rule for this target. */
+
+ nt = make1list( L0, a0->action->targets, 0 );
+ ns = make1list( L0, a0->action->sources, actions->flags );
+
+ if( actions->flags & RULE_TOGETHER )
+ for( a1 = a0->next; a1; a1 = a1->next )
+ if( a1->action->rule == rule && !a1->action->running )
+ {
+ ns = make1list( ns, a1->action->sources, actions->flags );
+ a1->action->running = 1;
+ }
+
+ /* If doing only updated (or existing) sources, but none have */
+ /* been updated (or exist), skip this action. */
+
+ if( !ns && ( actions->flags & ( RULE_NEWSRCS | RULE_EXISTING ) ) )
+ {
+ list_free( nt );
+ continue;
+ }
+
+ swap_settings( &settings_module, &settings_target, rule->module, t );
+ if (!shell)
+ shell = var_get( "JAMSHELL" ); /* shell is per-target */
+
+ /* If we had 'actions xxx bind vars' we bind the vars now. */
+
+ boundvars = make1settings( actions->bindlist );
+ pushsettings( boundvars );
+
+ /*
+ * Build command, starting with all source args.
+ *
+ * If cmd_new returns 0, it's because the resulting command
+ * length is > MAXLINE. In this case, we'll slowly reduce
+ * the number of source arguments presented until it does
+ * fit. This only applies to actions that allow PIECEMEAL
+ * commands.
+ *
+ * While reducing slowly takes a bit of compute time to get
+ * things just right, it's worth it to get as close to MAXLINE
+ * as possible, because launching the commands we're executing
+ * is likely to be much more compute intensive!
+ *
+ * Note we loop through at least once, for sourceless actions.
+ */
+
+ start = 0;
+ chunk = length = list_length( ns );
+
+ do
+ {
+ /* Build cmd: cmd_new consumes its lists. */
+
+ CMD *cmd = cmd_new( rule,
+ list_copy( L0, nt ),
+ list_sublist( ns, start, chunk ),
+ list_copy( L0, shell ) );
+
+ if( cmd )
+ {
+ /* It fit: chain it up. */
+
+ if( !cmds ) cmds = cmd;
+ else cmds->tail->next = cmd;
+ cmds->tail = cmd;
+ start += chunk;
+ }
+ else if( ( actions->flags & RULE_PIECEMEAL ) && chunk > 1 )
+ {
+ /* Reduce chunk size slowly. */
+
+ chunk = chunk * 9 / 10;
+ }
+ else
+ {
+ /* Too long and not splittable. */
- printf( "%s actions too long (max %d):\n",
- rule->name, MAXLINE );
+ printf( "%s actions too long (max %d):\n",
+ rule->name, MAXLINE );
/* Tell the user what didn't fit */
cmd = cmd_new(
- rule, list_copy( L0, nt ),
- list_sublist( ns, start, chunk ),
- list_new( L0, newstr( "%" ) ) );
+ rule, list_copy( L0, nt ),
+ list_sublist( ns, start, chunk ),
+ list_new( L0, newstr( "%" ) ) );
printf( cmd->buf );
-
- exit( EXITBAD );
- }
- }
- while( start < length );
-
- /* These were always copied when used. */
-
- list_free( nt );
- list_free( ns );
-
- /* Free the variables whose values were bound by */
- /* 'actions xxx bind vars' */
-
- popsettings( boundvars );
- freesettings( boundvars );
- }
- swap_settings( &settings_module, &settings_target, 0, 0 );
- return cmds;
+ exit( EXITBAD );
+ }
+ }
+ while( start < length );
+
+ /* These were always copied when used. */
+
+ list_free( nt );
+ list_free( ns );
+
+ /* Free the variables whose values were bound by */
+ /* 'actions xxx bind vars' */
+
+ popsettings( boundvars );
+ freesettings( boundvars );
+ }
+
+ swap_settings( &settings_module, &settings_target, 0, 0 );
+ return cmds;
}
+
/*
- * make1list() - turn a list of targets into a LIST, for $(<) and $(>)
+ * make1list() - turn a list of targets into a LIST, for $(<) and $(>).
*/
-static LIST *
-make1list(
- LIST *l,
- TARGETS *targets,
- int flags )
+static LIST * make1list( LIST * l, TARGETS * targets, int flags )
{
for( ; targets; targets = targets->next )
{
- TARGET *t = targets->target;
+ TARGET * t = targets->target;
- if( t->binding == T_BIND_UNBOUND )
- make1bind( t );
+ if ( t->binding == T_BIND_UNBOUND )
+ make1bind( t );
- if ( ( flags & RULE_EXISTING ) && ( flags & RULE_NEWSRCS ) )
- {
- if ( t->binding != T_BIND_EXISTS && t->fate <= T_FATE_STABLE)
- continue;
- }
- else
- {
- if( ( flags & RULE_EXISTING ) && t->binding != T_BIND_EXISTS )
- continue;
-
- if( ( flags & RULE_NEWSRCS ) && t->fate <= T_FATE_STABLE )
- continue;
- }
-
- /* Prohibit duplicates for RULE_TOGETHER */
+ if ( ( flags & RULE_EXISTING ) && ( flags & RULE_NEWSRCS ) )
+ {
+ if ( t->binding != T_BIND_EXISTS && t->fate <= T_FATE_STABLE )
+ continue;
+ }
+ else
+ {
+ if ( ( flags & RULE_EXISTING ) && t->binding != T_BIND_EXISTS )
+ continue;
- if( flags & RULE_TOGETHER )
- {
- LIST *m;
+ if ( ( flags & RULE_NEWSRCS ) && t->fate <= T_FATE_STABLE )
+ continue;
+ }
- for( m = l; m; m = m->next )
- if( !strcmp( m->string, t->boundname ) )
- break;
+ /* Prohibit duplicates for RULE_TOGETHER. */
+ if ( flags & RULE_TOGETHER )
+ {
+ LIST * m;
- if( m )
- continue;
- }
+ for ( m = l; m; m = m->next )
+ if ( !strcmp( m->string, t->boundname ) )
+ break;
- /* Build new list */
+ if ( m )
+ continue;
+ }
- l = list_new( l, copystr( t->boundname ) );
+ /* Build new list. */
+ l = list_new( l, copystr( t->boundname ) );
}
return l;
}
+
/*
- * make1settings() - for vars that get bound values, build up replacement lists
+ * make1settings() - for vars that get bound values, build up replacement lists.
*/
-static SETTINGS *
-make1settings( LIST *vars )
+static SETTINGS * make1settings( LIST * vars )
{
- SETTINGS *settings = 0;
-
- for( ; vars; vars = list_next( vars ) )
- {
- LIST *l = var_get( vars->string );
- LIST *nl = 0;
-
- for( ; l; l = list_next( l ) )
- {
- TARGET *t = bindtarget( l->string );
+ SETTINGS * settings = 0;
- /* Make sure the target is bound */
-
- if( t->binding == T_BIND_UNBOUND )
- make1bind( t );
+ for ( ; vars; vars = list_next( vars ) )
+ {
+ LIST * l = var_get( vars->string );
+ LIST * nl = 0;
- /* Build new list */
+ for ( ; l; l = list_next( l ) )
+ {
+ TARGET * t = bindtarget( l->string );
- nl = list_new( nl, copystr( t->boundname ) );
- }
+ /* Make sure the target is bound. */
+ if ( t->binding == T_BIND_UNBOUND )
+ make1bind( t );
- /* Add to settings chain */
+ /* Build new list. */
+ nl = list_new( nl, copystr( t->boundname ) );
+ }
- settings = addsettings( settings, VAR_SET, vars->string, nl );
- }
+ /* Add to settings chain. */
+ settings = addsettings( settings, VAR_SET, vars->string, nl );
+ }
- return settings;
+ return settings;
}
+
/*
- * make1bind() - bind targets that weren't bound in dependency analysis
+ * make1bind() - bind targets that were not bound during dependency analysis
*
- * Spot the kludge! If a target is not in the dependency tree, it didn't
- * get bound by make0(), so we have to do it here. Ugly.
+ * Spot the kludge! If a target is not in the dependency tree, it did not get
+ * get bound by make0(), so we have to do it here. Ugly.
*/
-static void
-make1bind(
- TARGET *t )
+static void make1bind( TARGET * t )
{
- if( t->flags & T_FLAG_NOTFILE )
- return;
+ if ( t->flags & T_FLAG_NOTFILE )
+ return;
- pushsettings( t->settings );
- t->boundname = search( t->name, &t->time, 0,
- (t->flags & T_FLAG_ISFILE) );
- t->binding = t->time ? T_BIND_EXISTS : T_BIND_MISSING;
- popsettings( t->settings );
+ pushsettings( t->settings );
+ t->boundname = search( t->name, &t->time, 0, ( t->flags & T_FLAG_ISFILE ) );
+ t->binding = t->time ? T_BIND_EXISTS : T_BIND_MISSING;
+ popsettings( t->settings );
}
Modified: trunk/tools/jam/src/mem.c
==============================================================================
--- trunk/tools/jam/src/mem.c (original)
+++ trunk/tools/jam/src/mem.c 2008-08-29 08:59:49 EDT (Fri, 29 Aug 2008)
@@ -16,7 +16,7 @@
#define ATOMIC_UNCOLLECTABLE
#define NO_EXECUTE_PERMISSION
#define ALL_INTERIOR_POINTERS
-
+
#define LARGE_CONFIG
/*
#define NO_SIGNALS
@@ -25,11 +25,11 @@
#ifndef GC_DEBUG
#define NO_DEBUGGING
#endif
-
+
#ifdef __GLIBC__
#define __USE_GNU
#endif
-
+
#include "boehm_gc/reclaim.c"
#include "boehm_gc/allchblk.c"
#include "boehm_gc/misc.c"
@@ -60,7 +60,7 @@
#include "boehm_gc/gc_dlopen.c"
#include "boehm_gc/backgraph.c"
#include "boehm_gc/win32_threads.c"
-
+
/* Needs to be last. */
#include "boehm_gc/finalize.c"
Modified: trunk/tools/jam/src/mem.h
==============================================================================
--- trunk/tools/jam/src/mem.h (original)
+++ trunk/tools/jam/src/mem.h 2008-08-29 08:59:49 EDT (Fri, 29 Aug 2008)
@@ -25,7 +25,7 @@
#define bjam_calloc_raw_x(n,s) calloc(n,s)
#define bjam_realloc_raw_x(p,s) realloc(p,s)
#define bjam_free_raw_x(p) free(p)
-
+
#ifndef BJAM_NEWSTR_NO_ALLOCATE
#define BJAM_NEWSTR_NO_ALLOCATE
#endif
@@ -54,7 +54,7 @@
#define bjam_calloc_x(n,s) calloc(n,s)
#define bjam_realloc_x(p,s) realloc(p,s)
#define bjam_free_x(p) free(p)
-
+
#ifndef BJAM_NEWSTR_NO_ALLOCATE
#define BJAM_NEWSTR_NO_ALLOCATE
#endif
Modified: trunk/tools/jam/src/mkjambase.c
==============================================================================
--- trunk/tools/jam/src/mkjambase.c (original)
+++ trunk/tools/jam/src/mkjambase.c 2008-08-29 08:59:49 EDT (Fri, 29 Aug 2008)
@@ -17,10 +17,10 @@
*
* Results look like this:
*
- * char *jambase[] = {
- * "...\n",
- * ...
- * 0 };
+ * char *jambase[] = {
+ * "...\n",
+ * ...
+ * 0 };
*
* Handles \'s and "'s specially; knows to delete blank and comment lines.
*
@@ -31,101 +31,101 @@
int main( int argc, char **argv, char **envp )
{
- char buf[ 1024 ];
- FILE *fin;
- FILE *fout;
- char *p;
- int doDotC = 0;
-
- if( argc < 3 )
- {
- fprintf( stderr, "usage: %s jambase.c Jambase ...\n", argv[0] );
- return -1;
- }
-
- if( !( fout = fopen( argv[1], "w" ) ) )
- {
- perror( argv[1] );
- return -1;
- }
-
- /* If the file ends in .c generate a C source file */
-
- if( ( p = strrchr( argv[1], '.' ) ) && !strcmp( p, ".c" ) )
- doDotC++;
-
- /* Now process the files */
-
- argc -= 2, argv += 2;
-
- if( doDotC )
- {
- fprintf( fout, "/* Generated by mkjambase from Jambase */\n" );
- fprintf( fout, "char *jambase[] = {\n" );
- }
-
- for( ; argc--; argv++ )
- {
- if( !( fin = fopen( *argv, "r" ) ) )
- {
- perror( *argv );
- return -1;
- }
-
- if( doDotC )
- {
- fprintf( fout, "/* %s */\n", *argv );
- }
- else
- {
- fprintf( fout, "### %s ###\n", *argv );
- }
-
- while( fgets( buf, sizeof( buf ), fin ) )
- {
- if( doDotC )
- {
- char *p = buf;
-
- /* Strip leading whitespace. */
-
- while( *p == ' ' || *p == '\t' || *p == '\n' )
- p++;
-
- /* Drop comments and empty lines. */
-
- if( *p == '#' || !*p )
- continue;
-
- /* Copy */
-
- putc( '"', fout );
-
- for( ; *p && *p != '\n'; p++ )
- switch( *p )
- {
- case '\\': putc( '\\', fout ); putc( '\\', fout ); break;
- case '"': putc( '\\', fout ); putc( '"', fout ); break;
+ char buf[ 1024 ];
+ FILE *fin;
+ FILE *fout;
+ char *p;
+ int doDotC = 0;
+
+ if( argc < 3 )
+ {
+ fprintf( stderr, "usage: %s jambase.c Jambase ...\n", argv[0] );
+ return -1;
+ }
+
+ if( !( fout = fopen( argv[1], "w" ) ) )
+ {
+ perror( argv[1] );
+ return -1;
+ }
+
+ /* If the file ends in .c generate a C source file */
+
+ if( ( p = strrchr( argv[1], '.' ) ) && !strcmp( p, ".c" ) )
+ doDotC++;
+
+ /* Now process the files */
+
+ argc -= 2, argv += 2;
+
+ if( doDotC )
+ {
+ fprintf( fout, "/* Generated by mkjambase from Jambase */\n" );
+ fprintf( fout, "char *jambase[] = {\n" );
+ }
+
+ for( ; argc--; argv++ )
+ {
+ if( !( fin = fopen( *argv, "r" ) ) )
+ {
+ perror( *argv );
+ return -1;
+ }
+
+ if( doDotC )
+ {
+ fprintf( fout, "/* %s */\n", *argv );
+ }
+ else
+ {
+ fprintf( fout, "### %s ###\n", *argv );
+ }
+
+ while( fgets( buf, sizeof( buf ), fin ) )
+ {
+ if( doDotC )
+ {
+ char *p = buf;
+
+ /* Strip leading whitespace. */
+
+ while( *p == ' ' || *p == '\t' || *p == '\n' )
+ p++;
+
+ /* Drop comments and empty lines. */
+
+ if( *p == '#' || !*p )
+ continue;
+
+ /* Copy */
+
+ putc( '"', fout );
+
+ for( ; *p && *p != '\n'; p++ )
+ switch( *p )
+ {
+ case '\\': putc( '\\', fout ); putc( '\\', fout ); break;
+ case '"': putc( '\\', fout ); putc( '"', fout ); break;
case '\r': break;
- default: putc( *p, fout ); break;
- }
+ default: putc( *p, fout ); break;
+ }
- fprintf( fout, "\\n\",\n" );
- }
- else
- {
- fprintf( fout, "%s", buf );
- }
-
- }
-
- fclose( fin );
- }
-
- if( doDotC )
- fprintf( fout, "0 };\n" );
+ fprintf( fout, "\\n\",\n" );
+ }
+ else
+ {
+ fprintf( fout, "%s", buf );
+ }
- fclose( fout );
+ }
- return 0;
+ fclose( fin );
+ }
+
+ if( doDotC )
+ fprintf( fout, "0 };\n" );
+
+ fclose( fout );
+
+ return 0;
}
Modified: trunk/tools/jam/src/modules.c
==============================================================================
--- trunk/tools/jam/src/modules.c (original)
+++ trunk/tools/jam/src/modules.c 2008-08-29 08:59:49 EDT (Fri, 29 Aug 2008)
@@ -16,11 +16,12 @@
#include "strings.h"
#include <assert.h>
-static struct hash* module_hash = 0;
+static struct hash * module_hash = 0;
-static char* new_module_str( module_t* m, char* suffix )
+
+static char * new_module_str( module_t * m, char * suffix )
{
- char* result;
+ char * result;
string s;
string_copy( &s, m->name );
string_append( &s, suffix );
@@ -29,10 +30,11 @@
return result;
}
-module_t* bindmodule( char* name )
+
+module_t * bindmodule( char * name )
{
PROFILE_ENTER(BINDMODULE);
-
+
string s;
module_t m_, *m = &m_;
@@ -45,9 +47,9 @@
string_append( &s, name );
string_push_back( &s, '.' );
}
-
+
m->name = s.value;
-
+
if ( hashenter( module_hash, (HASHDATA **)&m ) )
{
m->name = newstr( m->name );
@@ -115,46 +117,47 @@
var_hash_swap( &m->variables );
}
-void exit_module( module_t* m )
+
+void exit_module( module_t * m )
{
var_hash_swap( &m->variables );
}
-void import_module(LIST* module_names, module_t* target_module)
+
+void import_module( LIST * module_names, module_t * target_module )
{
PROFILE_ENTER(IMPORT_MODULE);
-
- struct hash* h;
-
- if (!target_module->imported_modules)
- target_module->imported_modules = hashinit( sizeof(char*), "imported");
+
+ struct hash * h;
+
+ if ( !target_module->imported_modules )
+ target_module->imported_modules = hashinit( sizeof( char * ), "imported" );
h = target_module->imported_modules;
- for(;module_names; module_names = module_names->next) {
-
- char* s = module_names->string;
- char** ss = &s;
-
- hashenter(h, (HASHDATA**)&ss);
+ for ( ; module_names; module_names = module_names->next )
+ {
+ char * s = module_names->string;
+ char * * ss = &s;
+ hashenter( h, (HASHDATA * *)&ss );
}
-
+
PROFILE_EXIT(IMPORT_MODULE);
}
-static void add_module_name( void* r_, void* result_ )
+
+static void add_module_name( void * r_, void * result_ )
{
- char** r = (char**)r_;
- LIST** result = (LIST**)result_;
+ char * * r = (char * *)r_;
+ LIST * * result = (LIST * *)result_;
*result = list_new( *result, copystr( *r ) );
}
-LIST* imported_modules(module_t* module)
-{
- LIST *result = L0;
+LIST * imported_modules( module_t * module )
+{
+ LIST * result = L0;
if ( module->imported_modules )
hashenumerate( module->imported_modules, add_module_name, &result );
-
return result;
}
Modified: trunk/tools/jam/src/native.h
==============================================================================
--- trunk/tools/jam/src/native.h (original)
+++ trunk/tools/jam/src/native.h 2008-08-29 08:59:49 EDT (Fri, 29 Aug 2008)
@@ -24,9 +24,9 @@
};
/* MSVC debugger gets confused unless this is provided */
-typedef struct native_rule_t native_rule_t ;
+typedef struct native_rule_t native_rule_t ;
-void declare_native_rule(char* module, char* rule, char** args,
+void declare_native_rule(char* module, char* rule, char** args,
LIST*(*f)(PARSE*, FRAME*), int version);
Modified: trunk/tools/jam/src/newstr.c
==============================================================================
--- trunk/tools/jam/src/newstr.c (original)
+++ trunk/tools/jam/src/newstr.c 2008-08-29 08:59:49 EDT (Fri, 29 Aug 2008)
@@ -26,7 +26,7 @@
*
* Once a string is passed to newstr(), the returned string is readonly.
*
- * This implementation builds a hash table of all strings, so that multiple
+ * This implementation builds a hash table of all strings, so that multiple
* calls of newstr() on the same string allocate memory for the string once.
* Strings are never actually freed.
*/
@@ -104,25 +104,25 @@
char *
newstr( char *string )
{
- STRING str, *s = &str;
+ STRING str, *s = &str;
- if( !strhash )
- strhash = hashinit( sizeof( STRING ), "strings" );
+ if( !strhash )
+ strhash = hashinit( sizeof( STRING ), "strings" );
- *s = string;
+ *s = string;
- if( hashenter( strhash, (HASHDATA **)&s ) )
- {
- int l = strlen( string );
- char *m = (char *)allocate( l + 1 );
-
- strtotal += l + 1;
- memcpy( m, string, l + 1 );
- *s = m;
- }
+ if( hashenter( strhash, (HASHDATA **)&s ) )
+ {
+ int l = strlen( string );
+ char *m = (char *)allocate( l + 1 );
+
+ strtotal += l + 1;
+ memcpy( m, string, l + 1 );
+ *s = m;
+ }
strcount_in += 1;
- return *s;
+ return *s;
}
/*
@@ -133,7 +133,7 @@
copystr( char *s )
{
strcount_in += 1;
- return s;
+ return s;
}
/*
@@ -160,11 +160,11 @@
BJAM_FREE(strblock_chain);
strblock_chain = n;
}
-
+
hashdone( strhash );
-
+
if( DEBUG_MEM )
printf( "%dK in strings\n", strtotal / 1024 );
-
+
/* printf( "--- %d strings of %d dangling\n", strcount_in-strcount_out, strcount_in ); */
}
Modified: trunk/tools/jam/src/option.c
==============================================================================
--- trunk/tools/jam/src/option.c (original)
+++ trunk/tools/jam/src/option.c 2008-08-29 08:59:49 EDT (Fri, 29 Aug 2008)
@@ -12,9 +12,9 @@
*
* {o >o
* \<>) "Process command line options as defined in <option.h>.
- * Return the number of argv[] elements used up by options,
- * or -1 if an invalid option flag was given or an argument
- * was supplied for an option that does not require one."
+ * Return the number of argv[] elements used up by options,
+ * or -1 if an invalid option flag was given or an argument
+ * was supplied for an option that does not require one."
*/
int
@@ -31,73 +31,68 @@
for( i = 0; i < argc; i++ )
{
- char *arg;
+ char *arg;
- if( argv[i][0] != '-' || ( argv[i][1] != '-' && !isalpha( argv[i][1] ) ) )
- continue;
+ if( argv[i][0] != '-' || ( argv[i][1] != '-' && !isalpha( argv[i][1] ) ) )
+ continue;
- if( !optc-- )
- {
- printf( "too many options (%d max)\n", N_OPTS );
- return -1;
- }
-
- for( arg = &argv[i][1]; *arg; arg++ )
- {
- char *f;
-
- for( f = opts; *f; f++ )
- if( *f == *arg )
- break;
-
- if( !*f )
- {
- printf( "Invalid option: -%c\n", *arg );
- return -1;
- }
-
- optv->flag = *f;
-
- if( f[1] != ':' )
- {
- optv++->val = "true";
- }
- else if( arg[1] )
- {
- optv++->val = &arg[1];
- break;
- }
- else if( ++i < argc )
- {
- optv++->val = argv[i];
- break;
- }
- else
- {
- printf( "option: -%c needs argument\n", *f );
- return -1;
- }
- }
+ if( !optc-- )
+ {
+ printf( "too many options (%d max)\n", N_OPTS );
+ return -1;
+ }
+
+ for( arg = &argv[i][1]; *arg; arg++ )
+ {
+ char *f;
+
+ for( f = opts; *f; f++ )
+ if( *f == *arg )
+ break;
+
+ if( !*f )
+ {
+ printf( "Invalid option: -%c\n", *arg );
+ return -1;
+ }
+
+ optv->flag = *f;
+
+ if( f[1] != ':' )
+ {
+ optv++->val = "true";
+ }
+ else if( arg[1] )
+ {
+ optv++->val = &arg[1];
+ break;
+ }
+ else if( ++i < argc )
+ {
+ optv++->val = argv[i];
+ break;
+ }
+ else
+ {
+ printf( "option: -%c needs argument\n", *f );
+ return -1;
+ }
+ }
}
return i;
}
+
/*
- * Name: getoptval() - find an option given its character
+ * Name: getoptval() - find an option given its character.
*/
-char *
-getoptval(
- option *optv,
- char opt,
- int subopt )
+char * getoptval( option * optv, char opt, int subopt )
{
- int i;
-
- for( i = 0; i < N_OPTS; i++, optv++ )
- if( optv->flag == opt && !subopt-- )
- return optv->val;
-
- return 0;
+ int i;
+ for ( i = 0; i < N_OPTS; ++i, ++optv )
+ if ( ( optv->flag == opt ) && !subopt-- )
+ return optv->val;
+ return 0;
}
Modified: trunk/tools/jam/src/option.h
==============================================================================
--- trunk/tools/jam/src/option.h (original)
+++ trunk/tools/jam/src/option.h 2008-08-29 08:59:49 EDT (Fri, 29 Aug 2008)
@@ -13,11 +13,11 @@
typedef struct option
{
- char flag; /* filled in by getoption() */
- char *val; /* set to random address if true */
+ char flag; /* filled in by getoption() */
+ char *val; /* set to random address if true */
} option;
# define N_OPTS 256
-int getoptions( int argc, char **argv, char *opts, option *optv );
-char * getoptval( option *optv, char opt, int subopt );
+int getoptions( int argc, char **argv, char *opts, option *optv );
+char * getoptval( option *optv, char opt, int subopt );
Modified: trunk/tools/jam/src/output.c
==============================================================================
--- trunk/tools/jam/src/output.c (original)
+++ trunk/tools/jam/src/output.c 2008-08-29 08:59:49 EDT (Fri, 29 Aug 2008)
@@ -1,4 +1,4 @@
-/*
+/*
Copyright 2007 Rene Rivera
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)
@@ -12,10 +12,11 @@
#define bjam_out (stdout)
#define bjam_err (stderr)
-static void out_(
- const char * data,
- FILE * io
- )
+static void out_
+(
+ char const * data,
+ FILE * io
+)
{
while ( *data )
{
@@ -26,36 +27,39 @@
}
}
-void out_action(
- const char * action,
- const char * target,
- const char * command,
- const char * out_data,
- const char * err_data,
- int exit_reason
- )
+
+void out_action
+(
+ char const * action,
+ char const * target,
+ char const * command,
+ char const * out_data,
+ char const * err_data,
+ int exit_reason
+)
{
- /* print out the action+target line, if the action is quite
- the action should be null. */
+ /* Print out the action+target line, if the action is quite the action
+ * should be null.
+ */
if ( action )
{
- fprintf(bjam_out,"%s %s\n",action,target);
+ fprintf( bjam_out, "%s %s\n", action, target );
}
-
- /* print out the command executed if given -d+2 */
+
+ /* Print out the command executed if given -d+2. */
if ( DEBUG_EXEC )
{
- fputs(command,bjam_out);
- fputc('\n',bjam_out);
+ fputs( command, bjam_out );
+ fputc( '\n', bjam_out );
}
-
- /* print out the command executed to the command stream */
+
+ /* Print out the command executed to the command stream. */
if ( globs.cmdout )
{
- fputs(command,globs.cmdout);
+ fputs( command, globs.cmdout );
}
- switch (exit_reason)
+ switch ( exit_reason )
{
case EXIT_OK:
break;
@@ -63,59 +67,60 @@
break;
case EXIT_TIMEOUT:
{
- /* process expired, make user aware with explicit message */
+ /* Process expired, make user aware with explicit message. */
if ( action )
{
- /* but only output for non-quietly actions */
- fprintf(bjam_out, "%d second time limit exceeded\n", globs.timeout);
+ /* But only output for non-quietly actions. */
+ fprintf( bjam_out, "%d second time limit exceeded\n", globs.timeout );
}
break;
}
default:
break;
}
-
- /* print out the command output, if requested */
+
+ /* Print out the command output, if requested. */
if ( action )
{
- /* but only output for non-quietly actions */
- if (0 != out_data &&
- ( globs.pipe_action & 1 /* STDOUT_FILENO */ ||
- globs.pipe_action == 0))
+ /* But only output for non-quietly actions. */
+ if ( ( 0 != out_data ) &&
+ ( ( globs.pipe_action & 1 /* STDOUT_FILENO */ ) ||
+ ( globs.pipe_action == 0 ) ) )
{
- out_(out_data,bjam_out);
+ out_( out_data, bjam_out );
}
- if (0 != err_data &&
- globs.pipe_action & 2 /* STDERR_FILENO */)
+ if ( ( 0 != err_data ) &&
+ ( globs.pipe_action & 2 /* STDERR_FILENO */ ) )
{
- out_(err_data,bjam_err);
+ out_( err_data, bjam_err );
}
}
-
- fflush(bjam_out);
- fflush(bjam_err);
- fflush(globs.cmdout);
+
+ fflush( bjam_out );
+ fflush( bjam_err );
+ fflush( globs.cmdout );
}
char * outf_int( int value )
{
char buffer[50];
- sprintf(buffer, "%i", value);
- return newstr(buffer);
+ sprintf( buffer, "%i", value );
+ return newstr( buffer );
}
+
char * outf_double( double value )
{
char buffer[50];
- sprintf(buffer, "%f", value);
- return newstr(buffer);
+ sprintf( buffer, "%f", value );
+ return newstr( buffer );
}
+
char * outf_time( time_t value )
{
char buffer[50];
- strftime(buffer,49,"%Y-%m-%d %H:%M:%SZ",gmtime(&value));
- return newstr(buffer);
+ strftime( buffer, 49, "%Y-%m-%d %H:%M:%SZ", gmtime( &value ) );
+ return newstr( buffer );
}
-
Modified: trunk/tools/jam/src/output.h
==============================================================================
--- trunk/tools/jam/src/output.h (original)
+++ trunk/tools/jam/src/output.h 2008-08-29 08:59:49 EDT (Fri, 29 Aug 2008)
@@ -1,4 +1,4 @@
-/*
+/*
Copyright 2007 Rene Rivera
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)
Modified: trunk/tools/jam/src/parse.c
==============================================================================
--- trunk/tools/jam/src/parse.c (original)
+++ trunk/tools/jam/src/parse.c 2008-08-29 08:59:49 EDT (Fri, 29 Aug 2008)
@@ -22,9 +22,9 @@
* parse.c - make and destroy parse trees as driven by the parser
*
* 09/07/00 (seiwald) - ref count on PARSE to avoid freeing when used,
- * as per Matt Armstrong.
+ * as per Matt Armstrong.
* 09/11/00 (seiwald) - structure reworked to reflect that (*func)()
- * returns a LIST *.
+ * returns a LIST *.
*/
static PARSE *yypsave;
@@ -32,63 +32,63 @@
void
parse_file( char *f, FRAME* frame )
{
- /* Suspend scan of current file */
- /* and push this new file in the stream */
+ /* Suspend scan of current file */
+ /* and push this new file in the stream */
- yyfparse(f);
+ yyfparse(f);
- /* Now parse each block of rules and execute it. */
- /* Execute it outside of the parser so that recursive */
- /* calls to yyrun() work (no recursive yyparse's). */
+ /* Now parse each block of rules and execute it. */
+ /* Execute it outside of the parser so that recursive */
+ /* calls to yyrun() work (no recursive yyparse's). */
- for(;;)
- {
- PARSE *p;
+ for(;;)
+ {
+ PARSE *p;
- /* Filled by yyparse() calling parse_save() */
+ /* Filled by yyparse() calling parse_save() */
- yypsave = 0;
+ yypsave = 0;
- /* If parse error or empty parse, outta here */
+ /* If parse error or empty parse, outta here */
- if( yyparse() || !( p = yypsave ) )
- break;
+ if( yyparse() || !( p = yypsave ) )
+ break;
- /* Run the parse tree. */
+ /* Run the parse tree. */
parse_evaluate( p, frame );
- parse_free( p );
- }
+ parse_free( p );
+ }
}
void
parse_save( PARSE *p )
{
- yypsave = p;
+ yypsave = p;
}
-PARSE *
-parse_make(
- LIST *(*func)( PARSE *p, FRAME *args ),
- PARSE *left,
- PARSE *right,
- PARSE *third,
- char *string,
- char *string1,
- int num )
-{
- PARSE *p = (PARSE *)BJAM_MALLOC( sizeof( PARSE ) );
-
- p->func = func;
- p->left = left;
- p->right = right;
- p->third = third;
- p->string = string;
- p->string1 = string1;
- p->num = num;
- p->refs = 1;
+
+PARSE * parse_make(
+ LIST *(*func)( PARSE *p, FRAME *args ),
+ PARSE *left,
+ PARSE *right,
+ PARSE *third,
+ char *string,
+ char *string1,
+ int num )
+{
+ PARSE *p = (PARSE *)BJAM_MALLOC( sizeof( PARSE ) );
+
+ p->func = func;
+ p->left = left;
+ p->right = right;
+ p->third = third;
+ p->string = string;
+ p->string1 = string1;
+ p->num = num;
+ p->refs = 1;
p->rulename = 0;
-
+
if ( left )
{
p->file = left->file;
@@ -99,39 +99,40 @@
yyinput_stream( &p->file, &p->line );
}
- return p;
+ return p;
}
void
parse_refer( PARSE *p )
{
- ++p->refs;
+ ++p->refs;
}
-void
-parse_free( PARSE *p )
+
+void parse_free( PARSE * p )
{
- if( --p->refs )
- return;
+ if ( --p->refs )
+ return;
+
+ if ( p->string )
+ freestr( p->string );
+ if ( p->string1 )
+ freestr( p->string1 );
+ if ( p->left )
+ parse_free( p->left );
+ if ( p->right )
+ parse_free( p->right );
+ if ( p->third )
+ parse_free( p->third );
+ if ( p->rulename )
+ freestr( p->rulename );
- if( p->string )
- freestr( p->string );
- if( p->string1 )
- freestr( p->string1 );
- if( p->left )
- parse_free( p->left );
- if( p->right )
- parse_free( p->right );
- if( p->third )
- parse_free( p->third );
- if ( p->rulename )
- freestr( p->rulename );
-
- BJAM_FREE( (char *)p );
+ BJAM_FREE( (char *)p );
}
-LIST* parse_evaluate( PARSE *p, FRAME* frame )
+
+LIST * parse_evaluate( PARSE * p, FRAME * frame )
{
frame->procedure = p;
- return (*p->func)(p, frame);
+ return (*p->func)( p, frame );
}
Modified: trunk/tools/jam/src/parse.h
==============================================================================
--- trunk/tools/jam/src/parse.h (original)
+++ trunk/tools/jam/src/parse.h 2008-08-29 08:59:49 EDT (Fri, 29 Aug 2008)
@@ -42,7 +42,7 @@
void parse_file( char *f, FRAME* frame );
void parse_save( PARSE *p );
-PARSE * parse_make(
+PARSE * parse_make(
LIST *(*func)( PARSE *p, FRAME* frame ),
PARSE *left,
PARSE *right,
Modified: trunk/tools/jam/src/pathmac.c
==============================================================================
--- trunk/tools/jam/src/pathmac.c (original)
+++ trunk/tools/jam/src/pathmac.c 2008-08-29 08:59:49 EDT (Fri, 29 Aug 2008)
@@ -22,9 +22,9 @@
*
* External routines:
*
- * path_parse() - split a file name into dir/base/suffix/member
- * path_build() - build a filename given dir/base/suffix/member
- * path_parent() - make a PATHNAME point to its parent dir
+ * path_parse() - split a file name into dir/base/suffix/member
+ * path_build() - build a filename given dir/base/suffix/member
+ * path_parent() - make a PATHNAME point to its parent dir
*
* File_parse() and path_build() just manipuate a string and a structure;
* they do not make system calls.
@@ -41,10 +41,10 @@
* 03/16/95 (seiwald) - fixed accursed typo on line 69.
* 05/03/96 (seiwald) - split from filent.c, fileunix.c
* 12/20/96 (seiwald) - when looking for the rightmost . in a file name,
- * don't include the archive member name.
+ * don't include the archive member name.
* 01/10/01 (seiwald) - path_parse now strips the trailing : from the
- * directory name, unless the directory name is all
- * :'s, so that $(d:P) works.
+ * directory name, unless the directory name is all
+ * :'s, so that $(d:P) works.
*/
/*
@@ -52,131 +52,131 @@
*/
void
-path_parse(
- char *file,
- PATHNAME *f )
+path_parse(
+ char *file,
+ PATHNAME *f )
{
- char *p, *q;
- char *end;
-
- memset( (char *)f, 0, sizeof( *f ) );
-
- /* Look for <grist> */
-
- if( file[0] == '<' && ( p = strchr( file, '>' ) ) )
- {
- f->f_grist.ptr = file;
- f->f_grist.len = p - file;
- file = p + 1;
- }
-
- /* Look for dir: */
-
- if( p = strrchr( file, DELIM ) )
- {
- f->f_dir.ptr = file;
- f->f_dir.len = p - file;
- file = p + 1;
-
- /* All :'s? Include last : as part of directory name */
-
- while( p > f->f_dir.ptr && *--p == DELIM )
- ;
-
- if( p == f->f_dir.ptr )
- f->f_dir.len++;
- }
-
- end = file + strlen( file );
-
- /* Look for (member) */
-
- if( ( p = strchr( file, '(' ) ) && end[-1] == ')' )
- {
- f->f_member.ptr = p + 1;
- f->f_member.len = end - p - 2;
- end = p;
- }
-
- /* Look for .suffix */
- /* This would be memrchr() */
-
- p = 0;
- q = file;
-
- while( q = memchr( q, '.', end - q ) )
- p = q++;
-
- if( p )
- {
- f->f_suffix.ptr = p;
- f->f_suffix.len = end - p;
- end = p;
- }
+ char *p, *q;
+ char *end;
- /* Leaves base */
+ memset( (char *)f, 0, sizeof( *f ) );
- f->f_base.ptr = file;
- f->f_base.len = end - file;
+ /* Look for <grist> */
+
+ if( file[0] == '<' && ( p = strchr( file, '>' ) ) )
+ {
+ f->f_grist.ptr = file;
+ f->f_grist.len = p - file;
+ file = p + 1;
+ }
+
+ /* Look for dir: */
+
+ if( p = strrchr( file, DELIM ) )
+ {
+ f->f_dir.ptr = file;
+ f->f_dir.len = p - file;
+ file = p + 1;
+
+ /* All :'s? Include last : as part of directory name */
+
+ while( p > f->f_dir.ptr && *--p == DELIM )
+ ;
+
+ if( p == f->f_dir.ptr )
+ f->f_dir.len++;
+ }
+
+ end = file + strlen( file );
+
+ /* Look for (member) */
+
+ if( ( p = strchr( file, '(' ) ) && end[-1] == ')' )
+ {
+ f->f_member.ptr = p + 1;
+ f->f_member.len = end - p - 2;
+ end = p;
+ }
+
+ /* Look for .suffix */
+ /* This would be memrchr() */
+
+ p = 0;
+ q = file;
+
+ while( q = memchr( q, '.', end - q ) )
+ p = q++;
+
+ if( p )
+ {
+ f->f_suffix.ptr = p;
+ f->f_suffix.len = end - p;
+ end = p;
+ }
+
+ /* Leaves base */
+
+ f->f_base.ptr = file;
+ f->f_base.len = end - file;
}
/*
- * path_build() - build a filename given dir/base/suffix/member
+ * path_build() - build a filename given dir/base/suffix/member.
*/
-
-# define DIR_EMPTY 0 /* "" */
-# define DIR_DOT 1 /* : */
-# define DIR_DOTDOT 2 /* :: */
-# define DIR_ABS 3 /* dira:dirb: */
-# define DIR_REL 4 /* :dira:dirb: */
-
-# define G_DIR 0 /* take dir */
-# define G_ROOT 1 /* take root */
-# define G_CAT 2 /* prepend root to dir */
-# define G_DTDR 3 /* :: of rel dir */
-# define G_DDDD 4 /* make it ::: (../..) */
-# define G_MT 5 /* leave it empty */
+
+# define DIR_EMPTY 0 /* "" */
+# define DIR_DOT 1 /* : */
+# define DIR_DOTDOT 2 /* :: */
+# define DIR_ABS 3 /* dira:dirb: */
+# define DIR_REL 4 /* :dira:dirb: */
+
+# define G_DIR 0 /* take dir */
+# define G_ROOT 1 /* take root */
+# define G_CAT 2 /* prepend root to dir */
+# define G_DTDR 3 /* :: of rel dir */
+# define G_DDDD 4 /* make it ::: (../..) */
+# define G_MT 5 /* leave it empty */
char grid[5][5] = {
-/* EMPTY DOT DOTDOT ABS REL */
-/* EMPTY */ { G_MT, G_DIR, G_DIR, G_DIR, G_DIR },
-/* DOT */ { G_ROOT, G_DIR, G_DIR, G_DIR, G_DIR },
-/* DOTDOT */ { G_ROOT, G_ROOT, G_DDDD, G_DIR, G_DTDR },
-/* ABS */ { G_ROOT, G_ROOT, G_ROOT, G_DIR, G_CAT },
-/* REL */ { G_ROOT, G_ROOT, G_ROOT, G_DIR, G_CAT }
+/* EMPTY DOT DOTDOT ABS REL */
+/* EMPTY */ { G_MT, G_DIR, G_DIR, G_DIR, G_DIR },
+/* DOT */ { G_ROOT, G_DIR, G_DIR, G_DIR, G_DIR },
+/* DOTDOT */ { G_ROOT, G_ROOT, G_DDDD, G_DIR, G_DTDR },
+/* ABS */ { G_ROOT, G_ROOT, G_ROOT, G_DIR, G_CAT },
+/* REL */ { G_ROOT, G_ROOT, G_ROOT, G_DIR, G_CAT }
} ;
static int
-file_flags(
- char *ptr,
- int len )
+file_flags(
+ char *ptr,
+ int len )
{
- if( !len )
- return DIR_EMPTY;
- if( len == 1 && ptr[0] == DELIM )
- return DIR_DOT;
- if( len == 2 && ptr[0] == DELIM && ptr[1] == DELIM )
- return DIR_DOTDOT;
- if( ptr[0] == DELIM )
- return DIR_REL;
- return DIR_ABS;
+ if( !len )
+ return DIR_EMPTY;
+ if( len == 1 && ptr[0] == DELIM )
+ return DIR_DOT;
+ if( len == 2 && ptr[0] == DELIM && ptr[1] == DELIM )
+ return DIR_DOTDOT;
+ if( ptr[0] == DELIM )
+ return DIR_REL;
+ return DIR_ABS;
}
void
path_build(
- PATHNAME *f,
- string* file,
- int binding )
+ PATHNAME *f,
+ string* file,
+ int binding )
{
int dflag, rflag, act;
file_build1( f, file );
-
+
/* Combine root & directory, according to the grid. */
-
+
dflag = file_flags( f->f_dir.ptr, f->f_dir.len );
rflag = file_flags( f->f_root.ptr, f->f_root.len );
-
+
switch( act = grid[ rflag ][ dflag ] )
{
case G_DTDR:
@@ -185,35 +185,35 @@
string_push_back( file, DELIM );
}
/* fall through */
-
- case G_DIR:
+
+ case G_DIR:
/* take dir */
string_append_range( file, f->f_dir.ptr, f->f_dir.ptr + f->f_dir.len );
break;
-
- case G_ROOT:
+
+ case G_ROOT:
/* take root */
string_append_range( file, f->f_root.ptr, f->f_root.ptr + f->f_root.len );
break;
-
- case G_CAT:
+
+ case G_CAT:
/* prepend root to dir */
string_append_range( file, f->f_root.ptr, f->f_root.ptr + f->f_root.len );
if( file->value[file->size - 1] == DELIM )
string_pop_back( file );
string_append_range( file, f->f_dir.ptr, f->f_dir.ptr + f->f_dir.len );
break;
-
- case G_DDDD:
+
+ case G_DDDD:
/* make it ::: (../..) */
string_append( file, ":::" );
break;
}
/* Put : between dir and file (if none already) */
-
- if( act != G_MT &&
- file->value[file->size - 1] != DELIM &&
+
+ if( act != G_MT &&
+ file->value[file->size - 1] != DELIM &&
( f->f_base.len || f->f_suffix.len ) )
{
string_push_back( file, DELIM );
@@ -235,27 +235,27 @@
string_append_range( file, f->f_member.ptr, f->f_member.ptr + f->f_member.len );
string_push_back( file, ')' );
}
-
+
if( DEBUG_SEARCH )
printf(" -> '%s'\n", file->value);
}
/*
- * path_parent() - make a PATHNAME point to its parent dir
+ * path_parent() - make a PATHNAME point to its parent dir
*/
void
path_parent( PATHNAME *f )
{
- /* just set everything else to nothing */
+ /* just set everything else to nothing */
- f->f_base.ptr =
- f->f_suffix.ptr =
- f->f_member.ptr = "";
-
- f->f_base.len =
- f->f_suffix.len =
- f->f_member.len = 0;
+ f->f_base.ptr =
+ f->f_suffix.ptr =
+ f->f_member.ptr = "";
+
+ f->f_base.len =
+ f->f_suffix.len =
+ f->f_member.len = 0;
}
# endif /* OS_MAC */
Modified: trunk/tools/jam/src/pathsys.h
==============================================================================
--- trunk/tools/jam/src/pathsys.h (original)
+++ trunk/tools/jam/src/pathsys.h 2008-08-29 08:59:49 EDT (Fri, 29 Aug 2008)
@@ -5,7 +5,7 @@
*/
/*
- * pathsys.h - PATHNAME struct
+ * pathsys.h - PATHNAME struct
*/
/*
@@ -13,7 +13,7 @@
*
* <grist> is salt to distinguish between targets that otherwise would
* have the same name: it never appears in the bound name of a target.
- * (member) is an archive member name: the syntax is arbitrary, but must
+ * (member) is an archive member name: the syntax is arbitrary, but must
* agree in path_parse(), path_build() and the Jambase.
*
* On VMS, we keep track of whether the original path was a directory
@@ -29,22 +29,22 @@
typedef struct _pathpart PATHPART;
struct _pathpart {
- char *ptr;
- int len;
+ char *ptr;
+ int len;
};
struct _pathname {
- PATHPART part[6];
+ PATHPART part[6];
# ifdef OS_VMS
- int parent;
+ int parent;
# endif
-# define f_grist part[0]
-# define f_root part[1]
-# define f_dir part[2]
-# define f_base part[3]
-# define f_suffix part[4]
-# define f_member part[5]
+# define f_grist part[0]
+# define f_root part[1]
+# define f_dir part[2]
+# define f_base part[3]
+# define f_suffix part[4]
+# define f_member part[5]
} ;
Modified: trunk/tools/jam/src/pathunix.c
==============================================================================
--- trunk/tools/jam/src/pathunix.c (original)
+++ trunk/tools/jam/src/pathunix.c 2008-08-29 08:59:49 EDT (Fri, 29 Aug 2008)
@@ -29,9 +29,9 @@
*
* External routines:
*
- * path_parse() - split a file name into dir/base/suffix/member
- * path_build() - build a filename given dir/base/suffix/member
- * path_parent() - make a PATHNAME point to its parent dir
+ * path_parse() - split a file name into dir/base/suffix/member
+ * path_build() - build a filename given dir/base/suffix/member
+ * path_parent() - make a PATHNAME point to its parent dir
*
* File_parse() and path_build() just manipuate a string and a structure;
* they do not make system calls.
@@ -48,7 +48,7 @@
* 03/16/95 (seiwald) - fixed accursed typo on line 69.
* 05/03/96 (seiwald) - split from filent.c, fileunix.c
* 12/20/96 (seiwald) - when looking for the rightmost . in a file name,
- * don't include the archive member name.
+ * don't include the archive member name.
* 01/13/01 (seiwald) - turn on \ handling on UNIX, on by accident
*/
@@ -57,87 +57,87 @@
*/
void
-path_parse(
- char *file,
- PATHNAME *f )
+path_parse(
+ char *file,
+ PATHNAME *f )
{
- char *p, *q;
- char *end;
-
- memset( (char *)f, 0, sizeof( *f ) );
-
- /* Look for <grist> */
-
- if( file[0] == '<' && ( p = strchr( file, '>' ) ) )
- {
- f->f_grist.ptr = file;
- f->f_grist.len = p - file;
- file = p + 1;
- }
+ char *p, *q;
+ char *end;
- /* Look for dir/ */
+ memset( (char *)f, 0, sizeof( *f ) );
- p = strrchr( file, '/' );
+ /* Look for <grist> */
+
+ if( file[0] == '<' && ( p = strchr( file, '>' ) ) )
+ {
+ f->f_grist.ptr = file;
+ f->f_grist.len = p - file;
+ file = p + 1;
+ }
+
+ /* Look for dir/ */
+
+ p = strrchr( file, '/' );
# if PATH_DELIM == '\\'
- /* On NT, look for dir\ as well */
- {
- char *p1 = strrchr( file, '\\' );
- p = p1 > p ? p1 : p;
- }
+ /* On NT, look for dir\ as well */
+ {
+ char *p1 = strrchr( file, '\\' );
+ p = p1 > p ? p1 : p;
+ }
# endif
- if( p )
- {
- f->f_dir.ptr = file;
- f->f_dir.len = p - file;
-
- /* Special case for / - dirname is /, not "" */
+ if( p )
+ {
+ f->f_dir.ptr = file;
+ f->f_dir.len = p - file;
+
+ /* Special case for / - dirname is /, not "" */
- if( !f->f_dir.len )
- f->f_dir.len = 1;
+ if( !f->f_dir.len )
+ f->f_dir.len = 1;
# if PATH_DELIM == '\\'
- /* Special case for D:/ - dirname is D:/, not "D:" */
+ /* Special case for D:/ - dirname is D:/, not "D:" */
- if( f->f_dir.len == 2 && file[1] == ':' )
- f->f_dir.len = 3;
+ if( f->f_dir.len == 2 && file[1] == ':' )
+ f->f_dir.len = 3;
# endif
- file = p + 1;
- }
+ file = p + 1;
+ }
- end = file + strlen( file );
+ end = file + strlen( file );
- /* Look for (member) */
+ /* Look for (member) */
- if( ( p = strchr( file, '(' ) ) && end[-1] == ')' )
- {
- f->f_member.ptr = p + 1;
- f->f_member.len = end - p - 2;
- end = p;
- }
+ if( ( p = strchr( file, '(' ) ) && end[-1] == ')' )
+ {
+ f->f_member.ptr = p + 1;
+ f->f_member.len = end - p - 2;
+ end = p;
+ }
- /* Look for .suffix */
- /* This would be memrchr() */
+ /* Look for .suffix */
+ /* This would be memrchr() */
- p = 0;
- q = file;
+ p = 0;
+ q = file;
- while( q = (char *)memchr( q, '.', end - q ) )
- p = q++;
+ while( q = (char *)memchr( q, '.', end - q ) )
+ p = q++;
- if( p )
- {
- f->f_suffix.ptr = p;
- f->f_suffix.len = end - p;
- end = p;
- }
+ if( p )
+ {
+ f->f_suffix.ptr = p;
+ f->f_suffix.len = end - p;
+ end = p;
+ }
- /* Leaves base */
+ /* Leaves base */
- f->f_base.ptr = file;
- f->f_base.len = end - file;
+ f->f_base.ptr = file;
+ f->f_base.len = end - file;
}
/*
@@ -188,22 +188,22 @@
void
path_build(
- PATHNAME *f,
- string *file,
- int binding )
+ PATHNAME *f,
+ string *file,
+ int binding )
{
file_build1( f, file );
-
+
/* Don't prepend root if it's . or directory is rooted */
# if PATH_DELIM == '/'
- if( f->f_root.len
+ if( f->f_root.len
&& !( f->f_root.len == 1 && f->f_root.ptr[0] == '.' )
&& !( f->f_dir.len && f->f_dir.ptr[0] == '/' ) )
# else /* unix */
- if( f->f_root.len
+ if( f->f_root.len
&& !( f->f_root.len == 1 && f->f_root.ptr[0] == '.' )
&& !( f->f_dir.len && f->f_dir.ptr[0] == '/' )
&& !( f->f_dir.len && f->f_dir.ptr[0] == '\\' )
@@ -213,7 +213,7 @@
{
string_append_range( file, f->f_root.ptr, f->f_root.ptr + f->f_root.len );
- /* If 'root' already ends with path delimeter,
+ /* If 'root' already ends with path delimeter,
don't add yet 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] ) );
@@ -258,21 +258,21 @@
}
/*
- * path_parent() - make a PATHNAME point to its parent dir
+ * path_parent() - make a PATHNAME point to its parent dir
*/
void
path_parent( PATHNAME *f )
{
- /* just set everything else to nothing */
+ /* just set everything else to nothing */
- f->f_base.ptr =
- f->f_suffix.ptr =
- f->f_member.ptr = "";
-
- f->f_base.len =
- f->f_suffix.len =
- f->f_member.len = 0;
+ f->f_base.ptr =
+ f->f_suffix.ptr =
+ f->f_member.ptr = "";
+
+ f->f_base.len =
+ f->f_suffix.len =
+ f->f_member.len = 0;
}
#ifdef NT
@@ -296,7 +296,7 @@
/* Is the string valid? */
if (!lpszShortPath) {
SetLastError(ERROR_INVALID_PARAMETER);
- return 0;
+ return 0;
}
/* Is the path valid? */
@@ -305,7 +305,7 @@
/* Convert "/" to "\" */
for (i=0;i<len;++i) {
- if (lpszShortPath[i]==_T('/'))
+ if (lpszShortPath[i]==_T('/'))
path[i]=_T('\\');
else
path[i]=lpszShortPath[i];
@@ -331,7 +331,7 @@
}
_tcsncpy(ret,path,2);
}
-
+
/* Expand the path for each subpath, and strip trailing backslashes */
for (prev_pos = pos-1;pos<=len;++pos) {
if (path[pos]==_T('\\') || (path[pos]==_T('\0') &&
@@ -356,9 +356,9 @@
/* If it's ".." element, we need to append it, not
the name in parent that FindFirstFile will return.
Same goes for "." */
-
+
if (new_element[0] == _T('.') && new_element[1] == _T('\0') ||
- new_element[0] == _T('.') && new_element[1] == _T('.')
+ new_element[0] == _T('.') && new_element[1] == _T('.')
&& new_element[2] == _T('\0'))
{
_tcscat(ret, new_element);
@@ -378,21 +378,21 @@
prev_pos = pos;
}
}
-
+
len=_tcslen(ret)+1;
if (cchBuffer>=len)
_tcscpy(lpszLongPath,ret);
-
+
return len;
}
char* short_path_to_long_path(char* short_path)
-{
+{
char buffer2[_MAX_PATH];
int ret = ShortPathToLongPath(short_path, buffer2, _MAX_PATH);
if (ret)
- return newstr(buffer2);
+ return newstr(buffer2);
else
return newstr(short_path);
}
@@ -446,14 +446,14 @@
const char * path_tmpfile(void)
{
const char * result = 0;
-
+
string file_path;
string_copy(&file_path,path_tmpdir());
string_push_back(&file_path,PATH_DELIM);
string_append(&file_path,path_tmpnam());
result = newstr(file_path.value);
string_free(&file_path);
-
+
return result;
}
Modified: trunk/tools/jam/src/pathvms.c
==============================================================================
--- trunk/tools/jam/src/pathvms.c (original)
+++ trunk/tools/jam/src/pathvms.c 2008-08-29 08:59:49 EDT (Fri, 29 Aug 2008)
@@ -22,14 +22,14 @@
*
* External routines:
*
- * path_parse() - split a file name into dir/base/suffix/member
- * path_build() - build a filename given dir/base/suffix/member
- * path_parent() - make a PATHNAME point to its parent dir
+ * path_parse() - split a file name into dir/base/suffix/member
+ * path_build() - build a filename given dir/base/suffix/member
+ * path_parent() - make a PATHNAME point to its parent dir
*
* File_parse() and path_build() just manipuate a string and a structure;
* they do not make system calls.
*
- * WARNING! This file contains voodoo logic, as black magic is
+ * WARNING! This file contains voodoo logic, as black magic is
* necessary for wrangling with VMS file name. Woe be to people
* who mess with this code.
*
@@ -42,192 +42,192 @@
*/
void
-path_parse(
- char *file,
- PATHNAME *f )
+path_parse(
+ char *file,
+ PATHNAME *f )
{
- char *p, *q;
- char *end;
-
- memset( (char *)f, 0, sizeof( *f ) );
+ char *p, *q;
+ char *end;
- /* Look for <grist> */
+ memset( (char *)f, 0, sizeof( *f ) );
- if( file[0] == '<' && ( p = strchr( file, '>' ) ) )
- {
- f->f_grist.ptr = file;
- f->f_grist.len = p - file;
- file = p + 1;
- }
+ /* Look for <grist> */
- /* Look for dev:[dir] or dev: */
+ if( file[0] == '<' && ( p = strchr( file, '>' ) ) )
+ {
+ f->f_grist.ptr = file;
+ f->f_grist.len = p - file;
+ file = p + 1;
+ }
+
+ /* Look for dev:[dir] or dev: */
- if( ( p = strchr( file, ']' ) ) || ( p = strchr( file, ':' ) ) )
- {
- f->f_dir.ptr = file;
- f->f_dir.len = p + 1 - file;
- file = p + 1;
- }
+ if( ( p = strchr( file, ']' ) ) || ( p = strchr( file, ':' ) ) )
+ {
+ f->f_dir.ptr = file;
+ f->f_dir.len = p + 1 - file;
+ file = p + 1;
+ }
- end = file + strlen( file );
+ end = file + strlen( file );
- /* Look for (member) */
+ /* Look for (member) */
- if( ( p = strchr( file, '(' ) ) && end[-1] == ')' )
- {
- f->f_member.ptr = p + 1;
- f->f_member.len = end - p - 2;
- end = p;
- }
+ if( ( p = strchr( file, '(' ) ) && end[-1] == ')' )
+ {
+ f->f_member.ptr = p + 1;
+ f->f_member.len = end - p - 2;
+ end = p;
+ }
- /* Look for .suffix */
- /* This would be memrchr() */
+ /* Look for .suffix */
+ /* This would be memrchr() */
- p = 0;
- q = file;
+ p = 0;
+ q = file;
- while( q = (char *)memchr( q, '.', end - q ) )
- p = q++;
+ while( q = (char *)memchr( q, '.', end - q ) )
+ p = q++;
- if( p )
- {
- f->f_suffix.ptr = p;
- f->f_suffix.len = end - p;
- end = p;
- }
+ if( p )
+ {
+ f->f_suffix.ptr = p;
+ f->f_suffix.len = end - p;
+ end = p;
+ }
- /* Leaves base */
+ /* Leaves base */
- f->f_base.ptr = file;
- f->f_base.len = end - file;
+ f->f_base.ptr = file;
+ f->f_base.len = end - file;
- /* Is this a directory without a file spec? */
+ /* Is this a directory without a file spec? */
- f->parent = 0;
+ f->parent = 0;
}
/*
- * dir mods result
- * --- --- ------
+ * dir mods result
+ * --- --- ------
* Rerooting:
*
- * (none) :R=dev: dev:
- * devd: :R=dev: devd:
- * devd:[dir] :R=dev: devd:[dir]
- * [.dir] :R=dev: dev:[dir] questionable
- * [dir] :R=dev: dev:[dir]
+ * (none) :R=dev: dev:
+ * devd: :R=dev: devd:
+ * devd:[dir] :R=dev: devd:[dir]
+ * [.dir] :R=dev: dev:[dir] questionable
+ * [dir] :R=dev: dev:[dir]
*
- * (none) :R=[rdir] [rdir] questionable
- * devd: :R=[rdir] devd:
- * devd:[dir] :R=[rdir] devd:[dir]
- * [.dir] :R=[rdir] [rdir.dir] questionable
- * [dir] :R=[rdir] [rdir]
+ * (none) :R=[rdir] [rdir] questionable
+ * devd: :R=[rdir] devd:
+ * devd:[dir] :R=[rdir] devd:[dir]
+ * [.dir] :R=[rdir] [rdir.dir] questionable
+ * [dir] :R=[rdir] [rdir]
*
- * (none) :R=dev:[root] dev:[root]
- * devd: :R=dev:[root] devd:
- * devd:[dir] :R=dev:[root] devd:[dir]
- * [.dir] :R=dev:[root] dev:[root.dir]
- * [dir] :R=dev:[root] [dir]
+ * (none) :R=dev:[root] dev:[root]
+ * devd: :R=dev:[root] devd:
+ * devd:[dir] :R=dev:[root] devd:[dir]
+ * [.dir] :R=dev:[root] dev:[root.dir]
+ * [dir] :R=dev:[root] [dir]
*
* Climbing to parent:
*
*/
-# define DIR_EMPTY 0 /* empty string */
-# define DIR_DEV 1 /* dev: */
-# define DIR_DEVDIR 2 /* dev:[dir] */
-# define DIR_DOTDIR 3 /* [.dir] */
-# define DIR_DASHDIR 4 /* [-] or [-.dir] */
-# define DIR_ABSDIR 5 /* [dir] */
-# define DIR_ROOT 6 /* [000000] or dev:[000000] */
-
-# define G_DIR 0 /* take just dir */
-# define G_ROOT 1 /* take just root */
-# define G_VAD 2 /* root's dev: + [abs] */
-# define G_DRD 3 /* root's dev:[dir] + [.rel] */
-# define G_VRD 4 /* root's dev: + [.rel] made [abs] */
-# define G_DDD 5 /* root's dev:[dir] + . + [dir] */
+# define DIR_EMPTY 0 /* empty string */
+# define DIR_DEV 1 /* dev: */
+# define DIR_DEVDIR 2 /* dev:[dir] */
+# define DIR_DOTDIR 3 /* [.dir] */
+# define DIR_DASHDIR 4 /* [-] or [-.dir] */
+# define DIR_ABSDIR 5 /* [dir] */
+# define DIR_ROOT 6 /* [000000] or dev:[000000] */
+
+# define G_DIR 0 /* take just dir */
+# define G_ROOT 1 /* take just root */
+# define G_VAD 2 /* root's dev: + [abs] */
+# define G_DRD 3 /* root's dev:[dir] + [.rel] */
+# define G_VRD 4 /* root's dev: + [.rel] made [abs] */
+# define G_DDD 5 /* root's dev:[dir] + . + [dir] */
static int grid[7][7] = {
-/* root/dir EMPTY DEV DEVDIR DOTDIR DASH, ABSDIR ROOT */
-/* EMPTY */ G_DIR, G_DIR, G_DIR, G_DIR, G_DIR, G_DIR, G_DIR,
-/* DEV */ G_ROOT, G_DIR, G_DIR, G_VRD, G_VAD, G_VAD, G_VAD,
-/* DEVDIR */ G_ROOT, G_DIR, G_DIR, G_DRD, G_VAD, G_VAD, G_VAD,
-/* DOTDIR */ G_ROOT, G_DIR, G_DIR, G_DRD, G_DIR, G_DIR, G_DIR,
-/* DASHDIR */ G_ROOT, G_DIR, G_DIR, G_DRD, G_DDD, G_DIR, G_DIR,
-/* ABSDIR */ G_ROOT, G_DIR, G_DIR, G_DRD, G_DIR, G_DIR, G_DIR,
-/* ROOT */ G_ROOT, G_DIR, G_DIR, G_VRD, G_DIR, G_DIR, G_DIR,
+/* root/dir EMPTY DEV DEVDIR DOTDIR DASH, ABSDIR ROOT */
+/* EMPTY */ G_DIR, G_DIR, G_DIR, G_DIR, G_DIR, G_DIR, G_DIR,
+/* DEV */ G_ROOT, G_DIR, G_DIR, G_VRD, G_VAD, G_VAD, G_VAD,
+/* DEVDIR */ G_ROOT, G_DIR, G_DIR, G_DRD, G_VAD, G_VAD, G_VAD,
+/* DOTDIR */ G_ROOT, G_DIR, G_DIR, G_DRD, G_DIR, G_DIR, G_DIR,
+/* DASHDIR */ G_ROOT, G_DIR, G_DIR, G_DRD, G_DDD, G_DIR, G_DIR,
+/* ABSDIR */ G_ROOT, G_DIR, G_DIR, G_DRD, G_DIR, G_DIR, G_DIR,
+/* ROOT */ G_ROOT, G_DIR, G_DIR, G_VRD, G_DIR, G_DIR, G_DIR,
} ;
struct dirinf {
- int flags;
+ int flags;
- struct {
- char *ptr;
- int len;
- } dev, dir;
+ struct {
+ char *ptr;
+ int len;
+ } dev, dir;
} ;
static char *
-strnchr(
- char *buf,
- int c,
- int len )
+strnchr(
+ char *buf,
+ int c,
+ int len )
{
- while( len-- )
- if( *buf && *buf++ == c )
- return buf - 1;
+ while( len-- )
+ if( *buf && *buf++ == c )
+ return buf - 1;
- return 0;
+ return 0;
}
static void
-dir_flags(
- char *buf,
- int len,
- struct dirinf *i )
+dir_flags(
+ char *buf,
+ int len,
+ struct dirinf *i )
{
- char *p;
+ char *p;
- if( !buf || !len )
- {
- i->flags = DIR_EMPTY;
- i->dev.ptr =
- i->dir.ptr = 0;
- i->dev.len =
- i->dir.len = 0;
- }
- else if( p = strnchr( buf, ':', len ) )
- {
- i->dev.ptr = buf;
- i->dev.len = p + 1 - buf;
- i->dir.ptr = buf + i->dev.len;
- i->dir.len = len - i->dev.len;
- i->flags = i->dir.len && *i->dir.ptr == '[' ? DIR_DEVDIR : DIR_DEV;
- }
- else
- {
- i->dev.ptr = buf;
- i->dev.len = 0;
- i->dir.ptr = buf;
- i->dir.len = len;
-
- if( *buf == '[' && buf[1] == ']' )
- i->flags = DIR_EMPTY;
- else if( *buf == '[' && buf[1] == '.' )
- i->flags = DIR_DOTDIR;
- else if( *buf == '[' && buf[1] == '-' )
- i->flags = DIR_DASHDIR;
- else
- i->flags = DIR_ABSDIR;
- }
+ if( !buf || !len )
+ {
+ i->flags = DIR_EMPTY;
+ i->dev.ptr =
+ i->dir.ptr = 0;
+ i->dev.len =
+ i->dir.len = 0;
+ }
+ else if( p = strnchr( buf, ':', len ) )
+ {
+ i->dev.ptr = buf;
+ i->dev.len = p + 1 - buf;
+ i->dir.ptr = buf + i->dev.len;
+ i->dir.len = len - i->dev.len;
+ i->flags = i->dir.len && *i->dir.ptr == '[' ? DIR_DEVDIR : DIR_DEV;
+ }
+ else
+ {
+ i->dev.ptr = buf;
+ i->dev.len = 0;
+ i->dir.ptr = buf;
+ i->dir.len = len;
+
+ if( *buf == '[' && buf[1] == ']' )
+ i->flags = DIR_EMPTY;
+ else if( *buf == '[' && buf[1] == '.' )
+ i->flags = DIR_DOTDIR;
+ else if( *buf == '[' && buf[1] == '-' )
+ i->flags = DIR_DASHDIR;
+ else
+ i->flags = DIR_ABSDIR;
+ }
- /* But if its rooted in any way */
+ /* But if its rooted in any way */
- if( i->dir.len == 8 && !strncmp( i->dir.ptr, "[000000]", 8 ) )
- i->flags = DIR_ROOT;
+ if( i->dir.len == 8 && !strncmp( i->dir.ptr, "[000000]", 8 ) )
+ i->flags = DIR_ROOT;
}
/*
@@ -236,15 +236,15 @@
void
path_build(
- PATHNAME *f,
- string *file,
- int binding )
+ PATHNAME *f,
+ string *file,
+ int binding )
{
struct dirinf root, dir;
int g;
file_build1( f, file );
-
+
/* Get info on root and dir for combining. */
dir_flags( f->f_root.ptr, f->f_root.len, &root );
@@ -254,23 +254,23 @@
switch( g = grid[ root.flags ][ dir.flags ] )
{
- case G_DIR:
+ case G_DIR:
/* take dir */
string_append_range( file, f->f_dir.ptr, f->f_dir.ptr + f->f_dir.len );
break;
- case G_ROOT:
+ case G_ROOT:
/* take root */
string_append_range( file, f->f_root.ptr, f->f_root.ptr + f->f_root.len );
break;
- case G_VAD:
+ case G_VAD:
/* root's dev + abs directory */
string_append_range( file, root.dev.ptr, root.dev.ptr + root.dev.len );
string_append_range( file, dir.dir.ptr, dir.dir.ptr + dir.dir.len );
break;
-
- case G_DRD:
+
+ case G_DRD:
case G_DDD:
/* root's dev:[dir] + rel directory */
string_append_range( file, f->f_root.ptr, f->f_root.ptr + f->f_root.len );
@@ -289,7 +289,7 @@
string_append_range( file, dir.dir.ptr + 1, dir.dir.ptr + 1 + dir.dir.len - 1 );
break;
- case G_VRD:
+ case G_VRD:
/* root's dev + rel directory made abs */
string_append_range( file, root.dev.ptr, root.dev.ptr + root.dev.len );
string_push_back( file, '[' );
@@ -304,15 +304,15 @@
printf( "%d x %d = %d (%s)\n", root.flags, dir.flags,
grid[ root.flags ][ dir.flags ], file->value );
}
-# endif
+# endif
- /*
+ /*
* Now do the special :P modifier when no file was present.
- * (none) (none)
- * [dir1.dir2] [dir1]
- * [dir] [000000]
- * [.dir] (none)
- * [] []
+ * (none) (none)
+ * [dir1.dir2] [dir1]
+ * [dir] [000000]
+ * [.dir] (none)
+ * [] []
*/
if( file->value[file->size - 1] == ']' && f->parent )
@@ -337,7 +337,7 @@
/* handle .- or - */
if( p > file->value && p[-1] == '.' )
--p;
-
+
*p++ = ']';
break;
}
@@ -388,7 +388,7 @@
# ifdef DEBUG
if( DEBUG_SEARCH )
- printf("built %.*s + %.*s / %.*s suf %.*s mem %.*s -> %s\n",
+ printf("built %.*s + %.*s / %.*s suf %.*s mem %.*s -> %s\n",
f->f_root.len, f->f_root.ptr,
f->f_dir.len, f->f_dir.ptr,
f->f_base.len, f->f_base.ptr,
@@ -399,26 +399,26 @@
}
/*
- * path_parent() - make a PATHNAME point to its parent dir
+ * path_parent() - make a PATHNAME point to its parent dir
*/
void
path_parent( PATHNAME *f )
{
- if( f->f_base.len )
- {
- f->f_base.ptr =
- f->f_suffix.ptr =
- f->f_member.ptr = "";
-
- f->f_base.len =
- f->f_suffix.len =
- f->f_member.len = 0;
- }
- else
- {
- f->parent = 1;
- }
+ if( f->f_base.len )
+ {
+ f->f_base.ptr =
+ f->f_suffix.ptr =
+ f->f_member.ptr = "";
+
+ f->f_base.len =
+ f->f_suffix.len =
+ f->f_member.len = 0;
+ }
+ else
+ {
+ f->parent = 1;
+ }
}
# endif /* VMS */
Modified: trunk/tools/jam/src/regexp.c
==============================================================================
--- trunk/tools/jam/src/regexp.c (original)
+++ trunk/tools/jam/src/regexp.c 2008-08-29 08:59:49 EDT (Fri, 29 Aug 2008)
@@ -1,22 +1,22 @@
/*
* regcomp and regexec -- regsub and regerror are elsewhere
*
- * Copyright (c) 1986 by University of Toronto.
- * Written by Henry Spencer. Not derived from licensed software.
+ * Copyright (c) 1986 by University of Toronto.
+ * Written by Henry Spencer. Not derived from licensed software.
*
- * Permission is granted to anyone to use this software for any
- * purpose on any computer system, and to redistribute it freely,
- * subject to the following restrictions:
- *
- * 1. The author is not responsible for the consequences of use of
- * this software, no matter how awful, even if they arise
- * from defects in it.
+ * Permission is granted to anyone to use this software for any
+ * purpose on any computer system, and to redistribute it freely,
+ * subject to the following restrictions:
+ *
+ * 1. The author is not responsible for the consequences of use of
+ * this software, no matter how awful, even if they arise
+ * from defects in it.
*
- * 2. The origin of this software must not be misrepresented, either
- * by explicit claim or by omission.
+ * 2. The origin of this software must not be misrepresented, either
+ * by explicit claim or by omission.
*
- * 3. Altered versions must be plainly marked as such, and must not
- * be misrepresented as being the original software.
+ * 3. Altered versions must be plainly marked as such, and must not
+ * be misrepresented as being the original software.
*** THIS IS AN ALTERED VERSION. It was altered by John Gilmore,
*** hoptoad!gnu, on 27 Dec 1986, to add \n as an alternative to |
*** to assist in implementing egrep.
@@ -55,10 +55,10 @@
* compile to execute that permits the execute phase to run lots faster on
* simple cases. They are:
*
- * regstart char that must begin a match; '\0' if none obvious
- * reganch is the match anchored (at beginning-of-line only)?
- * regmust string (pointer into program) that match must include, or NULL
- * regmlen length of regmust string
+ * regstart char that must begin a match; '\0' if none obvious
+ * reganch is the match anchored (at beginning-of-line only)?
+ * regmust string (pointer into program) that match must include, or NULL
+ * regmlen length of regmust string
*
* Regstart and reganch permit very fast decisions on suitable starting points
* for a match, cutting down the work a lot. Regmust permits fast rejection
@@ -86,45 +86,45 @@
* to the thing following the set of BRANCHes.) The opcodes are:
*/
-/* definition number opnd? meaning */
-#define END 0 /* no End of program. */
-#define BOL 1 /* no Match "" at beginning of line. */
-#define EOL 2 /* no Match "" at end of line. */
-#define ANY 3 /* no Match any one character. */
-#define ANYOF 4 /* str Match any character in this string. */
-#define ANYBUT 5 /* str Match any character not in this string. */
-#define BRANCH 6 /* node Match this alternative, or the next... */
-#define BACK 7 /* no Match "", "next" ptr points backward. */
-#define EXACTLY 8 /* str Match this string. */
-#define NOTHING 9 /* no Match empty string. */
-#define STAR 10 /* node Match this (simple) thing 0 or more times. */
-#define PLUS 11 /* node Match this (simple) thing 1 or more times. */
-#define WORDA 12 /* no Match "" at wordchar, where prev is nonword */
-#define WORDZ 13 /* no Match "" at nonwordchar, where prev is word */
-#define OPEN 20 /* no Mark this point in input as start of #n. */
- /* OPEN+1 is number 1, etc. */
-#define CLOSE 30 /* no Analogous to OPEN. */
+/* definition number opnd? meaning */
+#define END 0 /* no End of program. */
+#define BOL 1 /* no Match "" at beginning of line. */
+#define EOL 2 /* no Match "" at end of line. */
+#define ANY 3 /* no Match any one character. */
+#define ANYOF 4 /* str Match any character in this string. */
+#define ANYBUT 5 /* str Match any character not in this string. */
+#define BRANCH 6 /* node Match this alternative, or the next... */
+#define BACK 7 /* no Match "", "next" ptr points backward. */
+#define EXACTLY 8 /* str Match this string. */
+#define NOTHING 9 /* no Match empty string. */
+#define STAR 10 /* node Match this (simple) thing 0 or more times. */
+#define PLUS 11 /* node Match this (simple) thing 1 or more times. */
+#define WORDA 12 /* no Match "" at wordchar, where prev is nonword */
+#define WORDZ 13 /* no Match "" at nonwordchar, where prev is word */
+#define OPEN 20 /* no Mark this point in input as start of #n. */
+ /* OPEN+1 is number 1, etc. */
+#define CLOSE 30 /* no Analogous to OPEN. */
/*
* Opcode notes:
*
- * BRANCH The set of branches constituting a single choice are hooked
- * together with their "next" pointers, since precedence prevents
- * anything being concatenated to any individual branch. The
- * "next" pointer of the last BRANCH in a choice points to the
- * thing following the whole choice. This is also where the
- * final "next" pointer of each individual branch points; each
- * branch starts with the operand node of a BRANCH node.
- *
- * BACK Normal "next" pointers all implicitly point forward; BACK
- * exists to make loop structures possible.
- *
- * STAR,PLUS '?', and complex '*' and '+', are implemented as circular
- * BRANCH structures using BACK. Simple cases (one character
- * per match) are implemented with STAR and PLUS for speed
- * and to minimize recursive plunges.
+ * BRANCH The set of branches constituting a single choice are hooked
+ * together with their "next" pointers, since precedence prevents
+ * anything being concatenated to any individual branch. The
+ * "next" pointer of the last BRANCH in a choice points to the
+ * thing following the whole choice. This is also where the
+ * final "next" pointer of each individual branch points; each
+ * branch starts with the operand node of a BRANCH node.
+ *
+ * BACK Normal "next" pointers all implicitly point forward; BACK
+ * exists to make loop structures possible.
+ *
+ * STAR,PLUS '?', and complex '*' and '+', are implemented as circular
+ * BRANCH structures using BACK. Simple cases (one character
+ * per match) are implemented with STAR and PLUS for speed
+ * and to minimize recursive plunges.
*
- * OPEN,CLOSE ...are numbered at compile time.
+ * OPEN,CLOSE ...are numbered at compile time.
*/
/*
@@ -137,9 +137,9 @@
* Using two bytes for the "next" pointer is vast overkill for most things,
* but allows patterns to get big without disasters.
*/
-#define OP(p) (*(p))
-#define NEXT(p) (((*((p)+1)&0377)<<8) + (*((p)+2)&0377))
-#define OPERAND(p) ((p) + 3)
+#define OP(p) (*(p))
+#define NEXT(p) (((*((p)+1)&0377)<<8) + (*((p)+2)&0377))
+#define OPERAND(p) ((p) + 3)
/*
* See regmagic.h for one further detail of program structure.
@@ -150,36 +150,36 @@
* Utility definitions.
*/
#ifndef CHARBITS
-#define UCHARAT(p) ((int)*(unsigned char *)(p))
+#define UCHARAT(p) ((int)*(unsigned char *)(p))
#else
-#define UCHARAT(p) ((int)*(p)&CHARBITS)
+#define UCHARAT(p) ((int)*(p)&CHARBITS)
#endif
-#define FAIL(m) { regerror(m); return(NULL); }
-#define ISMULT(c) ((c) == '*' || (c) == '+' || (c) == '?')
+#define FAIL(m) { regerror(m); return(NULL); }
+#define ISMULT(c) ((c) == '*' || (c) == '+' || (c) == '?')
/*
* Flags to be passed up and down.
*/
-#define HASWIDTH 01 /* Known never to match null string. */
-#define SIMPLE 02 /* Simple enough to be STAR/PLUS operand. */
-#define SPSTART 04 /* Starts with * or +. */
-#define WORST 0 /* Worst case. */
+#define HASWIDTH 01 /* Known never to match null string. */
+#define SIMPLE 02 /* Simple enough to be STAR/PLUS operand. */
+#define SPSTART 04 /* Starts with * or +. */
+#define WORST 0 /* Worst case. */
/*
* Global work variables for regcomp().
*/
-static char *regparse; /* Input-scan pointer. */
-static int regnpar; /* () count. */
+static char *regparse; /* Input-scan pointer. */
+static int regnpar; /* () count. */
static char regdummy;
-static char *regcode; /* Code-emit pointer; ®dummy = don't. */
-static long regsize; /* Code size. */
+static char *regcode; /* Code-emit pointer; ®dummy = don't. */
+static long regsize; /* Code size. */
/*
* Forward declarations for regcomp()'s friends.
*/
#ifndef STATIC
-#define STATIC static
+#define STATIC static
#endif
STATIC char *reg( int paren, int *flagp );
STATIC char *regbranch( int *flagp );
@@ -213,81 +213,81 @@
regexp *
regcomp( char *exp )
{
- register regexp *r;
- register char *scan;
- register char *longest;
- register unsigned len;
- int flags;
+ register regexp *r;
+ register char *scan;
+ register char *longest;
+ register unsigned len;
+ int flags;
- if (exp == NULL)
- FAIL("NULL argument");
+ if (exp == NULL)
+ FAIL("NULL argument");
- /* First pass: determine size, legality. */
+ /* First pass: determine size, legality. */
#ifdef notdef
- if (exp[0] == '.' && exp[1] == '*') exp += 2; /* aid grep */
+ if (exp[0] == '.' && exp[1] == '*') exp += 2; /* aid grep */
#endif
- regparse = (char *)exp;
- regnpar = 1;
- regsize = 0L;
- regcode = ®dummy;
- regc(MAGIC);
- if (reg(0, &flags) == NULL)
- return(NULL);
-
- /* Small enough for pointer-storage convention? */
- if (regsize >= 32767L) /* Probably could be 65535L. */
- FAIL("regexp too big");
-
- /* Allocate space. */
- r = (regexp *)BJAM_MALLOC(sizeof(regexp) + (unsigned)regsize);
- if (r == NULL)
- FAIL("out of space");
-
- /* Second pass: emit code. */
- regparse = (char *)exp;
- regnpar = 1;
- regcode = r->program;
- regc(MAGIC);
- if (reg(0, &flags) == NULL)
- return(NULL);
-
- /* Dig out information for optimizations. */
- r->regstart = '\0'; /* Worst-case defaults. */
- r->reganch = 0;
- r->regmust = NULL;
- r->regmlen = 0;
- scan = r->program+1; /* First BRANCH. */
- if (OP(regnext(scan)) == END) { /* Only one top-level choice. */
- scan = OPERAND(scan);
-
- /* Starting-point info. */
- if (OP(scan) == EXACTLY)
- r->regstart = *OPERAND(scan);
- else if (OP(scan) == BOL)
- r->reganch++;
-
- /*
- * If there's something expensive in the r.e., find the
- * longest literal string that must appear and make it the
- * regmust. Resolve ties in favor of later strings, since
- * the regstart check works with the beginning of the r.e.
- * and avoiding duplication strengthens checking. Not a
- * strong reason, but sufficient in the absence of others.
- */
- if (flags&SPSTART) {
- longest = NULL;
- len = 0;
- for (; scan != NULL; scan = regnext(scan))
- if (OP(scan) == EXACTLY && strlen(OPERAND(scan)) >= len) {
- longest = OPERAND(scan);
- len = strlen(OPERAND(scan));
- }
- r->regmust = longest;
- r->regmlen = len;
- }
- }
+ regparse = (char *)exp;
+ regnpar = 1;
+ regsize = 0L;
+ regcode = ®dummy;
+ regc(MAGIC);
+ if (reg(0, &flags) == NULL)
+ return(NULL);
+
+ /* Small enough for pointer-storage convention? */
+ if (regsize >= 32767L) /* Probably could be 65535L. */
+ FAIL("regexp too big");
+
+ /* Allocate space. */
+ r = (regexp *)BJAM_MALLOC(sizeof(regexp) + (unsigned)regsize);
+ if (r == NULL)
+ FAIL("out of space");
+
+ /* Second pass: emit code. */
+ regparse = (char *)exp;
+ regnpar = 1;
+ regcode = r->program;
+ regc(MAGIC);
+ if (reg(0, &flags) == NULL)
+ return(NULL);
+
+ /* Dig out information for optimizations. */
+ r->regstart = '\0'; /* Worst-case defaults. */
+ r->reganch = 0;
+ r->regmust = NULL;
+ r->regmlen = 0;
+ scan = r->program+1; /* First BRANCH. */
+ if (OP(regnext(scan)) == END) { /* Only one top-level choice. */
+ scan = OPERAND(scan);
+
+ /* Starting-point info. */
+ if (OP(scan) == EXACTLY)
+ r->regstart = *OPERAND(scan);
+ else if (OP(scan) == BOL)
+ r->reganch++;
+
+ /*
+ * If there's something expensive in the r.e., find the
+ * longest literal string that must appear and make it the
+ * regmust. Resolve ties in favor of later strings, since
+ * the regstart check works with the beginning of the r.e.
+ * and avoiding duplication strengthens checking. Not a
+ * strong reason, but sufficient in the absence of others.
+ */
+ if (flags&SPSTART) {
+ longest = NULL;
+ len = 0;
+ for (; scan != NULL; scan = regnext(scan))
+ if (OP(scan) == EXACTLY && strlen(OPERAND(scan)) >= len) {
+ longest = OPERAND(scan);
+ len = strlen(OPERAND(scan));
+ }
+ r->regmust = longest;
+ r->regmlen = len;
+ }
+ }
- return(r);
+ return(r);
}
/*
@@ -301,69 +301,69 @@
*/
static char *
reg(
- int paren, /* Parenthesized? */
- int *flagp )
+ int paren, /* Parenthesized? */
+ int *flagp )
{
- register char *ret;
- register char *br;
- register char *ender;
- register int parno;
- int flags;
-
- *flagp = HASWIDTH; /* Tentatively. */
-
- /* Make an OPEN node, if parenthesized. */
- if (paren) {
- if (regnpar >= NSUBEXP)
- FAIL("too many ()");
- parno = regnpar;
- regnpar++;
- ret = regnode(OPEN+parno);
- } else
- ret = NULL;
-
- /* Pick up the branches, linking them together. */
- br = regbranch(&flags);
- if (br == NULL)
- return(NULL);
- if (ret != NULL)
- regtail(ret, br); /* OPEN -> first. */
- else
- ret = br;
- if (!(flags&HASWIDTH))
- *flagp &= ~HASWIDTH;
- *flagp |= flags&SPSTART;
- while (*regparse == '|' || *regparse == '\n') {
- regparse++;
- br = regbranch(&flags);
- if (br == NULL)
- return(NULL);
- regtail(ret, br); /* BRANCH -> BRANCH. */
- if (!(flags&HASWIDTH))
- *flagp &= ~HASWIDTH;
- *flagp |= flags&SPSTART;
- }
-
- /* Make a closing node, and hook it on the end. */
- ender = regnode((paren) ? CLOSE+parno : END);
- regtail(ret, ender);
-
- /* Hook the tails of the branches to the closing node. */
- for (br = ret; br != NULL; br = regnext(br))
- regoptail(br, ender);
-
- /* Check for proper termination. */
- if (paren && *regparse++ != ')') {
- FAIL("unmatched ()");
- } else if (!paren && *regparse != '\0') {
- if (*regparse == ')') {
- FAIL("unmatched ()");
- } else
- FAIL("junk on end"); /* "Can't happen". */
- /* NOTREACHED */
- }
+ register char *ret;
+ register char *br;
+ register char *ender;
+ register int parno;
+ int flags;
+
+ *flagp = HASWIDTH; /* Tentatively. */
+
+ /* Make an OPEN node, if parenthesized. */
+ if (paren) {
+ if (regnpar >= NSUBEXP)
+ FAIL("too many ()");
+ parno = regnpar;
+ regnpar++;
+ ret = regnode(OPEN+parno);
+ } else
+ ret = NULL;
+
+ /* Pick up the branches, linking them together. */
+ br = regbranch(&flags);
+ if (br == NULL)
+ return(NULL);
+ if (ret != NULL)
+ regtail(ret, br); /* OPEN -> first. */
+ else
+ ret = br;
+ if (!(flags&HASWIDTH))
+ *flagp &= ~HASWIDTH;
+ *flagp |= flags&SPSTART;
+ while (*regparse == '|' || *regparse == '\n') {
+ regparse++;
+ br = regbranch(&flags);
+ if (br == NULL)
+ return(NULL);
+ regtail(ret, br); /* BRANCH -> BRANCH. */
+ if (!(flags&HASWIDTH))
+ *flagp &= ~HASWIDTH;
+ *flagp |= flags&SPSTART;
+ }
+
+ /* Make a closing node, and hook it on the end. */
+ ender = regnode((paren) ? CLOSE+parno : END);
+ regtail(ret, ender);
+
+ /* Hook the tails of the branches to the closing node. */
+ for (br = ret; br != NULL; br = regnext(br))
+ regoptail(br, ender);
+
+ /* Check for proper termination. */
+ if (paren && *regparse++ != ')') {
+ FAIL("unmatched ()");
+ } else if (!paren && *regparse != '\0') {
+ if (*regparse == ')') {
+ FAIL("unmatched ()");
+ } else
+ FAIL("junk on end"); /* "Can't happen". */
+ /* NOTREACHED */
+ }
- return(ret);
+ return(ret);
}
/*
@@ -374,31 +374,31 @@
static char *
regbranch( int *flagp )
{
- register char *ret;
- register char *chain;
- register char *latest;
- int flags;
-
- *flagp = WORST; /* Tentatively. */
-
- ret = regnode(BRANCH);
- chain = NULL;
- while (*regparse != '\0' && *regparse != ')' &&
- *regparse != '\n' && *regparse != '|') {
- latest = regpiece(&flags);
- if (latest == NULL)
- return(NULL);
- *flagp |= flags&HASWIDTH;
- if (chain == NULL) /* First piece. */
- *flagp |= flags&SPSTART;
- else
- regtail(chain, latest);
- chain = latest;
- }
- if (chain == NULL) /* Loop ran zero times. */
- (void) regnode(NOTHING);
+ register char *ret;
+ register char *chain;
+ register char *latest;
+ int flags;
+
+ *flagp = WORST; /* Tentatively. */
+
+ ret = regnode(BRANCH);
+ chain = NULL;
+ while (*regparse != '\0' && *regparse != ')' &&
+ *regparse != '\n' && *regparse != '|') {
+ latest = regpiece(&flags);
+ if (latest == NULL)
+ return(NULL);
+ *flagp |= flags&HASWIDTH;
+ if (chain == NULL) /* First piece. */
+ *flagp |= flags&SPSTART;
+ else
+ regtail(chain, latest);
+ chain = latest;
+ }
+ if (chain == NULL) /* Loop ran zero times. */
+ (void) regnode(NOTHING);
- return(ret);
+ return(ret);
}
/*
@@ -413,56 +413,56 @@
static char *
regpiece( int *flagp )
{
- register char *ret;
- register char op;
- register char *next;
- int flags;
-
- ret = regatom(&flags);
- if (ret == NULL)
- return(NULL);
-
- op = *regparse;
- if (!ISMULT(op)) {
- *flagp = flags;
- return(ret);
- }
-
- if (!(flags&HASWIDTH) && op != '?')
- FAIL("*+ operand could be empty");
- *flagp = (op != '+') ? (WORST|SPSTART) : (WORST|HASWIDTH);
-
- if (op == '*' && (flags&SIMPLE))
- reginsert(STAR, ret);
- else if (op == '*') {
- /* Emit x* as (x&|), where & means "self". */
- reginsert(BRANCH, ret); /* Either x */
- regoptail(ret, regnode(BACK)); /* and loop */
- regoptail(ret, ret); /* back */
- regtail(ret, regnode(BRANCH)); /* or */
- regtail(ret, regnode(NOTHING)); /* null. */
- } else if (op == '+' && (flags&SIMPLE))
- reginsert(PLUS, ret);
- else if (op == '+') {
- /* Emit x+ as x(&|), where & means "self". */
- next = regnode(BRANCH); /* Either */
- regtail(ret, next);
- regtail(regnode(BACK), ret); /* loop back */
- regtail(next, regnode(BRANCH)); /* or */
- regtail(ret, regnode(NOTHING)); /* null. */
- } else if (op == '?') {
- /* Emit x? as (x|) */
- reginsert(BRANCH, ret); /* Either x */
- regtail(ret, regnode(BRANCH)); /* or */
- next = regnode(NOTHING); /* null. */
- regtail(ret, next);
- regoptail(ret, next);
- }
- regparse++;
- if (ISMULT(*regparse))
- FAIL("nested *?+");
+ register char *ret;
+ register char op;
+ register char *next;
+ int flags;
+
+ ret = regatom(&flags);
+ if (ret == NULL)
+ return(NULL);
+
+ op = *regparse;
+ if (!ISMULT(op)) {
+ *flagp = flags;
+ return(ret);
+ }
+
+ if (!(flags&HASWIDTH) && op != '?')
+ FAIL("*+ operand could be empty");
+ *flagp = (op != '+') ? (WORST|SPSTART) : (WORST|HASWIDTH);
+
+ if (op == '*' && (flags&SIMPLE))
+ reginsert(STAR, ret);
+ else if (op == '*') {
+ /* Emit x* as (x&|), where & means "self". */
+ reginsert(BRANCH, ret); /* Either x */
+ regoptail(ret, regnode(BACK)); /* and loop */
+ regoptail(ret, ret); /* back */
+ regtail(ret, regnode(BRANCH)); /* or */
+ regtail(ret, regnode(NOTHING)); /* null. */
+ } else if (op == '+' && (flags&SIMPLE))
+ reginsert(PLUS, ret);
+ else if (op == '+') {
+ /* Emit x+ as x(&|), where & means "self". */
+ next = regnode(BRANCH); /* Either */
+ regtail(ret, next);
+ regtail(regnode(BACK), ret); /* loop back */
+ regtail(next, regnode(BRANCH)); /* or */
+ regtail(ret, regnode(NOTHING)); /* null. */
+ } else if (op == '?') {
+ /* Emit x? as (x|) */
+ reginsert(BRANCH, ret); /* Either x */
+ regtail(ret, regnode(BRANCH)); /* or */
+ next = regnode(NOTHING); /* null. */
+ regtail(ret, next);
+ regoptail(ret, next);
+ }
+ regparse++;
+ if (ISMULT(*regparse))
+ FAIL("nested *?+");
- return(ret);
+ return(ret);
}
/*
@@ -476,199 +476,199 @@
static char *
regatom( int *flagp )
{
- register char *ret;
- int flags;
+ register char *ret;
+ int flags;
- *flagp = WORST; /* Tentatively. */
+ *flagp = WORST; /* Tentatively. */
- switch (*regparse++) {
- /* FIXME: these chars only have meaning at beg/end of pat? */
- case '^':
- ret = regnode(BOL);
- break;
- case '$':
- ret = regnode(EOL);
- break;
- case '.':
- ret = regnode(ANY);
- *flagp |= HASWIDTH|SIMPLE;
- break;
- case '[': {
- register int classr;
- register int classend;
-
- if (*regparse == '^') { /* Complement of range. */
- ret = regnode(ANYBUT);
- regparse++;
- } else
- ret = regnode(ANYOF);
- if (*regparse == ']' || *regparse == '-')
- regc(*regparse++);
- while (*regparse != '\0' && *regparse != ']') {
- if (*regparse == '-') {
- regparse++;
- if (*regparse == ']' || *regparse == '\0')
- regc('-');
- else {
- classr = UCHARAT(regparse-2)+1;
- classend = UCHARAT(regparse);
- if (classr > classend+1)
- FAIL("invalid [] range");
- for (; classr <= classend; classr++)
- regc(classr);
- regparse++;
- }
- } else
- regc(*regparse++);
- }
- regc('\0');
- if (*regparse != ']')
- FAIL("unmatched []");
- regparse++;
- *flagp |= HASWIDTH|SIMPLE;
- }
- break;
- case '(':
- ret = reg(1, &flags);
- if (ret == NULL)
- return(NULL);
- *flagp |= flags&(HASWIDTH|SPSTART);
- break;
- case '\0':
- case '|':
- case '\n':
- case ')':
- FAIL("internal urp"); /* Supposed to be caught earlier. */
- break;
- case '?':
- case '+':
- case '*':
- FAIL("?+* follows nothing");
- break;
- case '\\':
- switch (*regparse++) {
- case '\0':
- FAIL("trailing \\");
- break;
- case '<':
- ret = regnode(WORDA);
- break;
- case '>':
- ret = regnode(WORDZ);
- break;
- /* FIXME: Someday handle \1, \2, ... */
- default:
- /* Handle general quoted chars in exact-match routine */
- goto de_fault;
- }
- break;
- de_fault:
- default:
- /*
- * Encode a string of characters to be matched exactly.
- *
- * This is a bit tricky due to quoted chars and due to
- * '*', '+', and '?' taking the SINGLE char previous
- * as their operand.
- *
- * On entry, the char at regparse[-1] is going to go
- * into the string, no matter what it is. (It could be
- * following a \ if we are entered from the '\' case.)
- *
- * Basic idea is to pick up a good char in ch and
- * examine the next char. If it's *+? then we twiddle.
- * If it's \ then we frozzle. If it's other magic char
- * we push ch and terminate the string. If none of the
- * above, we push ch on the string and go around again.
- *
- * regprev is used to remember where "the current char"
- * starts in the string, if due to a *+? we need to back
- * up and put the current char in a separate, 1-char, string.
- * When regprev is NULL, ch is the only char in the
- * string; this is used in *+? handling, and in setting
- * flags |= SIMPLE at the end.
- */
- {
- char *regprev;
- register char ch;
-
- regparse--; /* Look at cur char */
- ret = regnode(EXACTLY);
- for ( regprev = 0 ; ; ) {
- ch = *regparse++; /* Get current char */
- switch (*regparse) { /* look at next one */
-
- default:
- regc(ch); /* Add cur to string */
- break;
-
- case '.': case '[': case '(':
- case ')': case '|': case '\n':
- case '$': case '^':
- case '\0':
- /* FIXME, $ and ^ should not always be magic */
- magic:
- regc(ch); /* dump cur char */
- goto done; /* and we are done */
-
- case '?': case '+': case '*':
- if (!regprev) /* If just ch in str, */
- goto magic; /* use it */
- /* End mult-char string one early */
- regparse = regprev; /* Back up parse */
- goto done;
-
- case '\\':
- regc(ch); /* Cur char OK */
- switch (regparse[1]){ /* Look after \ */
- case '\0':
- case '<':
- case '>':
- /* FIXME: Someday handle \1, \2, ... */
- goto done; /* Not quoted */
- default:
- /* Backup point is \, scan * point is after it. */
- regprev = regparse;
- regparse++;
- continue; /* NOT break; */
- }
- }
- regprev = regparse; /* Set backup point */
- }
- done:
- regc('\0');
- *flagp |= HASWIDTH;
- if (!regprev) /* One char? */
- *flagp |= SIMPLE;
- }
- break;
- }
+ switch (*regparse++) {
+ /* FIXME: these chars only have meaning at beg/end of pat? */
+ case '^':
+ ret = regnode(BOL);
+ break;
+ case '$':
+ ret = regnode(EOL);
+ break;
+ case '.':
+ ret = regnode(ANY);
+ *flagp |= HASWIDTH|SIMPLE;
+ break;
+ case '[': {
+ register int classr;
+ register int classend;
+
+ if (*regparse == '^') { /* Complement of range. */
+ ret = regnode(ANYBUT);
+ regparse++;
+ } else
+ ret = regnode(ANYOF);
+ if (*regparse == ']' || *regparse == '-')
+ regc(*regparse++);
+ while (*regparse != '\0' && *regparse != ']') {
+ if (*regparse == '-') {
+ regparse++;
+ if (*regparse == ']' || *regparse == '\0')
+ regc('-');
+ else {
+ classr = UCHARAT(regparse-2)+1;
+ classend = UCHARAT(regparse);
+ if (classr > classend+1)
+ FAIL("invalid [] range");
+ for (; classr <= classend; classr++)
+ regc(classr);
+ regparse++;
+ }
+ } else
+ regc(*regparse++);
+ }
+ regc('\0');
+ if (*regparse != ']')
+ FAIL("unmatched []");
+ regparse++;
+ *flagp |= HASWIDTH|SIMPLE;
+ }
+ break;
+ case '(':
+ ret = reg(1, &flags);
+ if (ret == NULL)
+ return(NULL);
+ *flagp |= flags&(HASWIDTH|SPSTART);
+ break;
+ case '\0':
+ case '|':
+ case '\n':
+ case ')':
+ FAIL("internal urp"); /* Supposed to be caught earlier. */
+ break;
+ case '?':
+ case '+':
+ case '*':
+ FAIL("?+* follows nothing");
+ break;
+ case '\\':
+ switch (*regparse++) {
+ case '\0':
+ FAIL("trailing \\");
+ break;
+ case '<':
+ ret = regnode(WORDA);
+ break;
+ case '>':
+ ret = regnode(WORDZ);
+ break;
+ /* FIXME: Someday handle \1, \2, ... */
+ default:
+ /* Handle general quoted chars in exact-match routine */
+ goto de_fault;
+ }
+ break;
+ de_fault:
+ default:
+ /*
+ * Encode a string of characters to be matched exactly.
+ *
+ * This is a bit tricky due to quoted chars and due to
+ * '*', '+', and '?' taking the SINGLE char previous
+ * as their operand.
+ *
+ * On entry, the char at regparse[-1] is going to go
+ * into the string, no matter what it is. (It could be
+ * following a \ if we are entered from the '\' case.)
+ *
+ * Basic idea is to pick up a good char in ch and
+ * examine the next char. If it's *+? then we twiddle.
+ * If it's \ then we frozzle. If it's other magic char
+ * we push ch and terminate the string. If none of the
+ * above, we push ch on the string and go around again.
+ *
+ * regprev is used to remember where "the current char"
+ * starts in the string, if due to a *+? we need to back
+ * up and put the current char in a separate, 1-char, string.
+ * When regprev is NULL, ch is the only char in the
+ * string; this is used in *+? handling, and in setting
+ * flags |= SIMPLE at the end.
+ */
+ {
+ char *regprev;
+ register char ch;
+
+ regparse--; /* Look at cur char */
+ ret = regnode(EXACTLY);
+ for ( regprev = 0 ; ; ) {
+ ch = *regparse++; /* Get current char */
+ switch (*regparse) { /* look at next one */
+
+ default:
+ regc(ch); /* Add cur to string */
+ break;
+
+ case '.': case '[': case '(':
+ case ')': case '|': case '\n':
+ case '$': case '^':
+ case '\0':
+ /* FIXME, $ and ^ should not always be magic */
+ magic:
+ regc(ch); /* dump cur char */
+ goto done; /* and we are done */
+
+ case '?': case '+': case '*':
+ if (!regprev) /* If just ch in str, */
+ goto magic; /* use it */
+ /* End mult-char string one early */
+ regparse = regprev; /* Back up parse */
+ goto done;
+
+ case '\\':
+ regc(ch); /* Cur char OK */
+ switch (regparse[1]){ /* Look after \ */
+ case '\0':
+ case '<':
+ case '>':
+ /* FIXME: Someday handle \1, \2, ... */
+ goto done; /* Not quoted */
+ default:
+ /* Backup point is \, scan * point is after it. */
+ regprev = regparse;
+ regparse++;
+ continue; /* NOT break; */
+ }
+ }
+ regprev = regparse; /* Set backup point */
+ }
+ done:
+ regc('\0');
+ *flagp |= HASWIDTH;
+ if (!regprev) /* One char? */
+ *flagp |= SIMPLE;
+ }
+ break;
+ }
- return(ret);
+ return(ret);
}
/*
- regnode - emit a node
*/
-static char * /* Location. */
+static char * /* Location. */
regnode( int op )
{
- register char *ret;
- register char *ptr;
+ register char *ret;
+ register char *ptr;
- ret = regcode;
- if (ret == ®dummy) {
- regsize += 3;
- return(ret);
- }
-
- ptr = ret;
- *ptr++ = op;
- *ptr++ = '\0'; /* Null "next" pointer. */
- *ptr++ = '\0';
- regcode = ptr;
+ ret = regcode;
+ if (ret == ®dummy) {
+ regsize += 3;
+ return(ret);
+ }
+
+ ptr = ret;
+ *ptr++ = op;
+ *ptr++ = '\0'; /* Null "next" pointer. */
+ *ptr++ = '\0';
+ regcode = ptr;
- return(ret);
+ return(ret);
}
/*
@@ -677,10 +677,10 @@
static void
regc( int b )
{
- if (regcode != ®dummy)
- *regcode++ = b;
- else
- regsize++;
+ if (regcode != ®dummy)
+ *regcode++ = b;
+ else
+ regsize++;
}
/*
@@ -690,28 +690,28 @@
*/
static void
reginsert(
- char op,
- char *opnd )
+ char op,
+ char *opnd )
{
- register char *src;
- register char *dst;
- register char *place;
-
- if (regcode == ®dummy) {
- regsize += 3;
- return;
- }
-
- src = regcode;
- regcode += 3;
- dst = regcode;
- while (src > opnd)
- *--dst = *--src;
-
- place = opnd; /* Op node, where operand used to be. */
- *place++ = op;
- *place++ = '\0';
- *place++ = '\0';
+ register char *src;
+ register char *dst;
+ register char *place;
+
+ if (regcode == ®dummy) {
+ regsize += 3;
+ return;
+ }
+
+ src = regcode;
+ regcode += 3;
+ dst = regcode;
+ while (src > opnd)
+ *--dst = *--src;
+
+ place = opnd; /* Op node, where operand used to be. */
+ *place++ = op;
+ *place++ = '\0';
+ *place++ = '\0';
}
/*
@@ -719,31 +719,31 @@
*/
static void
regtail(
- char *p,
- char *val )
+ char *p,
+ char *val )
{
- register char *scan;
- register char *temp;
- register int offset;
-
- if (p == ®dummy)
- return;
-
- /* Find last node. */
- scan = p;
- for (;;) {
- temp = regnext(scan);
- if (temp == NULL)
- break;
- scan = temp;
- }
-
- if (OP(scan) == BACK)
- offset = scan - val;
- else
- offset = val - scan;
- *(scan+1) = (offset>>8)&0377;
- *(scan+2) = offset&0377;
+ register char *scan;
+ register char *temp;
+ register int offset;
+
+ if (p == ®dummy)
+ return;
+
+ /* Find last node. */
+ scan = p;
+ for (;;) {
+ temp = regnext(scan);
+ if (temp == NULL)
+ break;
+ scan = temp;
+ }
+
+ if (OP(scan) == BACK)
+ offset = scan - val;
+ else
+ offset = val - scan;
+ *(scan+1) = (offset>>8)&0377;
+ *(scan+2) = offset&0377;
}
/*
@@ -752,13 +752,13 @@
static void
regoptail(
- char *p,
- char *val )
+ char *p,
+ char *val )
{
- /* "Operandless" and "op != BRANCH" are synonymous in practice. */
- if (p == NULL || p == ®dummy || OP(p) != BRANCH)
- return;
- regtail(OPERAND(p), val);
+ /* "Operandless" and "op != BRANCH" are synonymous in practice. */
+ if (p == NULL || p == ®dummy || OP(p) != BRANCH)
+ return;
+ regtail(OPERAND(p), val);
}
/*
@@ -768,10 +768,10 @@
/*
* Global work variables for regexec().
*/
-static char *reginput; /* String-input pointer. */
-static char *regbol; /* Beginning of input, for ^ check. */
-static char **regstartp; /* Pointer to startp array. */
-static char **regendp; /* Ditto for endp. */
+static char *reginput; /* String-input pointer. */
+static char *regbol; /* Beginning of input, for ^ check. */
+static char **regstartp; /* Pointer to startp array. */
+static char **regendp; /* Ditto for endp. */
/*
* Forwards.
@@ -791,90 +791,90 @@
*/
int
regexec(
- register regexp *prog,
- register char *string )
+ register regexp *prog,
+ register char *string )
{
- register char *s;
+ register char *s;
- /* Be paranoid... */
- if (prog == NULL || string == NULL) {
- regerror("NULL parameter");
- return(0);
- }
-
- /* Check validity of program. */
- if (UCHARAT(prog->program) != MAGIC) {
- regerror("corrupted program");
- return(0);
- }
-
- /* If there is a "must appear" string, look for it. */
- if (prog->regmust != NULL) {
- s = (char *)string;
- while ((s = strchr(s, prog->regmust[0])) != NULL) {
- if (strncmp(s, prog->regmust, prog->regmlen) == 0)
- break; /* Found it. */
- s++;
- }
- if (s == NULL) /* Not present. */
- return(0);
- }
-
- /* Mark beginning of line for ^ . */
- regbol = (char *)string;
-
- /* Simplest case: anchored match need be tried only once. */
- if (prog->reganch)
- return(regtry(prog, string));
-
- /* Messy cases: unanchored match. */
- s = (char *)string;
- if (prog->regstart != '\0')
- /* We know what char it must start with. */
- while ((s = strchr(s, prog->regstart)) != NULL) {
- if (regtry(prog, s))
- return(1);
- s++;
- }
- else
- /* We don't -- general case. */
- do {
- if (regtry(prog, s))
- return(1);
- } while (*s++ != '\0');
+ /* Be paranoid... */
+ if (prog == NULL || string == NULL) {
+ regerror("NULL parameter");
+ return(0);
+ }
+
+ /* Check validity of program. */
+ if (UCHARAT(prog->program) != MAGIC) {
+ regerror("corrupted program");
+ return(0);
+ }
+
+ /* If there is a "must appear" string, look for it. */
+ if (prog->regmust != NULL) {
+ s = (char *)string;
+ while ((s = strchr(s, prog->regmust[0])) != NULL) {
+ if (strncmp(s, prog->regmust, prog->regmlen) == 0)
+ break; /* Found it. */
+ s++;
+ }
+ if (s == NULL) /* Not present. */
+ return(0);
+ }
+
+ /* Mark beginning of line for ^ . */
+ regbol = (char *)string;
+
+ /* Simplest case: anchored match need be tried only once. */
+ if (prog->reganch)
+ return(regtry(prog, string));
+
+ /* Messy cases: unanchored match. */
+ s = (char *)string;
+ if (prog->regstart != '\0')
+ /* We know what char it must start with. */
+ while ((s = strchr(s, prog->regstart)) != NULL) {
+ if (regtry(prog, s))
+ return(1);
+ s++;
+ }
+ else
+ /* We don't -- general case. */
+ do {
+ if (regtry(prog, s))
+ return(1);
+ } while (*s++ != '\0');
- /* Failure. */
- return(0);
+ /* Failure. */
+ return(0);
}
/*
- regtry - try match at specific point
*/
-static int /* 0 failure, 1 success */
+static int /* 0 failure, 1 success */
regtry(
- regexp *prog,
- char *string )
+ regexp *prog,
+ char *string )
{
- register int i;
- register char **sp;
- register char **ep;
-
- reginput = string;
- regstartp = prog->startp;
- regendp = prog->endp;
-
- sp = prog->startp;
- ep = prog->endp;
- for (i = NSUBEXP; i > 0; i--) {
- *sp++ = NULL;
- *ep++ = NULL;
- }
- if (regmatch(prog->program + 1)) {
- prog->startp[0] = string;
- prog->endp[0] = reginput;
- return(1);
- } else
- return(0);
+ register int i;
+ register char **sp;
+ register char **ep;
+
+ reginput = string;
+ regstartp = prog->startp;
+ regendp = prog->endp;
+
+ sp = prog->startp;
+ ep = prog->endp;
+ for (i = NSUBEXP; i > 0; i--) {
+ *sp++ = NULL;
+ *ep++ = NULL;
+ }
+ if (regmatch(prog->program + 1)) {
+ prog->startp[0] = string;
+ prog->endp[0] = reginput;
+ return(1);
+ } else
+ return(0);
}
/*
@@ -887,202 +887,202 @@
* need to know whether the rest of the match failed) by a loop instead of
* by recursion.
*/
-static int /* 0 failure, 1 success */
+static int /* 0 failure, 1 success */
regmatch( char *prog )
{
- register char *scan; /* Current node. */
- char *next; /* Next node. */
+ register char *scan; /* Current node. */
+ char *next; /* Next node. */
- scan = prog;
+ scan = prog;
#ifdef DEBUG
- if (scan != NULL && regnarrate)
- fprintf(stderr, "%s(\n", regprop(scan));
+ if (scan != NULL && regnarrate)
+ fprintf(stderr, "%s(\n", regprop(scan));
#endif
- while (scan != NULL) {
+ while (scan != NULL) {
#ifdef DEBUG
- if (regnarrate)
- fprintf(stderr, "%s...\n", regprop(scan));
+ if (regnarrate)
+ fprintf(stderr, "%s...\n", regprop(scan));
#endif
- next = regnext(scan);
+ next = regnext(scan);
- switch (OP(scan)) {
- case BOL:
- if (reginput != regbol)
- return(0);
- break;
- case EOL:
- if (*reginput != '\0')
- return(0);
- break;
- case WORDA:
- /* Must be looking at a letter, digit, or _ */
- if ((!isalnum(*reginput)) && *reginput != '_')
- return(0);
- /* Prev must be BOL or nonword */
- if (reginput > regbol &&
- (isalnum(reginput[-1]) || reginput[-1] == '_'))
- return(0);
- break;
- case WORDZ:
- /* Must be looking at non letter, digit, or _ */
- if (isalnum(*reginput) || *reginput == '_')
- return(0);
- /* We don't care what the previous char was */
- break;
- case ANY:
- if (*reginput == '\0')
- return(0);
- reginput++;
- break;
- case EXACTLY: {
- register int len;
- register char *opnd;
-
- opnd = OPERAND(scan);
- /* Inline the first character, for speed. */
- if (*opnd != *reginput)
- return(0);
- len = strlen(opnd);
- if (len > 1 && strncmp(opnd, reginput, len) != 0)
- return(0);
- reginput += len;
- }
- break;
- case ANYOF:
- if (*reginput == '\0' || strchr(OPERAND(scan), *reginput) == NULL)
- return(0);
- reginput++;
- break;
- case ANYBUT:
- if (*reginput == '\0' || strchr(OPERAND(scan), *reginput) != NULL)
- return(0);
- reginput++;
- break;
- case NOTHING:
- break;
- case BACK:
- break;
- case OPEN+1:
- case OPEN+2:
- case OPEN+3:
- case OPEN+4:
- case OPEN+5:
- case OPEN+6:
- case OPEN+7:
- case OPEN+8:
- case OPEN+9: {
- register int no;
- register char *save;
-
- no = OP(scan) - OPEN;
- save = reginput;
-
- if (regmatch(next)) {
- /*
- * Don't set startp if some later
- * invocation of the same parentheses
- * already has.
- */
- if (regstartp[no] == NULL)
- regstartp[no] = save;
- return(1);
- } else
- return(0);
- }
- break;
- case CLOSE+1:
- case CLOSE+2:
- case CLOSE+3:
- case CLOSE+4:
- case CLOSE+5:
- case CLOSE+6:
- case CLOSE+7:
- case CLOSE+8:
- case CLOSE+9: {
- register int no;
- register char *save;
-
- no = OP(scan) - CLOSE;
- save = reginput;
-
- if (regmatch(next)) {
- /*
- * Don't set endp if some later
- * invocation of the same parentheses
- * already has.
- */
- if (regendp[no] == NULL)
- regendp[no] = save;
- return(1);
- } else
- return(0);
- }
- break;
- case BRANCH: {
- register char *save;
-
- if (OP(next) != BRANCH) /* No choice. */
- next = OPERAND(scan); /* Avoid recursion. */
- else {
- do {
- save = reginput;
- if (regmatch(OPERAND(scan)))
- return(1);
- reginput = save;
- scan = regnext(scan);
- } while (scan != NULL && OP(scan) == BRANCH);
- return(0);
- /* NOTREACHED */
- }
- }
- break;
- case STAR:
- case PLUS: {
- register char nextch;
- register int no;
- register char *save;
- register int min;
-
- /*
- * Lookahead to avoid useless match attempts
- * when we know what character comes next.
- */
- nextch = '\0';
- if (OP(next) == EXACTLY)
- nextch = *OPERAND(next);
- min = (OP(scan) == STAR) ? 0 : 1;
- save = reginput;
- no = regrepeat(OPERAND(scan));
- while (no >= min) {
- /* If it could work, try it. */
- if (nextch == '\0' || *reginput == nextch)
- if (regmatch(next))
- return(1);
- /* Couldn't or didn't -- back up. */
- no--;
- reginput = save + no;
- }
- return(0);
- }
- break;
- case END:
- return(1); /* Success! */
- break;
- default:
- regerror("memory corruption");
- return(0);
- break;
- }
-
- scan = next;
- }
-
- /*
- * We get here only if there's trouble -- normally "case END" is
- * the terminating point.
- */
- regerror("corrupted pointers");
- return(0);
+ switch (OP(scan)) {
+ case BOL:
+ if (reginput != regbol)
+ return(0);
+ break;
+ case EOL:
+ if (*reginput != '\0')
+ return(0);
+ break;
+ case WORDA:
+ /* Must be looking at a letter, digit, or _ */
+ if ((!isalnum(*reginput)) && *reginput != '_')
+ return(0);
+ /* Prev must be BOL or nonword */
+ if (reginput > regbol &&
+ (isalnum(reginput[-1]) || reginput[-1] == '_'))
+ return(0);
+ break;
+ case WORDZ:
+ /* Must be looking at non letter, digit, or _ */
+ if (isalnum(*reginput) || *reginput == '_')
+ return(0);
+ /* We don't care what the previous char was */
+ break;
+ case ANY:
+ if (*reginput == '\0')
+ return(0);
+ reginput++;
+ break;
+ case EXACTLY: {
+ register int len;
+ register char *opnd;
+
+ opnd = OPERAND(scan);
+ /* Inline the first character, for speed. */
+ if (*opnd != *reginput)
+ return(0);
+ len = strlen(opnd);
+ if (len > 1 && strncmp(opnd, reginput, len) != 0)
+ return(0);
+ reginput += len;
+ }
+ break;
+ case ANYOF:
+ if (*reginput == '\0' || strchr(OPERAND(scan), *reginput) == NULL)
+ return(0);
+ reginput++;
+ break;
+ case ANYBUT:
+ if (*reginput == '\0' || strchr(OPERAND(scan), *reginput) != NULL)
+ return(0);
+ reginput++;
+ break;
+ case NOTHING:
+ break;
+ case BACK:
+ break;
+ case OPEN+1:
+ case OPEN+2:
+ case OPEN+3:
+ case OPEN+4:
+ case OPEN+5:
+ case OPEN+6:
+ case OPEN+7:
+ case OPEN+8:
+ case OPEN+9: {
+ register int no;
+ register char *save;
+
+ no = OP(scan) - OPEN;
+ save = reginput;
+
+ if (regmatch(next)) {
+ /*
+ * Don't set startp if some later
+ * invocation of the same parentheses
+ * already has.
+ */
+ if (regstartp[no] == NULL)
+ regstartp[no] = save;
+ return(1);
+ } else
+ return(0);
+ }
+ break;
+ case CLOSE+1:
+ case CLOSE+2:
+ case CLOSE+3:
+ case CLOSE+4:
+ case CLOSE+5:
+ case CLOSE+6:
+ case CLOSE+7:
+ case CLOSE+8:
+ case CLOSE+9: {
+ register int no;
+ register char *save;
+
+ no = OP(scan) - CLOSE;
+ save = reginput;
+
+ if (regmatch(next)) {
+ /*
+ * Don't set endp if some later
+ * invocation of the same parentheses
+ * already has.
+ */
+ if (regendp[no] == NULL)
+ regendp[no] = save;
+ return(1);
+ } else
+ return(0);
+ }
+ break;
+ case BRANCH: {
+ register char *save;
+
+ if (OP(next) != BRANCH) /* No choice. */
+ next = OPERAND(scan); /* Avoid recursion. */
+ else {
+ do {
+ save = reginput;
+ if (regmatch(OPERAND(scan)))
+ return(1);
+ reginput = save;
+ scan = regnext(scan);
+ } while (scan != NULL && OP(scan) == BRANCH);
+ return(0);
+ /* NOTREACHED */
+ }
+ }
+ break;
+ case STAR:
+ case PLUS: {
+ register char nextch;
+ register int no;
+ register char *save;
+ register int min;
+
+ /*
+ * Lookahead to avoid useless match attempts
+ * when we know what character comes next.
+ */
+ nextch = '\0';
+ if (OP(next) == EXACTLY)
+ nextch = *OPERAND(next);
+ min = (OP(scan) == STAR) ? 0 : 1;
+ save = reginput;
+ no = regrepeat(OPERAND(scan));
+ while (no >= min) {
+ /* If it could work, try it. */
+ if (nextch == '\0' || *reginput == nextch)
+ if (regmatch(next))
+ return(1);
+ /* Couldn't or didn't -- back up. */
+ no--;
+ reginput = save + no;
+ }
+ return(0);
+ }
+ break;
+ case END:
+ return(1); /* Success! */
+ break;
+ default:
+ regerror("memory corruption");
+ return(0);
+ break;
+ }
+
+ scan = next;
+ }
+
+ /*
+ * We get here only if there's trouble -- normally "case END" is
+ * the terminating point.
+ */
+ regerror("corrupted pointers");
+ return(0);
}
/*
@@ -1091,43 +1091,43 @@
static int
regrepeat( char *p )
{
- register int count = 0;
- register char *scan;
- register char *opnd;
-
- scan = reginput;
- opnd = OPERAND(p);
- switch (OP(p)) {
- case ANY:
- count = strlen(scan);
- scan += count;
- break;
- case EXACTLY:
- while (*opnd == *scan) {
- count++;
- scan++;
- }
- break;
- case ANYOF:
- while (*scan != '\0' && strchr(opnd, *scan) != NULL) {
- count++;
- scan++;
- }
- break;
- case ANYBUT:
- while (*scan != '\0' && strchr(opnd, *scan) == NULL) {
- count++;
- scan++;
- }
- break;
- default: /* Oh dear. Called inappropriately. */
- regerror("internal foulup");
- count = 0; /* Best compromise. */
- break;
- }
- reginput = scan;
+ register int count = 0;
+ register char *scan;
+ register char *opnd;
+
+ scan = reginput;
+ opnd = OPERAND(p);
+ switch (OP(p)) {
+ case ANY:
+ count = strlen(scan);
+ scan += count;
+ break;
+ case EXACTLY:
+ while (*opnd == *scan) {
+ count++;
+ scan++;
+ }
+ break;
+ case ANYOF:
+ while (*scan != '\0' && strchr(opnd, *scan) != NULL) {
+ count++;
+ scan++;
+ }
+ break;
+ case ANYBUT:
+ while (*scan != '\0' && strchr(opnd, *scan) == NULL) {
+ count++;
+ scan++;
+ }
+ break;
+ default: /* Oh dear. Called inappropriately. */
+ regerror("internal foulup");
+ count = 0; /* Best compromise. */
+ break;
+ }
+ reginput = scan;
- return(count);
+ return(count);
}
/*
@@ -1136,19 +1136,19 @@
static char *
regnext( register char *p )
{
- register int offset;
+ register int offset;
- if (p == ®dummy)
- return(NULL);
+ if (p == ®dummy)
+ return(NULL);
- offset = NEXT(p);
- if (offset == 0)
- return(NULL);
-
- if (OP(p) == BACK)
- return(p-offset);
- else
- return(p+offset);
+ offset = NEXT(p);
+ if (offset == 0)
+ return(NULL);
+
+ if (OP(p) == BACK)
+ return(p-offset);
+ else
+ return(p+offset);
}
#ifdef DEBUG
@@ -1161,40 +1161,40 @@
void
regdump( regexp *r )
{
- register char *s;
- register char op = EXACTLY; /* Arbitrary non-END op. */
- register char *next;
-
-
- s = r->program + 1;
- while (op != END) { /* While that wasn't END last time... */
- op = OP(s);
- printf("%2d%s", s-r->program, regprop(s)); /* Where, what. */
- next = regnext(s);
- if (next == NULL) /* Next ptr. */
- printf("(0)");
- else
- printf("(%d)", (s-r->program)+(next-s));
- s += 3;
- if (op == ANYOF || op == ANYBUT || op == EXACTLY) {
- /* Literal string, where present. */
- while (*s != '\0') {
- putchar(*s);
- s++;
- }
- s++;
- }
- putchar('\n');
- }
-
- /* Header fields of interest. */
- if (r->regstart != '\0')
- printf("start `%c' ", r->regstart);
- if (r->reganch)
- printf("anchored ");
- if (r->regmust != NULL)
- printf("must have \"%s\"", r->regmust);
- printf("\n");
+ register char *s;
+ register char op = EXACTLY; /* Arbitrary non-END op. */
+ register char *next;
+
+
+ s = r->program + 1;
+ while (op != END) { /* While that wasn't END last time... */
+ op = OP(s);
+ printf("%2d%s", s-r->program, regprop(s)); /* Where, what. */
+ next = regnext(s);
+ if (next == NULL) /* Next ptr. */
+ printf("(0)");
+ else
+ printf("(%d)", (s-r->program)+(next-s));
+ s += 3;
+ if (op == ANYOF || op == ANYBUT || op == EXACTLY) {
+ /* Literal string, where present. */
+ while (*s != '\0') {
+ putchar(*s);
+ s++;
+ }
+ s++;
+ }
+ putchar('\n');
+ }
+
+ /* Header fields of interest. */
+ if (r->regstart != '\0')
+ printf("start `%c' ", r->regstart);
+ if (r->reganch)
+ printf("anchored ");
+ if (r->regmust != NULL)
+ printf("must have \"%s\"", r->regmust);
+ printf("\n");
}
/*
@@ -1203,85 +1203,85 @@
static char *
regprop( char *op )
{
- register char *p;
- static char buf[50];
+ register char *p;
+ static char buf[50];
- (void) strcpy(buf, ":");
+ (void) strcpy(buf, ":");
- switch (OP(op)) {
- case BOL:
- p = "BOL";
- break;
- case EOL:
- p = "EOL";
- break;
- case ANY:
- p = "ANY";
- break;
- case ANYOF:
- p = "ANYOF";
- break;
- case ANYBUT:
- p = "ANYBUT";
- break;
- case BRANCH:
- p = "BRANCH";
- break;
- case EXACTLY:
- p = "EXACTLY";
- break;
- case NOTHING:
- p = "NOTHING";
- break;
- case BACK:
- p = "BACK";
- break;
- case END:
- p = "END";
- break;
- case OPEN+1:
- case OPEN+2:
- case OPEN+3:
- case OPEN+4:
- case OPEN+5:
- case OPEN+6:
- case OPEN+7:
- case OPEN+8:
- case OPEN+9:
- sprintf(buf+strlen(buf), "OPEN%d", OP(op)-OPEN);
- p = NULL;
- break;
- case CLOSE+1:
- case CLOSE+2:
- case CLOSE+3:
- case CLOSE+4:
- case CLOSE+5:
- case CLOSE+6:
- case CLOSE+7:
- case CLOSE+8:
- case CLOSE+9:
- sprintf(buf+strlen(buf), "CLOSE%d", OP(op)-CLOSE);
- p = NULL;
- break;
- case STAR:
- p = "STAR";
- break;
- case PLUS:
- p = "PLUS";
- break;
- case WORDA:
- p = "WORDA";
- break;
- case WORDZ:
- p = "WORDZ";
- break;
- default:
- regerror("corrupted opcode");
- break;
- }
- if (p != NULL)
- (void) strcat(buf, p);
- return(buf);
+ switch (OP(op)) {
+ case BOL:
+ p = "BOL";
+ break;
+ case EOL:
+ p = "EOL";
+ break;
+ case ANY:
+ p = "ANY";
+ break;
+ case ANYOF:
+ p = "ANYOF";
+ break;
+ case ANYBUT:
+ p = "ANYBUT";
+ break;
+ case BRANCH:
+ p = "BRANCH";
+ break;
+ case EXACTLY:
+ p = "EXACTLY";
+ break;
+ case NOTHING:
+ p = "NOTHING";
+ break;
+ case BACK:
+ p = "BACK";
+ break;
+ case END:
+ p = "END";
+ break;
+ case OPEN+1:
+ case OPEN+2:
+ case OPEN+3:
+ case OPEN+4:
+ case OPEN+5:
+ case OPEN+6:
+ case OPEN+7:
+ case OPEN+8:
+ case OPEN+9:
+ sprintf(buf+strlen(buf), "OPEN%d", OP(op)-OPEN);
+ p = NULL;
+ break;
+ case CLOSE+1:
+ case CLOSE+2:
+ case CLOSE+3:
+ case CLOSE+4:
+ case CLOSE+5:
+ case CLOSE+6:
+ case CLOSE+7:
+ case CLOSE+8:
+ case CLOSE+9:
+ sprintf(buf+strlen(buf), "CLOSE%d", OP(op)-CLOSE);
+ p = NULL;
+ break;
+ case STAR:
+ p = "STAR";
+ break;
+ case PLUS:
+ p = "PLUS";
+ break;
+ case WORDA:
+ p = "WORDA";
+ break;
+ case WORDZ:
+ p = "WORDZ";
+ break;
+ default:
+ regerror("corrupted opcode");
+ break;
+ }
+ if (p != NULL)
+ (void) strcat(buf, p);
+ return(buf);
}
#endif
@@ -1299,20 +1299,20 @@
static int
strcspn(
- char *s1,
- char *s2 )
+ char *s1,
+ char *s2 )
{
- register char *scan1;
- register char *scan2;
- register int count;
-
- count = 0;
- for (scan1 = s1; *scan1 != '\0'; scan1++) {
- for (scan2 = s2; *scan2 != '\0';) /* ++ moved down. */
- if (*scan1 == *scan2++)
- return(count);
- count++;
- }
- return(count);
+ register char *scan1;
+ register char *scan2;
+ register int count;
+
+ count = 0;
+ for (scan1 = s1; *scan1 != '\0'; scan1++) {
+ for (scan2 = s2; *scan2 != '\0';) /* ++ moved down. */
+ if (*scan1 == *scan2++)
+ return(count);
+ count++;
+ }
+ return(count);
}
#endif
Modified: trunk/tools/jam/src/regexp.h
==============================================================================
--- trunk/tools/jam/src/regexp.h (original)
+++ trunk/tools/jam/src/regexp.h 2008-08-29 08:59:49 EDT (Fri, 29 Aug 2008)
@@ -9,13 +9,13 @@
#define NSUBEXP 10
typedef struct regexp {
- char *startp[NSUBEXP];
- char *endp[NSUBEXP];
- char regstart; /* Internal use only. */
- char reganch; /* Internal use only. */
- char *regmust; /* Internal use only. */
- int regmlen; /* Internal use only. */
- char program[1]; /* Unwarranted chumminess with compiler. */
+ char *startp[NSUBEXP];
+ char *endp[NSUBEXP];
+ char regstart; /* Internal use only. */
+ char reganch; /* Internal use only. */
+ char *regmust; /* Internal use only. */
+ int regmlen; /* Internal use only. */
+ char program[1]; /* Unwarranted chumminess with compiler. */
} regexp;
regexp *regcomp( char *exp );
@@ -26,7 +26,7 @@
* 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/jam/src/rules.c
==============================================================================
--- trunk/tools/jam/src/rules.c (original)
+++ trunk/tools/jam/src/rules.c 2008-08-29 08:59:49 EDT (Fri, 29 Aug 2008)
@@ -53,11 +53,12 @@
typedef struct _located_target LOCATED_TARGET ;
-struct _located_target {
- char* file_name;
- TARGET* target;
+struct _located_target
+{
+ char * file_name;
+ TARGET * target;
};
-static struct hash *located_targets = 0;
+static struct hash * located_targets = 0;
/*
@@ -82,16 +83,16 @@
* enter_rule() - return pointer to RULE, creating it if necessary in
* target_module.
*/
-static RULE *
-enter_rule( char *rulename, module_t *target_module )
+static RULE * enter_rule( char * rulename, module_t * target_module )
{
- RULE rule, *r = &rule;
+ RULE rule;
+ RULE * r = &rule;
r->name = rulename;
- if ( hashenter( demand_rules( target_module ), (HASHDATA **)&r ) )
+ if ( hashenter( demand_rules( target_module ), (HASHDATA * *)&r ) )
{
- r->name = newstr( rulename ); /* never freed */
+ r->name = newstr( rulename ); /* never freed */
r->procedure = (PARSE *)0;
r->module = 0;
r->actions = 0;
@@ -105,38 +106,42 @@
return r;
}
+
/*
* define_rule() - return pointer to RULE, creating it if necessary in
* target_module. Prepare it to accept a body or action originating in
* src_module.
*/
-static RULE *
-define_rule( module_t *src_module, char *rulename, module_t *target_module )
-{
- RULE *r = enter_rule( rulename, target_module );
+static RULE * define_rule
+(
+ module_t * src_module,
+ char * rulename,
+ module_t * target_module
+)
+{
+ RULE * r = enter_rule( rulename, target_module );
if ( r->module != src_module ) /* if the rule was imported from elsewhere, clear it now */
{
- set_rule_body( r, 0, 0 );
+ set_rule_body( r, 0, 0 );
set_rule_actions( r, 0 );
r->module = src_module; /* r will be executed in the source module */
}
-
return r;
}
-void
-rule_free( RULE* r )
+
+void rule_free( RULE * r )
{
freestr( r->name );
r->name = "";
parse_free( r->procedure );
r->procedure = 0;
- if ( r->arguments )
- args_free( r->arguments );
+ if ( r->arguments )
+ args_free( r->arguments );
r->arguments = 0;
if ( r->actions )
- actions_free( r->actions );
+ actions_free( r->actions );
r->actions = 0;
}
@@ -147,25 +152,25 @@
TARGET *
bindtarget( const char *targetname )
{
- TARGET target, *t = ⌖
+ TARGET target, *t = ⌖
- if( !targethash )
- targethash = hashinit( sizeof( TARGET ), "targets" );
+ if( !targethash )
+ targethash = hashinit( sizeof( TARGET ), "targets" );
/* Perforce added const everywhere. No time to merge that change. */
#ifdef NT
targetname = short_path_to_long_path( (char*)targetname );
#endif
- t->name = (char*)targetname;
+ t->name = (char*)targetname;
- if( hashenter( targethash, (HASHDATA **)&t ) )
- {
- memset( (char *)t, '\0', sizeof( *t ) );
- t->name = newstr( (char*)targetname ); /* never freed */
- t->boundname = t->name; /* default for T_FLAG_NOTFILE */
- }
+ if( hashenter( targethash, (HASHDATA **)&t ) )
+ {
+ memset( (char *)t, '\0', sizeof( *t ) );
+ t->name = newstr( (char*)targetname ); /* never freed */
+ t->boundname = t->name; /* default for T_FLAG_NOTFILE */
+ }
- return t;
+ return t;
}
@@ -177,8 +182,8 @@
/* Check if there's a setting for LOCATE */
SETTINGS* s = t->settings;
for(; s ; s = s->next)
- {
- if (strcmp(s->symbol, "LOCATE") == 0)
+ {
+ if (strcmp(s->symbol, "LOCATE") == 0)
{
pushsettings(t->settings);
/* We're binding a target with explicit LOCATE. So
@@ -192,16 +197,19 @@
}
}
+
void bind_explicitly_located_targets()
{
if (targethash)
hashenumerate(targethash, bind_explicitly_located_target, (void*)0);
}
-/* TODO: this is probably not a good idea to use functions in other modules like
+
+/* TODO: it is probably not a good idea to use functions in other modules like
that. */
void call_bind_rule(char* target, char* boundname);
+
TARGET* search_for_target ( char * name, LIST* search_path )
{
PATHNAME f[1];
@@ -213,7 +221,7 @@
string_new( buf );
- path_parse( name, f );
+ path_parse( name, f );
f->f_grist.ptr = 0;
f->f_grist.len = 0;
@@ -256,7 +264,7 @@
string_truncate( buf, 0 );
path_build( f, buf, 1 );
- timestamp( buf->value, &time );
+ timestamp( buf->value, &time );
}
result = bindtarget( name );
@@ -265,32 +273,31 @@
result->binding = time ? T_BIND_EXISTS : T_BIND_MISSING;
call_bind_rule( result->name, result->boundname );
-
+
string_free( buf );
return result;
-
}
+
/*
* copytarget() - make a new target with the old target's name
*
* Not entered into hash table -- for internal nodes.
*/
-TARGET *
-copytarget( const TARGET *ot )
+TARGET * copytarget( const TARGET * ot )
{
- TARGET *t;
+ TARGET *t;
- t = (TARGET *)BJAM_MALLOC( sizeof( *t ) );
- memset( (char *)t, '\0', sizeof( *t ) );
- t->name = copystr( ot->name );
- t->boundname = t->name;
+ t = (TARGET *)BJAM_MALLOC( sizeof( *t ) );
+ memset( (char *)t, '\0', sizeof( *t ) );
+ t->name = copystr( ot->name );
+ t->boundname = t->name;
- t->flags |= T_FLAG_NOTFILE | T_FLAG_INTERNAL;
+ t->flags |= T_FLAG_NOTFILE | T_FLAG_INTERNAL;
- return t;
+ return t;
}
/*
@@ -300,78 +307,80 @@
void
touchtarget( char *t )
{
- bindtarget( t )->flags |= T_FLAG_TOUCHED;
+ bindtarget( t )->flags |= T_FLAG_TOUCHED;
}
+
/*
* targetlist() - turn list of target names into a TARGET chain
*
* Inputs:
- * chain existing TARGETS to append to
- * targets list of target names
+ * chain existing TARGETS to append to
+ * targets list of target names
*/
TARGETS *
-targetlist(
- TARGETS *chain,
- LIST *targets )
+targetlist(
+ TARGETS *chain,
+ LIST *targets )
{
- for( ; targets; targets = list_next( targets ) )
- chain = targetentry( chain, bindtarget( targets->string ) );
+ for( ; targets; targets = list_next( targets ) )
+ chain = targetentry( chain, bindtarget( targets->string ) );
- return chain;
+ return chain;
}
+
/*
* targetentry() - add a TARGET to a chain of TARGETS
*
* Inputs:
- * chain exisitng TARGETS to append to
- * target new target to append
+ * chain existing TARGETS to append to
+ * target new target to append
*/
TARGETS *
-targetentry(
- TARGETS *chain,
- TARGET *target )
+targetentry(
+ TARGETS *chain,
+ TARGET *target )
{
- TARGETS *c;
+ TARGETS *c;
- c = (TARGETS *)BJAM_MALLOC( sizeof( TARGETS ) );
- c->target = target;
+ c = (TARGETS *)BJAM_MALLOC( sizeof( TARGETS ) );
+ c->target = target;
- if( !chain ) chain = c;
- else chain->tail->next = c;
- chain->tail = c;
- c->next = 0;
+ if( !chain ) chain = c;
+ else chain->tail->next = c;
+ chain->tail = c;
+ c->next = 0;
- return chain;
+ return chain;
}
/*
* targetchain() - append two TARGET chains
*
* Inputs:
- * chain exisitng TARGETS to append to
- * target new target to append
+ * chain exisitng TARGETS to append to
+ * target new target to append
*/
TARGETS *
-targetchain(
- TARGETS *chain,
- TARGETS *targets )
+targetchain(
+ TARGETS *chain,
+ TARGETS *targets )
{
- TARGETS *c;
+ TARGETS *c;
- if( !targets )
- return chain;
- else if( !chain )
- return targets;
+ if( !targets )
+ return chain;
+ else if( !chain )
+ return targets;
- chain->tail->next = targets;
- chain->tail = targets->tail;
+ chain->tail->next = targets;
+ chain->tail = targets->tail;
- return chain;
+ return chain;
}
/*
@@ -380,19 +389,19 @@
ACTIONS *
actionlist(
- ACTIONS *chain,
- ACTION *action )
+ ACTIONS *chain,
+ ACTION *action )
{
- ACTIONS *actions = (ACTIONS *)BJAM_MALLOC( sizeof( ACTIONS ) );
+ ACTIONS *actions = (ACTIONS *)BJAM_MALLOC( sizeof( ACTIONS ) );
- actions->action = action;
+ actions->action = action;
- if( !chain ) chain = actions;
- else chain->tail->next = actions;
- chain->tail = actions;
- actions->next = 0;
+ if( !chain ) chain = actions;
+ else chain->tail->next = actions;
+ chain->tail = actions;
+ actions->next = 0;
- return chain;
+ return chain;
}
static SETTINGS* settings_freelist;
@@ -409,54 +418,54 @@
SETTINGS *
addsettings(
- SETTINGS *head,
- int flag,
- char *symbol,
- LIST *value )
-{
- SETTINGS *v;
-
- /* Look for previous setting */
-
- for( v = head; v; v = v->next )
- if( !strcmp( v->symbol, symbol ) )
- break;
-
- /* If not previously set, alloc a new. */
- /* If appending, do so. */
- /* Else free old and set new. */
+ SETTINGS *head,
+ int flag,
+ char *symbol,
+ LIST *value )
+{
+ SETTINGS *v;
+
+ /* Look for previous setting */
+
+ for( v = head; v; v = v->next )
+ if( !strcmp( v->symbol, symbol ) )
+ break;
- if( !v )
- {
+ /* If not previously set, alloc a new. */
+ /* If appending, do so. */
+ /* Else free old and set new. */
+
+ if( !v )
+ {
v = settings_freelist;
-
+
if ( v )
settings_freelist = v->next;
else
{
v = (SETTINGS *)BJAM_MALLOC( sizeof( *v ) );
}
-
- v->symbol = newstr( symbol );
- v->value = value;
- v->next = head;
- head = v;
- }
- else if( flag == VAR_APPEND )
- {
- v->value = list_append( v->value, value );
- }
- else if( flag != VAR_DEFAULT )
- {
- list_free( v->value );
- v->value = value;
- }
+
+ v->symbol = newstr( symbol );
+ v->value = value;
+ v->next = head;
+ head = v;
+ }
+ else if( flag == VAR_APPEND )
+ {
+ v->value = list_append( v->value, value );
+ }
+ else if( flag != VAR_DEFAULT )
+ {
+ list_free( v->value );
+ v->value = value;
+ }
else
list_free( value );
- /* Return (new) head of list. */
+ /* Return (new) head of list. */
- return head;
+ return head;
}
/*
@@ -466,8 +475,8 @@
void
pushsettings( SETTINGS *v )
{
- for( ; v; v = v->next )
- v->value = var_swap( v->symbol, v->value );
+ for( ; v; v = v->next )
+ v->value = var_swap( v->symbol, v->value );
}
/*
@@ -477,7 +486,7 @@
void
popsettings( SETTINGS *v )
{
- pushsettings( v ); /* just swap again */
+ pushsettings( v ); /* just swap again */
}
/*
@@ -489,7 +498,7 @@
SETTINGS *copy = 0, *v;
for (v = head; v; v = v->next)
- copy = addsettings(copy, VAR_SET, v->symbol, list_copy(0, v->value));
+ copy = addsettings(copy, VAR_SET, v->symbol, list_copy(0, v->value));
return copy;
}
@@ -528,17 +537,17 @@
void
freesettings( SETTINGS *v )
{
- while( v )
- {
- SETTINGS *n = v->next;
+ while( v )
+ {
+ SETTINGS *n = v->next;
- freestr( v->symbol );
- list_free( v->value );
+ freestr( v->symbol );
+ list_free( v->value );
v->next = settings_freelist;
settings_freelist = v;
- v = n;
- }
+ v = n;
+ }
}
static void freetarget( void *xt, void *data )
@@ -562,7 +571,7 @@
donerules()
{
hashenumerate( targethash, freetarget, 0 );
- hashdone( targethash );
+ hashdone( targethash );
while ( settings_freelist )
{
SETTINGS* n = settings_freelist->next;
@@ -633,7 +642,7 @@
if ( rule->arguments )
args_free( rule->arguments );
rule->arguments = args;
-
+
if ( procedure )
parse_refer( procedure );
if ( rule->procedure )
@@ -688,7 +697,7 @@
RULE* local = define_rule( m, rulename, m );
local->exported = exported;
set_rule_body( local, args, procedure );
-
+
/* Mark the procedure with the global rule name, regardless of
* whether the rule is exported. That gives us something
* reasonably identifiable that we can use, e.g. in profiling
@@ -708,7 +717,7 @@
if ( rule->actions )
actions_free( rule->actions );
rule->actions = actions;
-
+
}
static rule_actions* actions_new( char* command, LIST* bindlist, int flags )
@@ -732,7 +741,7 @@
/* Looks for a rule in the specified module, and returns it, if found.
First checks if the rule is present in the module's rule table.
- Second, if name of the rule is in the form name1.name2 and name1 is in
+ Second, if name of the rule is in the form name1.name2 and name1 is in
the list of imported modules, look in module 'name1' for rule 'name2'.
*/
RULE *lookup_rule( char *rulename, module_t *m, int local_only )
@@ -757,7 +766,7 @@
result = lookup_rule(p+1, bindmodule(rulename), 1);
}
*p = '.';
- }
+ }
}
if (result)
@@ -771,15 +780,15 @@
Mark it for execution in the instance where we've started lookup.
*/
int execute_in_class = (result->module == m);
- int execute_in_some_instance =
+ int execute_in_some_instance =
(result->module->class_module && result->module->class_module == m);
if (original_module != m && (execute_in_class || execute_in_some_instance))
- result->module = original_module;
+ result->module = original_module;
}
}
return result;
-
+
}
@@ -790,7 +799,7 @@
result = lookup_rule(rulename, m, 0);
if (!result)
result = lookup_rule(rulename, root_module(), 0);
- /* We've only one caller, 'evaluate_rule', which will complain about
+ /* We've only one caller, 'evaluate_rule', which will complain about
calling underfined rule. We could issue the error
here, but we don't have necessary information, such as frame.
*/
Modified: trunk/tools/jam/src/rules.h
==============================================================================
--- trunk/tools/jam/src/rules.h (original)
+++ trunk/tools/jam/src/rules.h 2008-08-29 08:59:49 EDT (Fri, 29 Aug 2008)
@@ -26,12 +26,12 @@
*
* The following are defined:
*
- * RULE - a generic jam rule, the product of RULE and ACTIONS
- * ACTIONS - a chain of ACTIONs
- * ACTION - a RULE instance with targets and sources
- * SETTINGS - variables to set when executing a TARGET's ACTIONS
- * TARGETS - a chain of TARGETs
- * TARGET - a file or "thing" that can be built
+ * RULE - a generic jam rule, the product of RULE and ACTIONS
+ * ACTIONS - a chain of ACTIONs
+ * ACTION - a RULE instance with targets and sources
+ * SETTINGS - variables to set when executing a TARGET's ACTIONS
+ * TARGETS - a chain of TARGETs
+ * TARGET - a file or "thing" that can be built
*
* 04/11/94 (seiwald) - Combined deps & headers into deps[2] in TARGET.
* 04/12/94 (seiwald) - actionlist() now just appends a single action.
@@ -77,77 +77,79 @@
typedef struct rule_actions rule_actions;
typedef struct argument_list argument_list;
-struct _rule {
- char *name;
- PARSE *procedure; /* parse tree from RULE */
- argument_list* arguments; /* argument checking info, or NULL for unchecked */
- rule_actions* actions; /* build actions, or NULL for no actions */
- module_t *module; /* module in which this rule is executed */
- int exported; /* nonzero if this rule is supposed to
- * appear in the global module and be
- * automatically imported into other modules
- */
+struct _rule
+{
+ char * name;
+ PARSE * procedure; /* parse tree from RULE */
+ argument_list * arguments; /* argument checking info, or NULL for unchecked
+ */
+ rule_actions * actions; /* build actions, or NULL for no actions */
+ module_t * module; /* module in which this rule is executed */
+ int exported; /* nonzero if this rule is supposed to appear in
+ * the global module and be automatically
+ * imported into other modules
+ */
#ifdef HAVE_PYTHON
- PyObject* python_function;
-#endif
+ PyObject * python_function;
+#endif
};
/* ACTIONS - a chain of ACTIONs */
struct _actions {
- ACTIONS *next;
- ACTIONS *tail; /* valid only for head */
- ACTION *action;
+ ACTIONS *next;
+ ACTIONS *tail; /* valid only for head */
+ ACTION *action;
} ;
/* ACTION - a RULE instance with targets and sources */
struct _action {
- RULE *rule;
- TARGETS *targets;
- TARGETS *sources; /* aka $(>) */
- char running; /* has been started */
- char status; /* see TARGET status */
+ RULE *rule;
+ TARGETS *targets;
+ TARGETS *sources; /* aka $(>) */
+ char running; /* has been started */
+ char status; /* see TARGET status */
} ;
/* SETTINGS - variables to set when executing a TARGET's ACTIONS */
struct _settings {
- SETTINGS *next;
- char *symbol; /* symbol name for var_set() */
- LIST *value; /* symbol value for var_set() */
+ SETTINGS *next;
+ char *symbol; /* symbol name for var_set() */
+ LIST *value; /* symbol value for var_set() */
} ;
/* TARGETS - a chain of TARGETs */
struct _targets {
- TARGETS *next;
- TARGETS *tail; /* valid only for head */
- TARGET *target;
+ TARGETS *next;
+ TARGETS *tail; /* valid only for head */
+ TARGET *target;
} ;
/* TARGET - a file or "thing" that can be built */
struct _target {
- char *name;
- char *boundname; /* if search() relocates target */
- ACTIONS *actions; /* rules to execute, if any */
- SETTINGS *settings; /* variables to define */
-
- short flags; /* status info */
-
-# define T_FLAG_TEMP 0x0001 /* TEMPORARY applied */
-# define T_FLAG_NOCARE 0x0002 /* NOCARE applied */
-# define T_FLAG_NOTFILE 0x0004 /* NOTFILE applied */
-# define T_FLAG_TOUCHED 0x0008 /* ALWAYS applied or -t target */
-# define T_FLAG_LEAVES 0x0010 /* LEAVES applied */
-# define T_FLAG_NOUPDATE 0x0020 /* NOUPDATE applied */
-# define T_FLAG_VISITED 0x0040 /* CWM: Used in debugging */
+ char *name;
+ char *boundname; /* if search() relocates target */
+ ACTIONS *actions; /* rules to execute, if any */
+ SETTINGS *settings; /* variables to define */
+
+ short flags; /* status info */
+
+# define T_FLAG_TEMP 0x0001 /* TEMPORARY applied */
+# define T_FLAG_NOCARE 0x0002 /* NOCARE applied */
+# define T_FLAG_NOTFILE 0x0004 /* NOTFILE applied */
+# define T_FLAG_TOUCHED 0x0008 /* ALWAYS applied or -t target */
+# define T_FLAG_LEAVES 0x0010 /* LEAVES applied */
+# define T_FLAG_NOUPDATE 0x0020 /* NOUPDATE applied */
+# define T_FLAG_VISITED 0x0040 /* CWM: Used in debugging */
/* this flag was added to support a new builtin rule named "RMBAD" */
/* it is used to force removal of outdated targets whose dependencies
* fail to build */
-
+
# define T_FLAG_RMOLD 0x0080 /* RMBAD applied */
/* this flag was added to support a new builting rule named "FAIL_EXPECTED" */
@@ -166,72 +168,72 @@
#ifdef OPT_SEMAPHORE
-# define T_MAKE_SEMAPHORE 5 /* Special target type for semaphores */
+# define T_MAKE_SEMAPHORE 5 /* Special target type for semaphores */
#endif
- char binding; /* how target relates to real file */
+ char binding; /* how target relates to real file */
-# define T_BIND_UNBOUND 0 /* a disembodied name */
-# define T_BIND_MISSING 1 /* couldn't find real file */
+# define T_BIND_UNBOUND 0 /* a disembodied name */
+# define T_BIND_MISSING 1 /* couldn't find real file */
#ifdef OPT_SEMAPHORE
- TARGET *semaphore; /* used in serialization */
+ TARGET *semaphore; /* used in serialization */
#endif
-# define T_BIND_PARENTS 2 /* using parent's timestamp */
-# define T_BIND_EXISTS 3 /* real file, timestamp valid */
+# define T_BIND_PARENTS 2 /* using parent's timestamp */
+# define T_BIND_EXISTS 3 /* real file, timestamp valid */
- TARGETS *depends; /* dependencies */
- TARGETS *dependents;/* the inverse of dependencies */
+ TARGETS *depends; /* dependencies */
+ TARGETS *dependents;/* the inverse of dependencies */
TARGETS *rebuilds; /* targets that should be force-rebuilt whenever this one is */
- TARGET *includes; /* includes */
- TARGET *original_target; /* original_target->includes = this */
+ TARGET *includes; /* internal includes node */
+ TARGET *original_target; /* original_target->includes = this */
char rescanned;
- time_t time; /* update time */
- time_t leaf; /* update time of leaf sources */
+ time_t time; /* update time */
+ time_t leaf; /* update time of leaf sources */
- char fate; /* make0()'s diagnosis */
+ char fate; /* make0()'s diagnosis */
-# define T_FATE_INIT 0 /* nothing done to target */
-# define T_FATE_MAKING 1 /* make0(target) on stack */
+# define T_FATE_INIT 0 /* nothing done to target */
+# define T_FATE_MAKING 1 /* make0(target) on stack */
-# define T_FATE_STABLE 2 /* target didn't need updating */
-# define T_FATE_NEWER 3 /* target newer than parent */
+# define T_FATE_STABLE 2 /* target didn't need updating */
+# define T_FATE_NEWER 3 /* target newer than parent */
-# define T_FATE_SPOIL 4 /* >= SPOIL rebuilds parents */
-# define T_FATE_ISTMP 4 /* unneeded temp target oddly present */
+# define T_FATE_SPOIL 4 /* >= SPOIL rebuilds parents */
+# define T_FATE_ISTMP 4 /* unneeded temp target oddly present */
-# define T_FATE_BUILD 5 /* >= BUILD rebuilds target */
-# define T_FATE_TOUCHED 5 /* manually touched with -t */
-# define T_FATE_REBUILD 6
-# define T_FATE_MISSING 7 /* is missing, needs updating */
-# define T_FATE_NEEDTMP 8 /* missing temp that must be rebuild */
-# define T_FATE_OUTDATED 9 /* is out of date, needs updating */
-# define T_FATE_UPDATE 10 /* deps updated, needs updating */
+# define T_FATE_BUILD 5 /* >= BUILD rebuilds target */
+# define T_FATE_TOUCHED 5 /* manually touched with -t */
+# define T_FATE_REBUILD 6
+# define T_FATE_MISSING 7 /* is missing, needs updating */
+# define T_FATE_NEEDTMP 8 /* missing temp that must be rebuild */
+# define T_FATE_OUTDATED 9 /* is out of date, needs updating */
+# define T_FATE_UPDATE 10 /* deps updated, needs updating */
-# define T_FATE_BROKEN 11 /* >= BROKEN ruins parents */
-# define T_FATE_CANTFIND 11 /* no rules to make missing target */
-# define T_FATE_CANTMAKE 12 /* can't find dependents */
+# define T_FATE_BROKEN 11 /* >= BROKEN ruins parents */
+# define T_FATE_CANTFIND 11 /* no rules to make missing target */
+# define T_FATE_CANTMAKE 12 /* can't find dependents */
- char progress; /* tracks make1() progress */
+ char progress; /* tracks make1() progress */
-# define T_MAKE_INIT 0 /* make1(target) not yet called */
-# define T_MAKE_ONSTACK 1 /* make1(target) on stack */
-# define T_MAKE_ACTIVE 2 /* make1(target) in make1b() */
-# define T_MAKE_RUNNING 3 /* make1(target) running commands */
-# define T_MAKE_DONE 4 /* make1(target) done */
+# define T_MAKE_INIT 0 /* make1(target) not yet called */
+# define T_MAKE_ONSTACK 1 /* make1(target) on stack */
+# define T_MAKE_ACTIVE 2 /* make1(target) in make1b() */
+# define T_MAKE_RUNNING 3 /* make1(target) running commands */
+# define T_MAKE_DONE 4 /* make1(target) done */
- char status; /* execcmd() result */
+ char status; /* execcmd() result */
- int asynccnt; /* child deps outstanding */
- TARGETS *parents; /* used by make1() for completion */
- char *cmds; /* type-punned command list */
+ int asynccnt; /* child deps outstanding */
+ TARGETS *parents; /* used by make1() for completion */
+ char *cmds; /* type-punned command list */
char* failed;
} ;
-void add_include( TARGET * including, TARGET * included );
-RULE *bindrule( char *rulename, module_t* );
+void add_include( TARGET * including, TARGET * included );
+RULE * bindrule ( char * rulename, module_t* );
RULE* import_rule( RULE* source, module_t* m, char* name );
RULE* new_rule_body( module_t* m, char* rulename, argument_list* args, PARSE* procedure, int exprt );
@@ -240,7 +242,7 @@
TARGET *copytarget( const TARGET *t );
void bind_explicitly_located_targets();
TARGET* search_for_target( char * name, LIST* search_path );
-void touchtarget( char *t );
+void touchtarget( char *t );
TARGETS *targetlist( TARGETS *chain, LIST *targets );
TARGETS *targetentry( TARGETS *chain, TARGET *target );
TARGETS *targetchain( TARGETS *chain, TARGETS *targets );
@@ -248,12 +250,12 @@
ACTIONS *actionlist( ACTIONS *chain, ACTION *action );
void freeactions( ACTIONS *chain );
SETTINGS *addsettings( SETTINGS *head, int flag, char *symbol, LIST *value );
-void pushsettings( SETTINGS *v );
-void popsettings( SETTINGS *v );
+void pushsettings( SETTINGS *v );
+void popsettings( SETTINGS *v );
SETTINGS *copysettings( SETTINGS *v );
-void freesettings( SETTINGS *v );
+void freesettings( SETTINGS *v );
void rule_free( RULE *r );
-void donerules();
+void donerules();
argument_list* args_new();
void args_refer( argument_list* );
Modified: trunk/tools/jam/src/scan.c
==============================================================================
--- trunk/tools/jam/src/scan.c (original)
+++ trunk/tools/jam/src/scan.c 2008-08-29 08:59:49 EDT (Fri, 29 Aug 2008)
@@ -17,30 +17,30 @@
*
* 12/26/93 (seiwald) - bump buf in yylex to 10240 - yuk.
* 09/16/94 (seiwald) - check for overflows, unmatched {}'s, etc.
- * Also handle tokens abutting EOF by remembering
- * to return EOF now matter how many times yylex()
- * reinvokes yyline().
+ * Also handle tokens abutting EOF by remembering
+ * to return EOF now matter how many times yylex()
+ * reinvokes yyline().
* 02/11/95 (seiwald) - honor only punctuation keywords if SCAN_PUNCT.
* 07/27/95 (seiwald) - Include jamgram.h after scan.h, so that YYSTYPE is
- * defined before Linux's yacc tries to redefine it.
+ * defined before Linux's yacc tries to redefine it.
*/
struct keyword {
- char *word;
- int type;
+ char *word;
+ int type;
} keywords[] = {
# include "jamgramtab.h"
- { 0, 0 }
+ { 0, 0 }
} ;
struct include {
- struct include *next; /* next serial include file */
- char *string; /* pointer into current line */
- char **strings; /* for yyfparse() -- text to parse */
- FILE *file; /* for yyfparse() -- file being read */
- char *fname; /* for yyfparse() -- file name */
- int line; /* line counter for error messages */
- char buf[ 512 ]; /* for yyfparse() -- line buffer */
+ struct include *next; /* next serial include file */
+ char *string; /* pointer into current line */
+ char **strings; /* for yyfparse() -- text to parse */
+ FILE *file; /* for yyfparse() -- file being read */
+ char *fname; /* for yyfparse() -- file name */
+ int line; /* line counter for error messages */
+ char buf[ 512 ]; /* for yyfparse() -- line buffer */
} ;
static struct include *incp = 0; /* current file; head of chain */
@@ -49,54 +49,54 @@
static int anyerrors = 0;
static char *symdump( YYSTYPE *s );
-# define BIGGEST_TOKEN 10240 /* no single token can be larger */
+# define BIGGEST_TOKEN 10240 /* no single token can be larger */
-/*
+/*
* Set parser mode: normal, string, or keyword
*/
void
yymode( int n )
{
- scanmode = n;
+ scanmode = n;
}
void
yyerror( char *s )
{
- if( incp )
- printf( "%s:%d: ", incp->fname, incp->line );
+ if( incp )
+ printf( "%s:%d: ", incp->fname, incp->line );
- printf( "%s at %s\n", s, symdump( &yylval ) );
+ printf( "%s at %s\n", s, symdump( &yylval ) );
- ++anyerrors;
+ ++anyerrors;
}
int
yyanyerrors()
{
- return anyerrors != 0;
+ return anyerrors != 0;
}
void
yyfparse( char *s )
{
- struct include *i = (struct include *)BJAM_MALLOC( sizeof( *i ) );
+ struct include *i = (struct include *)BJAM_MALLOC( sizeof( *i ) );
- /* Push this onto the incp chain. */
+ /* Push this onto the incp chain. */
- i->string = "";
- i->strings = 0;
- i->file = 0;
- i->fname = copystr( s );
- i->line = 0;
- i->next = incp;
- incp = i;
+ i->string = "";
+ i->strings = 0;
+ i->file = 0;
+ i->fname = copystr( s );
+ i->line = 0;
+ i->next = incp;
+ incp = i;
- /* If the filename is "+", it means use the internal jambase. */
+ /* If the filename is "+", it means use the internal jambase. */
- if( !strcmp( s, "+" ) )
- i->strings = jambase;
+ if( !strcmp( s, "+" ) )
+ i->strings = jambase;
}
/*
@@ -109,68 +109,68 @@
int
yyline()
{
- struct include *i = incp;
+ struct include *i = incp;
- if( !incp )
- return EOF;
+ if( !incp )
+ return EOF;
- /* Once we start reading from the input stream, we reset the */
- /* include insertion point so that the next include file becomes */
- /* the head of the list. */
+ /* Once we start reading from the input stream, we reset the */
+ /* include insertion point so that the next include file becomes */
+ /* the head of the list. */
- /* If there is more data in this line, return it. */
+ /* If there is more data in this line, return it. */
- if( *i->string )
- return *i->string++;
+ if( *i->string )
+ return *i->string++;
- /* If we're reading from an internal string list, go to the */
- /* next string. */
+ /* If we're reading from an internal string list, go to the */
+ /* next string. */
- if( i->strings )
- {
- if( !*i->strings )
- goto next;
+ if( i->strings )
+ {
+ if( !*i->strings )
+ goto next;
- i->line++;
- i->string = *(i->strings++);
- return *i->string++;
- }
+ i->line++;
+ i->string = *(i->strings++);
+ return *i->string++;
+ }
- /* If necessary, open the file */
+ /* If necessary, open the file */
- if( !i->file )
- {
- FILE *f = stdin;
+ if( !i->file )
+ {
+ FILE *f = stdin;
- if( strcmp( i->fname, "-" ) && !( f = fopen( i->fname, "r" ) ) )
- perror( i->fname );
+ if( strcmp( i->fname, "-" ) && !( f = fopen( i->fname, "r" ) ) )
+ perror( i->fname );
- i->file = f;
- }
+ i->file = f;
+ }
- /* If there's another line in this file, start it. */
+ /* If there's another line in this file, start it. */
- if( i->file && fgets( i->buf, sizeof( i->buf ), i->file ) )
- {
- i->line++;
- i->string = i->buf;
- return *i->string++;
- }
+ if( i->file && fgets( i->buf, sizeof( i->buf ), i->file ) )
+ {
+ i->line++;
+ i->string = i->buf;
+ return *i->string++;
+ }
next:
- /* This include is done. */
- /* Free it up and return EOF so yyparse() returns to parse_file(). */
+ /* This include is done. */
+ /* Free it up and return EOF so yyparse() returns to parse_file(). */
- incp = i->next;
+ incp = i->next;
- /* Close file, free name */
+ /* Close file, free name */
- if( i->file && i->file != stdin )
- fclose( i->file );
- freestr( i->fname );
- BJAM_FREE( (char *)i );
+ if( i->file && i->file != stdin )
+ fclose( i->file );
+ freestr( i->fname );
+ BJAM_FREE( (char *)i );
- return EOF;
+ return EOF;
}
/*
@@ -178,8 +178,8 @@
*
* Macros to move things along:
*
- * yychar() - return and advance character; invalid after EOF
- * yyprev() - back up one character; invalid before yychar()
+ * yychar() - return and advance character; invalid after EOF
+ * yyprev() - back up one character; invalid before yychar()
*
* yychar() returns a continuous stream of characters, until it hits
* the EOF of the current include file.
@@ -191,80 +191,80 @@
int
yylex()
{
- int c;
- char buf[BIGGEST_TOKEN];
- char *b = buf;
+ int c;
+ char buf[BIGGEST_TOKEN];
+ char *b = buf;
- if( !incp )
- goto eof;
+ if( !incp )
+ goto eof;
- /* Get first character (whitespace or of token) */
+ /* Get first character (whitespace or of token) */
- c = yychar();
+ c = yychar();
- if( scanmode == SCAN_STRING )
- {
- /* If scanning for a string (action's {}'s), look for the */
- /* closing brace. We handle matching braces, if they match! */
+ if( scanmode == SCAN_STRING )
+ {
+ /* If scanning for a string (action's {}'s), look for the */
+ /* closing brace. We handle matching braces, if they match! */
- int nest = 1;
+ int nest = 1;
- while( c != EOF && b < buf + sizeof( buf ) )
- {
- if( c == '{' )
- nest++;
+ while( c != EOF && b < buf + sizeof( buf ) )
+ {
+ if( c == '{' )
+ nest++;
- if( c == '}' && !--nest )
- break;
+ if( c == '}' && !--nest )
+ break;
- *b++ = c;
+ *b++ = c;
- c = yychar();
+ c = yychar();
/* turn trailing "\r\n" sequences into plain "\n"
* for Cygwin
*/
if (c == '\n' && b[-1] == '\r')
--b;
- }
+ }
- /* We ate the ending brace -- regurgitate it. */
+ /* We ate the ending brace -- regurgitate it. */
- if( c != EOF )
- yyprev();
+ if( c != EOF )
+ yyprev();
- /* Check obvious errors. */
+ /* Check obvious errors. */
- if( b == buf + sizeof( buf ) )
- {
- yyerror( "action block too big" );
- goto eof;
- }
-
- if( nest )
- {
- yyerror( "unmatched {} in action block" );
- goto eof;
- }
-
- *b = 0;
- yylval.type = STRING;
- yylval.string = newstr( buf );
+ if( b == buf + sizeof( buf ) )
+ {
+ yyerror( "action block too big" );
+ goto eof;
+ }
+
+ if( nest )
+ {
+ yyerror( "unmatched {} in action block" );
+ goto eof;
+ }
+
+ *b = 0;
+ yylval.type = STRING;
+ yylval.string = newstr( buf );
yylval.file = incp->fname;
yylval.line = incp->line;
-
- }
- else
- {
- char *b = buf;
- struct keyword *k;
- int inquote = 0;
- int notkeyword;
-
- /* Eat white space */
- for( ;; )
- {
+ }
+ else
+ {
+ char *b = buf;
+ struct keyword *k;
+ int inquote = 0;
+ int notkeyword;
+
+ /* Eat white space */
+
+ for( ;; )
+ {
/* Skip past white space */
while( c != EOF && isspace( c ) )
@@ -276,134 +276,134 @@
break;
while( ( c = yychar() ) != EOF && c != '\n' )
;
- }
+ }
- /* c now points to the first character of a token. */
+ /* c now points to the first character of a token. */
- if( c == EOF )
- goto eof;
+ if( c == EOF )
+ goto eof;
yylval.file = incp->fname;
yylval.line = incp->line;
-
- /* While scanning the word, disqualify it for (expensive) */
- /* keyword lookup when we can: $anything, "anything", \anything */
-
- notkeyword = c == '$';
-
- /* look for white space to delimit word */
- /* "'s get stripped but preserve white space */
- /* \ protects next character */
-
- while(
- c != EOF &&
- b < buf + sizeof( buf ) &&
- ( inquote || !isspace( c ) ) )
- {
- if( c == '"' )
- {
- /* begin or end " */
- inquote = !inquote;
- notkeyword = 1;
- }
- else if( c != '\\' )
- {
- /* normal char */
- *b++ = c;
- }
- else if( ( c = yychar()) != EOF )
- {
- /* \c */
- *b++ = c;
- notkeyword = 1;
- }
- else
- {
- /* \EOF */
- break;
- }
-
- c = yychar();
- }
-
- /* Check obvious errors. */
-
- if( b == buf + sizeof( buf ) )
- {
- yyerror( "string too big" );
- goto eof;
- }
-
- if( inquote )
- {
- yyerror( "unmatched \" in string" );
- goto eof;
- }
-
- /* We looked ahead a character - back up. */
-
- if( c != EOF )
- yyprev();
-
- /* scan token table */
- /* don't scan if it's obviously not a keyword or if its */
- /* an alphabetic when were looking for punctuation */
-
- *b = 0;
- yylval.type = ARG;
-
- if( !notkeyword && !( isalpha( *buf ) && scanmode == SCAN_PUNCT ) )
- {
- for( k = keywords; k->word; k++ )
- if( *buf == *k->word && !strcmp( k->word, buf ) )
- {
- yylval.type = k->type;
- yylval.string = k->word; /* used by symdump */
- break;
- }
- }
-
- if( yylval.type == ARG )
- yylval.string = newstr( buf );
- }
- if( DEBUG_SCAN )
- printf( "scan %s\n", symdump( &yylval ) );
+ /* While scanning the word, disqualify it for (expensive) */
+ /* keyword lookup when we can: $anything, "anything", \anything */
+
+ notkeyword = c == '$';
+
+ /* look for white space to delimit word */
+ /* "'s get stripped but preserve white space */
+ /* \ protects next character */
+
+ while(
+ c != EOF &&
+ b < buf + sizeof( buf ) &&
+ ( inquote || !isspace( c ) ) )
+ {
+ if( c == '"' )
+ {
+ /* begin or end " */
+ inquote = !inquote;
+ notkeyword = 1;
+ }
+ else if( c != '\\' )
+ {
+ /* normal char */
+ *b++ = c;
+ }
+ else if( ( c = yychar()) != EOF )
+ {
+ /* \c */
+ *b++ = c;
+ notkeyword = 1;
+ }
+ else
+ {
+ /* \EOF */
+ break;
+ }
+
+ c = yychar();
+ }
+
+ /* Check obvious errors. */
+
+ if( b == buf + sizeof( buf ) )
+ {
+ yyerror( "string too big" );
+ goto eof;
+ }
+
+ if( inquote )
+ {
+ yyerror( "unmatched \" in string" );
+ goto eof;
+ }
+
+ /* We looked ahead a character - back up. */
+
+ if( c != EOF )
+ yyprev();
+
+ /* scan token table */
+ /* don't scan if it's obviously not a keyword or if its */
+ /* an alphabetic when were looking for punctuation */
+
+ *b = 0;
+ yylval.type = ARG;
+
+ if( !notkeyword && !( isalpha( *buf ) && scanmode == SCAN_PUNCT ) )
+ {
+ for( k = keywords; k->word; k++ )
+ if( *buf == *k->word && !strcmp( k->word, buf ) )
+ {
+ yylval.type = k->type;
+ yylval.string = k->word; /* used by symdump */
+ break;
+ }
+ }
+
+ if( yylval.type == ARG )
+ yylval.string = newstr( buf );
+ }
+
+ if( DEBUG_SCAN )
+ printf( "scan %s\n", symdump( &yylval ) );
- return yylval.type;
+ return yylval.type;
eof:
yylval.file = "end-of-input"; /* just in case */
yylval.line = 0;
-
- yylval.type = EOF;
- return yylval.type;
+
+ yylval.type = EOF;
+ return yylval.type;
}
static char *
symdump( YYSTYPE *s )
{
- static char buf[ BIGGEST_TOKEN + 20 ];
+ static char buf[ BIGGEST_TOKEN + 20 ];
- switch( s->type )
- {
- case EOF:
- sprintf( buf, "EOF" );
- break;
- case 0:
- sprintf( buf, "unknown symbol %s", s->string );
- break;
- case ARG:
- sprintf( buf, "argument %s", s->string );
- break;
- case STRING:
- sprintf( buf, "string \"%s\"", s->string );
- break;
- default:
- sprintf( buf, "keyword %s", s->string );
- break;
- }
- return buf;
+ switch( s->type )
+ {
+ case EOF:
+ sprintf( buf, "EOF" );
+ break;
+ case 0:
+ sprintf( buf, "unknown symbol %s", s->string );
+ break;
+ case ARG:
+ sprintf( buf, "argument %s", s->string );
+ break;
+ case STRING:
+ sprintf( buf, "string \"%s\"", s->string );
+ break;
+ default:
+ sprintf( buf, "keyword %s", s->string );
+ break;
+ }
+ return buf;
}
/* Get information about the current file and line, for those epsilon
Modified: trunk/tools/jam/src/scan.h
==============================================================================
--- trunk/tools/jam/src/scan.h (original)
+++ trunk/tools/jam/src/scan.h 2008-08-29 08:59:49 EDT (Fri, 29 Aug 2008)
@@ -9,17 +9,17 @@
*
* External functions:
*
- * yyerror( char *s ) - print a parsing error message
- * yyfparse( char *s ) - scan include file s
- * yylex() - parse the next token, returning its type
- * yymode() - adjust lexicon of scanner
- * yyparse() - declaration for yacc parser
- * yyanyerrors() - indicate if any parsing errors occured
+ * yyerror( char *s ) - print a parsing error message
+ * yyfparse( char *s ) - scan include file s
+ * yylex() - parse the next token, returning its type
+ * yymode() - adjust lexicon of scanner
+ * yyparse() - declaration for yacc parser
+ * yyanyerrors() - indicate if any parsing errors occured
*
* The yymode() function is for the parser to adjust the lexicon of the
* scanner. Aside from normal keyword scanning, there is a mode to
- * handle action strings (look only for the closing }) and a mode to
- * ignore most keywords when looking for a punctuation keyword. This
+ * handle action strings (look only for the closing }) and a mode to
+ * ignore most keywords when looking for a punctuation keyword. This
* allows non-punctuation keywords to be used in lists without quoting.
*/
@@ -50,6 +50,6 @@
int yyparse();
void yyinput_stream( char** name, int* line );
-# define SCAN_NORMAL 0 /* normal parsing */
-# define SCAN_STRING 1 /* look only for matching } */
-# define SCAN_PUNCT 2 /* only punctuation keywords */
+# define SCAN_NORMAL 0 /* normal parsing */
+# define SCAN_STRING 1 /* look only for matching } */
+# define SCAN_PUNCT 2 /* only punctuation keywords */
Modified: trunk/tools/jam/src/search.c
==============================================================================
--- trunk/tools/jam/src/search.c (original)
+++ trunk/tools/jam/src/search.c 2008-08-29 08:59:49 EDT (Fri, 29 Aug 2008)
@@ -40,7 +40,7 @@
/* No guarantee that target is an allocated string, so be on the
* safe side */
char* target = copystr( target_ );
-
+
/* Likewise, don't rely on implementation details of newstr.c: allocate
* a copy of boundname */
char* boundname = copystr( boundname_ );
@@ -49,14 +49,14 @@
/* Prepare the argument list */
FRAME frame[1];
frame_init( frame );
-
+
/* First argument is the target name */
lol_add( frame->args, list_new( L0, target ) );
-
+
lol_add( frame->args, list_new( L0, boundname ) );
if( lol_get( frame->args, 1 ) )
evaluate_rule( bind_rule->string, frame );
-
+
/* Clean up */
frame_free( frame );
}
@@ -71,14 +71,14 @@
}
/*
- * search.c - find a target along $(SEARCH) or $(LOCATE)
+ * search.c - find a target along $(SEARCH) or $(LOCATE)
* First, check if LOCATE is set. If so, use it to determine
* the location of target and return, regardless of whether anything
* exists on that location.
*
* Second, examine all directories in SEARCH. If there's file already
* or there's another target with the same name which was placed
- * to this location via LOCATE setting, stop and return the location.
+ * to this location via LOCATE setting, stop and return the location.
* In case of previous target, return it's name via the third argument.
*
* This bevahiour allow to handle dependency on generated files. If
@@ -87,14 +87,14 @@
*/
char *
-search(
+search(
char *target,
time_t *time,
char **another_target,
int file
)
{
- PATHNAME f[1];
+ PATHNAME f[1];
LIST *varlist;
string buf[1];
int found = 0;
@@ -106,13 +106,13 @@
*another_target = 0;
if (! explicit_bindings )
- explicit_bindings = hashinit( sizeof(BINDING),
+ explicit_bindings = hashinit( sizeof(BINDING),
"explicitly specified locations");
string_new( buf );
/* Parse the filename */
- path_parse( target, f );
+ path_parse( target, f );
f->f_grist.ptr = 0;
f->f_grist.len = 0;
@@ -122,7 +122,7 @@
f->f_root.ptr = varlist->string;
f->f_root.len = strlen( varlist->string );
- path_build( f, buf, 1 );
+ path_build( f, buf, 1 );
if( DEBUG_SEARCH )
printf( "locate %s: %s\n", target, buf->value );
@@ -152,16 +152,16 @@
timestamp( buf->value, time );
b.binding = buf->value;
-
+
if( hashcheck( explicit_bindings, (HASHDATA**)&ba ) )
{
if( DEBUG_SEARCH )
- printf(" search %s: found explicitly located target %s\n",
+ printf(" search %s: found explicitly located target %s\n",
target, ba->target);
if( another_target )
*another_target = ba->target;
found = 1;
- break;
+ break;
}
else if( ff && ff->time )
{
@@ -207,7 +207,7 @@
compatibility, though. */
hashenter(explicit_bindings, (HASHDATA**)&ba);
}
-
+
/* prepare a call to BINDRULE if the variable is set */
call_bind_rule( target, boundname );
Modified: trunk/tools/jam/src/search.h
==============================================================================
--- trunk/tools/jam/src/search.h (original)
+++ trunk/tools/jam/src/search.h 2008-08-29 08:59:49 EDT (Fri, 29 Aug 2008)
@@ -5,7 +5,7 @@
*/
/*
- * search.h - find a target along $(SEARCH) or $(LOCATE)
+ * search.h - find a target along $(SEARCH) or $(LOCATE)
*/
char *search( char *target, time_t *time, char **another_target, int file );
Modified: trunk/tools/jam/src/strings.c
==============================================================================
--- trunk/tools/jam/src/strings.c (original)
+++ trunk/tools/jam/src/strings.c 2008-08-29 08:59:49 EDT (Fri, 29 Aug 2008)
@@ -24,7 +24,7 @@
assert( self->opt[0] == 0 );
return;
}
-
+
assert( self->size < self->capacity );
assert( ( self->capacity <= sizeof(self->opt) ) == ( self->value == self->opt ) );
assert( strlen( self->value ) == self->size );
@@ -106,10 +106,10 @@
char* p = self->value + self->size;
char* end = self->value + self->capacity;
assert_invariants( self );
-
+
while ( *rhs && p != end)
*p++ = *rhs++;
-
+
if ( p != end )
{
*p = 0;
@@ -127,10 +127,10 @@
char* p = self->value + self->size;
char* end = self->value + self->capacity;
assert_invariants( self );
-
+
while ( p != end && start != finish )
*p++ = *start++;
-
+
if ( p != end )
{
*p = 0;
@@ -182,7 +182,7 @@
int limit = sizeof(buffer) > 254 ? 254 : sizeof(buffer);
string_new(s);
-
+
for (i = 0; i < limit; ++i)
{
string_push_back( s, (char)(i + 1) );
@@ -195,7 +195,7 @@
}
string_free(s);
-
+
}
#endif
Modified: trunk/tools/jam/src/subst.c
==============================================================================
--- trunk/tools/jam/src/subst.c (original)
+++ trunk/tools/jam/src/subst.c 2008-08-29 08:59:49 EDT (Fri, 29 Aug 2008)
@@ -22,13 +22,13 @@
{
regex_entry entry, *e = &entry;
entry.pattern = pattern;
-
+
if ( !regex_hash )
regex_hash = hashinit(sizeof(regex_entry), "regex");
-
+
if ( hashenter( regex_hash, (HASHDATA **)&e ) )
e->regex = regcomp( (char*)pattern );
-
+
return e->regex;
}
@@ -36,13 +36,13 @@
builtin_subst(
PARSE *parse,
FRAME *frame )
-{
+{
LIST* result = L0;
LIST* arg1 = lol_get( frame->args, 0 );
if ( arg1 && list_next(arg1) && list_next(list_next(arg1)) )
- {
-
+ {
+
const char* source = arg1->string;
const char* pattern = list_next(arg1)->string;
regexp* repat = regex_compile( pattern );
@@ -50,7 +50,7 @@
if ( regexec( repat, (char*)source) )
{
LIST* subst = list_next(arg1);
-
+
while ((subst = list_next(subst)) != L0)
{
# define BUFLEN 4096
@@ -88,7 +88,7 @@
}
}
}
-
+
return result;
}
Modified: trunk/tools/jam/src/timestamp.c
==============================================================================
--- trunk/tools/jam/src/timestamp.c (original)
+++ trunk/tools/jam/src/timestamp.c 2008-08-29 08:59:49 EDT (Fri, 29 Aug 2008)
@@ -32,20 +32,20 @@
typedef struct _binding BINDING;
struct _binding {
- char *name;
- short flags;
+ char *name;
+ short flags;
-# define BIND_SCANNED 0x01 /* if directory or arch, has been scanned */
+# define BIND_SCANNED 0x01 /* if directory or arch, has been scanned */
- short progress;
+ short progress;
-# define BIND_INIT 0 /* never seen */
-# define BIND_NOENTRY 1 /* timestamp requested but file never found */
-# define BIND_SPOTTED 2 /* file found but not timed yet */
-# define BIND_MISSING 3 /* file found but can't get timestamp */
-# define BIND_FOUND 4 /* file found and time stamped */
+# define BIND_INIT 0 /* never seen */
+# define BIND_NOENTRY 1 /* timestamp requested but file never found */
+# define BIND_SPOTTED 2 /* file found but not timed yet */
+# define BIND_MISSING 3 /* file found but can't get timestamp */
+# define BIND_FOUND 4 /* file found and time stamped */
- time_t time; /* update time - 0 if not exist */
+ time_t time; /* update time - 0 if not exist */
} ;
static struct hash *bindhash = 0;
@@ -53,11 +53,11 @@
static char *time_progress[] =
{
- "INIT",
- "NOENTRY",
- "SPOTTED",
- "MISSING",
- "FOUND"
+ "INIT",
+ "NOENTRY",
+ "SPOTTED",
+ "MISSING",
+ "FOUND"
} ;
@@ -66,159 +66,159 @@
*/
void
-timestamp(
- char *target,
- time_t *time )
+timestamp(
+ char *target,
+ time_t *time )
{
PROFILE_ENTER(timestamp);
-
- PATHNAME f1, f2;
- BINDING binding, *b = &binding;
- string buf[1];
- string path;
- char *p;
+
+ PATHNAME f1, f2;
+ BINDING binding, *b = &binding;
+ string buf[1];
+ string path;
+ char *p;
# ifdef DOWNSHIFT_PATHS
string_copy( &path, target );
p = path.value;
- do
+ do
{
*p = tolower( *p );
# ifdef NT
/* On NT, we must use backslashes or the file won't be found. */
if (*p == '/')
*p = PATH_DELIM;
-# endif
+# endif
}
- while( *p++ );
+ while( *p++ );
- target = path.value;
+ target = path.value;
# endif
string_new( buf );
- if( !bindhash )
- bindhash = hashinit( sizeof( BINDING ), "bindings" );
-
- /* Quick path - is it there? */
-
- b->name = target;
- b->time = b->flags = 0;
- b->progress = BIND_INIT;
+ if( !bindhash )
+ bindhash = hashinit( sizeof( BINDING ), "bindings" );
- if( hashenter( bindhash, (HASHDATA **)&b ) )
- b->name = newstr( target ); /* never freed */
+ /* Quick path - is it there? */
- if( b->progress != BIND_INIT )
- goto afterscanning;
+ b->name = target;
+ b->time = b->flags = 0;
+ b->progress = BIND_INIT;
- b->progress = BIND_NOENTRY;
+ if( hashenter( bindhash, (HASHDATA **)&b ) )
+ b->name = newstr( target ); /* never freed */
- /* Not found - have to scan for it */
+ if( b->progress != BIND_INIT )
+ goto afterscanning;
- path_parse( target, &f1 );
+ b->progress = BIND_NOENTRY;
- /* Scan directory if not already done so */
+ /* Not found - have to scan for it */
- {
- BINDING binding, *b = &binding;
+ path_parse( target, &f1 );
- f2 = f1;
- f2.f_grist.len = 0;
- path_parent( &f2 );
- path_build( &f2, buf, 0 );
+ /* Scan directory if not already done so */
- b->name = buf->value;
- b->time = b->flags = 0;
- b->progress = BIND_INIT;
-
- if( hashenter( bindhash, (HASHDATA **)&b ) )
- b->name = newstr( buf->value ); /* never freed */
+ {
+ BINDING binding, *b = &binding;
- if( !( b->flags & BIND_SCANNED ) )
- {
- file_dirscan( buf->value, time_enter, bindhash );
- b->flags |= BIND_SCANNED;
- }
- }
+ f2 = f1;
+ f2.f_grist.len = 0;
+ path_parent( &f2 );
+ path_build( &f2, buf, 0 );
+
+ b->name = buf->value;
+ b->time = b->flags = 0;
+ b->progress = BIND_INIT;
+
+ if( hashenter( bindhash, (HASHDATA **)&b ) )
+ b->name = newstr( buf->value ); /* never freed */
+
+ if( !( b->flags & BIND_SCANNED ) )
+ {
+ file_dirscan( buf->value, time_enter, bindhash );
+ b->flags |= BIND_SCANNED;
+ }
+ }
- /* Scan archive if not already done so */
+ /* Scan archive if not already done so */
- if( f1.f_member.len )
- {
- BINDING binding, *b = &binding;
+ if( f1.f_member.len )
+ {
+ BINDING binding, *b = &binding;
- f2 = f1;
- f2.f_grist.len = 0;
- f2.f_member.len = 0;
+ f2 = f1;
+ f2.f_grist.len = 0;
+ f2.f_member.len = 0;
string_truncate( buf, 0 );
- path_build( &f2, buf, 0 );
+ path_build( &f2, buf, 0 );
- b->name = buf->value;
- b->time = b->flags = 0;
- b->progress = BIND_INIT;
-
- if( hashenter( bindhash, (HASHDATA **)&b ) )
- b->name = newstr( buf->value ); /* never freed */
-
- if( !( b->flags & BIND_SCANNED ) )
- {
- file_archscan( buf->value, time_enter, bindhash );
- b->flags |= BIND_SCANNED;
- }
- }
+ b->name = buf->value;
+ b->time = b->flags = 0;
+ b->progress = BIND_INIT;
+
+ if( hashenter( bindhash, (HASHDATA **)&b ) )
+ b->name = newstr( buf->value ); /* never freed */
+
+ if( !( b->flags & BIND_SCANNED ) )
+ {
+ file_archscan( buf->value, time_enter, bindhash );
+ b->flags |= BIND_SCANNED;
+ }
+ }
afterscanning:
- if( b->progress == BIND_SPOTTED )
- {
- if( file_time( b->name, &b->time ) < 0 )
- b->progress = BIND_MISSING;
- else
- b->progress = BIND_FOUND;
- }
+ if( b->progress == BIND_SPOTTED )
+ {
+ if( file_time( b->name, &b->time ) < 0 )
+ b->progress = BIND_MISSING;
+ else
+ b->progress = BIND_FOUND;
+ }
- *time = b->progress == BIND_FOUND ? b->time : 0;
+ *time = b->progress == BIND_FOUND ? b->time : 0;
string_free( buf );
# ifdef DOWNSHIFT_PATHS
string_free( &path );
#endif
-
+
PROFILE_EXIT(timestamp);
}
static void
-time_enter(
- void *closure,
- char *target,
- int found,
- time_t time )
+time_enter(
+ void *closure,
+ char *target,
+ int found,
+ time_t time )
{
- BINDING binding, *b = &binding;
- struct hash *bindhash = (struct hash *)closure;
+ BINDING binding, *b = &binding;
+ struct hash *bindhash = (struct hash *)closure;
# ifdef DOWNSHIFT_PATHS
- char path[ MAXJPATH ];
- char *p = path;
+ char path[ MAXJPATH ];
+ char *p = path;
- do *p++ = tolower( *target );
- while( *target++ );
+ do *p++ = tolower( *target );
+ while( *target++ );
- target = path;
+ target = path;
# endif
- b->name = target;
- b->flags = 0;
+ b->name = target;
+ b->flags = 0;
- if( hashenter( bindhash, (HASHDATA **)&b ) )
- b->name = newstr( target ); /* never freed */
+ if( hashenter( bindhash, (HASHDATA **)&b ) )
+ b->name = newstr( target ); /* never freed */
- b->time = time;
- b->progress = found ? BIND_FOUND : BIND_SPOTTED;
+ b->time = time;
+ b->progress = found ? BIND_FOUND : BIND_SPOTTED;
- if( DEBUG_BINDSCAN )
- printf( "time ( %s ) : %s\n", target, time_progress[b->progress] );
+ if( DEBUG_BINDSCAN )
+ printf( "time ( %s ) : %s\n", target, time_progress[b->progress] );
}
/*
@@ -228,5 +228,5 @@
void
donestamps()
{
- hashdone( bindhash );
+ hashdone( bindhash );
}
Modified: trunk/tools/jam/src/variable.c
==============================================================================
--- trunk/tools/jam/src/variable.c (original)
+++ trunk/tools/jam/src/variable.c 2008-08-29 08:59:49 EDT (Fri, 29 Aug 2008)
@@ -30,17 +30,17 @@
*
* External routines:
*
- * var_defines() - load a bunch of variable=value settings
- * var_string() - expand a string with variables in it
- * var_get() - get value of a user defined symbol
- * var_set() - set a variable in jam's user defined symbol table
- * var_swap() - swap a variable's value with the given one
- * var_done() - free variable tables
+ * var_defines() - load a bunch of variable=value settings
+ * var_string() - expand a string with variables in it
+ * var_get() - get value of a user defined symbol
+ * var_set() - set a variable in jam's user defined symbol table
+ * var_swap() - swap a variable's value with the given one
+ * var_done() - free variable tables
*
* Internal routines:
*
- * var_enter() - make new var symbol table entry, returning var ptr
- * var_dump() - dump a variable to stdout
+ * var_enter() - make new var symbol table entry, returning var ptr
+ * var_dump() - dump a variable to stdout
*
* 04/13/94 (seiwald) - added shorthand L0 for null list pointer
* 08/23/94 (seiwald) - Support for '+=' (append to variable)
@@ -58,8 +58,8 @@
typedef struct _variable VARIABLE ;
struct _variable {
- char *symbol;
- LIST *value;
+ char *symbol;
+ LIST *value;
} ;
static VARIABLE *var_enter( char *symbol );
@@ -99,34 +99,34 @@
string_new( buf );
- for( ; *e; e++ )
- {
- char *val;
+ for( ; *e; e++ )
+ {
+ char *val;
# ifdef OS_MAC
- /* On the mac (MPW), the var=val is actually var\0val */
- /* Think different. */
-
- if( ( val = strchr( *e, '=' ) ) || ( val = *e + strlen( *e ) ) )
+ /* On the mac (MPW), the var=val is actually var\0val */
+ /* Think different. */
+
+ if( ( val = strchr( *e, '=' ) ) || ( val = *e + strlen( *e ) ) )
# else
- if( val = strchr( *e, '=' ) )
+ if( val = strchr( *e, '=' ) )
# endif
- {
- LIST *l = L0;
- char *pp, *p;
+ {
+ LIST *l = L0;
+ char *pp, *p;
# ifdef OPT_NO_EXTERNAL_VARIABLE_SPLIT
char split = '\0';
# else
# ifdef OS_MAC
- char split = ',';
+ char split = ',';
# else
- char split = ' ';
+ char split = ' ';
# endif
# endif
size_t len = strlen(val + 1);
int quoted = val[1] == '"' && val[len] == '"' && len > 1;
-
+
if ( quoted && preprocess )
{
string_append_range( buf, val + 2, val + len );
@@ -142,7 +142,7 @@
if( !strncmp( val - 4, "PATH", 4 ) ||
!strncmp( val - 4, "Path", 4 ) ||
!strncmp( val - 4, "path", 4 ) )
- split = SPLITPATH;
+ split = SPLITPATH;
}
/* Do the split */
@@ -160,12 +160,12 @@
l = list_new( l, newstr( pp ) );
}
- /* Get name */
+ /* Get name */
string_append_range( buf, *e, val );
- var_set( buf->value, l, VAR_SET );
+ var_set( buf->value, l, VAR_SET );
string_truncate( buf, 0 );
- }
- }
+ }
+ }
string_free( buf );
}
@@ -187,8 +187,8 @@
while( *in )
{
- char *lastword;
- int dollar = 0;
+ char *lastword;
+ int dollar = 0;
/* Copy white space */
@@ -220,9 +220,9 @@
int depth = 1;
char *ine = in + 2;
char *split = 0;
-
+
/* Scan the content of the response file @() section. */
-
+
while( *ine && depth > 0 )
{
switch( *ine )
@@ -242,7 +242,7 @@
}
++ine;
}
-
+
if (!split)
{
/* the @() reference doesn't match the @(foo:E=bar) format.
@@ -257,13 +257,13 @@
if ( out+1 >= oute ) return -1;
*(out++) = ')';
}
-
+
else if ( depth == 0 )
{
string file_name_v;
int file_name_l = 0;
const char * file_name_s = 0;
-
+
/* expand the temporary file name var inline */
#if 0
string_copy(&file_name_v,"$(");
@@ -277,7 +277,7 @@
string_free(&file_name_v);
if ( file_name_l < 0 ) return -1;
file_name_s = out;
-
+
/* for stdout/stderr we will create a temp file and generate
a command that outputs the content as needed. */
if ( strcmp( "STDOUT", out ) == 0 || strcmp( "STDERR", out ) == 0 )
@@ -301,14 +301,14 @@
get nuked eventually. */
file_remove_atexit( file_name_s );
}
-
+
/* expand the file value into the file reference */
var_string_to_file( split+3, ine-split-4, file_name_s, lol );
-
+
/* continue on with the expansion */
out += strlen(out);
}
-
+
/* and continue with the parsing just past the @() reference */
in = ine;
}
@@ -324,7 +324,7 @@
return -1;
/* Don't increment, intentionally. */
*out= '\0';
-
+
/* If a variable encountered, expand it and and embed the */
/* space-separated members of the list in the output. */
@@ -460,7 +460,7 @@
if ( out_file ) fwrite(output_0,output_1-output_0,1,out_file);
if ( out_debug ) fwrite(output_0,output_1-output_0,1,stdout);
}
-
+
in = output_1;
}
@@ -509,9 +509,9 @@
#endif
{
VARIABLE var, *v = &var;
-
+
v->symbol = symbol;
-
+
if( varhash && hashcheck( varhash, (HASHDATA **)&v ) )
{
if( DEBUG_VARGET )
@@ -535,36 +535,36 @@
void
var_set(
- char *symbol,
- LIST *value,
- int flag )
-{
- VARIABLE *v = var_enter( symbol );
-
- if( DEBUG_VARSET )
- var_dump( symbol, value, "set" );
-
- switch( flag )
- {
- case VAR_SET:
- /* Replace value */
- list_free( v->value );
- v->value = value;
- break;
-
- case VAR_APPEND:
- /* Append value */
- v->value = list_append( v->value, value );
- break;
-
- case VAR_DEFAULT:
- /* Set only if unset */
- if( !v->value )
- v->value = value;
- else
- list_free( value );
- break;
- }
+ char *symbol,
+ LIST *value,
+ int flag )
+{
+ VARIABLE *v = var_enter( symbol );
+
+ if( DEBUG_VARSET )
+ var_dump( symbol, value, "set" );
+
+ switch( flag )
+ {
+ case VAR_SET:
+ /* Replace value */
+ list_free( v->value );
+ v->value = value;
+ break;
+
+ case VAR_APPEND:
+ /* Append value */
+ v->value = list_append( v->value, value );
+ break;
+
+ case VAR_DEFAULT:
+ /* Set only if unset */
+ if( !v->value )
+ v->value = value;
+ else
+ list_free( value );
+ break;
+ }
}
/*
@@ -573,18 +573,18 @@
LIST *
var_swap(
- char *symbol,
- LIST *value )
+ char *symbol,
+ LIST *value )
{
- VARIABLE *v = var_enter( symbol );
- LIST *oldvalue = v->value;
+ VARIABLE *v = var_enter( symbol );
+ LIST *oldvalue = v->value;
- if( DEBUG_VARSET )
- var_dump( symbol, value, "set" );
+ if( DEBUG_VARSET )
+ var_dump( symbol, value, "set" );
- v->value = value;
+ v->value = value;
- return oldvalue;
+ return oldvalue;
}
@@ -594,20 +594,20 @@
*/
static VARIABLE *
-var_enter( char *symbol )
+var_enter( char *symbol )
{
- VARIABLE var, *v = &var;
+ VARIABLE var, *v = &var;
- if( !varhash )
- varhash = hashinit( sizeof( VARIABLE ), "variables" );
+ if( !varhash )
+ varhash = hashinit( sizeof( VARIABLE ), "variables" );
- v->symbol = symbol;
- v->value = 0;
+ v->symbol = symbol;
+ v->value = 0;
- if( hashenter( varhash, (HASHDATA **)&v ) )
- v->symbol = newstr( symbol ); /* never freed */
+ if( hashenter( varhash, (HASHDATA **)&v ) )
+ v->symbol = newstr( symbol ); /* never freed */
- return v;
+ return v;
}
/*
@@ -616,13 +616,13 @@
static void
var_dump(
- char *symbol,
- LIST *value,
- char *what )
-{
- printf( "%s %s = ", what, symbol );
- list_print( value );
- printf( "\n" );
+ char *symbol,
+ LIST *value,
+ char *what )
+{
+ printf( "%s %s = ", what, symbol );
+ list_print( value );
+ printf( "\n" );
}
/*
@@ -639,5 +639,5 @@
var_done()
{
hashenumerate( varhash, delete_var_, (void*)0 );
- hashdone( varhash );
+ hashdone( varhash );
}
Modified: trunk/tools/jam/src/variable.h
==============================================================================
--- trunk/tools/jam/src/variable.h (original)
+++ trunk/tools/jam/src/variable.h 2008-08-29 08:59:49 EDT (Fri, 29 Aug 2008)
@@ -10,12 +10,12 @@
struct hash;
-void var_defines( char* const *e, int preprocess );
-int var_string( char *in, char *out, int outsize, LOL *lol );
-LIST * var_get( char *symbol );
-void var_set( char *symbol, LIST *value, int flag );
-LIST * var_swap( char *symbol, LIST *value );
-void var_done();
+void var_defines( char* const *e, int preprocess );
+int var_string( char *in, char *out, int outsize, LOL *lol );
+LIST * var_get( char *symbol );
+void var_set( char *symbol, LIST *value, int flag );
+LIST * var_swap( char *symbol, LIST *value );
+void var_done();
void var_hash_swap( struct hash** );
/** Expands the "in" expression directly into the "out" file.
@@ -29,7 +29,7 @@
* Defines for var_set().
*/
-# define VAR_SET 0 /* override previous value */
-# define VAR_APPEND 1 /* append to previous value */
-# define VAR_DEFAULT 2 /* set only if no previous value */
+# define VAR_SET 0 /* override previous value */
+# define VAR_APPEND 1 /* append to previous value */
+# define VAR_DEFAULT 2 /* set only if no previous value */
Modified: trunk/tools/jam/src/w32_getreg.c
==============================================================================
--- trunk/tools/jam/src/w32_getreg.c (original)
+++ trunk/tools/jam/src/w32_getreg.c 2008-08-29 08:59:49 EDT (Fri, 29 Aug 2008)
@@ -65,23 +65,23 @@
char const* path = lol_get(frame->args, 0)->string;
LIST* result = L0;
HKEY key = get_key(&path);
-
+
if (
key != 0
- && ERROR_SUCCESS == RegOpenKeyEx(key, path, 0, KEY_QUERY_VALUE, &key)
+ && ERROR_SUCCESS == RegOpenKeyEx(key, path, 0, KEY_QUERY_VALUE, &key)
)
{
DWORD type;
BYTE data[MAX_REGISTRY_DATA_LENGTH];
DWORD len = sizeof(data);
LIST const* const field = lol_get(frame->args, 1);
-
+
if ( ERROR_SUCCESS ==
RegQueryValueEx(key, field ? field->string : 0, 0, &type, data, &len) )
{
switch (type)
{
-
+
case REG_EXPAND_SZ:
{
long len;
@@ -101,7 +101,7 @@
string_free( expanded );
}
break;
-
+
case REG_MULTI_SZ:
{
char* s;
@@ -111,7 +111,7 @@
}
break;
-
+
case REG_DWORD:
{
char buf[100];
@@ -133,9 +133,9 @@
static LIST* get_subkey_names(HKEY key, char const* path)
{
LIST* result = 0;
-
- if ( ERROR_SUCCESS ==
- RegOpenKeyEx(key, path, 0, KEY_ENUMERATE_SUB_KEYS, &key)
+
+ if ( ERROR_SUCCESS ==
+ RegOpenKeyEx(key, path, 0, KEY_ENUMERATE_SUB_KEYS, &key)
)
{
char name[MAX_REGISTRY_KEYNAME_LENGTH];
@@ -143,47 +143,47 @@
DWORD index;
FILETIME last_write_time;
- for ( index = 0;
+ for ( index = 0;
ERROR_SUCCESS == RegEnumKeyEx(
key, index, name, &name_size, 0, 0, 0, &last_write_time);
- ++index,
+ ++index,
name_size = sizeof(name)
)
{
name[name_size] = 0;
result = list_append(result, list_new(0, newstr(name)));
}
-
+
RegCloseKey(key);
}
-
+
return result;
}
static LIST* get_value_names(HKEY key, char const* path)
{
LIST* result = 0;
-
+
if ( ERROR_SUCCESS == RegOpenKeyEx(key, path, 0, KEY_QUERY_VALUE, &key) )
{
char name[MAX_REGISTRY_VALUENAME_LENGTH];
DWORD name_size = sizeof(name);
DWORD index;
- for ( index = 0;
+ for ( index = 0;
ERROR_SUCCESS == RegEnumValue(
key, index, name, &name_size, 0, 0, 0, 0);
- ++index,
+ ++index,
name_size = sizeof(name)
)
{
name[name_size] = 0;
result = list_append(result, list_new(0, newstr(name)));
}
-
+
RegCloseKey(key);
}
-
+
return result;
}
@@ -194,7 +194,7 @@
{
char const* path = lol_get(frame->args, 0)->string;
char const* result_type = lol_get(frame->args, 1)->string;
-
+
HKEY key = get_key(&path);
if ( !strcmp(result_type, "subkeys") )
Modified: trunk/tools/jam/src/yyacc.c
==============================================================================
--- trunk/tools/jam/src/yyacc.c (original)
+++ trunk/tools/jam/src/yyacc.c 2008-08-29 08:59:49 EDT (Fri, 29 Aug 2008)
@@ -11,11 +11,11 @@
/*
# yyacc - yacc wrapper
#
-# Allows tokens to be written as `literal` and then automatically
+# Allows tokens to be written as `literal` and then automatically
# substituted with #defined tokens.
#
# Usage:
-# yyacc file.y filetab.h file.yy
+# yyacc file.y filetab.h file.yy
#
# inputs:
# file.yy yacc grammar with ` literals
@@ -59,7 +59,7 @@
FILE * token_output_f = 0;
FILE * grammar_output_f = 0;
FILE * grammar_source_f = 0;
-
+
grammar_source_f = fopen(argv[3],"r");
if (grammar_source_f == 0) { result = 1; }
if (result == 0)
@@ -223,7 +223,7 @@
char * literal = s;
int l;
int c;
-
+
if (strcmp(s,":") == 0) literal = "_colon";
else if (strcmp(s,"!") == 0) literal = "_bang";
else if (strcmp(s,"!=") == 0) literal = "_bang_equals";
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