Increase size of buffer for parser error string. Should change this to a dynamically allocated string.

darcs-hash:20060531154028-ac50b-ada120ecfe65bcf1ad1b3d1a5fad41ae9dec133c.gz
This commit is contained in:
axel 2006-06-01 01:40:28 +10:00
parent 25365dbc54
commit 4722ddc373
2 changed files with 12 additions and 6 deletions

View file

@ -547,9 +547,10 @@ void debug( int level, const wchar_t *msg, ... )
sb_init( &sb ); sb_init( &sb );
sb_init( &sb2 ); sb_init( &sb2 );
va_start( va, msg );
sb_printf( &sb, L"%ls: ", program_name ); sb_printf( &sb, L"%ls: ", program_name );
va_start( va, msg );
sb_vprintf( &sb, msg, va ); sb_vprintf( &sb, msg, va );
va_end( va ); va_end( va );
@ -581,7 +582,7 @@ void write_screen( const wchar_t *msg, string_buffer_t *buff )
*/ */
while( *pos && ( !wcschr( L" \n\r\t", *pos ) ) ) while( *pos && ( !wcschr( L" \n\r\t", *pos ) ) )
{ {
/* /*
Check is token is wider than one line. Check is token is wider than one line.
If so we mark it as an overflow and break the token. If so we mark it as an overflow and break the token.
@ -606,7 +607,7 @@ void write_screen( const wchar_t *msg, string_buffer_t *buff )
else if( overflow ) else if( overflow )
{ {
/* /*
In case of overflow, we print a newline, except if we alreade are at position 0 In case of overflow, we print a newline, except if we already are at position 0
*/ */
wchar_t *token = wcsndup( start, pos-start ); wchar_t *token = wcsndup( start, pos-start );
if( line_width != 0 ) if( line_width != 0 )
@ -630,6 +631,7 @@ void write_screen( const wchar_t *msg, string_buffer_t *buff )
free( token ); free( token );
line_width += (line_width!=0?1:0) + tok_width; line_width += (line_width!=0?1:0) + tok_width;
} }
/* /*
Break on end of string Break on end of string
*/ */

View file

@ -252,6 +252,10 @@ The fish parser. Contains functions for parsing code.
#define UNKNOWN_BLOCK _( L"unknown/invalid block" ) #define UNKNOWN_BLOCK _( L"unknown/invalid block" )
/**
Size of the error string buffer
*/
#define ERR_STR_SZ 1024
/** Last error code */ /** Last error code */
int error_code; int error_code;
@ -262,7 +266,7 @@ event_block_t *global_event_block=0;
static int err_pos; static int err_pos;
/** Description of last error */ /** Description of last error */
static wchar_t err_str[256]; static wchar_t err_str[ERR_STR_SZ];
/** Pointer to the current tokenizer */ /** Pointer to the current tokenizer */
static tokenizer *current_tokenizer; static tokenizer *current_tokenizer;
@ -698,7 +702,7 @@ void error( int ec, int p, const wchar_t *str, ... )
err_pos = p; err_pos = p;
va_start( va, str ); va_start( va, str );
vswprintf( err_str, 256, str, va ); vswprintf( err_str, ERR_STR_SZ, str, va );
va_end( va ); va_end( va );
} }