Changeset 79007


Ignore:
Timestamp:
Jun 19, 2012, 12:33:49 PM (6 years ago)
Author:
Jurko Gospodnetic
Message:

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

Location:
trunk/tools/build/v2/engine
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/build/v2/engine/execcmd.h

    r79005 r79007  
    1717#define EXECCMD_H
    1818
     19#include "strings.h"
    1920#include <time.h>
    2021
     
    3839void exec_cmd
    3940(
    40     char const * command,
     41    string const * command,
    4142    ExecCmdCallback func,
    4243    void * closure,
  • trunk/tools/build/v2/engine/execnt.c

    r79006 r79007  
    6767static void onintr( int );
    6868/* trim leading and trailing whitespace */
    69 void string_new_trimmed( string * pResult, char const * source );
     69void string_new_trimmed( string * pResult, string const * source );
    7070/* is the command suitable for direct execution via CreateProcessA() */
    7171static long can_spawn( string * pCommand );
     
    189189void exec_cmd
    190190(
    191     char const * command_orig,
     191    string const * pCommand_orig,
    192192    ExecCmdCallback func,
    193193    void * closure,
     
    212212
    213213    /* Trim all leading and trailing leading whitespace. */
    214     string_new_trimmed( &command_local, command_orig );
     214    string_new_trimmed( &command_local, pCommand_orig );
    215215
    216216    /* Check to see if we need to hack around the line-length limitation. Look
     
    442442            string_new ( &cmdtab[ slot ].target );
    443443        }
    444         string_copy( &cmdtab[ slot ].command, command_orig );
     444        string_copy( &cmdtab[ slot ].command, pCommand_orig->value );
    445445
    446446        /* CreateProcessA() Windows API places a limit of 32768 characters
     
    630630 */
    631631
    632 void string_new_trimmed( string * pResult, char const * source )
    633 {
     632void string_new_trimmed( string * pResult, string const * pSource )
     633{
     634    char const * source = pSource->value;
    634635    int source_len;
    635636    while ( isspace( *source ) )
    636637        ++source;
    637     source_len = strlen( source );
     638    source_len = pSource->size - ( source - pSource->value );
    638639    while ( ( source_len > 0 ) && isspace( source[ source_len - 1 ] ) )
    639640        --source_len;
  • trunk/tools/build/v2/engine/execunix.c

    r79005 r79007  
    1010#include "execcmd.h"
    1111#include "output.h"
     12#include "strings.h"
    1213#include <errno.h>
    1314#include <signal.h>
     
    116117void exec_cmd
    117118(
    118     char const * command,
     119    string const * pCommand,
    119120    ExecCmdCallback func,
    120121    void * closure,
     
    158159            switch ( object_str( list_item( iter ) )[0] )
    159160            {
    160                 case '%': argv[ i ] = command; ++gotpercent; break;
     161                case '%': argv[ i ] = pCommand->value; ++gotpercent; break;
    161162                case '!': argv[ i ] = jobno; break;
    162163                default : argv[ i ] = object_str( list_item( iter ) );
     
    167168
    168169        if ( !gotpercent )
    169         argv[ i++ ] = command;
     170        argv[ i++ ] = pCommand->value;
    170171
    171172        argv[ i ] = 0;
     
    175176        argv[ 0 ] = "/bin/sh";
    176177        argv[ 1 ] = "-c";
    177         argv[ 2 ] = command;
     178        argv[ 2 ] = pCommand->value;
    178179        argv[ 3 ] = 0;
    179180    }
     
    183184
    184185    /* Save off actual command string. */
    185     cmdtab[ slot ].command = BJAM_MALLOC_ATOMIC( strlen( command ) + 1 );
    186     strcpy( cmdtab[ slot ].command, command );
     186    cmdtab[ slot ].command = BJAM_MALLOC_ATOMIC( pCommand->size + 1 );
     187    strcpy( cmdtab[ slot ].command, pCommand->value );
    187188
    188189    /* Initialize only once. */
  • trunk/tools/build/v2/engine/make1.c

    r78987 r79007  
    555555            /* Pop state first because exec_cmd() could push state. */
    556556            pop_state( &state_stack );
    557             exec_cmd( cmd->buf->value, make_closure, pState->t, cmd->shell,
    558                 rule_name, target );
     557            exec_cmd( cmd->buf, make_closure, pState->t, cmd->shell, rule_name,
     558                target );
    559559        }
    560560    }
Note: See TracChangeset for help on using the changeset viewer.