From 4722ddc373a4a0ec4f84a75dff4140625d03707f Mon Sep 17 00:00:00 2001 From: axel Date: Thu, 1 Jun 2006 01:40:28 +1000 Subject: [PATCH] Increase size of buffer for parser error string. Should change this to a dynamically allocated string. darcs-hash:20060531154028-ac50b-ada120ecfe65bcf1ad1b3d1a5fad41ae9dec133c.gz --- common.c | 10 ++++++---- parser.c | 8 ++++++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/common.c b/common.c index 2c9dac8c2..7bf600167 100644 --- a/common.c +++ b/common.c @@ -547,9 +547,10 @@ void debug( int level, const wchar_t *msg, ... ) sb_init( &sb ); sb_init( &sb2 ); - va_start( va, msg ); - + sb_printf( &sb, L"%ls: ", program_name ); + + va_start( va, msg ); sb_vprintf( &sb, msg, 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 ) ) ) { - + /* Check is token is wider than one line. 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 ) { /* - 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 ); if( line_width != 0 ) @@ -630,6 +631,7 @@ void write_screen( const wchar_t *msg, string_buffer_t *buff ) free( token ); line_width += (line_width!=0?1:0) + tok_width; } + /* Break on end of string */ diff --git a/parser.c b/parser.c index 6e58b54b1..829469299 100644 --- a/parser.c +++ b/parser.c @@ -252,6 +252,10 @@ The fish parser. Contains functions for parsing code. #define UNKNOWN_BLOCK _( L"unknown/invalid block" ) +/** + Size of the error string buffer +*/ +#define ERR_STR_SZ 1024 /** Last error code */ int error_code; @@ -262,7 +266,7 @@ event_block_t *global_event_block=0; static int err_pos; /** Description of last error */ -static wchar_t err_str[256]; +static wchar_t err_str[ERR_STR_SZ]; /** Pointer to the current tokenizer */ static tokenizer *current_tokenizer; @@ -698,7 +702,7 @@ void error( int ec, int p, const wchar_t *str, ... ) err_pos = p; va_start( va, str ); - vswprintf( err_str, 256, str, va ); + vswprintf( err_str, ERR_STR_SZ, str, va ); va_end( va ); }