diff --git a/appveyor.yml b/appveyor.yml index 4e175514b..4ca454ca9 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -55,7 +55,7 @@ for: echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> NO WARNINGS" echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" - src\engine\b2.exe --debug-configuration b2 warnings-as-errors=on toolset=%TEST_TOOLSET% + src\engine\b2.exe --debug-configuration b2 warnings-as-errors=on variant=debug,release address-model=32,64 toolset=%TEST_TOOLSET% - cmd: | echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> BOOTSTRAP" diff --git a/azure-pipelines.yml b/azure-pipelines.yml index fc67c0a7c..c8cafeace 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -164,7 +164,7 @@ stages: set -e CXX_PATH=`which ${CXX}` echo "using ${TEST_TOOLSET} : : ${CXX_PATH} ;" > ${HOME}/user-config.jam - ./src/engine/b2 b2 warnings-as-errors=on toolset=${TEST_TOOLSET} + ./src/engine/b2 b2 warnings-as-errors=on variant=debug,release address-model=32,64 toolset=${TEST_TOOLSET} displayName: "No Warnings" - bash: | set -e @@ -210,7 +210,7 @@ stages: $env:HOME = $env:HOMEDRIVE + $env:HOMEPATH $env:path += ';' + $env:CXX_PATH echo "using" $env:TEST_TOOLSET ":" ":" $env:CXX ";" > $env:HOME/user-config.jam - ./src/engine/b2.exe --debug-configuration b2 warnings-as-errors=on toolset=$env:TEST_TOOLSET + ./src/engine/b2.exe --debug-configuration b2 warnings-as-errors=on variant=debug,release toolset=$env:TEST_TOOLSET displayName: "No Warnings" - powershell: | $env:HOME = $env:HOMEDRIVE + $env:HOMEPATH @@ -311,7 +311,7 @@ stages: set -e CXX_PATH=`which ${CXX}` echo "using ${TEST_TOOLSET} : : ${CXX_PATH} ;" > ${HOME}/user-config.jam - ./src/engine/b2 b2 warnings-as-errors=on toolset=${TEST_TOOLSET} + ./src/engine/b2 b2 warnings-as-errors=on variant=debug,release address-model=32,64 toolset=${TEST_TOOLSET} displayName: "No Warnings" - bash: | set -e diff --git a/src/engine/builtins.cpp b/src/engine/builtins.cpp index cf3971621..2f6ff2217 100644 --- a/src/engine/builtins.cpp +++ b/src/engine/builtins.cpp @@ -911,7 +911,7 @@ LIST * glob_recursive( char const * pattern ) { OBJECT * p; path->f_dir.ptr = object_str( list_item( iter ) ); - path->f_dir.len = strlen( object_str( list_item( iter ) ) ); + path->f_dir.len = int32_t(strlen( object_str( list_item( iter ) ) )); path_build( path, file_string ); p = object_new( file_string->value ); @@ -1749,14 +1749,14 @@ LIST * builtin_pad( FRAME * frame, int flags ) OBJECT * string = list_front( lol_get( frame->args, 0 ) ); char const * width_s = object_str( list_front( lol_get( frame->args, 1 ) ) ); - int current = strlen( object_str( string ) ); - int desired = atoi( width_s ); + int32_t current = int32_t(strlen( object_str( string ) )); + int32_t desired = atoi( width_s ); if ( current >= desired ) return list_new( object_copy( string ) ); else { char * buffer = (char *)BJAM_MALLOC( desired + 1 ); - int i; + int32_t i; LIST * result; strcpy( buffer, object_str( string ) ); @@ -1886,7 +1886,7 @@ LIST *builtin_readlink( FRAME * frame, int flags ) #else char static_buf[256]; char * buf = static_buf; - size_t bufsize = 256; + int32_t bufsize = 256; LIST * result = 0; while (1) { ssize_t len = readlink( path, buf, bufsize ); @@ -1894,7 +1894,7 @@ LIST *builtin_readlink( FRAME * frame, int flags ) { break; } - else if ( size_t(len) < bufsize ) + else if ( int32_t(len) < bufsize ) { buf[ len ] = '\0'; result = list_new( object_new( buf ) ); @@ -2400,7 +2400,7 @@ LIST * builtin_shell( FRAME * frame, int flags ) LIST * command = lol_get( frame->args, 0 ); LIST * result = L0; string s; - int ret; + int32_t ret; char buffer[ 1024 ]; FILE * p = NULL; int exit_status = -1; @@ -2435,7 +2435,7 @@ LIST * builtin_shell( FRAME * frame, int flags ) string_new( &s ); - while ( ( ret = fread( buffer, sizeof( char ), sizeof( buffer ) - 1, p ) ) > + while ( ( ret = int32_t(fread( buffer, sizeof( char ), sizeof( buffer ) - 1, p )) ) > 0 ) { buffer[ ret ] = 0; diff --git a/src/engine/config.h b/src/engine/config.h index 9ff147d8e..1df3501e5 100644 --- a/src/engine/config.h +++ b/src/engine/config.h @@ -31,4 +31,21 @@ http://www.boost.org/LICENSE_1_0.txt) #endif #endif +// Correct missing types in some earlier compilers.. + +#include +#ifndef INT32_MIN + +// VS 2013 is barely C++11/C99. And opts to not provide specific sized int types. +// Provide a generic implementation of the sizes we use. +#if UINT_MAX == 0xffffffff +typedef int int32_t; +#elif (USHRT_MAX == 0xffffffff) +typedef short int32_t; +#elif ULONG_MAX == 0xffffffff +typedef long int32_t; +#endif + +#endif + #endif diff --git a/src/engine/debug.cpp b/src/engine/debug.cpp index 2a19e072b..8fcf7e362 100644 --- a/src/engine/debug.cpp +++ b/src/engine/debug.cpp @@ -73,7 +73,7 @@ void profile_enter( OBJECT * rulename, profile_frame * frame ) } -void profile_memory( long mem ) +void profile_memory( size_t mem ) { if ( DEBUG_PROFILE ) if ( profile_stack && profile_stack->info ) diff --git a/src/engine/debug.h b/src/engine/debug.h index d61faf450..20824577e 100644 --- a/src/engine/debug.h +++ b/src/engine/debug.h @@ -45,7 +45,7 @@ typedef struct profile_frame profile_frame * profile_init( OBJECT * rulename, profile_frame * ); void profile_enter( OBJECT * rulename, profile_frame * ); -void profile_memory( long mem ); +void profile_memory( size_t mem ); void profile_exit( profile_frame * ); void profile_dump(); double profile_clock(); diff --git a/src/engine/debugger.cpp b/src/engine/debugger.cpp index 051166699..f3b2f042d 100644 --- a/src/engine/debugger.cpp +++ b/src/engine/debugger.cpp @@ -160,14 +160,16 @@ static LIST * debug_list_read( FILE * in ) { int len; int i; - int ch; LIST * result = L0; - fscanf( in, "%d", &len ); - ch = fgetc( in ); - assert( ch == '\n' ); - for ( i = 0; i < len; ++i ) + int ret = fscanf( in, "%d", &len ); + if (ret == 1) { - result = list_push_back( result, debug_object_read( in ) ); + int ch = fgetc( in ); + if (ch > 0) assert( ch == '\n' ); + for ( i = 0; i < len; ++i ) + { + result = list_push_back( result, debug_object_read( in ) ); + } } return result; } @@ -328,7 +330,7 @@ static OBJECT * make_absolute_path( OBJECT * filename ) const char * root = object_str( cwd() ); path_parse( object_str( filename ), path1 ); path1->f_root.ptr = root; - path1->f_root.len = strlen( root ); + path1->f_root.len = int32_t(strlen( root )); string_new( buf ); path_build( path1, buf ); result = object_new( buf->value ); @@ -580,7 +582,7 @@ static int debug_add_breakpoint( const char * name ) long line = strtoul( ptr + 1, &end, 10 ); if ( line > 0 && line <= INT_MAX && end != ptr + 1 && *end == 0 ) { - OBJECT * file = object_new_range( file_ptr, ptr - file_ptr ); + OBJECT * file = object_new_range( file_ptr, int32_t(ptr - file_ptr) ); return add_line_breakpoint( file, line ); } else @@ -615,7 +617,7 @@ static int get_breakpoint_by_name( const char * name ) long line = strtoul( ptr + 1, &end, 10 ); if ( line > 0 && line <= INT_MAX && end != ptr + 1 && *end == 0 ) { - OBJECT * file = object_new_range( file_ptr, ptr - file_ptr ); + OBJECT * file = object_new_range( file_ptr, int32_t(ptr - file_ptr) ); result = handle_line_breakpoint( file, line ); object_free( file ); } @@ -772,7 +774,7 @@ static int get_module_filename( string * out ) DWORD result; string_reserve( out, 256 + 1 ); string_truncate( out, 256 ); - while( ( result = GetModuleFileNameA( NULL, out->value, out->size ) ) == out->size ) + while( ( result = GetModuleFileNameA( NULL, out->value, DWORD(out->size) ) ) == DWORD(out->size) ) { string_reserve( out, out->size * 2 + 1); string_truncate( out, out->size * 2 ); @@ -2690,7 +2692,7 @@ static int process_command( char * line ) *iter++ = '\0'; } } - result = run_command( current - buffer, (const char **)buffer ); + result = run_command( int(current - buffer), (const char **)buffer ); free( (void *)buffer ); return result; } diff --git a/src/engine/execcmd.cpp b/src/engine/execcmd.cpp index 8e6ec4f50..dfbd5a7f8 100644 --- a/src/engine/execcmd.cpp +++ b/src/engine/execcmd.cpp @@ -41,9 +41,9 @@ static int intr; */ void argv_from_shell( char const * * argv, LIST * shell, char const * command, - int const slot ) + int32_t const slot ) { - static char jobno[ 4 ]; + static char jobno[ 12 ]; int i; int gotpercent = 0; @@ -74,12 +74,12 @@ void argv_from_shell( char const * * argv, LIST * shell, char const * command, /* Returns whether the given command string contains lines longer than the given * maximum. */ -int check_cmd_for_too_long_lines( char const * command, size_t max, - int * const error_length, int * const error_max_length ) +int check_cmd_for_too_long_lines( char const * command, int32_t max, + int32_t * const error_length, int32_t * const error_max_length ) { while ( *command ) { - size_t const l = strcspn( command, "\n" ); + int32_t const l = int32_t(strcspn( command, "\n" )); if ( l > max ) { *error_length = l; diff --git a/src/engine/execcmd.h b/src/engine/execcmd.h index b39e8ae2d..fa24e432d 100644 --- a/src/engine/execcmd.h +++ b/src/engine/execcmd.h @@ -54,8 +54,8 @@ int exec_check ( string const * command, LIST * * pShell, - int * error_length, - int * error_max_length + int32_t * error_length, + int32_t * error_max_length ); /* exec_check() return codes. */ @@ -91,7 +91,7 @@ void exec_wait(); * given shell list. */ void argv_from_shell( char const * * argv, LIST * shell, char const * command, - int const slot ); + int32_t const slot ); /* Interrupt routine bumping the internal interrupt counter. Needs to be * registered by platform specific exec*.c modules. @@ -109,7 +109,7 @@ int is_raw_command_request( LIST * shell ); /* Utility worker for exec_check() checking whether all the given command lines * are under the specified length limit. */ -int check_cmd_for_too_long_lines( char const * command, size_t max, - int * const error_length, int * const error_max_length ); +int check_cmd_for_too_long_lines( char const * command, int32_t max, + int32_t * const error_length, int32_t * const error_max_length ); #endif diff --git a/src/engine/execnt.cpp b/src/engine/execnt.cpp index 0b28087fe..be0a57a9b 100644 --- a/src/engine/execnt.cpp +++ b/src/engine/execnt.cpp @@ -69,9 +69,9 @@ /* get the maximum shell command line length according to the OS */ -static int maxline(); +static int32_t maxline(); /* valid raw command string length */ -static long raw_command_length( char const * command ); +static int32_t raw_command_length( char const * command ); /* add two 64-bit unsigned numbers, h1l1 and h2l2 */ static FILETIME add_64( unsigned long h1, unsigned long l1, @@ -87,33 +87,33 @@ static double running_time( HANDLE const ); /* terminate the given process, after terminating all its children first */ static void kill_process_tree( DWORD const procesdId, HANDLE const ); /* waits for a command to complete or time out */ -static int try_wait( int const timeoutMillis ); +static int32_t try_wait( int32_t const timeoutMillis ); /* reads any pending output for running commands */ static void read_output(); /* checks if a command ran out of time, and kills it */ -static int try_kill_one(); +static int32_t try_kill_one(); /* is the first process a parent (direct or indirect) to the second one */ -static int is_parent_child( DWORD const parent, DWORD const child ); +static int32_t is_parent_child( DWORD const parent, DWORD const child ); /* */ static void close_alert( PROCESS_INFORMATION const * const ); /* close any alerts hanging around */ static void close_alerts(); /* prepare a command file to be executed using an external shell */ -static char const * prepare_command_file( string const * command, int slot ); +static char const * prepare_command_file( string const * command, int32_t slot ); /* invoke the actual external process using the given command line */ -static void invoke_cmd( char const * const command, int const slot ); +static void invoke_cmd( char const * const command, int32_t const slot ); /* find a free slot in the running commands table */ -static int get_free_cmdtab_slot(); +static int32_t get_free_cmdtab_slot(); /* put together the final command string we are to run */ static void string_new_from_argv( string * result, char const * const * argv ); /* frees and renews the given string */ static void string_renew( string * const ); /* reports the last failed Windows API related error message */ -static void reportWindowsError( char const * const apiName, int slot ); +static void reportWindowsError( char const * const apiName, int32_t slot ); /* closes a Windows HANDLE and resets its variable to 0. */ static void closeWinHandle( HANDLE * const handle ); /* Adds the job index to the list of currently active jobs. */ -static void register_wait( int job_id ); +static void register_wait( int32_t job_id ); /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ @@ -132,7 +132,7 @@ static void register_wait( int job_id ); #define EXECCMD_PIPE_READ 0 #define EXECCMD_PIPE_WRITE 1 -static int intr_installed; +static int32_t intr_installed; /* The list of commands we run. */ @@ -154,7 +154,7 @@ static struct _cmdtab_t HANDLE wait_handle; - int flags; + int32_t flags; /* Function called when the command completes. */ ExecCmdCallback func; @@ -162,14 +162,14 @@ static struct _cmdtab_t /* Opaque data passed back to the 'func' callback. */ void * closure; } * cmdtab = NULL; -static int cmdtab_size = 0; +static int32_t cmdtab_size = 0; /* A thread-safe single element queue. Used by the worker threads * to signal the main thread that a process is completed. */ struct { - int job_index; + int32_t job_index; HANDLE read_okay; HANDLE write_okay; } process_queue; @@ -185,7 +185,7 @@ void execnt_unit_test() * Use a table instead. */ { - typedef struct test { const char * command; int result; } test; + typedef struct test { const char * command; int32_t result; } test; test tests[] = { { "", 0 }, { " ", 0 }, @@ -218,9 +218,9 @@ void execnt_unit_test() } { - int const length = maxline() + 9; - char * const cmd = (char *)BJAM_MALLOC_ATOMIC( length + 1 ); - memset( cmd, 'x', length ); + int32_t const length = maxline() + 9; + char * const cmd = (char *)BJAM_MALLOC_ATOMIC( size_t(length) + 1 ); + memset( cmd, 'x', size_t(length) ); cmd[ length ] = 0; assert( raw_command_length( cmd ) == length ); BJAM_FREE( cmd ); @@ -266,12 +266,12 @@ void exec_done( void ) * exec_check() - preprocess and validate the command */ -int exec_check +int32_t exec_check ( string const * command, LIST * * pShell, - int * error_length, - int * error_max_length + int32_t * error_length, + int32_t * error_max_length ) { /* Default shell does nothing when triggered with an empty or a @@ -290,7 +290,7 @@ int exec_check /* Check prerequisites for executing raw commands. */ if ( is_raw_command_request( *pShell ) ) { - long const raw_cmd_length = raw_command_length( command->value ); + int32_t const raw_cmd_length = raw_command_length( command->value ); if ( raw_cmd_length < 0 ) { /* Invalid characters detected - fallback to default shell. */ @@ -333,14 +333,14 @@ int exec_check void exec_cmd ( string const * cmd_orig, - int flags, + int32_t flags, ExecCmdCallback func, void * closure, LIST * shell ) { - int const slot = get_free_cmdtab_slot(); - int const is_raw_cmd = is_raw_command_request( shell ); + int32_t const slot = get_free_cmdtab_slot(); + int32_t const is_raw_cmd = is_raw_command_request( shell ); string cmd_local[ 1 ]; /* Initialize default shell - anything more than /Q/C is non-portable. */ @@ -380,7 +380,7 @@ void exec_cmd end = p; string_new( cmd_local ); string_append_range( cmd_local, start, end ); - assert( long(cmd_local->size) == raw_command_length( cmd_orig->value ) ); + assert( int32_t(cmd_local->size) == raw_command_length( cmd_orig->value ) ); } /* If we are not running a raw command directly, prepare a command file to * be executed using an external shell and the actual command string using @@ -424,8 +424,8 @@ void exec_cmd void exec_wait() { - int i = -1; - int exit_reason; /* reason why a command completed */ + int32_t i = -1; + int32_t exit_reason; /* reason why a command completed */ /* Wait for a command to complete, while snarfing up any output. */ while ( 1 ) @@ -447,7 +447,7 @@ void exec_wait() { DWORD exit_code; timing_info time; - int rstat; + int32_t rstat; /* The time data for the command. */ record_times( cmdtab[ i ].pi.hProcess, &time ); @@ -494,7 +494,7 @@ void exec_wait() * process in our running commands table. */ -static void invoke_cmd( char const * const command, int const slot ) +static void invoke_cmd( char const * const command, int32_t const slot ) { SECURITY_ATTRIBUTES sa = { sizeof( SECURITY_ATTRIBUTES ), 0, 0 }; SECURITY_DESCRIPTOR sd; @@ -577,16 +577,16 @@ static void invoke_cmd( char const * const command, int const slot ) * http://support.microsoft.com/default.aspx?scid=kb;en-us;830473 */ -static int raw_maxline() +static int32_t raw_maxline() { if ( IsWindowsVersionOrGreater(5,0,0) == TRUE ) return 8191; /* XP */ if ( IsWindowsVersionOrGreater(4,0,0) == TRUE ) return 2047; /* NT 4.x */ return 996; /* NT 3.5.1 */ } -static int maxline() +static int32_t maxline() { - static int result; + static int32_t result; if ( !result ) result = raw_maxline(); return result; } @@ -632,7 +632,7 @@ static void string_renew( string * const s ) * affect the executed command). */ -static long raw_command_length( char const * command ) +static int32_t raw_command_length( char const * command ) { char const * p; char const * escape = 0; @@ -688,7 +688,7 @@ static long raw_command_length( char const * command ) while ( *p ); /* Return the number of characters the command will occupy. */ - return ( newline ? newline : p ) - command; + return int32_t(( newline ? newline : p ) - command); } @@ -771,7 +771,7 @@ static void read_pipe ( HANDLE in, /* the pipe to read from */ string * out, - int forwarding_mode + int32_t forwarding_mode ) { DWORD bytesInBuffer = 0; @@ -820,7 +820,7 @@ static void read_pipe static void read_output() { - int i; + int32_t i; for ( i = 0; i < globs.jobs; ++i ) if ( cmdtab[ i ].pi.hProcess ) { @@ -839,17 +839,17 @@ static void CALLBACK try_wait_callback( void * data, BOOLEAN is_timeout ) { struct _cmdtab_t * slot = ( struct _cmdtab_t * )data; WaitForSingleObject( process_queue.write_okay, INFINITE ); - process_queue.job_index = slot - cmdtab; + process_queue.job_index = int32_t(slot - cmdtab); assert( !is_timeout ); SetEvent( process_queue.read_okay ); /* Okay. Non-blocking. */ UnregisterWait( slot->wait_handle ); } -static int try_wait_impl( DWORD timeout ) +static int32_t try_wait_impl( DWORD timeout ) { - int job_index; - int res = WaitForSingleObject( process_queue.read_okay, timeout ); + int32_t job_index; + int32_t res = WaitForSingleObject( process_queue.read_okay, timeout ); if ( res != WAIT_OBJECT_0 ) return -1; job_index = process_queue.job_index; @@ -857,7 +857,7 @@ static int try_wait_impl( DWORD timeout ) return job_index; } -static void register_wait( int job_id ) +static void register_wait( int32_t job_id ) { if ( globs.jobs > MAXIMUM_WAIT_OBJECTS ) { @@ -874,13 +874,13 @@ static void register_wait( int job_id ) * cmdtab array, or -1. */ -static int try_wait( int const timeoutMillis ) +static int32_t try_wait( int32_t const timeoutMillis ) { if ( globs.jobs <= MAXIMUM_WAIT_OBJECTS ) { - int i; + int32_t i; HANDLE active_handles[ MAXIMUM_WAIT_OBJECTS ]; - int job_ids[ MAXIMUM_WAIT_OBJECTS ]; + int32_t job_ids[ MAXIMUM_WAIT_OBJECTS ]; DWORD num_handles = 0; DWORD wait_api_result; for ( i = 0; i < globs.jobs; ++i ) @@ -910,12 +910,12 @@ static int try_wait( int const timeoutMillis ) } -static int try_kill_one() +static int32_t try_kill_one() { /* Only need to check if a timeout was specified with the -l option. */ if ( globs.timeout > 0 ) { - int i; + int32_t i; for ( i = 0; i < globs.jobs; ++i ) if ( cmdtab[ i ].pi.hProcess ) { @@ -946,7 +946,7 @@ static void close_alerts() */ if ( ( (float)clock() / (float)( CLOCKS_PER_SEC * 5 ) ) < ( 1.0 / 5.0 ) ) { - int i; + int32_t i; for ( i = 0; i < globs.jobs; ++i ) if ( cmdtab[ i ].pi.hProcess ) close_alert( &cmdtab[ i ].pi ); @@ -1034,7 +1034,7 @@ static double creation_time( HANDLE const process ) * process is System (first argument is ignored). */ -static int is_parent_child( DWORD const parent, DWORD const child ) +static int32_t is_parent_child( DWORD const parent, DWORD const child ) { HANDLE process_snapshot_h = INVALID_HANDLE_VALUE; @@ -1202,7 +1202,7 @@ static void close_alert( PROCESS_INFORMATION const * const pi ) * function. */ -static FILE * open_command_file( int const slot ) +static FILE * open_command_file( int32_t const slot ) { string * const command_file = cmdtab[ slot ].command_file; @@ -1234,13 +1234,13 @@ static FILE * open_command_file( int const slot ) { char * const index1 = command_file->value + command_file->size - 6; char * const index2 = index1 + 1; - int waits_remaining; + int32_t waits_remaining; assert( command_file->value < index1 ); assert( index2 + 1 < command_file->value + command_file->size ); assert( index2[ 1 ] == '.' ); for ( waits_remaining = 3; ; --waits_remaining ) { - int index; + int32_t index; for ( index = 0; index != 20; ++index ) { FILE * f; @@ -1262,7 +1262,7 @@ static FILE * open_command_file( int const slot ) * Prepare a command file to be executed using an external shell. */ -static char const * prepare_command_file( string const * command, int slot ) +static char const * prepare_command_file( string const * command, int32_t slot ) { FILE * const f = open_command_file( slot ); if ( !f ) @@ -1280,9 +1280,9 @@ static char const * prepare_command_file( string const * command, int slot ) * Find a free slot in the running commands table. */ -static int get_free_cmdtab_slot() +static int32_t get_free_cmdtab_slot() { - int slot; + int32_t slot; for ( slot = 0; slot < globs.jobs; ++slot ) if ( !cmdtab[ slot ].pi.hProcess ) return slot; @@ -1314,7 +1314,7 @@ static void string_new_from_argv( string * result, char const * const * argv ) * Reports the last failed Windows API related error message. */ -static void reportWindowsError( char const * const apiName, int slot ) +static void reportWindowsError( char const * const apiName, int32_t slot ) { char * errorMessage; char buf[24]; diff --git a/src/engine/execunix.cpp b/src/engine/execunix.cpp index 2740743c7..9b6ee0fc9 100644 --- a/src/engine/execunix.cpp +++ b/src/engine/execunix.cpp @@ -140,8 +140,8 @@ int exec_check ( string const * command, LIST * * pShell, - int * error_length, - int * error_max_length + int32_t * error_length, + int32_t * error_max_length ) { int const is_raw_cmd = is_raw_command_request( *pShell ); diff --git a/src/engine/execvms.cpp b/src/engine/execvms.cpp index b4b061845..e5a12bc62 100644 --- a/src/engine/execvms.cpp +++ b/src/engine/execvms.cpp @@ -75,8 +75,8 @@ int exec_check ( string const * command, LIST * * pShell, - int * error_length, - int * error_max_length + int32_t * error_length, + int32_t * error_max_length ) { int const is_raw_cmd = 1; diff --git a/src/engine/filent.cpp b/src/engine/filent.cpp index af89d5ef2..551f71c75 100644 --- a/src/engine/filent.cpp +++ b/src/engine/filent.cpp @@ -62,13 +62,13 @@ int file_collect_dir_content_( file_info_t * const d ) string pathspec[ 1 ]; string pathname[ 1 ]; LIST * files = L0; - int d_length; + int32_t d_length; assert( d ); assert( d->is_dir ); assert( list_empty( d->files ) ); - d_length = strlen( object_str( d->name ) ); + d_length = int32_t(strlen( object_str( d->name ) )); memset( (char *)&f, '\0', sizeof( f ) ); f.f_dir.ptr = object_str( d->name ); @@ -112,7 +112,7 @@ int file_collect_dir_content_( file_info_t * const d ) OBJECT * pathname_obj; f.f_base.ptr = finfo.cFileName; - f.f_base.len = strlen( finfo.cFileName ); + f.f_base.len = int32_t(strlen( finfo.cFileName )); string_truncate( pathname, 0 ); path_build( &f, pathname ); @@ -276,7 +276,7 @@ void file_query_( file_info_t * const info ) if ( ( dir = strrchr( pathstr, '\\' ) ) ) { - parent = object_new_range( pathstr, dir - pathstr ); + parent = object_new_range( pathstr, int32_t(dir - pathstr) ); } else { diff --git a/src/engine/fileunix.cpp b/src/engine/fileunix.cpp index 4c1b6adf3..9d8dc17fa 100644 --- a/src/engine/fileunix.cpp +++ b/src/engine/fileunix.cpp @@ -307,7 +307,7 @@ int file_collect_archive_content_( file_archive_info_t * const archive ) char * src; char * dest; - size_t ar_hdr_name_size = sizeof( ar_hdr.ar_name ); // Workaround for sizeof strncpy warning. + int32_t ar_hdr_name_size = sizeof( ar_hdr.ar_name ); // Workaround for sizeof strncpy warning. strncpy( lar_name, ar_hdr.ar_name, ar_hdr_name_size ); sscanf( ar_hdr.ar_date, "%ld", &lar_date ); diff --git a/src/engine/filevms.cpp b/src/engine/filevms.cpp index ab038d065..03f980a1e 100644 --- a/src/engine/filevms.cpp +++ b/src/engine/filevms.cpp @@ -229,7 +229,7 @@ file_cvttime( unsigned int *curtime, time_t *unixtime ) { - static const size_t divisor = 10000000; + static const int32_t divisor = 10000000; static unsigned int bastim[2] = { 0x4BEB4000, 0x007C9567 }; /* 1/1/1970 */ int delta[2], remainder; diff --git a/src/engine/function.cpp b/src/engine/function.cpp index 295192d15..357f331c3 100644 --- a/src/engine/function.cpp +++ b/src/engine/function.cpp @@ -40,7 +40,7 @@ #define PROFILE_EXIT_LOCAL(x) #endif -int glob( char const * s, char const * c ); +int32_t glob( char const * s, char const * c ); void backtrace( FRAME * ); void backtrace_line( FRAME * ); @@ -130,22 +130,22 @@ void backtrace_line( FRAME * ); typedef struct instruction { - unsigned int op_code; - int arg; + uint32_t op_code; + int32_t arg; } instruction; typedef struct _subfunction { OBJECT * name; FUNCTION * code; - int local; + int32_t local; } SUBFUNCTION; typedef struct _subaction { OBJECT * name; FUNCTION * command; - int flags; + int32_t flags; } SUBACTION; #define FUNCTION_BUILTIN 0 @@ -153,7 +153,7 @@ typedef struct _subaction struct argument { - int flags; + int32_t flags; #define ARG_ONE 0 #define ARG_OPTIONAL 1 #define ARG_PLUS 2 @@ -161,45 +161,45 @@ struct argument #define ARG_VARIADIC 4 OBJECT * type_name; OBJECT * arg_name; - int index; + int32_t index; }; struct arg_list { - int size; + int32_t size; struct argument * args; }; struct _function { - int type; - int reference_count; + int32_t type; + int32_t reference_count; OBJECT * rulename; struct arg_list * formal_arguments; - int num_formal_arguments; + int32_t num_formal_arguments; }; typedef struct _builtin_function { FUNCTION base; - LIST * ( * func )( FRAME *, int flags ); - int flags; + LIST * ( * func )( FRAME *, int32_t flags ); + int32_t flags; } BUILTIN_FUNCTION; typedef struct _jam_function { FUNCTION base; - int code_size; + int32_t code_size; instruction * code; - int num_constants; + int32_t num_constants; OBJECT * * constants; - int num_subfunctions; + int32_t num_subfunctions; SUBFUNCTION * functions; - int num_subactions; + int32_t num_subactions; SUBACTION * actions; FUNCTION * generic; OBJECT * file; - int line; + int32_t line; } JAM_FUNCTION; @@ -230,7 +230,7 @@ STACK * stack_global() static STACK result; if ( !stack ) { - int const size = 1 << 21; + int32_t const size = 1 << 21; stack = BJAM_MALLOC( size ); result.data = (char *)stack + size; } @@ -251,7 +251,7 @@ static void check_alignment( STACK * s ) assert( (size_t)s->data % LISTPTR_ALIGN == 0 ); } -void * stack_allocate( STACK * s, int size ) +void * stack_allocate( STACK * s, int32_t size ) { check_alignment( s ); s->data = (char *)s->data - size; @@ -259,7 +259,7 @@ void * stack_allocate( STACK * s, int size ) return s->data; } -void stack_deallocate( STACK * s, int size ) +void stack_deallocate( STACK * s, int32_t size ) { check_alignment( s ); s->data = (char *)s->data + size; @@ -284,13 +284,13 @@ LIST * stack_top( STACK * s ) return *(LIST * *)s->data; } -LIST * stack_at( STACK * s, int n ) +LIST * stack_at( STACK * s, int32_t n ) { check_alignment( s ); return *( (LIST * *)s->data + n ); } -void stack_set( STACK * s, int n, LIST * value ) +void stack_set( STACK * s, int32_t n, LIST * value ) { check_alignment( s ); *((LIST * *)s->data + n) = value; @@ -302,56 +302,56 @@ void * stack_get( STACK * s ) return s->data; } -LIST * frame_get_local( FRAME * frame, int idx ) +LIST * frame_get_local( FRAME * frame, int32_t idx ) { /* The only local variables are the arguments. */ return list_copy( lol_get( frame->args, idx ) ); } -static OBJECT * function_get_constant( JAM_FUNCTION * function, int idx ) +static OBJECT * function_get_constant( JAM_FUNCTION * function, int32_t idx ) { return function->constants[ idx ]; } static LIST * function_get_variable( JAM_FUNCTION * function, FRAME * frame, - int idx ) + int32_t idx ) { return list_copy( var_get( frame->module, function->constants[ idx ] ) ); } static void function_set_variable( JAM_FUNCTION * function, FRAME * frame, - int idx, LIST * value ) + int32_t idx, LIST * value ) { var_set( frame->module, function->constants[ idx ], value, VAR_SET ); } static LIST * function_swap_variable( JAM_FUNCTION * function, FRAME * frame, - int idx, LIST * value ) + int32_t idx, LIST * value ) { return var_swap( frame->module, function->constants[ idx ], value ); } static void function_append_variable( JAM_FUNCTION * function, FRAME * frame, - int idx, LIST * value ) + int32_t idx, LIST * value ) { var_set( frame->module, function->constants[ idx ], value, VAR_APPEND ); } static void function_default_variable( JAM_FUNCTION * function, FRAME * frame, - int idx, LIST * value ) + int32_t idx, LIST * value ) { var_set( frame->module, function->constants[ idx ], value, VAR_DEFAULT ); } static void function_set_rule( JAM_FUNCTION * function, FRAME * frame, - STACK * s, int idx ) + STACK * s, int32_t idx ) { SUBFUNCTION * sub = function->functions + idx; new_rule_body( frame->module, sub->name, sub->code, !sub->local ); } static void function_set_actions( JAM_FUNCTION * function, FRAME * frame, - STACK * s, int idx ) + STACK * s, int32_t idx ) { SUBACTION * sub = function->actions + idx; LIST * bindlist = stack_pop( s ); @@ -365,7 +365,7 @@ static void function_set_actions( JAM_FUNCTION * function, FRAME * frame, * returns -1. */ -static int get_argument_index( char const * s ) +static int32_t get_argument_index( char const * s ) { if ( s[ 0 ] != '\0') { @@ -412,7 +412,7 @@ static int get_argument_index( char const * s ) static LIST * function_get_named_variable( JAM_FUNCTION * function, FRAME * frame, OBJECT * name ) { - int const idx = get_argument_index( object_str( name ) ); + int32_t const idx = get_argument_index( object_str( name ) ); return idx == -1 ? list_copy( var_get( frame->module, name ) ) : list_copy( lol_get( frame->args, idx ) ); @@ -443,10 +443,10 @@ static void function_default_named_variable( JAM_FUNCTION * function, } static LIST * function_call_rule( JAM_FUNCTION * function, FRAME * frame, - STACK * s, int n_args, char const * unexpanded, OBJECT * file, int line ) + STACK * s, int32_t n_args, char const * unexpanded, OBJECT * file, int32_t line ) { FRAME inner[ 1 ]; - int i; + int32_t i; LIST * first = stack_pop( s ); LIST * result = L0; OBJECT * rulename; @@ -497,10 +497,10 @@ static LIST * function_call_rule( JAM_FUNCTION * function, FRAME * frame, return result; } -static LIST * function_call_member_rule( JAM_FUNCTION * function, FRAME * frame, STACK * s, int n_args, OBJECT * rulename, OBJECT * file, int line ) +static LIST * function_call_member_rule( JAM_FUNCTION * function, FRAME * frame, STACK * s, int32_t n_args, OBJECT * rulename, OBJECT * file, int32_t line ) { FRAME inner[ 1 ]; - int i; + int32_t i; LIST * first = stack_pop( s ); LIST * result = L0; RULE * rule; @@ -613,8 +613,8 @@ static LIST * function_call_member_rule( JAM_FUNCTION * function, FRAME * frame, typedef struct { - int sub1; - int sub2; + int32_t sub1; + int32_t sub2; } subscript_t; typedef struct @@ -631,9 +631,9 @@ typedef struct } VAR_EDITS; static LIST * apply_modifiers_impl( LIST * result, string * buf, - VAR_EDITS * edits, int n, LISTITER iter, LISTITER end ); + VAR_EDITS * edits, int32_t n, LISTITER iter, LISTITER end ); static void get_iters( subscript_t const subscript, LISTITER * const first, - LISTITER * const last, int const length ); + LISTITER * const last, int32_t const length ); /* @@ -671,7 +671,7 @@ static void get_iters( subscript_t const subscript, LISTITER * const first, * var_edit_file() below and path_build() obligingly follow this convention. */ -static int var_edit_parse( char const * mods, VAR_EDITS * edits, int havezeroed +static int32_t var_edit_parse( char const * mods, VAR_EDITS * edits, int32_t havezeroed ) { while ( *mods ) @@ -709,7 +709,7 @@ static int var_edit_parse( char const * mods, VAR_EDITS * edits, int havezeroed { if ( !havezeroed++ ) { - int i; + int32_t i; for ( i = 0; i < 6; ++i ) { edits->f.part[ i ].len = 0; @@ -731,7 +731,7 @@ static int var_edit_parse( char const * mods, VAR_EDITS * edits, int havezeroed else { fp->ptr = ++mods; - fp->len = strlen( mods ); + fp->len = int32_t(strlen( mods )); mods += fp->len; } } @@ -779,12 +779,12 @@ static void var_edit_file( char const * in, string * out, VAR_EDITS * edits ) * var_edit_translate_path() - translate path to os native format. */ -static void var_edit_translate_path( string * out, size_t pos, VAR_EDITS * edits ) +static void var_edit_translate_path( string * out, int32_t pos, VAR_EDITS * edits ) { if ( edits->to_windows ) { string result[ 1 ]; - int translated; + int32_t translated; /* Translate path to os native format. */ translated = path_translate_to_os( out->value + pos, result ); @@ -806,7 +806,7 @@ static void var_edit_translate_path( string * out, size_t pos, VAR_EDITS * edits * var_edit_shift() - do upshift/downshift & other mods. */ -static void var_edit_shift( string * out, size_t pos, VAR_EDITS * edits ) +static void var_edit_shift( string * out, int32_t pos, VAR_EDITS * edits ) { #if defined( OS_CYGWIN ) || defined( OS_VMS ) var_edit_translate_path( out, pos, edits ); @@ -834,10 +834,10 @@ static void var_edit_shift( string * out, size_t pos, VAR_EDITS * edits ) * Returns the number of VAR_EDITS pushed onto the STACK. */ -static int expand_modifiers( STACK * s, int n ) +static int32_t expand_modifiers( STACK * s, int32_t n ) { - int i; - int total = 1; + int32_t i; + int32_t total = 1; LIST * * args = (LIST**)stack_get( s ); for ( i = 0; i < n; ++i ) total *= list_length( args[ i ] ); @@ -850,7 +850,7 @@ static int expand_modifiers( STACK * s, int n ) iter[ i ] = list_begin( args[ i ] ); i = 0; { - int havezeroed; + int32_t havezeroed; loop: memset( out, 0, sizeof( *out ) ); havezeroed = 0; @@ -873,7 +873,7 @@ static int expand_modifiers( STACK * s, int n ) return total; } -static LIST * apply_modifiers( STACK * s, int n ) +static LIST * apply_modifiers( STACK * s, int32_t n ) { LIST * value = stack_top( s ); LIST * result = L0; @@ -953,7 +953,7 @@ static LIST * apply_subscript( STACK * s ) LIST * value = stack_top( s ); LIST * indices = stack_at( s, 1 ); LIST * result = L0; - int length = list_length( value ); + int32_t length = list_length( value ); string buf[ 1 ]; LISTITER indices_iter = list_begin( indices ); LISTITER const indices_end = list_end( indices ); @@ -980,10 +980,10 @@ static LIST * apply_subscript( STACK * s ) */ static void get_iters( subscript_t const subscript, LISTITER * const first, - LISTITER * const last, int const length ) + LISTITER * const last, int32_t const length ) { - int start; - int size; + int32_t start; + int32_t size; LISTITER iter; LISTITER end; { @@ -1028,9 +1028,9 @@ static void get_iters( subscript_t const subscript, LISTITER * const first, } static LIST * apply_modifiers_empty( LIST * result, string * buf, - VAR_EDITS * edits, int n ) + VAR_EDITS * edits, int32_t n ) { - int i; + int32_t i; for ( i = 0; i < n; ++i ) { if ( edits[ i ].empty.ptr ) @@ -1046,9 +1046,9 @@ static LIST * apply_modifiers_empty( LIST * result, string * buf, } static LIST * apply_modifiers_non_empty( LIST * result, string * buf, - VAR_EDITS * edits, int n, LISTITER begin, LISTITER end ) + VAR_EDITS * edits, int32_t n, LISTITER begin, LISTITER end ) { - int i; + int32_t i; LISTITER iter; for ( i = 0; i < n; ++i ) { @@ -1059,7 +1059,7 @@ static LIST * apply_modifiers_non_empty( LIST * result, string * buf, for ( iter = list_next( begin ); iter != end; iter = list_next( iter ) ) { - size_t size; + int32_t size; string_append( buf, edits[ i ].join.ptr ); size = buf->size; var_edit_file( object_str( list_item( iter ) ), buf, edits + i @@ -1084,20 +1084,20 @@ static LIST * apply_modifiers_non_empty( LIST * result, string * buf, } static LIST * apply_modifiers_impl( LIST * result, string * buf, - VAR_EDITS * edits, int n, LISTITER iter, LISTITER end ) + VAR_EDITS * edits, int32_t n, LISTITER iter, LISTITER end ) { return iter == end ? apply_modifiers_empty( result, buf, edits, n ) : apply_modifiers_non_empty( result, buf, edits, n, iter, end ); } -static LIST * apply_subscript_and_modifiers( STACK * s, int n ) +static LIST * apply_subscript_and_modifiers( STACK * s, int32_t n ) { LIST * const value = stack_top( s ); LIST * const indices = stack_at( s, 1 ); LIST * result = L0; VAR_EDITS * const edits = (VAR_EDITS *)((LIST * *)stack_get( s ) + 2); - int const length = list_length( value ); + int32_t const length = list_length( value ); string buf[ 1 ]; LISTITER indices_iter = list_begin( indices ); LISTITER const indices_end = list_end( indices ); @@ -1158,17 +1158,17 @@ typedef struct expansion_item /* Internal data initialized and used inside expand(). */ LISTITER current; /* Currently used value. */ - int size; /* Concatenated string length prior to concatenating the + int32_t size; /* Concatenated string length prior to concatenating the * item's current value. */ } expansion_item; -static LIST * expand( expansion_item * items, int const length ) +static LIST * expand( expansion_item * items, int32_t const length ) { LIST * result = L0; string buf[ 1 ]; - int size = 0; - int i; + int32_t size = 0; + int32_t i; assert( length > 0 ); for ( i = 0; i < length; ++i ) @@ -1190,10 +1190,10 @@ static LIST * expand( expansion_item * items, int const length ) * strings. */ { - int max = 0; + int32_t max = 0; for ( ; iter != end; iter = list_next( iter ) ) { - int const len = strlen( object_str( list_item( iter ) ) ); + int32_t const len = int32_t(strlen( object_str( list_item( iter ) ) )); if ( len > max ) max = len; } size += max; @@ -1230,9 +1230,9 @@ static LIST * expand( expansion_item * items, int const length ) return result; } -static void combine_strings( STACK * s, int n, string * out ) +static void combine_strings( STACK * s, int32_t n, string * out ) { - int i; + int32_t i; for ( i = 0; i < n; ++i ) { LIST * const values = stack_pop( s ); @@ -1254,8 +1254,8 @@ static void combine_strings( STACK * s, int n, string * out ) struct dynamic_array { - int size; - int capacity; + int32_t size; + int32_t capacity; void * data; }; @@ -1272,7 +1272,7 @@ static void dynamic_array_free( struct dynamic_array * array ) } static void dynamic_array_push_impl( struct dynamic_array * const array, - void const * const value, int const unit_size ) + void const * const value, int32_t const unit_size ) { if ( array->capacity == 0 ) { @@ -1302,7 +1302,7 @@ static void dynamic_array_push_impl( struct dynamic_array * const array, struct label_info { - int absolute_position; + int32_t absolute_position; struct dynamic_array uses[ 1 ]; }; @@ -1311,18 +1311,18 @@ struct label_info struct loop_info { - int type; - int label; - int cleanup_depth; + int32_t type; + int32_t label; + int32_t cleanup_depth; }; struct stored_rule { OBJECT * name; PARSE * parse; - int num_arguments; + int32_t num_arguments; struct arg_list * arguments; - int local; + int32_t local; }; typedef struct compiler @@ -1349,7 +1349,7 @@ static void compiler_init( compiler * c ) static void compiler_free( compiler * c ) { - int i; + int32_t i; dynamic_array_free( c->actions ); dynamic_array_free( c->rules ); for ( i = 0; i < c->labels->size; ++i ) @@ -1367,9 +1367,9 @@ static void compile_emit_instruction( compiler * c, instruction instr ) dynamic_array_push( c->code, instr ); } -static int compile_new_label( compiler * c ) +static int32_t compile_new_label( compiler * c ) { - int result = c->labels->size; + int32_t result = c->labels->size; struct label_info info; info.absolute_position = -1; dynamic_array_init( info.uses ); @@ -1377,23 +1377,23 @@ static int compile_new_label( compiler * c ) return result; } -static void compile_set_label( compiler * c, int label ) +static void compile_set_label( compiler * c, int32_t label ) { struct label_info * const l = &dynamic_array_at( struct label_info, c->labels, label ); - int const pos = c->code->size; - int i; + int32_t const pos = c->code->size; + int32_t i; assert( l->absolute_position == -1 ); l->absolute_position = pos; for ( i = 0; i < l->uses->size; ++i ) { - int id = dynamic_array_at( int, l->uses, i ); - int offset = (int)( pos - id - 1 ); + int32_t id = dynamic_array_at( int32_t, l->uses, i ); + int32_t offset = (int32_t)( pos - id - 1 ); dynamic_array_at( instruction, c->code, id ).arg = offset; } } -static void compile_emit( compiler * c, unsigned int op_code, int arg ) +static void compile_emit( compiler * c, uint32_t op_code, int32_t arg ) { instruction instr; instr.op_code = op_code; @@ -1401,11 +1401,11 @@ static void compile_emit( compiler * c, unsigned int op_code, int arg ) compile_emit_instruction( c, instr ); } -static void compile_emit_branch( compiler * c, unsigned int op_code, int label ) +static void compile_emit_branch( compiler * c, uint32_t op_code, int32_t label ) { struct label_info * const l = &dynamic_array_at( struct label_info, c->labels, label ); - int const pos = c->code->size; + int32_t const pos = c->code->size; instruction instr; instr.op_code = op_code; if ( l->absolute_position == -1 ) @@ -1414,18 +1414,18 @@ static void compile_emit_branch( compiler * c, unsigned int op_code, int label ) dynamic_array_push( l->uses, pos ); } else - instr.arg = (int)( l->absolute_position - pos - 1 ); + instr.arg = (int32_t)( l->absolute_position - pos - 1 ); compile_emit_instruction( c, instr ); } -static int compile_emit_constant( compiler * c, OBJECT * value ) +static int32_t compile_emit_constant( compiler * c, OBJECT * value ) { OBJECT * copy = object_copy( value ); dynamic_array_push( c->constants, copy ); return c->constants->size - 1; } -static void compile_push_cleanup( compiler * c, unsigned int op_code, int arg ) +static void compile_push_cleanup( compiler * c, uint32_t op_code, int32_t arg ) { instruction instr; instr.op_code = op_code; @@ -1438,19 +1438,19 @@ static void compile_pop_cleanup( compiler * c ) dynamic_array_pop( c->cleanups ); } -static void compile_emit_cleanups( compiler * c, int end ) +static void compile_emit_cleanups( compiler * c, int32_t end ) { - int i; + int32_t i; for ( i = c->cleanups->size; --i >= end; ) { compile_emit_instruction( c, dynamic_array_at( instruction, c->cleanups, i ) ); } } -static void compile_emit_loop_jump( compiler * c, int type ) +static void compile_emit_loop_jump( compiler * c, int32_t type ) { struct loop_info * info = NULL; - int i; + int32_t i; for ( i = c->loop_scopes->size; --i >= 0; ) { struct loop_info * elem = &dynamic_array_at( struct loop_info, c->loop_scopes, i ); @@ -1469,7 +1469,7 @@ static void compile_emit_loop_jump( compiler * c, int type ) compile_emit_branch( c, INSTR_JUMP, info->label ); } -static void compile_push_break_scope( compiler * c, int label ) +static void compile_push_break_scope( compiler * c, int32_t label ) { struct loop_info info; info.type = LOOP_INFO_BREAK; @@ -1478,7 +1478,7 @@ static void compile_push_break_scope( compiler * c, int label ) dynamic_array_push( c->loop_scopes, info ); } -static void compile_push_continue_scope( compiler * c, int label ) +static void compile_push_continue_scope( compiler * c, int32_t label ) { struct loop_info info; info.type = LOOP_INFO_CONTINUE; @@ -1501,8 +1501,8 @@ static void compile_pop_continue_scope( compiler * c ) dynamic_array_pop( c->loop_scopes ); } -static int compile_emit_rule( compiler * c, OBJECT * name, PARSE * parse, - int num_arguments, struct arg_list * arguments, int local ) +static int32_t compile_emit_rule( compiler * c, OBJECT * name, PARSE * parse, + int32_t num_arguments, struct arg_list * arguments, int32_t local ) { struct stored_rule rule; rule.name = object_copy( name ); @@ -1511,10 +1511,10 @@ static int compile_emit_rule( compiler * c, OBJECT * name, PARSE * parse, rule.arguments = arguments; rule.local = local; dynamic_array_push( c->rules, rule ); - return (int)( c->rules->size - 1 ); + return (int32_t)( c->rules->size - 1 ); } -static int compile_emit_actions( compiler * c, PARSE * parse ) +static int32_t compile_emit_actions( compiler * c, PARSE * parse ) { SUBACTION a; a.name = object_copy( parse->string ); @@ -1522,13 +1522,13 @@ static int compile_emit_actions( compiler * c, PARSE * parse ) parse->file, parse->line ); a.flags = parse->num; dynamic_array_push( c->actions, a ); - return (int)( c->actions->size - 1 ); + return (int32_t)( c->actions->size - 1 ); } static JAM_FUNCTION * compile_to_function( compiler * c ) { JAM_FUNCTION * const result = (JAM_FUNCTION*)BJAM_MALLOC( sizeof( JAM_FUNCTION ) ); - int i; + int32_t i; result->base.type = FUNCTION_JAM; result->base.reference_count = 1; result->base.formal_arguments = 0; @@ -1594,7 +1594,7 @@ typedef struct VAR_PARSE_ACTIONS typedef struct _var_parse { - int type; /* string, variable or file */ + int32_t type; /* string, variable or file */ } VAR_PARSE; typedef struct @@ -1634,7 +1634,7 @@ static VAR_PARSE_GROUP * var_parse_group_new() static void var_parse_group_free( VAR_PARSE_GROUP * group ) { - int i; + int32_t i; for ( i = 0; i < group->elems->size; ++i ) var_parse_free( dynamic_array_at( VAR_PARSE *, group->elems, i ) ); dynamic_array_free( group->elems ); @@ -1689,7 +1689,7 @@ static VAR_PARSE_ACTIONS * var_parse_actions_new() static void var_parse_actions_free( VAR_PARSE_ACTIONS * actions ) { - int i; + int32_t i; for ( i = 0; i < actions->elems->size; ++i ) var_parse_group_free( dynamic_array_at( VAR_PARSE_GROUP *, actions->elems, i ) ); @@ -1714,7 +1714,7 @@ static VAR_PARSE_VAR * var_parse_var_new() static void var_parse_var_free( VAR_PARSE_VAR * var ) { - int i; + int32_t i; var_parse_group_free( var->name ); if ( var->subscript ) var_parse_group_free( var->subscript ); @@ -1760,7 +1760,7 @@ static VAR_PARSE_FILE * var_parse_file_new( void ) static void var_parse_file_free( VAR_PARSE_FILE * file ) { - int i; + int32_t i; for ( i = 0; i < file->filename->size; ++i ) var_parse_group_free( dynamic_array_at( VAR_PARSE_GROUP *, file->filename, i ) ); @@ -1808,9 +1808,9 @@ static void var_parse_group_compile( VAR_PARSE_GROUP const * parse, static void var_parse_var_compile( VAR_PARSE_VAR const * parse, compiler * c ) { - int expand_name = 0; - int is_get_grist = 0; - int has_modifiers = 0; + int32_t expand_name = 0; + int32_t is_get_grist = 0; + int32_t has_modifiers = 0; /* Special case common modifiers */ if ( parse->modifiers->size == 1 ) { @@ -1831,7 +1831,7 @@ static void var_parse_var_compile( VAR_PARSE_VAR const * parse, compiler * c ) /* If there are modifiers, emit them in reverse order. */ if ( parse->modifiers->size > 0 && !is_get_grist ) { - int i; + int32_t i; has_modifiers = 1; for ( i = 0; i < parse->modifiers->size; ++i ) var_parse_group_compile( dynamic_array_at( VAR_PARSE_GROUP *, @@ -1852,7 +1852,7 @@ static void var_parse_var_compile( VAR_PARSE_VAR const * parse, compiler * c ) { OBJECT * const name = ( (VAR_PARSE_STRING *)dynamic_array_at( VAR_PARSE *, parse->name->elems, 0 ) )->s; - int const idx = get_argument_index( object_str( name ) ); + int32_t const idx = get_argument_index( object_str( name ) ); if ( idx != -1 ) compile_emit( c, INSTR_PUSH_ARG, idx ); else @@ -1900,7 +1900,7 @@ static void var_parse_string_compile( VAR_PARSE_STRING const * parse, static void var_parse_file_compile( VAR_PARSE_FILE const * parse, compiler * c ) { - int i; + int32_t i; for ( i = 0; i < parse->filename->size; ++i ) var_parse_group_compile( dynamic_array_at( VAR_PARSE_GROUP *, parse->filename, parse->filename->size - i - 1 ), c ); @@ -1936,7 +1936,7 @@ static void var_parse_group_compile( VAR_PARSE_GROUP const * parse, compiler * c ) { /* Emit the elements in reverse order. */ - int i; + int32_t i; for ( i = 0; i < parse->elems->size; ++i ) var_parse_compile( dynamic_array_at( VAR_PARSE *, parse->elems, parse->elems->size - i - 1 ), c ); @@ -1952,7 +1952,7 @@ static void var_parse_group_compile( VAR_PARSE_GROUP const * parse, compiler * c static void var_parse_actions_compile( VAR_PARSE_ACTIONS const * actions, compiler * c ) { - int i; + int32_t i; for ( i = 0; i < actions->elems->size; ++i ) var_parse_group_compile( dynamic_array_at( VAR_PARSE_GROUP *, actions->elems, actions->elems->size - i - 1 ), c ); @@ -1967,7 +1967,7 @@ static void var_parse_actions_compile( VAR_PARSE_ACTIONS const * actions, static VAR_PARSE * parse_at_file( char const * start, char const * mid, char const * end ); static VAR_PARSE * parse_variable( char const * * string ); -static int try_parse_variable( char const * * s_, char const * * string, +static int32_t try_parse_variable( char const * * s_, char const * * string, VAR_PARSE_GROUP * out ); static void balance_parentheses( char const * * s_, char const * * string, VAR_PARSE_GROUP * out ); @@ -2011,7 +2011,7 @@ static VAR_PARSE_ACTIONS * parse_actions( char const * string ) * starts with a variable, 0 otherwise. */ -static int try_parse_variable( char const * * s_, char const * * string, +static int32_t try_parse_variable( char const * * s_, char const * * string, VAR_PARSE_GROUP * out ) { char const * s = *s_; @@ -2026,7 +2026,7 @@ static int try_parse_variable( char const * * s_, char const * * string, } if ( s[ 0 ] == '@' && s[ 1 ] == '(' ) { - int depth = 1; + int32_t depth = 1; char const * ine; char const * split = 0; var_parse_group_maybe_add_constant( out, *string, s ); @@ -2062,7 +2062,7 @@ static int try_parse_variable( char const * * s_, char const * * string, static char const * current_file = ""; -static int current_line; +static int32_t current_line; static void parse_error( char const * message ) { @@ -2247,7 +2247,7 @@ static VAR_PARSE * parse_at_file( char const * start, char const * mid, void balance_parentheses( char const * * s_, char const * * string, VAR_PARSE_GROUP * out) { - int depth = 1; + int32_t depth = 1; char const * s = *s_; for ( ; ; ) { @@ -2287,10 +2287,10 @@ void balance_parentheses( char const * * s_, char const * * string, #define RESULT_RETURN 1 #define RESULT_NONE 2 -static void compile_parse( PARSE * parse, compiler * c, int result_location ); -static struct arg_list * arg_list_compile( PARSE * parse, int * num_arguments ); +static void compile_parse( PARSE * parse, compiler * c, int32_t result_location ); +static struct arg_list * arg_list_compile( PARSE * parse, int32_t * num_arguments ); -static void compile_condition( PARSE * parse, compiler * c, int branch_true, int label ) +static void compile_condition( PARSE * parse, compiler * c, int32_t branch_true, int32_t label ) { assert( parse->type == PARSE_EVAL ); switch ( parse->num ) @@ -2369,7 +2369,7 @@ static void compile_condition( PARSE * parse, compiler * c, int branch_true, int case EXPR_AND: if ( branch_true ) { - int f = compile_new_label( c ); + int32_t f = compile_new_label( c ); compile_condition( parse->left, c, 0, f ); compile_condition( parse->right, c, 1, label ); compile_set_label( c, f ); @@ -2389,7 +2389,7 @@ static void compile_condition( PARSE * parse, compiler * c, int branch_true, int } else { - int t = compile_new_label( c ); + int32_t t = compile_new_label( c ); compile_condition( parse->left, c, 1, t ); compile_condition( parse->right, c, 0, label ); compile_set_label( c, t ); @@ -2402,8 +2402,8 @@ static void compile_condition( PARSE * parse, compiler * c, int branch_true, int } } -static void adjust_result( compiler * c, int actual_location, - int desired_location ) +static void adjust_result( compiler * c, int32_t actual_location, + int32_t desired_location ) { if ( actual_location == desired_location ) ; @@ -2442,7 +2442,7 @@ static void compile_append_chain( PARSE * parse, compiler * c ) } } -static void compile_emit_debug(compiler * c, int line) +static void compile_emit_debug(compiler * c, int32_t line) { #ifdef JAM_DEBUGGER if ( debug_is_debugging() ) @@ -2450,7 +2450,7 @@ static void compile_emit_debug(compiler * c, int line) #endif } -static void compile_parse( PARSE * parse, compiler * c, int result_location ) +static void compile_parse( PARSE * parse, compiler * c, int32_t result_location ) { compile_emit_debug(c, parse->line); if ( parse->type == PARSE_APPEND ) @@ -2467,8 +2467,8 @@ static void compile_parse( PARSE * parse, compiler * c, int result_location ) compile_parse( parse->left, c, result_location ); else { - int f = compile_new_label( c ); - int end = compile_new_label( c ); + int32_t f = compile_new_label( c ); + int32_t end = compile_new_label( c ); out_printf( "%s:%d: Conditional used as list (check operator " "precedence).\n", object_str( parse->file ), parse->line ); @@ -2486,10 +2486,10 @@ static void compile_parse( PARSE * parse, compiler * c, int result_location ) } else if ( parse->type == PARSE_FOREACH ) { - int var = compile_emit_constant( c, parse->string ); - int top = compile_new_label( c ); - int end = compile_new_label( c ); - int continue_ = compile_new_label( c ); + int32_t var = compile_emit_constant( c, parse->string ); + int32_t top = compile_new_label( c ); + int32_t end = compile_new_label( c ); + int32_t continue_ = compile_new_label( c ); /* * Evaluate the list. @@ -2536,7 +2536,7 @@ static void compile_parse( PARSE * parse, compiler * c, int result_location ) } else if ( parse->type == PARSE_IF ) { - int f = compile_new_label( c ); + int32_t f = compile_new_label( c ); /* Emit the condition */ compile_condition( parse->left, c, 0, f ); /* Emit the if block */ @@ -2544,7 +2544,7 @@ static void compile_parse( PARSE * parse, compiler * c, int result_location ) if ( parse->third->type != PARSE_NULL || result_location != RESULT_NONE ) { /* Emit the else block */ - int end = compile_new_label( c ); + int32_t end = compile_new_label( c ); compile_emit_branch( c, INSTR_JUMP, end ); compile_set_label( c, f ); compile_parse( parse->third, c, result_location ); @@ -2556,12 +2556,12 @@ static void compile_parse( PARSE * parse, compiler * c, int result_location ) } else if ( parse->type == PARSE_WHILE ) { - int nested_result = result_location == RESULT_NONE + int32_t nested_result = result_location == RESULT_NONE ? RESULT_NONE : RESULT_RETURN; - int test = compile_new_label( c ); - int top = compile_new_label( c ); - int end = compile_new_label( c ); + int32_t test = compile_new_label( c ); + int32_t top = compile_new_label( c ); + int32_t end = compile_new_label( c ); /* Make sure that we return an empty list if the loop runs zero times. */ adjust_result( c, RESULT_NONE, nested_result ); @@ -2590,7 +2590,7 @@ static void compile_parse( PARSE * parse, compiler * c, int result_location ) } else if ( parse->type == PARSE_MODULE ) { - int const nested_result = result_location == RESULT_NONE + int32_t const nested_result = result_location == RESULT_NONE ? RESULT_NONE : RESULT_RETURN; compile_parse( parse->left, c, RESULT_STACK ); @@ -2633,7 +2633,7 @@ static void compile_parse( PARSE * parse, compiler * c, int result_location ) } else if ( parse->type == PARSE_LOCAL ) { - int nested_result = result_location == RESULT_NONE + int32_t nested_result = result_location == RESULT_NONE ? RESULT_NONE : RESULT_RETURN; /* This should be left recursive group of compile_appends. */ @@ -2658,7 +2658,7 @@ static void compile_parse( PARSE * parse, compiler * c, int result_location ) if ( group->elems->size == 1 && dynamic_array_at( VAR_PARSE *, group->elems, 0 )->type == VAR_PARSE_TYPE_STRING ) { - int const name = compile_emit_constant( c, ( + int32_t const name = compile_emit_constant( c, ( (VAR_PARSE_STRING *)dynamic_array_at( VAR_PARSE *, group->elems, 0 ) )->s ); var_parse_group_free( group ); @@ -2736,7 +2736,7 @@ static void compile_parse( PARSE * parse, compiler * c, int result_location ) else { /* Too complex. Fall back on push/pop. */ - int end = compile_new_label( c ); + int32_t end = compile_new_label( c ); compile_parse( parse->left, c, RESULT_STACK ); compile_emit_branch( c, INSTR_PUSH_ON, end ); compile_push_cleanup( c, INSTR_POP_ON, 0 ); @@ -2749,7 +2749,7 @@ static void compile_parse( PARSE * parse, compiler * c, int result_location ) } else { - int end = compile_new_label( c ); + int32_t end = compile_new_label( c ); compile_parse( parse->left, c, RESULT_STACK ); compile_emit_branch( c, INSTR_PUSH_ON, end ); compile_push_cleanup( c, INSTR_POP_ON, 0 ); @@ -2763,7 +2763,7 @@ static void compile_parse( PARSE * parse, compiler * c, int result_location ) else if ( parse->type == PARSE_RULE ) { PARSE * p; - int n = 0; + int32_t n = 0; VAR_PARSE_GROUP * group; char const * s = object_str( parse->string ); @@ -2811,8 +2811,8 @@ static void compile_parse( PARSE * parse, compiler * c, int result_location ) else if ( parse->type == PARSE_SET ) { PARSE * vars = parse->left; - unsigned int op_code; - unsigned int op_code_group; + uint32_t op_code; + uint32_t op_code_group; switch ( parse->num ) { @@ -2832,7 +2832,7 @@ static void compile_parse( PARSE * parse, compiler * c, int result_location ) if ( group->elems->size == 1 && dynamic_array_at( VAR_PARSE *, group->elems, 0 )->type == VAR_PARSE_TYPE_STRING ) { - int const name = compile_emit_constant( c, ( + int32_t const name = compile_emit_constant( c, ( (VAR_PARSE_STRING *)dynamic_array_at( VAR_PARSE *, group->elems, 0 ) )->s ); var_parse_group_free( group ); @@ -2875,16 +2875,16 @@ static void compile_parse( PARSE * parse, compiler * c, int result_location ) } else if ( parse->type == PARSE_SETCOMP ) { - int n_args; + int32_t n_args; struct arg_list * args = arg_list_compile( parse->right, &n_args ); - int const rule_id = compile_emit_rule( c, parse->string, parse->left, + int32_t const rule_id = compile_emit_rule( c, parse->string, parse->left, n_args, args, parse->num ); compile_emit( c, INSTR_RULE, rule_id ); adjust_result( c, RESULT_NONE, result_location ); } else if ( parse->type == PARSE_SETEXEC ) { - int const actions_id = compile_emit_actions( c, parse ); + int32_t const actions_id = compile_emit_actions( c, parse ); compile_parse( parse->left, c, RESULT_STACK ); compile_emit( c, INSTR_ACTIONS, actions_id ); adjust_result( c, RESULT_NONE, result_location ); @@ -2907,13 +2907,13 @@ static void compile_parse( PARSE * parse, compiler * c, int result_location ) } else if ( parse->type == PARSE_SWITCH ) { - int const switch_end = compile_new_label( c ); + int32_t const switch_end = compile_new_label( c ); compile_parse( parse->left, c, RESULT_STACK ); for ( parse = parse->right; parse; parse = parse->right ) { - int const id = compile_emit_constant( c, parse->left->string ); - int const next_case = compile_new_label( c ); + int32_t const id = compile_emit_constant( c, parse->left->string ); + int32_t const next_case = compile_new_label( c ); compile_emit( c, INSTR_PUSH_CONSTANT, id ); compile_emit_branch( c, INSTR_JUMP_NOT_GLOB, next_case ); compile_parse( parse->left->left, c, result_location ); @@ -2954,7 +2954,7 @@ void function_set_rulename( FUNCTION * function, OBJECT * rulename ) function->rulename = rulename; } -void function_location( FUNCTION * function_, OBJECT * * file, int * line ) +void function_location( FUNCTION * function_, OBJECT * * file, int32_t * line ) { if ( function_->type == FUNCTION_BUILTIN ) { @@ -2978,10 +2978,10 @@ void function_location( FUNCTION * function_, OBJECT * * file, int * line ) } static struct arg_list * arg_list_compile_builtin( char const * * args, - int * num_arguments ); + int32_t * num_arguments ); -FUNCTION * function_builtin( LIST * ( * func )( FRAME * frame, int flags ), - int flags, char const * * args ) +FUNCTION * function_builtin( LIST * ( * func )( FRAME * frame, int32_t flags ), + int32_t flags, char const * * args ) { BUILTIN_FUNCTION * result = (BUILTIN_FUNCTION*)BJAM_MALLOC( sizeof( BUILTIN_FUNCTION ) ); result->base.type = FUNCTION_BUILTIN; @@ -3009,7 +3009,7 @@ FUNCTION * function_compile( PARSE * parse ) } FUNCTION * function_compile_actions( char const * actions, OBJECT * file, - int line ) + int32_t line ) { compiler c[ 1 ]; JAM_FUNCTION * result; @@ -3028,7 +3028,7 @@ FUNCTION * function_compile_actions( char const * actions, OBJECT * file, return (FUNCTION *)result; } -static void argument_list_print( struct arg_list * args, int num_args ); +static void argument_list_print( struct arg_list * args, int32_t num_args ); /* Define delimiters for type check elements in argument lists (and return type @@ -3042,7 +3042,7 @@ static void argument_list_print( struct arg_list * args, int num_args ); * specification. */ -int is_type_name( char const * s ) +int32_t is_type_name( char const * s ) { return s[ 0 ] == TYPE_OPEN_DELIM && s[ strlen( s ) - 1 ] == TYPE_CLOSE_DELIM; @@ -3113,18 +3113,18 @@ static void type_check( OBJECT * type_name, LIST * values, FRAME * caller, caller, called, arg_name ); } -void argument_list_check( struct arg_list * formal, int formal_count, +void argument_list_check( struct arg_list * formal, int32_t formal_count, FUNCTION * function, FRAME * frame ) { LOL * all_actual = frame->args; - int i; + int32_t i; for ( i = 0; i < formal_count; ++i ) { LIST * actual = lol_get( all_actual, i ); LISTITER actual_iter = list_begin( actual ); LISTITER const actual_end = list_end( actual ); - int j; + int32_t j; for ( j = 0; j < formal[ i ].size; ++j ) { struct argument * formal_arg = &formal[ i ].args[ j ]; @@ -3178,22 +3178,22 @@ void argument_list_check( struct arg_list * formal, int formal_count, } } -void argument_list_push( struct arg_list * formal, int formal_count, +void argument_list_push( struct arg_list * formal, int32_t formal_count, FUNCTION * function, FRAME * frame, STACK * s ) { LOL * all_actual = frame->args; - int i; + int32_t i; for ( i = 0; i < formal_count; ++i ) { LIST * actual = lol_get( all_actual, i ); LISTITER actual_iter = list_begin( actual ); LISTITER const actual_end = list_end( actual ); - int j; + int32_t j; for ( j = 0; j < formal[ i ].size; ++j ) { struct argument * formal_arg = &formal[ i ].args[ j ]; - LIST * value; + LIST * value = L0; switch ( formal_arg->flags ) { @@ -3255,13 +3255,13 @@ void argument_list_push( struct arg_list * formal, int formal_count, } } -void argument_list_pop( struct arg_list * formal, int formal_count, +void argument_list_pop( struct arg_list * formal, int32_t formal_count, FRAME * frame, STACK * s ) { - int i; + int32_t i; for ( i = formal_count - 1; i >= 0; --i ) { - int j; + int32_t j; for ( j = formal[ i ].size - 1; j >= 0 ; --j ) { struct argument * formal_arg = &formal[ i ].args[ j ]; @@ -3288,7 +3288,7 @@ struct argument_compiler { struct dynamic_array args[ 1 ]; struct argument arg; - int state; + int32_t state; #define ARGUMENT_COMPILER_START 0 #define ARGUMENT_COMPILER_FOUND_TYPE 1 #define ARGUMENT_COMPILER_FOUND_OBJECT 2 @@ -3308,7 +3308,7 @@ static void argument_compiler_free( struct argument_compiler * c ) } static void argument_compiler_add( struct argument_compiler * c, OBJECT * arg, - OBJECT * file, int line ) + OBJECT * file, int32_t line ) { switch ( c->state ) { @@ -3391,7 +3391,7 @@ static void argument_compiler_recurse( struct argument_compiler * c, } static struct arg_list arg_compile_impl( struct argument_compiler * c, - OBJECT * file, int line ) + OBJECT * file, int32_t line ) { struct arg_list result; switch ( c->state ) @@ -3458,7 +3458,7 @@ static void argument_list_compiler_recurse( struct argument_list_compiler * c, } } -static struct arg_list * arg_list_compile( PARSE * parse, int * num_arguments ) +static struct arg_list * arg_list_compile( PARSE * parse, int32_t * num_arguments ) { if ( parse ) { @@ -3478,7 +3478,7 @@ static struct arg_list * arg_list_compile( PARSE * parse, int * num_arguments ) } static struct arg_list * arg_list_compile_builtin( char const * * args, - int * num_arguments ) + int32_t * num_arguments ) { if ( args ) { @@ -3518,14 +3518,14 @@ static struct arg_list * arg_list_compile_builtin( char const * * args, return 0; } -static void argument_list_print( struct arg_list * args, int num_args ) +static void argument_list_print( struct arg_list * args, int32_t num_args ) { if ( args ) { - int i; + int32_t i; for ( i = 0; i < num_args; ++i ) { - int j; + int32_t j; if ( i ) out_printf( " : " ); for ( j = 0; j < args[ i ].size; ++j ) { @@ -3547,17 +3547,17 @@ static void argument_list_print( struct arg_list * args, int num_args ) struct arg_list * argument_list_bind_variables( struct arg_list * formal, - int formal_count, module_t * module, int * counter ) + int32_t formal_count, module_t * module, int32_t * counter ) { if ( formal ) { struct arg_list * result = (struct arg_list *)BJAM_MALLOC( sizeof( struct arg_list ) * formal_count ); - int i; + int32_t i; for ( i = 0; i < formal_count; ++i ) { - int j; + int32_t j; struct argument * args = (struct argument *)BJAM_MALLOC( sizeof( struct argument ) * formal[ i ].size ); for ( j = 0; j < formal[ i ].size; ++j ) @@ -3580,12 +3580,12 @@ struct arg_list * argument_list_bind_variables( struct arg_list * formal, } -void argument_list_free( struct arg_list * args, int args_count ) +void argument_list_free( struct arg_list * args, int32_t args_count ) { - int i; + int32_t i; for ( i = 0; i < args_count; ++i ) { - int j; + int32_t j; for ( j = 0; j < args[ i ].size; ++j ) { if ( args[ i ].args[ j ].type_name ) @@ -3614,7 +3614,7 @@ FUNCTION * function_unbind_variables( FUNCTION * f ) } FUNCTION * function_bind_variables( FUNCTION * f, module_t * module, - int * counter ) + int32_t * counter ) { if ( f->type == FUNCTION_BUILTIN ) return f; @@ -3626,7 +3626,7 @@ FUNCTION * function_bind_variables( FUNCTION * f, module_t * module, JAM_FUNCTION * func = (JAM_FUNCTION *)f; JAM_FUNCTION * new_func = (JAM_FUNCTION *)BJAM_MALLOC( sizeof( JAM_FUNCTION ) ); instruction * code; - int i; + int32_t i; assert( f->type == FUNCTION_JAM ); memcpy( new_func, func, sizeof( JAM_FUNCTION ) ); new_func->base.reference_count = 1; @@ -3640,7 +3640,7 @@ FUNCTION * function_bind_variables( FUNCTION * f, module_t * module, for ( i = 0; ; ++i ) { OBJECT * key; - int op_code; + int32_t op_code; code = func->code + i; switch ( code->op_code ) { @@ -3657,7 +3657,7 @@ FUNCTION * function_bind_variables( FUNCTION * f, module_t * module, case INSTR_CALL_RULE: ++i; continue; case INSTR_PUSH_MODULE: { - int depth = 1; + int32_t depth = 1; ++i; while ( depth > 0 ) { @@ -3707,7 +3707,7 @@ LIST * function_get_variables( FUNCTION * f ) JAM_FUNCTION * func = (JAM_FUNCTION *)f; LIST * result = L0; instruction * code; - int i; + int32_t i; assert( f->type == FUNCTION_JAM ); if ( func->generic ) func = ( JAM_FUNCTION * )func->generic; @@ -3723,7 +3723,7 @@ LIST * function_get_variables( FUNCTION * f ) case INSTR_CALL_RULE: ++i; continue; case INSTR_PUSH_MODULE: { - int depth = 1; + int32_t depth = 1; ++i; while ( depth > 0 ) { @@ -3767,7 +3767,7 @@ void function_refer( FUNCTION * func ) void function_free( FUNCTION * function_ ) { - int i; + int32_t i; if ( --function_->reference_count != 0 ) return; @@ -3871,7 +3871,9 @@ LIST * function_run( FUNCTION * function_, FRAME * frame, STACK * s ) LIST * l; LIST * r; LIST * result = L0; +#ifndef NDEBUG void * saved_stack = s->data; +#endif PROFILE_ENTER_LOCAL(function_run); @@ -4250,8 +4252,8 @@ LIST * function_run( FUNCTION * function_, FRAME * frame, STACK * s ) backtrace( frame ); assert( saved_stack == s->data ); } -#endif assert( saved_stack == s->data ); +#endif debug_on_exit_function( function->base.rulename ); PROFILE_EXIT_LOCAL(function_run_INSTR_RETURN); PROFILE_EXIT_LOCAL(function_run); @@ -4467,7 +4469,7 @@ LIST * function_run( FUNCTION * function_, FRAME * frame, STACK * s ) OBJECT * varname = function->constants[ code->arg ]; TARGET * t = bindtarget( list_front( targets ) ); SETTINGS * s = t->settings; - int found = 0; + int32_t found = 0; for ( ; s != 0; s = s->next ) { if ( object_equal( s->symbol, varname ) ) @@ -4653,8 +4655,8 @@ LIST * function_run( FUNCTION * function_, FRAME * frame, STACK * s ) case INSTR_APPLY_MODIFIERS: { PROFILE_ENTER_LOCAL(function_run_INSTR_APPLY_MODIFIERS); - int n; - int i; + int32_t n; + int32_t i; l = stack_pop( s ); n = expand_modifiers( s, code->arg ); stack_push( s, l ); @@ -4682,8 +4684,8 @@ LIST * function_run( FUNCTION * function_, FRAME * frame, STACK * s ) case INSTR_APPLY_INDEX_MODIFIERS: { PROFILE_ENTER_LOCAL(function_run_INSTR_APPLY_INDEX_MODIFIERS); - int i; - int n; + int32_t i; + int32_t n; l = stack_pop( s ); r = stack_pop( s ); n = expand_modifiers( s, code->arg ); @@ -4703,9 +4705,9 @@ LIST * function_run( FUNCTION * function_, FRAME * frame, STACK * s ) case INSTR_APPLY_MODIFIERS_GROUP: { PROFILE_ENTER_LOCAL(function_run_INSTR_APPLY_MODIFIERS_GROUP); - int i; + int32_t i; LIST * const vars = stack_pop( s ); - int const n = expand_modifiers( s, code->arg ); + int32_t const n = expand_modifiers( s, code->arg ); LIST * result = L0; LISTITER iter = list_begin( vars ); LISTITER const end = list_end( vars ); @@ -4749,10 +4751,10 @@ LIST * function_run( FUNCTION * function_, FRAME * frame, STACK * s ) case INSTR_APPLY_INDEX_MODIFIERS_GROUP: { PROFILE_ENTER_LOCAL(function_run_INSTR_APPLY_INDEX_MODIFIERS_GROUP); - int i; + int32_t i; LIST * const vars = stack_pop( s ); LIST * const r = stack_pop( s ); - int const n = expand_modifiers( s, code->arg ); + int32_t const n = expand_modifiers( s, code->arg ); LIST * result = L0; LISTITER iter = list_begin( vars ); LISTITER const end = list_end( vars ); @@ -4778,11 +4780,11 @@ LIST * function_run( FUNCTION * function_, FRAME * frame, STACK * s ) case INSTR_COMBINE_STRINGS: { PROFILE_ENTER_LOCAL(function_run_INSTR_COMBINE_STRINGS); - size_t const buffer_size = code->arg * sizeof( expansion_item ); + int32_t const buffer_size = code->arg * sizeof( expansion_item ); LIST * * const stack_pos = (LIST * * const)stack_get( s ); expansion_item * items = (expansion_item *)stack_allocate( s, buffer_size ); LIST * result; - int i; + int32_t i; for ( i = 0; i < code->arg; ++i ) items[ i ].values = stack_pos[ i ]; result = expand( items, code->arg ); @@ -4809,7 +4811,7 @@ LIST * function_run( FUNCTION * function_, FRAME * frame, STACK * s ) if ( value[ 0 ] == '<' && ( p = strchr( value, '>' ) ) ) { if( p[ 1 ] ) - new_object = object_new_range( value, p - value + 1 ); + new_object = object_new_range( value, int32_t(p - value + 1) ); else new_object = object_copy( list_item( iter ) ); } @@ -4936,7 +4938,7 @@ LIST * function_run( FUNCTION * function_, FRAME * frame, STACK * s ) string buf[ 1 ]; char const * out; OBJECT * tmp_filename = 0; - int out_debug = DEBUG_EXEC ? 1 : 0; + int32_t out_debug = DEBUG_EXEC ? 1 : 0; FILE * out_file = 0; string_new( buf ); combine_strings( s, code->arg, buf ); @@ -4948,7 +4950,7 @@ LIST * function_run( FUNCTION * function_, FRAME * frame, STACK * s ) if ( ( strcmp( "STDOUT", out ) == 0 ) || ( strcmp( "STDERR", out ) == 0 ) ) { - int err_redir = strcmp( "STDERR", out ) == 0; + int32_t err_redir = strcmp( "STDERR", out ) == 0; string result[ 1 ]; tmp_filename = path_tmpfile(); @@ -5069,7 +5071,7 @@ LIST * function_run( FUNCTION * function_, FRAME * frame, STACK * s ) #ifdef HAVE_PYTHON static struct arg_list * arg_list_compile_python( PyObject * bjam_signature, - int * num_arguments ) + int32_t * num_arguments ) { if ( bjam_signature ) { @@ -5127,18 +5129,18 @@ FUNCTION * function_python( PyObject * function, PyObject * bjam_signature ) } -static void argument_list_to_python( struct arg_list * formal, int formal_count, +static void argument_list_to_python( struct arg_list * formal, int32_t formal_count, FUNCTION * function, FRAME * frame, PyObject * kw ) { LOL * all_actual = frame->args; - int i; + int32_t i; for ( i = 0; i < formal_count; ++i ) { LIST * actual = lol_get( all_actual, i ); LISTITER actual_iter = list_begin( actual ); LISTITER const actual_end = list_end( actual ); - int j; + int32_t j; for ( j = 0; j < formal[ i ].size; ++j ) { struct argument * formal_arg = &formal[ i ].args[ j ]; @@ -5259,7 +5261,7 @@ static LIST * call_python_function( PYTHON_FUNCTION * function, FRAME * frame ) LIST * result = 0; PyObject * arguments = 0; PyObject * kw = NULL; - int i; + int32_t i; PyObject * py_result; FRAME * prev_frame_before_python_call; @@ -5290,8 +5292,8 @@ static LIST * call_python_function( PYTHON_FUNCTION * function, FRAME * frame ) { if ( PyList_Check( py_result ) ) { - int size = PyList_Size( py_result ); - int i; + int32_t size = PyList_Size( py_result ); + int32_t i; for ( i = 0; i < size; ++i ) { OBJECT * s = python_to_string( PyList_GetItem( py_result, i ) ); diff --git a/src/engine/function.h b/src/engine/function.h index 73c837f52..397487537 100644 --- a/src/engine/function.h +++ b/src/engine/function.h @@ -22,18 +22,18 @@ void stack_push( STACK * s, LIST * l ); LIST * stack_pop( STACK * s ); FUNCTION * function_compile( PARSE * parse ); -FUNCTION * function_builtin( LIST * ( * func )( FRAME * frame, int flags ), int flags, const char * * args ); +FUNCTION * function_builtin( LIST * ( * func )( FRAME * frame, int32_t flags ), int32_t flags, const char * * args ); void function_refer( FUNCTION * ); void function_free( FUNCTION * ); OBJECT * function_rulename( FUNCTION * ); void function_set_rulename( FUNCTION *, OBJECT * ); -void function_location( FUNCTION *, OBJECT * *, int * ); +void function_location( FUNCTION *, OBJECT * *, int32_t * ); LIST * function_run( FUNCTION * function, FRAME * frame, STACK * s ); -FUNCTION * function_compile_actions( const char * actions, OBJECT * file, int line ); +FUNCTION * function_compile_actions( const char * actions, OBJECT * file, int32_t line ); void function_run_actions( FUNCTION * function, FRAME * frame, STACK * s, string * out ); -FUNCTION * function_bind_variables( FUNCTION * f, module_t * module, int * counter ); +FUNCTION * function_bind_variables( FUNCTION * f, module_t * module, int32_t * counter ); FUNCTION * function_unbind_variables( FUNCTION * f ); LIST * function_get_variables( FUNCTION * f ); diff --git a/src/engine/hash.cpp b/src/engine/hash.cpp index f3dcef88a..9dcd5816b 100644 --- a/src/engine/hash.cpp +++ b/src/engine/hash.cpp @@ -45,12 +45,12 @@ struct hash */ struct { - int nel; + int32_t nel; ITEM * * base; } tab; - int bloat; /* tab.nel / items.nel */ - int inel; /* initial number of elements */ + int32_t bloat; /* tab.nel / items.nel */ + int32_t inel; /* initial number of elements */ /* * the array of records, maintained by these routines - essentially a @@ -58,16 +58,16 @@ struct hash */ struct { - int more; /* how many more ITEMs fit in lists[ list ] */ + int32_t 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 size; /* sizeof( ITEM ) + aligned datalen */ - int nel; /* total ITEMs held by all lists[] */ - int list; /* index into lists[] */ + int32_t size; /* sizeof( ITEM ) + aligned datalen */ + int32_t nel; /* total ITEMs held by all lists[] */ + int32_t list; /* index into lists[] */ struct { - int nel; /* total ITEMs held by this list */ + int32_t nel; /* total ITEMs held by this list */ char * base; /* base of ITEMs array */ } lists[ MAX_LISTS ]; } items; @@ -78,7 +78,7 @@ struct hash static void hashrehash( struct hash * ); static void hashstat( struct hash * ); -static unsigned int hash_keyval( OBJECT * key ) +static uint32_t hash_keyval( OBJECT * key ) { return object_hash( key ); } @@ -96,7 +96,7 @@ static unsigned int hash_keyval( OBJECT * key ) * hashinit() - initialize a hash table, returning a handle */ -struct hash * hashinit( int datalen, char const * name ) +struct hash * hashinit( int32_t datalen, char const * name ) { struct hash * hp = (struct hash *)BJAM_MALLOC( sizeof( *hp ) ); @@ -123,7 +123,7 @@ struct hash * hashinit( int datalen, char const * name ) * bucket or to 0 if our item is the first item in its bucket. */ -static ITEM * hash_search( struct hash * hp, unsigned int keyval, +static ITEM * hash_search( struct hash * hp, uint32_t keyval, OBJECT * keydata, ITEM * * previous ) { ITEM * i = *hash_bucket( hp, keyval ); @@ -146,10 +146,10 @@ static ITEM * hash_search( struct hash * hp, unsigned int keyval, * hash_insert() - insert a record in the table or return the existing one */ -HASHDATA * hash_insert( struct hash * hp, OBJECT * key, int * found ) +HASHDATA * hash_insert( struct hash * hp, OBJECT * key, int32_t * found ) { ITEM * i; - unsigned int keyval = hash_keyval( key ); + uint32_t keyval = hash_keyval( key ); #ifdef HASH_DEBUG_PROFILE profile_frame prof[ 1 ]; @@ -201,7 +201,7 @@ HASHDATA * hash_insert( struct hash * hp, OBJECT * key, int * found ) HASHDATA * hash_find( struct hash * hp, OBJECT * key ) { ITEM * i; - unsigned int keyval = hash_keyval( key ); + uint32_t keyval = hash_keyval( key ); #ifdef HASH_DEBUG_PROFILE profile_frame prof[ 1 ]; @@ -235,7 +235,7 @@ HASHDATA * hash_find( struct hash * hp, OBJECT * key ) static void hashrehash( struct hash * hp ) { - int i = ++hp->items.list; + int32_t i = ++hp->items.list; hp->items.more = i ? 2 * hp->items.nel : hp->inel; hp->items.next = (char *)BJAM_MALLOC( hp->items.more * hp->items.size ); hp->items.free = 0; @@ -254,7 +254,7 @@ static void hashrehash( struct hash * hp ) for ( i = 0; i < hp->items.list; ++i ) { - int nel = hp->items.lists[ i ].nel; + int32_t nel = hp->items.lists[ i ].nel; char * next = hp->items.lists[ i ].base; for ( ; nel--; next += hp->items.size ) @@ -277,11 +277,11 @@ static void hashrehash( struct hash * hp ) void hashenumerate( struct hash * hp, void (* f)( void *, void * ), void * data ) { - int i; + int32_t i; for ( i = 0; i <= hp->items.list; ++i ) { char * next = hp->items.lists[ i ].base; - int nel = hp->items.lists[ i ].nel; + int32_t nel = hp->items.lists[ i ].nel; if ( i == hp->items.list ) nel -= hp->items.more; @@ -301,7 +301,7 @@ void hashenumerate( struct hash * hp, void (* f)( void *, void * ), void * data void hash_free( struct hash * hp ) { - int i; + int32_t i; if ( !hp ) return; if ( hp->tab.base ) diff --git a/src/engine/hash.h b/src/engine/hash.h index 7ed633d73..5f69f97cb 100644 --- a/src/engine/hash.h +++ b/src/engine/hash.h @@ -28,7 +28,7 @@ typedef struct hashdata HASHDATA; * datalen - item size * name - used for debugging */ -struct hash * hashinit( int datalen, char const * name ); +struct hash * hashinit( int32_t datalen, char const * name ); /* * hash_free() - free a hash table, given its handle @@ -57,7 +57,7 @@ void hashenumerate( struct hash *, void (* f)( void *, void * ), void * data ); * - if the key is present then *found == 1 and the result is a pointer to the * existing record. */ -HASHDATA * hash_insert( struct hash *, OBJECT * key, int * found ); +HASHDATA * hash_insert( struct hash *, OBJECT * key, int32_t * found ); /* * hash_find() - find a record in the table or NULL if none exists diff --git a/src/engine/jam.cpp b/src/engine/jam.cpp index c419f1fa1..0af7c3d0f 100644 --- a/src/engine/jam.cpp +++ b/src/engine/jam.cpp @@ -743,7 +743,7 @@ char * executable_path( char const * argv0 ) { int mib[ 4 ] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 }; char buf[ 1024 ]; - size_t size = sizeof( buf ); + int32_t size = sizeof( buf ); sysctl( mib, 4, buf, &size, NULL, 0 ); return ( !size || size == sizeof( buf ) ) ? NULL : strndup( buf, size ); } diff --git a/src/engine/jam_strings.cpp b/src/engine/jam_strings.cpp index c9ed8a17f..b5aef5f1c 100644 --- a/src/engine/jam_strings.cpp +++ b/src/engine/jam_strings.cpp @@ -26,12 +26,12 @@ static void assert_invariants( string * self ) } assert( self->size < self->capacity ); - assert( ( self->capacity <= sizeof( self->opt ) ) == ( self->value == self->opt ) ); + assert( ( self->capacity <= int32_t(sizeof( self->opt )) ) == ( self->value == self->opt ) ); assert( self->value[ self->size ] == 0 ); /* String objects modified manually after construction to contain embedded * '\0' characters are considered structurally valid. */ - assert( strlen( self->value ) <= self->size ); + assert( strlen( self->value ) <= size_t(self->size) ); for ( i = 0; i < 4; ++i ) { @@ -67,20 +67,20 @@ void string_free( string * s ) } -static void string_reserve_internal( string * self, size_t capacity ) +static void string_reserve_internal( string * self, int32_t capacity ) { if ( self->value == self->opt ) { - self->value = (char *)BJAM_MALLOC_ATOMIC( capacity + + self->value = (char *)BJAM_MALLOC_ATOMIC( size_t(capacity) + JAM_STRING_MAGIC_SIZE ); self->value[ 0 ] = 0; size_t opt_size = sizeof(self->opt); // Workaround sizeof in strncat warning. strncat( self->value, self->opt, opt_size ); - assert( strlen( self->value ) <= self->capacity && "Regression test" ); + assert( strlen( self->value ) <= size_t(self->capacity) && "Regression test" ); } else { - self->value = (char *)BJAM_REALLOC( self->value, capacity + + self->value = (char *)BJAM_REALLOC( self->value, size_t(capacity) + JAM_STRING_MAGIC_SIZE ); } #ifndef NDEBUG @@ -90,7 +90,7 @@ static void string_reserve_internal( string * self, size_t capacity ) } -void string_reserve( string * self, size_t capacity ) +void string_reserve( string * self, int32_t capacity ) { assert_invariants( self ); if ( capacity <= self->capacity ) @@ -100,12 +100,12 @@ void string_reserve( string * self, size_t capacity ) } -static void maybe_reserve( string * self, size_t new_size ) +static void maybe_reserve( string * self, int32_t new_size ) { - size_t capacity = self->capacity; + int32_t capacity = self->capacity; if ( capacity <= new_size ) { - size_t new_capacity = capacity; + int32_t new_capacity = capacity; while ( new_capacity <= new_size ) new_capacity <<= 1; string_reserve_internal( self, new_capacity ); @@ -115,13 +115,13 @@ static void maybe_reserve( string * self, size_t new_size ) void string_append( string * self, char const * rhs ) { - size_t rhs_size = strlen( rhs ); - size_t new_size = self->size + rhs_size; + int32_t rhs_size = int32_t(strlen( rhs )); + int32_t new_size = self->size + rhs_size; assert_invariants( self ); maybe_reserve( self, new_size ); - memcpy( self->value + self->size, rhs, rhs_size + 1 ); + memcpy( self->value + self->size, rhs, size_t(rhs_size) + 1 ); self->size = new_size; assert_invariants( self ); @@ -130,14 +130,14 @@ void string_append( string * self, char const * rhs ) void string_append_range( string * self, char const * start, char const * finish ) { - size_t rhs_size = finish - start; - size_t new_size = self->size + rhs_size; + int32_t rhs_size = int32_t(finish - start); + int32_t new_size = self->size + rhs_size; assert_invariants( self ); maybe_reserve( self, new_size ); if ( start != finish ) - memcpy( self->value + self->size, start, rhs_size ); + memcpy( self->value + self->size, start, size_t(rhs_size) ); self->size = new_size; self->value[ new_size ] = 0; @@ -151,7 +151,7 @@ void string_copy( string * s, char const * rhs ) string_append( s, rhs ); } -void string_truncate( string * self, size_t n ) +void string_truncate( string * self, int32_t n ) { assert_invariants( self ); assert( n <= self->capacity ); @@ -198,9 +198,9 @@ void string_unit_test() for ( i = 0; i < limit; ++i ) { string_push_back( s, (char)( i + 1 ) ); - assert( s->size == i + 1 ); + assert( s->size == int32_t(i + 1) ); } - assert( s->size == limit ); + assert( s->size == int32_t(limit) ); assert( s->value != s->opt ); for ( i = 0; i < limit; ++i ) assert( s->value[ i ] == (char)( i + 1 ) ); @@ -212,7 +212,7 @@ void string_unit_test() string copy[ 1 ]; string_copy( copy, original ); assert( !strcmp( copy->value, original ) ); - assert( copy->size == strlen( original ) ); + assert( copy->size == int32_t(strlen( original )) ); string_free( copy ); } diff --git a/src/engine/jam_strings.h b/src/engine/jam_strings.h index f47db10af..02b744a65 100644 --- a/src/engine/jam_strings.h +++ b/src/engine/jam_strings.h @@ -14,8 +14,8 @@ typedef struct string { char * value; - unsigned long size; - unsigned long capacity; + int32_t size; + int32_t capacity; char opt[ 32 ]; #ifndef NDEBUG char magic[ 4 ]; @@ -28,8 +28,8 @@ void string_free( string * ); void string_append( string *, char const * ); void string_append_range( string *, char const *, char const * ); void string_push_back( string * s, char x ); -void string_reserve( string *, size_t ); -void string_truncate( string *, size_t ); +void string_reserve( string *, int32_t ); +void string_truncate( string *, int32_t ); void string_pop_back( string * ); char string_back( string * ); void string_rtrim( string * ); diff --git a/src/engine/jamgram.cpp b/src/engine/jamgram.cpp index 163428b1d..2f7382dfa 100644 --- a/src/engine/jamgram.cpp +++ b/src/engine/jamgram.cpp @@ -1,4 +1,4 @@ -/* A Bison parser, made by GNU Bison 3.6.2. */ +/* A Bison parser, made by GNU Bison 3.6.4. */ /* Bison implementation for Yacc-like parsers in C @@ -49,7 +49,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "3.6.2" +#define YYBISON_VERSION "3.6.4" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -764,7 +764,7 @@ static const yytype_int8 yytranslate[] = }; #if YYDEBUG - /* YYRLINEYYN -- Source line where rule number YYN was defined. */ + /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ static const yytype_int16 yyrline[] = { 0, 145, 145, 147, 158, 160, 164, 166, 168, 168, @@ -846,7 +846,7 @@ static const yytype_int16 yytoknum[] = #define yytable_value_is_error(Yyn) \ 0 - /* YYPACTSTATE-NUM -- Index in YYTABLE of the portion describing + /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ static const yytype_int16 yypact[] = { @@ -873,7 +873,7 @@ static const yytype_int16 yypact[] = -119, 115, -119, -119, -119, 140, -119 }; - /* YYDEFACTSTATE-NUM -- Default reduction number in state STATE-NUM. + /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. Performed when YYTABLE does not specify something else to do. Zero means the default is an error. */ static const yytype_int8 yydefact[] = @@ -901,7 +901,7 @@ static const yytype_int8 yydefact[] = 60, 0, 19, 95, 37, 11, 96 }; - /* YYPGOTONTERM-NUM. */ + /* YYPGOTO[NTERM-NUM]. */ static const yytype_int16 yypgoto[] = { -119, -119, -118, 25, -119, -119, 96, -119, -119, -119, @@ -913,7 +913,7 @@ static const yytype_int16 yypgoto[] = -119, -119, -119, -119, -119, -119, -119, -119 }; - /* YYDEFGOTONTERM-NUM. */ + /* YYDEFGOTO[NTERM-NUM]. */ static const yytype_int16 yydefgoto[] = { -1, 17, 38, 39, 31, 168, 40, 109, 140, 175, @@ -925,7 +925,7 @@ static const yytype_int16 yydefgoto[] = 53, 84, 149, 148, 23, 61, 87, 121 }; - /* YYTABLEYYPACT[STATE-NUM] -- What to do in state STATE-NUM. If + /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If positive, shift that token. If negative, reduce the rule whose number is the opposite. If YYTABLE_NINF, syntax error. */ static const yytype_int16 yytable[] = @@ -986,7 +986,7 @@ static const yytype_int16 yycheck[] = 14, 15, 16 }; - /* YYSTOSSTATE-NUM -- The (internal number of the) accessing + /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing symbol of state STATE-NUM. */ static const yytype_int8 yystos[] = { @@ -1013,7 +1013,7 @@ static const yytype_int8 yystos[] = 48, 53, 63, 10, 48, 105, 53 }; - /* YYR1YYN -- Symbol number of symbol that rule YYN derives. */ + /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const yytype_int8 yyr1[] = { 0, 51, 52, 52, 53, 53, 54, 54, 55, 56, @@ -1031,7 +1031,7 @@ static const yytype_int8 yyr1[] = 118, 117 }; - /* YYR2YYN -- Number of symbols on the right hand side of rule YYN. */ + /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */ static const yytype_int8 yyr2[] = { 0, 2, 0, 1, 1, 1, 1, 2, 0, 0, diff --git a/src/engine/jamgram.hpp b/src/engine/jamgram.hpp index 6d19ae77b..325bbe141 100644 --- a/src/engine/jamgram.hpp +++ b/src/engine/jamgram.hpp @@ -1,4 +1,4 @@ -/* A Bison parser, made by GNU Bison 3.6.2. */ +/* A Bison parser, made by GNU Bison 3.6.4. */ /* Bison interface for Yacc-like parsers in C diff --git a/src/engine/lists.cpp b/src/engine/lists.cpp index af602b504..d646c6e22 100644 --- a/src/engine/lists.cpp +++ b/src/engine/lists.cpp @@ -16,30 +16,30 @@ static LIST * freelist[ 32 ]; /* junkpile for list_dealloc() */ -static unsigned get_bucket( unsigned size ) +static int32_t get_bucket( int32_t size ) { - unsigned bucket = 0; - while ( size > ( 1u << bucket ) ) ++bucket; + int32_t bucket = 0; + while ( size > ( int32_t(1) << bucket ) ) ++bucket; return bucket; } -static LIST * list_alloc( unsigned const size ) +static LIST * list_alloc( int32_t size ) { - unsigned const bucket = get_bucket( size ); + int32_t bucket = get_bucket( size ); if ( freelist[ bucket ] ) { LIST * result = freelist[ bucket ]; freelist[ bucket ] = result->impl.next; return result; } - return (LIST *)BJAM_MALLOC( sizeof( LIST ) + ( 1u << bucket ) * + return (LIST *)BJAM_MALLOC( sizeof( LIST ) + ( size_t( 1 ) << bucket ) * sizeof( OBJECT * ) ); } static void list_dealloc( LIST * l ) { - unsigned size = list_length( l ); - unsigned bucket; + int32_t size = list_length( l ); + int32_t bucket; LIST * node = l; if ( size == 0 ) return; @@ -64,13 +64,13 @@ LIST * list_append( LIST * l, LIST * nl ) return nl; if ( !list_empty( nl ) ) { - unsigned int const l_size = list_length( l ); - int const nl_size = list_length( nl ); - int const size = l_size + nl_size; - unsigned const bucket = get_bucket( size ); + int32_t l_size = list_length( l ); + int32_t nl_size = list_length( nl ); + int32_t size = l_size + nl_size; + int32_t bucket = get_bucket( size ); /* Do we need to reallocate? */ - if ( l_size <= ( 1u << ( bucket - 1 ) ) ) + if ( l_size <= ( int32_t(1) << ( bucket - 1 ) ) ) { LIST * result = list_alloc( size ); memcpy( list_begin( result ), list_begin( l ), l_size * sizeof( @@ -111,7 +111,7 @@ LIST * list_new( OBJECT * value ) LIST * list_push_back( LIST * head, OBJECT * value ) { - unsigned int size = list_length( head ); + int32_t size = list_length( head ); if ( DEBUG_LISTS ) out_printf( "list > %s <\n", object_str( value ) ); @@ -142,8 +142,8 @@ LIST * list_push_back( LIST * head, OBJECT * value ) LIST * list_copy( LIST * l ) { - int size = list_length( l ); - int i; + int32_t size = list_length( l ); + int32_t i; LIST * result; if ( size == 0 ) return L0; @@ -162,7 +162,7 @@ LIST * list_copy_range( LIST * l, LISTITER first, LISTITER last ) return L0; else { - int size = last - first; + int32_t size = int32_t( last - first ); LIST * result = list_alloc( size ); LISTITER dest = list_begin( result ); result->impl.size = size; @@ -177,17 +177,17 @@ LIST * list_copy_range( LIST * l, LISTITER first, LISTITER last ) * list_sublist() - copy a subset of a list of strings. */ -LIST * list_sublist( LIST * l, int start, int count ) +LIST * list_sublist( LIST * l, int32_t start, int32_t count ) { - int end = start + count; - int size = list_length( l ); + int32_t end = start + count; + int32_t size = list_length( l ); if ( start >= size ) return L0; if ( end > size ) end = size; return list_copy_range( l, list_begin( l ) + start, list_begin( l ) + end ); } -static int str_ptr_compare( void const * va, void const * vb ) +static int32_t str_ptr_compare( void const * va, void const * vb ) { OBJECT * a = *( (OBJECT * *)va ); OBJECT * b = *( (OBJECT * *)vb ); @@ -197,7 +197,7 @@ static int str_ptr_compare( void const * va, void const * vb ) LIST * list_sort( LIST * l ) { - int len; + int32_t len; LIST * result; if ( !l ) @@ -235,7 +235,7 @@ void list_free( LIST * head ) LIST * list_pop_front( LIST * l ) { - unsigned size = list_length( l ); + int32_t size = list_length( l ); assert( size ); --size; object_free( list_front( l ) ); @@ -263,11 +263,11 @@ LIST * list_pop_front( LIST * l ) LIST * list_reverse( LIST * l ) { - int size = list_length( l ); + int32_t size = list_length( l ); if ( size == 0 ) return L0; { LIST * const result = list_alloc( size ); - int i; + int32_t i; result->impl.size = size; for ( i = 0; i < size; ++i ) list_begin( result )[ i ] = object_copy( list_begin( l )[ size - i - @@ -276,9 +276,9 @@ LIST * list_reverse( LIST * l ) } } -int list_cmp( LIST * t, LIST * s ) +int32_t list_cmp( LIST * t, LIST * s ) { - int status = 0; + int32_t status = 0; LISTITER t_it = list_begin( t ); LISTITER const t_end = list_end( t ); LISTITER s_it = list_begin( s ); @@ -298,7 +298,7 @@ int list_cmp( LIST * t, LIST * s ) return status; } -int list_is_sublist( LIST * sub, LIST * l ) +int32_t list_is_sublist( LIST * sub, LIST * l ) { LISTITER iter = list_begin( sub ); LISTITER const end = list_end( sub ); @@ -329,13 +329,13 @@ void list_print( LIST * l ) * list_length() - return the number of items in the list */ -int list_length( LIST * l ) +int32_t list_length( LIST * l ) { return l ? l->impl.size : 0; } -int list_in( LIST * l, OBJECT * value ) +int32_t list_in( LIST * l, OBJECT * value ) { LISTITER iter = list_begin( l ); LISTITER end = list_end( l ); @@ -365,8 +365,7 @@ LIST * list_unique( LIST * sorted_list ) void list_done() { - unsigned int i; - for ( i = 0; i < sizeof( freelist ) / sizeof( freelist[ 0 ] ); ++i ) + for ( int32_t i = 0; i < int32_t(sizeof( freelist ) / sizeof( freelist[ 0 ] )); ++i ) { LIST * l = freelist[ i ]; while ( l ) @@ -406,7 +405,7 @@ void lol_add( LOL * lol, LIST * l ) void lol_free( LOL * lol ) { - int i; + int32_t i; for ( i = 0; i < lol->count; ++i ) list_free( lol->list[ i ] ); lol->count = 0; @@ -417,7 +416,7 @@ void lol_free( LOL * lol ) * lol_get() - return one of the LISTs in the LOL. */ -LIST * lol_get( LOL * lol, int i ) +LIST * lol_get( LOL * lol, int32_t i ) { return i < lol->count ? lol->list[ i ] : L0; } @@ -429,7 +428,7 @@ LIST * lol_get( LOL * lol, int i ) void lol_print( LOL * lol ) { - int i; + int32_t i; for ( i = 0; i < lol->count; ++i ) { if ( i ) diff --git a/src/engine/lists.h b/src/engine/lists.h index c26be620d..2f802b368 100644 --- a/src/engine/lists.h +++ b/src/engine/lists.h @@ -54,7 +54,7 @@ typedef struct _list { union { - int size; + int32_t size; struct _list * next; OBJECT * align; } impl; @@ -68,7 +68,7 @@ typedef OBJECT * * LISTITER; #define LOL_MAX 19 typedef struct _lol { - int count; + int32_t count; LIST * list[ LOL_MAX ]; } LOL; @@ -79,15 +79,15 @@ LIST * list_copy_range( LIST * destination, LISTITER first, LISTITER last ); void list_free( LIST * head ); LIST * list_push_back( LIST * head, OBJECT * value ); void list_print( LIST * ); -int list_length( LIST * ); -LIST * list_sublist( LIST *, int start, int count ); +int32_t list_length( LIST * ); +LIST * list_sublist( LIST *, int32_t start, int32_t count ); LIST * list_pop_front( LIST * ); LIST * list_sort( LIST * ); LIST * list_unique( LIST * sorted_list ); -int list_in( LIST *, OBJECT * value ); +int32_t list_in( LIST *, OBJECT * value ); LIST * list_reverse( LIST * ); -int list_cmp( LIST * lhs, LIST * rhs ); -int list_is_sublist( LIST * sub, LIST * l ); +int32_t list_cmp( LIST * lhs, LIST * rhs ); +int32_t list_is_sublist( LIST * sub, LIST * l ); void list_done(); LISTITER list_begin( LIST * ); @@ -159,7 +159,7 @@ namespace b2 { namespace jam { inline iterator begin() { return iterator(list_begin(list_obj)); } inline iterator end() { return iterator(list_end(list_obj)); } inline bool empty() const { return list_empty(list_obj) || length() == 0; } - inline int length() const { return list_length(list_obj); } + inline int32_t length() const { return list_length(list_obj); } inline list &append(const list &other) { list_obj = list_append(list_obj, list_copy(other.list_obj)); diff --git a/src/engine/make.cpp b/src/engine/make.cpp index 470626e56..065adcaef 100644 --- a/src/engine/make.cpp +++ b/src/engine/make.cpp @@ -56,7 +56,7 @@ static TARGETS * make0sort( TARGETS * c ); #ifdef OPT_GRAPH_DEBUG_EXT - static void dependGraphOutput( TARGET * t, int depth ); + static void dependGraphOutput( TARGET * t, int32_t depth ); #endif static char const * target_fate[] = @@ -91,10 +91,10 @@ static char const * target_bind[] = * make() - make a target, given its name. */ -int make( LIST * targets, int anyhow ) +int32_t make( LIST * targets, int32_t anyhow ) { COUNTS counts[ 1 ]; - int status = 0; /* 1 if anything fails */ + int32_t status = 0; /* 1 if anything fails */ #ifdef OPT_HEADER_CACHE_EXT hcache_init(); @@ -188,7 +188,7 @@ static void update_dependants( TARGET * t ) if ( DEBUG_FATE ) { out_printf( "fate change %s from %s to %s (as dependent of %s)\n", - object_str( p->name ), target_fate[ (int) fate0 ], target_fate[ (int) p->fate ], object_str( t->name ) ); + object_str( p->name ), target_fate[ (int32_t) fate0 ], target_fate[ (int32_t) p->fate ], object_str( t->name ) ); } /* If we are done visiting it, go back and make sure its dependants @@ -219,7 +219,7 @@ static void force_rebuilds( TARGET * t ) { if ( DEBUG_FATE ) out_printf( "fate change %s from %s to %s (by rebuild)\n", - object_str( r->name ), target_fate[ (int) r->fate ], target_fate[ T_FATE_REBUILD ] ); + object_str( r->name ), target_fate[ (int32_t) r->fate ], target_fate[ T_FATE_REBUILD ] ); /* Force rebuild it. */ r->fate = T_FATE_REBUILD; @@ -231,9 +231,9 @@ static void force_rebuilds( TARGET * t ) } -int make0rescan( TARGET * t, TARGET * rescanning ) +int32_t make0rescan( TARGET * t, TARGET * rescanning ) { - int result = 0; + int32_t result = 0; TARGETS * c; /* Check whether we have already found a cycle. */ @@ -281,9 +281,9 @@ void make0 ( TARGET * t, TARGET * p, /* parent */ - int depth, /* for display purposes */ + int32_t depth, /* for display purposes */ COUNTS * counts, /* for reporting */ - int anyhow, + int32_t anyhow, TARGET * rescanning ) /* forcibly touch all (real) targets */ { @@ -293,13 +293,13 @@ void make0 timestamp last; timestamp leaf; timestamp hlast; - int fate; + int32_t fate; char const * flag = ""; SETTINGS * s; #ifdef OPT_GRAPH_DEBUG_EXT - int savedFate; - int oldTimeStamp; + int32_t savedFate; + int32_t oldTimeStamp; #endif if ( DEBUG_MAKEPROG ) @@ -392,7 +392,7 @@ void make0 case T_BIND_MISSING: case T_BIND_PARENTS: out_printf( "time\t--\t%s%s: %s\n", spaces( depth ), - object_str( t->name ), target_bind[ (int)t->binding ] ); + object_str( t->name ), target_bind[ (int32_t)t->binding ] ); break; case T_BIND_EXISTS: @@ -409,7 +409,7 @@ void make0 /* Step 3a: Recursively make0() dependencies. */ for ( c = t->depends; c; c = c->next ) { - int const internal = t->flags & T_FLAG_INTERNAL; + int32_t const internal = t->flags & T_FLAG_INTERNAL; /* Warn about circular deps, except for includes, which include each * other alot. @@ -453,7 +453,7 @@ void make0 /* Step 3d: Detect cycles. */ { - int cycle_depth = depth; + int32_t cycle_depth = depth; for ( c = t->depends; c; c = c->next ) { TARGET * scc_root = target_scc( c->target ); @@ -512,8 +512,8 @@ void make0 if ( DEBUG_FATE ) if ( fate < c->target->fate ) out_printf( "fate change %s from %s to %s by dependency %s\n", - object_str( t->name ), target_fate[ (int)fate ], - target_fate[ (int)c->target->fate ], object_str( + object_str( t->name ), target_fate[ (int32_t)fate ], + target_fate[ (int32_t)c->target->fate ], object_str( c->target->name ) ); #endif } @@ -760,7 +760,7 @@ void make0 flag = "*"; if ( DEBUG_MAKEPROG ) - out_printf( "made%s\t%s\t%s%s\n", flag, target_fate[ (int)t->fate ], + out_printf( "made%s\t%s\t%s%s\n", flag, target_fate[ (int32_t)t->fate ], spaces( depth ), object_str( t->name ) ); } @@ -783,7 +783,7 @@ static char const * target_name( TARGET * t ) * dependGraphOutput() - output the DG after make0 has run. */ -static void dependGraphOutput( TARGET * t, int depth ) +static void dependGraphOutput( TARGET * t, int32_t depth ) { TARGETS * c; @@ -864,7 +864,7 @@ static void dependGraphOutput( TARGET * t, int depth ) for ( c = t->depends; c; c = c->next ) { out_printf( " %s : Depends on %s (%s)", spaces( depth ), - target_name( c->target ), target_fate[ (int)c->target->fate ] ); + target_name( c->target ), target_fate[ (int32_t)c->target->fate ] ); if ( !timestamp_cmp( &c->target->time, &t->time ) ) out_printf( " (max time)"); out_printf( "\n" ); diff --git a/src/engine/make.h b/src/engine/make.h index 537b9e98f..5fcdb7a2e 100644 --- a/src/engine/make.h +++ b/src/engine/make.h @@ -16,20 +16,20 @@ #include "object.h" #include "rules.h" -int make( LIST * targets, int anyhow ); -int make1( LIST * t ); +int32_t make( LIST * targets, int32_t anyhow ); +int32_t make1( LIST * t ); typedef struct { - int temp; - int updating; - int cantfind; - int cantmake; - int targets; - int made; + int32_t temp; + int32_t updating; + int32_t cantfind; + int32_t cantmake; + int32_t targets; + int32_t made; } COUNTS ; -void make0( TARGET * t, TARGET * p, int depth, COUNTS * counts, int anyhow, +void make0( TARGET * t, TARGET * p, int32_t depth, COUNTS * counts, int32_t anyhow, TARGET * rescanning ); diff --git a/src/engine/make1.cpp b/src/engine/make1.cpp index 61f0614a1..0e6e49e6d 100644 --- a/src/engine/make1.cpp +++ b/src/engine/make1.cpp @@ -59,24 +59,24 @@ #endif static CMD * make1cmds ( TARGET * ); -static LIST * make1list ( LIST *, TARGETS *, int flags ); +static LIST * make1list ( LIST *, TARGETS *, int32_t flags ); static SETTINGS * make1settings ( struct module_t *, LIST * vars ); static void make1bind ( TARGET * ); -static void push_cmds( CMDLIST * cmds, int status ); -static int cmd_sem_lock( TARGET * t ); +static void push_cmds( CMDLIST * cmds, int32_t status ); +static int32_t cmd_sem_lock( TARGET * t ); static void cmd_sem_unlock( TARGET * t ); -static int targets_contains( TARGETS * l, TARGET * t ); -static int targets_equal( TARGETS * l1, TARGETS * l2 ); +static int32_t targets_contains( TARGETS * l, TARGET * t ); +static int32_t targets_equal( TARGETS * l1, TARGETS * l2 ); /* Ugly static - it is too hard to carry it through the callbacks. */ static struct { - int failed; - int skipped; - int total; - int made; + int32_t failed; + int32_t skipped; + int32_t total; + int32_t made; } counts[ 1 ]; /* Target state. */ @@ -90,16 +90,16 @@ struct _state state * prev; /* previous state on stack */ TARGET * t; /* current target */ TARGET * parent; /* parent argument necessary for MAKE1A */ - int curstate; /* current state */ + int32_t curstate; /* current state */ }; static void make1a( state * const ); static void make1b( state * const ); static void make1c( state const * const ); -static void make1c_closure( void * const closure, int status, +static void make1c_closure( void * const closure, int32_t status, timing_info const * const, char const * const cmd_stdout, - char const * const cmd_stderr, int const cmd_exit_reason ); + char const * const cmd_stderr, int32_t const cmd_exit_reason ); typedef struct _stack { @@ -111,7 +111,7 @@ static stack state_stack = { NULL }; static state * state_freelist = NULL; /* Currently running command counter. */ -static int cmdsrunning; +static int32_t cmdsrunning; static state * alloc_state() @@ -163,7 +163,7 @@ static void pop_state( stack * const pStack ) static state * push_state( stack * const pStack, TARGET * const t, - TARGET * const parent, int const curstate ) + TARGET * const parent, int32_t const curstate ) { state * const pState = alloc_state(); pState->t = t; @@ -194,13 +194,13 @@ static void push_stack_on_stack( stack * const pDest, stack * const pSrc ) * make1() - execute commands to update a list of targets and all of their dependencies */ -static int intr = 0; -static int quit = 0; +static int32_t intr = 0; +static int32_t quit = 0; -int make1( LIST * targets ) +int32_t make1( LIST * targets ) { state * pState; - int status = 0; + int32_t status = 0; memset( (char *)counts, 0, sizeof( *counts ) ); @@ -512,7 +512,7 @@ static void make1c( state const * const pState ) { TARGET * const t = pState->t; CMD * const cmd = (CMD *)t->cmds; - int exec_flags = 0; + int32_t exec_flags = 0; if ( cmd ) { @@ -786,7 +786,7 @@ static void call_timing_rule( TARGET * target, timing_info const * const time ) static void call_action_rule ( TARGET * target, - int status, + int32_t status, timing_info const * time, char const * executed_command, char const * command_output @@ -869,11 +869,11 @@ static void call_action_rule static void make1c_closure ( void * const closure, - int status_orig, + int32_t status_orig, timing_info const * const time, char const * const cmd_stdout, char const * const cmd_stderr, - int const cmd_exit_reason + int32_t const cmd_exit_reason ) { TARGET * const t = (TARGET *)closure; @@ -984,7 +984,7 @@ static void make1c_closure } /* push the next MAKE1C state after a command is run. */ -static void push_cmds( CMDLIST * cmds, int status ) +static void push_cmds( CMDLIST * cmds, int32_t status ) { CMDLIST * cmd_iter; for( cmd_iter = cmds; cmd_iter; cmd_iter = cmd_iter->next ) @@ -1065,12 +1065,12 @@ static void swap_settings static CMD * make1cmds( TARGET * t ) { CMD * cmds = 0; - CMD * last_cmd; + CMD * last_cmd = 0; LIST * shell = L0; module_t * settings_module = 0; TARGET * settings_target = 0; - ACTIONS * a0; - int const running_flag = globs.noexec ? A_RUNNING_NOEXEC : A_RUNNING; + ACTIONS * a0 = 0; + int32_t const running_flag = globs.noexec ? A_RUNNING_NOEXEC : A_RUNNING; /* Step through actions. */ @@ -1168,21 +1168,21 @@ static CMD * make1cmds( TARGET * t ) * Note that we loop through at least once, for sourceless actions. */ { - int const length = list_length( ns ); - int start = 0; - int chunk = length; - int cmd_count = 0; + int32_t const length = list_length( ns ); + int32_t start = 0; + int32_t chunk = length; + int32_t cmd_count = 0; TARGETS * semaphores = NULL; TARGETS * targets_iter; - int unique_targets; + int32_t unique_targets; do { CMD * cmd; - int cmd_check_result; - int cmd_error_length; - int cmd_error_max_length; - int retry = 0; - int accept_command = 0; + int32_t cmd_check_result; + int32_t cmd_error_length; + int32_t cmd_error_max_length; + int32_t retry = 0; + int32_t accept_command = 0; /* Build cmd: cmd_new() takes ownership of its lists. */ cmd = cmd_new( rule, list_copy( nt ), list_sublist( ns, start, @@ -1219,9 +1219,10 @@ static CMD * make1cmds( TARGET * t ) : "contains a line that is too long"; assert( cmd_check_result == EXEC_CHECK_TOO_LONG || cmd_check_result == EXEC_CHECK_LINE_TOO_LONG ); - out_printf( "%s action %s (%d, max %d):\n", object_str( - rule->name ), error_message, cmd_error_length, - cmd_error_max_length ); + out_printf( + "%s action %s (%d, max %d):\n", + object_str( rule->name ), error_message, + cmd_error_length, cmd_error_max_length ); /* Tell the user what did not fit. */ out_puts( cmd->buf->value ); @@ -1314,7 +1315,7 @@ static CMD * make1cmds( TARGET * t ) * 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, int32_t flags ) { for ( ; targets; targets = targets->next ) { @@ -1417,7 +1418,7 @@ static void make1bind( TARGET * t ) } -static int targets_contains( TARGETS * l, TARGET * t ) +static int32_t targets_contains( TARGETS * l, TARGET * t ) { for ( ; l; l = l->next ) { @@ -1429,7 +1430,7 @@ static int targets_contains( TARGETS * l, TARGET * t ) return 0; } -static int targets_equal( TARGETS * l1, TARGETS * l2 ) +static int32_t targets_equal( TARGETS * l1, TARGETS * l2 ) { for ( ; l1 && l2; l1 = l1->next, l2 = l2->next ) { @@ -1442,7 +1443,7 @@ static int targets_equal( TARGETS * l1, TARGETS * l2 ) #ifdef OPT_SEMAPHORE -static int cmd_sem_lock( TARGET * t ) +static int32_t cmd_sem_lock( TARGET * t ) { CMD * cmd = (CMD *)t->cmds; TARGETS * iter; diff --git a/src/engine/md5.cpp b/src/engine/md5.cpp index c35d96c5e..2c53be85e 100644 --- a/src/engine/md5.cpp +++ b/src/engine/md5.cpp @@ -320,25 +320,25 @@ md5_init(md5_state_t *pms) } void -md5_append(md5_state_t *pms, const md5_byte_t *data, int nbytes) +md5_append(md5_state_t *pms, const md5_byte_t *data, size_t nbytes) { const md5_byte_t *p = data; - int left = nbytes; - int offset = (pms->count[0] >> 3) & 63; + size_t left = nbytes; + size_t offset = (pms->count[0] >> 3) & 63; md5_word_t nbits = (md5_word_t)(nbytes << 3); if (nbytes <= 0) return; /* Update the message length. */ - pms->count[1] += nbytes >> 29; + pms->count[1] += md5_word_t(nbytes >> 29); pms->count[0] += nbits; if (pms->count[0] < nbits) pms->count[1]++; /* Process an initial partial block. */ if (offset) { - int copy = (offset + nbytes > 64 ? 64 - offset : nbytes); + size_t copy = (offset + nbytes > 64 ? 64 - offset : nbytes); memcpy(pms->buf + offset, p, copy); if (offset + copy < 64) diff --git a/src/engine/md5.h b/src/engine/md5.h index 698c995d8..cbfde5976 100644 --- a/src/engine/md5.h +++ b/src/engine/md5.h @@ -50,6 +50,8 @@ #ifndef md5_INCLUDED # define md5_INCLUDED +#include + /* * This package supports both compile-time and run-time determination of CPU * byte order. If ARCH_IS_BIG_ENDIAN is defined as 0, the code will be @@ -71,7 +73,7 @@ typedef struct md5_state_s { } md5_state_t; #ifdef __cplusplus -extern "C" +extern "C" { #endif @@ -79,7 +81,7 @@ extern "C" void md5_init(md5_state_t *pms); /* Append a string to the message. */ -void md5_append(md5_state_t *pms, const md5_byte_t *data, int nbytes); +void md5_append(md5_state_t *pms, const md5_byte_t *data, size_t nbytes); /* Finish the message and return the digest. */ void md5_finish(md5_state_t *pms, md5_byte_t digest[16]); diff --git a/src/engine/modules/order.cpp b/src/engine/modules/order.cpp index 38209b889..dcfee4343 100644 --- a/src/engine/modules/order.cpp +++ b/src/engine/modules/order.cpp @@ -15,7 +15,7 @@ /* Use quite klugy approach: when we add order dependency from 'a' to 'b', just * append 'b' to of value of variable 'a'. */ -LIST * add_pair( FRAME * frame, int flags ) +LIST * add_pair( FRAME * frame, int32_t flags ) { LIST * arg = lol_get( frame->args, 0 ); LISTITER iter = list_begin( arg ); @@ -29,9 +29,9 @@ LIST * add_pair( FRAME * frame, int flags ) /* Given a list and a value, returns position of that value in the list, or -1 * if not found. */ -int list_index( LIST * list, OBJECT * value ) +int32_t list_index( LIST * list, OBJECT * value ) { - int result = 0; + int32_t result = 0; LISTITER iter = list_begin( list ); LISTITER const end = list_end( list ); for ( ; iter != end; iter = list_next( iter ), ++result ) @@ -47,15 +47,15 @@ enum colors { white, gray, black }; * vertices which were not yet visited. After that, 'current_vertex' is added to * '*result_ptr'. */ -void do_ts( int * * graph, int current_vertex, int * colors, int * * result_ptr +void do_ts( int32_t * * graph, int32_t current_vertex, int32_t * colors, int32_t * * result_ptr ) { - int i; + int32_t i; colors[ current_vertex ] = gray; for ( i = 0; graph[ current_vertex ][ i ] != -1; ++i ) { - int adjacent_vertex = graph[ current_vertex ][ i ]; + int32_t adjacent_vertex = graph[ current_vertex ][ i ]; if ( colors[ adjacent_vertex ] == white ) do_ts( graph, adjacent_vertex, colors, result_ptr ); /* The vertex is either black, in which case we do not have to do @@ -70,10 +70,10 @@ void do_ts( int * * graph, int current_vertex, int * colors, int * * result_ptr } -void topological_sort( int * * graph, int num_vertices, int * result ) +static void topological_sort( int32_t * * graph, int32_t num_vertices, int32_t * result ) { - int i; - int * colors = ( int * )BJAM_CALLOC( num_vertices, sizeof( int ) ); + int32_t i; + int32_t * colors = ( int32_t * )BJAM_CALLOC( num_vertices, sizeof( int32_t ) ); for ( i = 0; i < num_vertices; ++i ) colors[ i ] = white; @@ -85,34 +85,34 @@ void topological_sort( int * * graph, int num_vertices, int * result ) } -LIST * order( FRAME * frame, int flags ) +LIST * order( FRAME * frame, int32_t flags ) { LIST * arg = lol_get( frame->args, 0 ); LIST * result = L0; - int src; + int32_t src; LISTITER iter = list_begin( arg ); LISTITER const end = list_end( arg ); /* We need to create a graph of order dependencies between the passed * objects. We assume there are no duplicates passed to 'add_pair'. */ - int length = list_length( arg ); - int * * graph = ( int * * )BJAM_CALLOC( length, sizeof( int * ) ); - int * order = ( int * )BJAM_MALLOC( ( length + 1 ) * sizeof( int ) ); + int32_t length = list_length( arg ); + int32_t * * graph = ( int32_t * * )BJAM_CALLOC( length, sizeof( int32_t * ) ); + int32_t * order = ( int32_t * )BJAM_MALLOC( ( length + 1 ) * sizeof( int32_t ) ); for ( src = 0; iter != end; iter = list_next( iter ), ++src ) { /* For all objects this one depends upon, add elements to 'graph'. */ LIST * dependencies = var_get( frame->module, list_item( iter ) ); - int index = 0; + int32_t index = 0; LISTITER dep_iter = list_begin( dependencies ); LISTITER const dep_end = list_end( dependencies ); - graph[ src ] = ( int * )BJAM_CALLOC( list_length( dependencies ) + 1, - sizeof( int ) ); + graph[ src ] = ( int32_t * )BJAM_CALLOC( list_length( dependencies ) + 1, + sizeof( int32_t ) ); for ( ; dep_iter != dep_end; dep_iter = list_next( dep_iter ) ) { - int const dst = list_index( arg, list_item( dep_iter ) ); + int32_t const dst = list_index( arg, list_item( dep_iter ) ); if ( dst != -1 ) graph[ src ][ index++ ] = dst; } @@ -122,10 +122,10 @@ LIST * order( FRAME * frame, int flags ) topological_sort( graph, length, order ); { - int index = length - 1; + int32_t index = length - 1; for ( ; index >= 0; --index ) { - int i; + int32_t i; LISTITER iter = list_begin( arg ); for ( i = 0; i < order[ index ]; ++i, iter = list_next( iter ) ); result = list_push_back( result, object_copy( list_item( iter ) ) ); @@ -134,7 +134,7 @@ LIST * order( FRAME * frame, int flags ) /* Clean up */ { - int i; + int32_t i; for ( i = 0; i < length; ++i ) BJAM_FREE( graph[ i ] ); BJAM_FREE( graph ); diff --git a/src/engine/modules/property-set.cpp b/src/engine/modules/property-set.cpp index 1f3394107..30236ee3a 100644 --- a/src/engine/modules/property-set.cpp +++ b/src/engine/modules/property-set.cpp @@ -26,8 +26,8 @@ struct ps_map_entry struct ps_map { struct ps_map_entry * * table; - size_t table_size; - size_t num_elems; + int32_t table_size; + int32_t num_elems; }; static unsigned list_hash(LIST * key) @@ -63,10 +63,10 @@ static int list_equal( LIST * lhs, LIST * rhs ) static void ps_map_init( struct ps_map * map ) { - size_t i; + int32_t i; map->table_size = 2; map->num_elems = 0; - map->table = (struct ps_map_entry * *)BJAM_MALLOC( map->table_size * sizeof( struct ps_map_entry * ) ); + map->table = (struct ps_map_entry * *)BJAM_MALLOC( size_t(map->table_size) * sizeof( struct ps_map_entry * ) ); for ( i = 0; i < map->table_size; ++i ) { map->table[ i ] = NULL; @@ -75,7 +75,7 @@ static void ps_map_init( struct ps_map * map ) static void ps_map_destroy( struct ps_map * map ) { - size_t i; + int32_t i; for ( i = 0; i < map->table_size; ++i ) { struct ps_map_entry * pos; @@ -93,8 +93,8 @@ static void ps_map_destroy( struct ps_map * map ) static void ps_map_rehash( struct ps_map * map ) { struct ps_map old = *map; - size_t i; - map->table = (struct ps_map_entry * *)BJAM_MALLOC( map->table_size * 2 * sizeof( struct ps_map_entry * ) ); + int32_t i; + map->table = (struct ps_map_entry * *)BJAM_MALLOC( size_t(map->table_size) * 2 * sizeof( struct ps_map_entry * ) ); map->table_size *= 2; for ( i = 0; i < map->table_size; ++i ) { diff --git a/src/engine/modules/regex.cpp b/src/engine/modules/regex.cpp index fa5355858..eae846d75 100644 --- a/src/engine/modules/regex.cpp +++ b/src/engine/modules/regex.cpp @@ -48,7 +48,7 @@ LIST * regex_split( FRAME * frame, int flags ) prev = pos = object_str( s ); while ( regexec( re, pos ) ) { - result = list_push_back( result, object_new_range( prev, re->startp[ 0 ] - prev ) ); + result = list_push_back( result, object_new_range( prev, int32_t(re->startp[ 0 ] - prev) ) ); prev = re->endp[ 0 ]; /* Handle empty matches */ if ( *pos == '\0' ) diff --git a/src/engine/native.cpp b/src/engine/native.cpp index 68828aa31..0f80080f6 100644 --- a/src/engine/native.cpp +++ b/src/engine/native.cpp @@ -12,7 +12,7 @@ void declare_native_rule( char const * module, char const * rule, - char const * * args, LIST * (*f)( FRAME *, int ), int version ) + char const * * args, LIST * (*f)( FRAME *, int32_t ), int32_t version ) { OBJECT * const module_obj = module ? object_new( module ) : 0 ; module_t * m = bindmodule( module_obj ); @@ -23,7 +23,7 @@ void declare_native_rule( char const * module, char const * rule, { OBJECT * const name = object_new( rule ); - int found; + int32_t found; native_rule_t * const np = (native_rule_t *)hash_insert( m->native_rules, name, &found ); np->name = name; diff --git a/src/engine/native.h b/src/engine/native.h index f80b0e0f0..5367552f5 100644 --- a/src/engine/native.h +++ b/src/engine/native.h @@ -25,11 +25,11 @@ typedef struct native_rule_t * * Versions are numbered from 1. */ - int version; + int32_t version; } native_rule_t; /* MSVC debugger gets confused unless the native_rule_t typedef is provided. */ void declare_native_rule( char const * module, char const * rule, - char const * * args, LIST * (*f)( FRAME *, int ), int version ); + char const * * args, LIST * (*f)( FRAME *, int32_t ), int32_t version ); #endif diff --git a/src/engine/object.cpp b/src/engine/object.cpp index 07866baf4..069bc215e 100644 --- a/src/engine/object.cpp +++ b/src/engine/object.cpp @@ -55,15 +55,15 @@ struct hash_item typedef struct string_set { - unsigned int num; - unsigned int size; + int32_t num; + int32_t size; struct hash_item * * data; } string_set; static string_set strhash; -static int strtotal = 0; -static int strcount_in = 0; -static int strcount_out = 0; +static int32_t strtotal = 0; +static int32_t strcount_in = 0; +static int32_t strcount_out = 0; /* @@ -89,13 +89,13 @@ static char * storage_finish = 0; * allocate() - Allocate n bytes of immortal string storage. */ -static char * allocate( size_t n ) +static char * allocate( int32_t n ) { #ifdef BJAM_NEWSTR_NO_ALLOCATE return (char *)BJAM_MALLOC( n ); #else /* See if we can grab storage from an existing block. */ - size_t remaining = storage_finish - storage_start; + int32_t remaining = int32_t(storage_finish - storage_start); n = ( ( n + ALLOC_ALIGNMENT - 1 ) / ALLOC_ALIGNMENT ) * ALLOC_ALIGNMENT; if ( remaining >= n ) { @@ -106,13 +106,13 @@ static char * allocate( size_t n ) else /* Must allocate a new block. */ { strblock * new_block; - size_t nalloc = n; + int32_t nalloc = n; if ( nalloc < STRING_BLOCK ) nalloc = STRING_BLOCK; /* Allocate a new block and link into the chain. */ new_block = (strblock *)BJAM_MALLOC( offsetof( strblock, data[ 0 ] ) + - nalloc * sizeof( new_block->data[ 0 ] ) ); + size_t(nalloc) * sizeof( new_block->data[ 0 ] ) ); if ( new_block == 0 ) return 0; new_block->next = strblock_chain; @@ -130,7 +130,7 @@ static char * allocate( size_t n ) } -static unsigned int hash_keyval( char const * key, int const size ) +static unsigned int hash_keyval( char const * key, int32_t size ) { unsigned int const magic = 2147059363; unsigned int hash = 0; @@ -171,14 +171,13 @@ static void string_set_done( string_set * set ) static void string_set_resize( string_set * set ) { - unsigned i; string_set new_set; new_set.num = set->num * 2; new_set.size = set->size; new_set.data = (struct hash_item * *)BJAM_MALLOC( sizeof( struct hash_item * ) * new_set.num ); memset( new_set.data, 0, sizeof( struct hash_item * ) * new_set.num ); - for ( i = 0; i < set->num; ++i ) + for ( int32_t i = 0; i < set->num; ++i ) { while ( set->data[ i ] ) { @@ -195,7 +194,7 @@ static void string_set_resize( string_set * set ) static char const * string_set_insert( string_set * set, char const * string, - int const size ) + int32_t const size ) { unsigned hash = hash_keyval( string, size ); unsigned pos = hash % set->num; @@ -230,25 +229,11 @@ static char const * string_set_insert( string_set * set, char const * string, } -static struct hash_item * object_get_item( OBJECT * obj ) -{ - return (struct hash_item *)( (char *)obj - offsetof( struct hash_item, data - ) ); -} - - -static void object_validate( OBJECT * obj ) -{ - assert( obj ); - assert( object_get_item( obj )->header.magic == OBJECT_MAGIC ); -} - - /* * object_new_range() - create an object from a string of given length */ -OBJECT * object_new_range( char const * const string, int const size ) +OBJECT * object_new_range( char const * const string, int32_t size ) { ++strcount_in; @@ -278,12 +263,26 @@ OBJECT * object_new_range( char const * const string, int const size ) OBJECT * object_new( char const * const string ) { - return object_new_range( string, strlen( string ) ); + return object_new_range( string, int32_t(strlen( string )) ); } #ifndef object_copy +static struct hash_item * object_get_item( OBJECT * obj ) +{ + return (struct hash_item *)( (char *)obj - offsetof( struct hash_item, data + ) ); +} + + +static void object_validate( OBJECT * obj ) +{ + assert( obj ); + assert( object_get_item( obj )->header.magic == OBJECT_MAGIC ); +} + + /* * object_copy() - return a copy of an object */ diff --git a/src/engine/object.h b/src/engine/object.h index e53078d73..555e9851c 100644 --- a/src/engine/object.h +++ b/src/engine/object.h @@ -18,7 +18,7 @@ typedef struct _object OBJECT; OBJECT * object_new( char const * const ); -OBJECT * object_new_range( char const * const, int const size ); +OBJECT * object_new_range( char const * const, int32_t size ); void object_done( void ); #if defined(NDEBUG) && !defined(BJAM_NO_MEM_CACHE) diff --git a/src/engine/pathnt.cpp b/src/engine/pathnt.cpp index 5b0cc4659..cff639bc9 100644 --- a/src/engine/pathnt.cpp +++ b/src/engine/pathnt.cpp @@ -94,11 +94,11 @@ void path_get_temp_path_( string * buffer ) * - path_key_cache path/key mapping cache object already initialized */ -static int canonicWindowsPath( char const * const path, int const path_length, +static int canonicWindowsPath( char const * const path, int32_t path_length, string * const out ) { char const * last_element; - unsigned long saved_size; + int32_t saved_size; char const * p; int missing_parent; @@ -138,7 +138,7 @@ static int canonicWindowsPath( char const * const path, int const path_length, if ( p >= path ) { char const * const dir = path; - int const dir_length = p - path; + const int32_t dir_length = int32_t(p - path); OBJECT * const dir_obj = object_new_range( dir, dir_length ); int found; path_key_entry * const result = (path_key_entry *)hash_insert( @@ -170,7 +170,7 @@ static int canonicWindowsPath( char const * const path, int const path_length, if ( !missing_parent ) { char const * const n = last_element; - int const n_length = path + path_length - n; + int32_t n_length = int32_t(path + path_length - n); if ( !( n_length == 1 && n[ 0 ] == '.' ) && !( n_length == 2 && n[ 0 ] == '.' && n[ 1 ] == '.' ) ) { @@ -239,7 +239,7 @@ static path_key_entry * path_key( OBJECT * const path, if ( !found ) { OBJECT * normalized; - int normalized_size; + int32_t normalized_size; path_key_entry * nresult; result->path = path; { @@ -394,8 +394,8 @@ OBJECT * path_as_key( OBJECT * path ) static void free_path_key_entry( void * xentry, void * const data ) { path_key_entry * const entry = (path_key_entry *)xentry; - object_free( entry->path ); - object_free( entry->key ); + if (entry->path) object_free( entry->path ); + if (entry->key) object_free( entry->key ); } diff --git a/src/engine/pathsys.cpp b/src/engine/pathsys.cpp index 00687d159..7e6d57a34 100644 --- a/src/engine/pathsys.cpp +++ b/src/engine/pathsys.cpp @@ -64,7 +64,7 @@ void path_parse( char const * file, PATHNAME * f ) if ( ( file[ 0 ] == '<' ) && ( p = strchr( file, '>' ) ) ) { f->f_grist.ptr = file; - f->f_grist.len = p - file; + f->f_grist.len = int32_t(p - file); file = p + 1; } @@ -83,7 +83,7 @@ void path_parse( char const * file, PATHNAME * f ) if ( p ) { f->f_dir.ptr = file; - f->f_dir.len = p - file; + f->f_dir.len = int32_t(p - file); /* Special case for / - dirname is /, not "" */ if ( !f->f_dir.len ) @@ -104,7 +104,7 @@ void path_parse( char const * file, PATHNAME * f ) if ( ( p = strchr( file, '(' ) ) && ( end[ -1 ] == ')' ) ) { f->f_member.ptr = p + 1; - f->f_member.len = end - p - 2; + f->f_member.len = int32_t(end - p - 2); end = p; } @@ -115,13 +115,13 @@ void path_parse( char const * file, PATHNAME * f ) if ( p ) { f->f_suffix.ptr = p; - f->f_suffix.len = end - p; + f->f_suffix.len = int32_t(end - p); end = p; } /* Leaves base. */ f->f_base.ptr = file; - f->f_base.len = end - file; + f->f_base.len = int32_t(end - file); } @@ -316,7 +316,7 @@ std::string b2::paths::normalize(const std::string &p) // want this function to obtain a canonic representation. std::replace(result.begin(), result.end(), '\\', '/'); - size_t ellipsis = 0; + int32_t ellipsis = 0; for (auto end_pos = result.length(); end_pos > 0; ) { auto path_pos = result.rfind('/', end_pos-1); diff --git a/src/engine/pathsys.h b/src/engine/pathsys.h index ffb62c18e..272cae214 100644 --- a/src/engine/pathsys.h +++ b/src/engine/pathsys.h @@ -38,7 +38,7 @@ Distributed under the Boost Software License, Version 1.0. typedef struct _pathpart { char const * ptr; - int len; + int32_t len; } PATHPART; typedef struct _pathname diff --git a/src/engine/regexp.cpp b/src/engine/regexp.cpp index 537bc828d..dacae6252 100644 --- a/src/engine/regexp.cpp +++ b/src/engine/regexp.cpp @@ -154,9 +154,9 @@ * Utility definitions. */ #ifndef CHARBITS -#define UCHARAT(p) ((int)*(const unsigned char *)(p)) +#define UCHARAT(p) ((int32_t)*(const unsigned char *)(p)) #else -#define UCHARAT(p) ((int)*(p)&CHARBITS) +#define UCHARAT(p) ((int32_t)*(p)&CHARBITS) #endif #define FAIL(m) { regerror(m); return(NULL); } @@ -173,11 +173,11 @@ /* * Global work variables for regcomp(). */ -static char *regparse; /* Input-scan pointer. */ -static int regnpar; /* () count. */ +static char *regparse; /* Input-scan pointer. */ +static int32_t 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 int32_t regsize; /* Code size. */ /* * Forward declarations for regcomp()'s friends. @@ -185,18 +185,18 @@ static long regsize; /* Code size. */ #ifndef STATIC #define STATIC static #endif -STATIC char *reg( int paren, int *flagp ); -STATIC char *regbranch( int *flagp ); -STATIC char *regpiece( int *flagp ); -STATIC char *regatom( int *flagp ); -STATIC char *regnode( int op ); +STATIC char *reg( int32_t paren, int32_t *flagp ); +STATIC char *regbranch( int32_t *flagp ); +STATIC char *regpiece( int32_t *flagp ); +STATIC char *regatom( int32_t *flagp ); +STATIC char *regnode( int32_t op ); STATIC char *regnext( char *p ); -STATIC void regc( int b ); +STATIC void regc( int32_t b ); STATIC void reginsert( char op, char *opnd ); STATIC void regtail( char *p, char *val ); STATIC void regoptail( char *p, char *val ); #ifdef STRCSPN -STATIC int strcspn(); +STATIC int32_t strcspn(); #endif /* @@ -220,8 +220,8 @@ regcomp( const char *exp ) regexp *r; char *scan; char *longest; - unsigned len; - int flags; + int32_t len; + int32_t flags; if (exp == NULL) FAIL("NULL argument"); @@ -232,7 +232,7 @@ regcomp( const char *exp ) #endif regparse = (char *)exp; regnpar = 1; - regsize = 0L; + regsize = 0; regcode = ®dummy; regc(MAGIC); if (reg(0, &flags) == NULL) @@ -243,7 +243,7 @@ regcomp( const char *exp ) FAIL("regexp too big"); /* Allocate space. */ - r = (regexp *)BJAM_MALLOC(sizeof(regexp) + (unsigned)regsize); + r = (regexp *)BJAM_MALLOC(sizeof(regexp) + regsize); if (r == NULL) FAIL("out of space"); @@ -282,9 +282,9 @@ regcomp( const char *exp ) longest = NULL; len = 0; for (; scan != NULL; scan = regnext(scan)) - if (OP(scan) == EXACTLY && strlen(OPERAND(scan)) >= len) { + if (OP(scan) == EXACTLY && static_cast(strlen(OPERAND(scan))) >= len) { longest = OPERAND(scan); - len = strlen(OPERAND(scan)); + len = static_cast(strlen(OPERAND(scan))); } r->regmust = longest; r->regmlen = len; @@ -305,14 +305,14 @@ regcomp( const char *exp ) */ static char * reg( - int paren, /* Parenthesized? */ - int *flagp ) + int32_t paren, /* Parenthesized? */ + int32_t *flagp ) { char *ret; char *br; char *ender; - int parno = 0; - int flags; + int32_t parno = 0; + int32_t flags; *flagp = HASWIDTH; /* Tentatively. */ @@ -376,12 +376,12 @@ reg( * Implements the concatenation operator. */ static char * -regbranch( int *flagp ) +regbranch( int32_t *flagp ) { char *ret; char *chain; char *latest; - int flags; + int32_t flags; *flagp = WORST; /* Tentatively. */ @@ -415,12 +415,12 @@ regbranch( int *flagp ) * endmarker role is not redundant. */ static char * -regpiece( int *flagp ) +regpiece( int32_t *flagp ) { char *ret; char op; char *next; - int flags; + int32_t flags; ret = regatom(&flags); if (ret == NULL) @@ -478,10 +478,10 @@ regpiece( int *flagp ) * separate node; the code is simpler that way and it's not worth fixing. */ static char * -regatom( int *flagp ) +regatom( int32_t *flagp ) { char *ret; - int flags; + int32_t flags; *flagp = WORST; /* Tentatively. */ @@ -498,8 +498,8 @@ regatom( int *flagp ) *flagp |= HASWIDTH|SIMPLE; break; case '[': { - int classr; - int classend; + int32_t classr; + int32_t classend; if (*regparse == '^') { /* Complement of range. */ ret = regnode(ANYBUT); @@ -655,7 +655,7 @@ regatom( int *flagp ) - regnode - emit a node */ static char * /* Location. */ -regnode( int op ) +regnode( int32_t op ) { char *ret; char *ptr; @@ -679,7 +679,7 @@ regnode( int op ) - regc - emit (if appropriate) a byte of code */ static void -regc( int b ) +regc( int32_t b ) { if (regcode != ®dummy) *regcode++ = b; @@ -728,7 +728,7 @@ regtail( { char *scan; char *temp; - int offset; + size_t offset; if (p == ®dummy) return; @@ -780,12 +780,12 @@ static const char **regendp; /* Ditto for endp. */ /* * Forwards. */ -STATIC int regtry( regexp *prog, const char *string ); -STATIC int regmatch( char *prog ); -STATIC int regrepeat( char *p ); +STATIC int32_t regtry( regexp *prog, const char *string ); +STATIC int32_t regmatch( char *prog ); +STATIC int32_t regrepeat( char *p ); #ifdef DEBUG -int regnarrate = 0; +int32_t regnarrate = 0; void regdump(); STATIC char *regprop(); #endif @@ -793,7 +793,7 @@ STATIC char *regprop(); /* - regexec - match a regexp against a string */ -int +int32_t regexec( regexp *prog, const char *string ) @@ -858,12 +858,12 @@ regexec( * regtry() - try match at specific point. */ -static int /* 0 failure, 1 success */ +static int32_t /* 0 failure, 1 success */ regtry( regexp *prog, const char *string ) { - int i; + int32_t i; const char * * sp; const char * * ep; @@ -899,7 +899,7 @@ regtry( * whether the rest of the match failed) by a loop instead of by recursion. */ -static int /* 0 failure, 1 success */ +static int32_t /* 0 failure, 1 success */ regmatch( char * prog ) { char * scan; /* Current node. */ @@ -947,7 +947,7 @@ regmatch( char * prog ) reginput++; break; case EXACTLY: { - int len; + size_t len; char *opnd; opnd = OPERAND(scan); @@ -983,7 +983,7 @@ regmatch( char * prog ) case OPEN+7: case OPEN+8: case OPEN+9: { - int no; + int32_t no; const char *save; no = OP(scan) - OPEN; @@ -1011,7 +1011,7 @@ regmatch( char * prog ) case CLOSE+7: case CLOSE+8: case CLOSE+9: { - int no; + int32_t no; const char *save; no = OP(scan) - CLOSE; @@ -1051,9 +1051,9 @@ regmatch( char * prog ) case STAR: case PLUS: { char nextch; - int no; + int32_t no; const char *save; - int min; + int32_t min; /* * Lookahead to avoid useless match attempts @@ -1100,10 +1100,10 @@ regmatch( char * prog ) /* - regrepeat - repeatedly match something simple, report how many */ -static int +static int32_t regrepeat( char *p ) { - int count = 0; + int32_t count = 0; const char *scan; char *opnd; @@ -1111,7 +1111,7 @@ regrepeat( char *p ) opnd = OPERAND(p); switch (OP(p)) { case ANY: - count = strlen(scan); + count = int32_t(strlen(scan)); scan += count; break; case EXACTLY: @@ -1148,7 +1148,7 @@ regrepeat( char *p ) static char * regnext( char *p ) { - int offset; + int32_t offset; if (p == ®dummy) return(NULL); @@ -1309,14 +1309,14 @@ regprop( char *op ) * of characters not from s2 */ -static int +static int32_t strcspn( char *s1, char *s2 ) { char *scan1; char *scan2; - int count; + int32_t count; count = 0; for (scan1 = s1; *scan1 != '\0'; scan1++) { diff --git a/src/engine/regexp.h b/src/engine/regexp.h index 3a52ba3d6..bbac95eeb 100644 --- a/src/engine/regexp.h +++ b/src/engine/regexp.h @@ -16,13 +16,13 @@ typedef struct regexp { char regstart; /* Internal use only. */ char reganch; /* Internal use only. */ char * regmust; /* Internal use only. */ - int regmlen; /* Internal use only. */ + int32_t regmlen; /* Internal use only. */ char program[ 1 ]; /* Unwarranted chumminess with compiler. */ } regexp; regexp * regcomp( char const * exp ); -int regexec( regexp * prog, char const * string ); +int32_t regexec( regexp * prog, char const * string ); void regerror( char const * s ); diff --git a/src/engine/search.cpp b/src/engine/search.cpp index 7529e02dc..7bafc2b6c 100644 --- a/src/engine/search.cpp +++ b/src/engine/search.cpp @@ -98,7 +98,7 @@ void set_explicit_binding( OBJECT * target, OBJECT * locate ) /* Root the target path at the given location. */ f->f_root.ptr = object_str( locate ); - f->f_root.len = strlen( object_str( locate ) ); + f->f_root.len = int32_t(strlen( object_str( locate ) )); path_build( f, buf ); boundname = object_new( buf->value ); @@ -164,7 +164,7 @@ OBJECT * search( OBJECT * target, timestamp * const time, { OBJECT * key; f->f_root.ptr = object_str( list_front( varlist ) ); - f->f_root.len = strlen( object_str( list_front( varlist ) ) ); + f->f_root.len = int32_t(strlen( object_str( list_front( varlist ) ) )); path_build( f, buf ); @@ -189,7 +189,7 @@ OBJECT * search( OBJECT * target, timestamp * const time, OBJECT * test_path; f->f_root.ptr = object_str( list_item( iter ) ); - f->f_root.len = strlen( object_str( list_item( iter ) ) ); + f->f_root.len = int32_t(strlen( object_str( list_item( iter ) ) )); string_truncate( buf, 0 ); path_build( f, buf ); diff --git a/src/engine/variable.cpp b/src/engine/variable.cpp index 574c344ce..b597c842c 100644 --- a/src/engine/variable.cpp +++ b/src/engine/variable.cpp @@ -90,7 +90,7 @@ void var_defines( struct module_t * module, const char * const * e, int preproce ) { LIST * l = L0; - size_t const len = strlen( val + 1 ); + int32_t const len = int32_t(strlen( val + 1 )); int const quoted = ( val[ 1 ] == '"' ) && ( val[ len ] == '"' ) && ( len > 1 ); diff --git a/src/engine/w32_getreg.cpp b/src/engine/w32_getreg.cpp index 1ba06274b..4df13c04f 100644 --- a/src/engine/w32_getreg.cpp +++ b/src/engine/w32_getreg.cpp @@ -43,7 +43,7 @@ static HKEY get_key(char const** path) for (p = dlRootKeys; p->name; ++p) { - int n = strlen(p->name); + size_t n = strlen(p->name); if (!strncmp(*path,p->name,n)) { if ((*path)[n] == '\\' || (*path)[n] == 0) @@ -81,14 +81,14 @@ LIST * builtin_system_registry( FRAME * frame, int flags ) case REG_EXPAND_SZ: { - unsigned long len; + DWORD len; string expanded[1]; string_new(expanded); while ( (len = ExpandEnvironmentStringsA( - (LPCSTR)data, expanded->value, expanded->capacity)) - > expanded->capacity + (LPCSTR)data, expanded->value, (DWORD)expanded->capacity)) + > DWORD(expanded->capacity) ) string_reserve(expanded, len);