diff --git a/src/engine/execcmd.h b/src/engine/execcmd.h index 783415f2b..938e577ad 100644 --- a/src/engine/execcmd.h +++ b/src/engine/execcmd.h @@ -16,6 +16,7 @@ #ifndef EXECCMD_H #define EXECCMD_H +#include "strings.h" #include typedef struct timing_info @@ -37,7 +38,7 @@ typedef void (* ExecCmdCallback) void exec_cmd ( - char const * command, + string const * command, ExecCmdCallback func, void * closure, LIST * shell, diff --git a/src/engine/execnt.c b/src/engine/execnt.c index efcfd1e5d..816e66c05 100644 --- a/src/engine/execnt.c +++ b/src/engine/execnt.c @@ -66,7 +66,7 @@ int maxline(); /* bump intr to note command interruption */ static void onintr( int ); /* trim leading and trailing whitespace */ -void string_new_trimmed( string * pResult, char const * source ); +void string_new_trimmed( string * pResult, string const * source ); /* is the command suitable for direct execution via CreateProcessA() */ static long can_spawn( string * pCommand ); /* add two 64-bit unsigned numbers, h1l1 and h2l2 */ @@ -188,7 +188,7 @@ void execnt_unit_test() void exec_cmd ( - char const * command_orig, + string const * pCommand_orig, ExecCmdCallback func, void * closure, LIST * shell, @@ -211,7 +211,7 @@ void exec_cmd } /* Trim all leading and trailing leading whitespace. */ - string_new_trimmed( &command_local, command_orig ); + string_new_trimmed( &command_local, pCommand_orig ); /* 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 @@ -441,7 +441,7 @@ void exec_cmd string_free( &cmdtab[ slot ].target ); string_new ( &cmdtab[ slot ].target ); } - string_copy( &cmdtab[ slot ].command, command_orig ); + string_copy( &cmdtab[ slot ].command, pCommand_orig->value ); /* CreateProcessA() Windows API places a limit of 32768 characters * (bytes) on the allowed command-line length, including a trailing @@ -629,12 +629,13 @@ int maxline() * value needs to be released using string_free(). */ -void string_new_trimmed( string * pResult, char const * source ) +void string_new_trimmed( string * pResult, string const * pSource ) { + char const * source = pSource->value; int source_len; while ( isspace( *source ) ) ++source; - source_len = strlen( source ); + source_len = pSource->size - ( source - pSource->value ); while ( ( source_len > 0 ) && isspace( source[ source_len - 1 ] ) ) --source_len; string_new( pResult ); diff --git a/src/engine/execunix.c b/src/engine/execunix.c index 0ab7dff6e..3150d84df 100644 --- a/src/engine/execunix.c +++ b/src/engine/execunix.c @@ -9,6 +9,7 @@ #include "lists.h" #include "execcmd.h" #include "output.h" +#include "strings.h" #include #include #include @@ -115,7 +116,7 @@ void onintr( int disp ) void exec_cmd ( - char const * command, + string const * pCommand, ExecCmdCallback func, void * closure, LIST * shell, @@ -157,7 +158,7 @@ void exec_cmd { switch ( object_str( list_item( iter ) )[0] ) { - case '%': argv[ i ] = command; ++gotpercent; break; + case '%': argv[ i ] = pCommand->value; ++gotpercent; break; case '!': argv[ i ] = jobno; break; default : argv[ i ] = object_str( list_item( iter ) ); } @@ -166,7 +167,7 @@ void exec_cmd } if ( !gotpercent ) - argv[ i++ ] = command; + argv[ i++ ] = pCommand->value; argv[ i ] = 0; } @@ -174,7 +175,7 @@ void exec_cmd { argv[ 0 ] = "/bin/sh"; argv[ 1 ] = "-c"; - argv[ 2 ] = command; + argv[ 2 ] = pCommand->value; argv[ 3 ] = 0; } @@ -182,8 +183,8 @@ void exec_cmd ++cmdsrunning; /* Save off actual command string. */ - cmdtab[ slot ].command = BJAM_MALLOC_ATOMIC( strlen( command ) + 1 ); - strcpy( cmdtab[ slot ].command, command ); + cmdtab[ slot ].command = BJAM_MALLOC_ATOMIC( pCommand->size + 1 ); + strcpy( cmdtab[ slot ].command, pCommand->value ); /* Initialize only once. */ if ( !initialized ) diff --git a/src/engine/make1.c b/src/engine/make1.c index 07d213d07..9a6773419 100644 --- a/src/engine/make1.c +++ b/src/engine/make1.c @@ -554,8 +554,8 @@ static void make1c( state * pState ) { /* Pop state first because exec_cmd() could push state. */ pop_state( &state_stack ); - exec_cmd( cmd->buf->value, make_closure, pState->t, cmd->shell, - rule_name, target ); + exec_cmd( cmd->buf, make_closure, pState->t, cmd->shell, rule_name, + target ); } } else