mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-28 13:53:10 +00:00
Use dynamically sized buffer for reporting error messages in the parser
darcs-hash:20060828151913-ac50b-02453c13d107f88023b2331bf40daf6d329ac597.gz
This commit is contained in:
parent
0e0a61119f
commit
f5f15f9de2
1 changed files with 12 additions and 11 deletions
23
parser.c
23
parser.c
|
@ -251,11 +251,6 @@ The fish parser. Contains functions for parsing code.
|
||||||
#define UNKNOWN_BLOCK N_( L"unknown/invalid block" )
|
#define UNKNOWN_BLOCK N_( L"unknown/invalid block" )
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
Size of the error string buffer
|
|
||||||
*/
|
|
||||||
#define ERR_STR_SZ 1024
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Datastructure to describe a block type, like while blocks, command substitution blocks, etc.
|
Datastructure to describe a block type, like while blocks, command substitution blocks, etc.
|
||||||
*/
|
*/
|
||||||
|
@ -350,7 +345,7 @@ io_data_t *block_io;
|
||||||
static int err_pos;
|
static int err_pos;
|
||||||
|
|
||||||
/** Description of last error */
|
/** Description of last error */
|
||||||
static wchar_t err_str[ERR_STR_SZ];
|
static string_buffer_t *err_buff=0;
|
||||||
|
|
||||||
/** Pointer to the current tokenizer */
|
/** Pointer to the current tokenizer */
|
||||||
static tokenizer *current_tokenizer;
|
static tokenizer *current_tokenizer;
|
||||||
|
@ -756,11 +751,17 @@ void error( int ec, int p, const wchar_t *str, ... )
|
||||||
{
|
{
|
||||||
va_list va;
|
va_list va;
|
||||||
|
|
||||||
|
if( !err_buff )
|
||||||
|
err_buff = sb_halloc( global_context );
|
||||||
|
|
||||||
|
|
||||||
error_code = ec;
|
error_code = ec;
|
||||||
err_pos = p;
|
err_pos = p;
|
||||||
|
|
||||||
va_start( va, str );
|
va_start( va, str );
|
||||||
vswprintf( err_str, ERR_STR_SZ, str, va );
|
|
||||||
|
sb_vprintf( err_buff, str, va );
|
||||||
|
|
||||||
va_end( va );
|
va_end( va );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1007,11 +1008,11 @@ void parser_destroy()
|
||||||
*/
|
*/
|
||||||
static void print_errors( string_buffer_t *target, const wchar_t *prefix )
|
static void print_errors( string_buffer_t *target, const wchar_t *prefix )
|
||||||
{
|
{
|
||||||
if( error_code )
|
if( error_code && err_buff )
|
||||||
{
|
{
|
||||||
int tmp;
|
int tmp;
|
||||||
|
|
||||||
sb_printf( target, L"%ls: %ls\n", prefix, err_str );
|
sb_printf( target, L"%ls: %ls\n", prefix, (wchar_t *)err_buff->buff );
|
||||||
|
|
||||||
tmp = current_tokenizer_pos;
|
tmp = current_tokenizer_pos;
|
||||||
current_tokenizer_pos = err_pos;
|
current_tokenizer_pos = err_pos;
|
||||||
|
@ -1027,9 +1028,9 @@ static void print_errors( string_buffer_t *target, const wchar_t *prefix )
|
||||||
*/
|
*/
|
||||||
static void print_errors_stderr()
|
static void print_errors_stderr()
|
||||||
{
|
{
|
||||||
if( error_code )
|
if( error_code && err_buff )
|
||||||
{
|
{
|
||||||
debug( 0, L"%ls", err_str );
|
debug( 0, L"%ls", (wchar_t *)err_buff->buff );
|
||||||
int tmp;
|
int tmp;
|
||||||
|
|
||||||
tmp = current_tokenizer_pos;
|
tmp = current_tokenizer_pos;
|
||||||
|
|
Loading…
Reference in a new issue