diff options
author | 2012-08-04 13:02:44 -0700 | |
---|---|---|
committer | 2012-08-04 13:02:44 -0700 | |
commit | 7a4622714184f196d8592ee6188945fb0528bd06 (patch) | |
tree | 6096d73657c584d80abcf187c67617ad810d7e45 /parser.cpp | |
parent | b904aa78e854b55414a5f6ea0a995fe9a852ee99 (diff) |
More warning fixes and switching from int to long or size_t
Diffstat (limited to 'parser.cpp')
-rw-r--r-- | parser.cpp | 41 |
1 files changed, 19 insertions, 22 deletions
@@ -1226,11 +1226,9 @@ const wchar_t *parser_t::get_buffer() const int parser_t::is_help( const wchar_t *s, int min_match ) const { - int len; - CHECK( s, 0 ); - len = wcslen(s); + size_t len = wcslen(s); min_match = maxi( min_match, 3 ); @@ -2173,14 +2171,13 @@ int parser_t::parse_job( process_t *p, if( make_sub_block ) { - int end_pos = end-tok_string( tok ); + long end_pos = end-tok_string( tok ); const wcstring sub_block(tok_string( tok ) + current_tokenizer_pos, end_pos - current_tokenizer_pos); p->type = INTERNAL_BLOCK; args.at( 0 ) = completion_t(sub_block); - tok_set_pos( tok, - end_pos ); + tok_set_pos( tok, (int)end_pos ); while( prev_block != current_block ) { @@ -2392,8 +2389,8 @@ void parser_t::eval_job( tokenizer *tok ) { t3 = get_time(); profile_item->level=eval_level; - profile_item->parse = t2-t1; - profile_item->exec=t3-t2; + profile_item->parse = (int)(t2-t1); + profile_item->exec=(int)(t3-t2); } if( current_block->type == WHILE ) @@ -2860,6 +2857,8 @@ int parser_t::test( const wchar_t * buff, tokenizer *previous_tokenizer=current_tokenizer; int previous_pos=current_tokenizer_pos; + + // PCA These statics are terrifying - I have no idea whether and why these variables need to be static static int block_pos[BLOCK_MAX_COUNT]; static int block_type[BLOCK_MAX_COUNT]; int res = 0; @@ -2897,9 +2896,8 @@ int parser_t::test( const wchar_t * buff, if( block_level ) { - int i; - int len = wcslen(buff); - for( i=0; i<len; i++ ) + size_t len = wcslen(buff); + for( size_t i=0; i<len; i++ ) { block_level[i] = -1; } @@ -3546,8 +3544,7 @@ int parser_t::test( const wchar_t * buff, if( block_level ) { int last_level = 0; - int i, j; - int len = wcslen(buff); + size_t i, len = wcslen(buff); for( i=0; i<len; i++ ) { if( block_level[i] >= 0 ) @@ -3558,11 +3555,12 @@ int parser_t::test( const wchar_t * buff, level. This avoid using the wrong indentation level if a new line starts with whitespace. */ - for( j=i-1; j>=0; j-- ) + size_t prev_char_idx = i; + while (prev_char_idx--) { - if( !wcschr( L" \n\t\r", buff[j] ) ) + if( !wcschr( L" \n\t\r", buff[prev_char_idx] ) ) break; - block_level[j] = last_level; + block_level[prev_char_idx] = last_level; } } block_level[i] = last_level; @@ -3573,15 +3571,14 @@ int parser_t::test( const wchar_t * buff, validator had at exit. This makes sure a new line is correctly indented even if it is empty. */ - for( j=len-1; j>=0; j-- ) + size_t suffix_idx = len; + while (suffix_idx--) { - if( !wcschr( L" \n\t\r", buff[j] ) ) + if( !wcschr( L" \n\t\r", buff[suffix_idx] ) ) break; - block_level[j] = count; + block_level[suffix_idx] = count; } - - - } + } /* Calculate exit status |