diff options
author | ridiculousfish <corydoras@ridiculousfish.com> | 2011-12-26 19:18:46 -0800 |
---|---|---|
committer | ridiculousfish <corydoras@ridiculousfish.com> | 2011-12-26 19:18:46 -0800 |
commit | 8d2f107d61a8b0e099ab9a59b8a32c236da5a5fc (patch) | |
tree | 89f718ab74f8400332534aee237c6f925348f05c /tokenizer.cpp | |
parent | 3f16ace6784caab54fb054836ee93902e9701913 (diff) |
Some changes to migrate towards C++ and a multithreaded model
Diffstat (limited to 'tokenizer.cpp')
-rw-r--r-- | tokenizer.cpp | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/tokenizer.cpp b/tokenizer.cpp index 07c4c6d9..cea534d4 100644 --- a/tokenizer.cpp +++ b/tokenizer.cpp @@ -87,7 +87,7 @@ static int check_size( tokenizer *tok, size_t len ) { wchar_t *tmp; tok->last_len = len +1; - tmp = realloc( tok->last, sizeof(wchar_t)*tok->last_len ); + tmp = (wchar_t *)realloc( tok->last, sizeof(wchar_t)*tok->last_len ); if( tmp == 0 ) { wperror( L"realloc" ); @@ -143,7 +143,7 @@ void tok_init( tokenizer *tok, const wchar_t *b, int flags ) void tok_destroy( tokenizer *tok ) { CHECK( tok, ); - + free( tok->last ); if( tok->free_orig ) free( tok->orig_buff ); @@ -153,14 +153,14 @@ int tok_last_type( tokenizer *tok ) { CHECK( tok, TOK_ERROR ); CHECK( tok->buff, TOK_ERROR ); - + return tok->last_type; } wchar_t *tok_last( tokenizer *tok ) { CHECK( tok, 0 ); - + return tok->last; } @@ -231,7 +231,7 @@ static void read_string( tokenizer *tok ) { do_loop = 0; } - + } else if( *tok->buff == L'\n' && mode == 0) @@ -240,15 +240,15 @@ static void read_string( tokenizer *tok ) do_loop = 0; break; } - + tok->buff++; continue; } - - + + /* The modes are as follows: - + 0: regular text 1: inside of subshell 2: inside of array brackets @@ -266,18 +266,18 @@ static void read_string( tokenizer *tok ) mode = 1; break; } - + case L'[': { if( tok->buff != start ) mode=2; break; } - + case L'\'': case L'"': { - + const wchar_t *end = quote_end( tok->buff ); tok->last_quote = *tok->buff; if( end ) @@ -287,7 +287,7 @@ static void read_string( tokenizer *tok ) else { tok->buff += wcslen( tok->buff ); - + if( (!tok->accept_unfinished) ) { tok_error( tok, TOK_UNTERMINATED_QUOTE, QUOTE_ERROR ); @@ -332,7 +332,7 @@ static void read_string( tokenizer *tok ) } do_loop = 0; } - + break; } @@ -488,7 +488,7 @@ static void read_redirect( tokenizer *tok, int fd ) wchar_t tok_last_quote( tokenizer *tok ) { CHECK( tok, 0 ); - + return tok->last_quote; } @@ -520,7 +520,7 @@ void tok_next( tokenizer *tok ) CHECK( tok, ); CHECK( tok->buff, ); - + if( tok_last_type( tok ) == TOK_ERROR ) { tok->has_next=0; @@ -552,7 +552,7 @@ void tok_next( tokenizer *tok ) break; } } - + if( *tok->buff == L'#') { @@ -649,7 +649,7 @@ wchar_t *tok_first( const wchar_t *str ) wchar_t *res=0; CHECK( str, 0 ); - + tok_init( &t, str, 0 ); switch( tok_last_type( &t ) ) @@ -670,7 +670,7 @@ wchar_t *tok_first( const wchar_t *str ) int tok_get_pos( tokenizer *tok ) { CHECK( tok, 0 ); - + return tok->last_pos; } @@ -678,7 +678,7 @@ int tok_get_pos( tokenizer *tok ) void tok_set_pos( tokenizer *tok, int pos ) { CHECK( tok, ); - + tok->buff = tok->orig_buff + pos; tok->has_next = 1; tok_next( tok ); |