2
0
mirror of https://github.com/boostorg/build.git synced 2026-02-14 12:42:11 +00:00

Updated the Boost.Jam exec_cmd() interface to take its command parameter as a string object instead of a raw char *.

[SVN r79007]
This commit is contained in:
Jurko Gospodnetić
2012-06-19 12:33:49 +00:00
parent 09e976d0cb
commit b45ec34c91
4 changed files with 18 additions and 15 deletions

View File

@@ -16,6 +16,7 @@
#ifndef EXECCMD_H
#define EXECCMD_H
#include "strings.h"
#include <time.h>
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,

View File

@@ -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 );

View File

@@ -9,6 +9,7 @@
#include "lists.h"
#include "execcmd.h"
#include "output.h"
#include "strings.h"
#include <errno.h>
#include <signal.h>
#include <stdio.h>
@@ -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 )

View File

@@ -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