diff --git a/builtin.c b/builtin.c index 0093aa859..6d0bf6c11 100644 --- a/builtin.c +++ b/builtin.c @@ -2619,9 +2619,9 @@ static int builtin_end( wchar_t **argv ) else { debug(0, - _(L"%ls: Missing function definition information. This is a fish bug. If you can reproduce it, please file a bug report to %s."), - argv[0], - PACKAGE_BUGREPORT); + _(L"%ls: Missing function definition information."), + argv[0] ); + bugreport(); } } @@ -2633,7 +2633,6 @@ static int builtin_end( wchar_t **argv ) parser_pop_block(); } - /* If everything goes ok, return status of last command to execute. */ diff --git a/common.c b/common.c index 05747103b..a63cbce91 100644 --- a/common.c +++ b/common.c @@ -1601,3 +1601,11 @@ int create_directory( wchar_t *d ) return ok?0:-1; } +void bugreport() +{ + debug( 1, + _( L"This is a bug. " + L"If you can reproduce it, please send a bug report to %s." ), + PACKAGE_BUGREPORT ); +} + diff --git a/common.h b/common.h index 4b8928d5f..323dd1cae 100644 --- a/common.h +++ b/common.h @@ -77,13 +77,11 @@ extern wchar_t *program_name; #define CHECK( arg, retval ) \ if( !(arg) ) \ { \ - debug( 1, \ - _( L"function %s called with null value for argument %s. " \ - L"This is a bug. " \ - L"If you can reproduce it, please send a bug report to %s." ), \ + debug( 0, \ + _( L"function %s called with null value for argument %s. " ), \ __func__, \ - #arg, \ - PACKAGE_BUGREPORT ); \ + #arg ); \ + bugreport(); \ return retval; \ } @@ -113,16 +111,14 @@ extern wchar_t *program_name; Check if signals are blocked. If so, print an error message and return from the function performing this check. */ -#define CHECK_BLOCK( retval ) \ +#define CHECK_BLOCK( retval ) \ if( signal_is_blocked() ) \ { \ debug( 0, \ - L"function %s called while blocking signals. " \ - L"This is a bug. " \ - L"If you can reproduce it, please send a bug report to %s.", \ - __func__, \ - PACKAGE_BUGREPORT ); \ - return retval; \ + _( L"function %s called while blocking signals. " ), \ + __func__); \ + bugreport(); \ + return retval; \ } /** @@ -405,5 +401,10 @@ void tokenize_variable_array( const wchar_t *val, array_list_t *out ); */ int create_directory( wchar_t *d ); +/** + Print a short message about how to file a bug report to stderr +*/ +void bugreport(); + #endif diff --git a/parser.c b/parser.c index 689d8ad41..4460c2d14 100644 --- a/parser.c +++ b/parser.c @@ -56,12 +56,6 @@ The fish parser. Contains functions for parsing code. */ #define MAX_RECURSION_DEPTH 128 -/** - Message about reporting bugs, used on weird internal error to - hopefully get them to report stuff. -*/ -#define BUGREPORT_MSG _( L"If this error can be reproduced, please send a bug report to %s.") - /** Error message for improper use of the exec builtin */ @@ -474,11 +468,9 @@ void parser_pop_block() if( !current_block ) { debug( 1, - L"function %s called on empty block stack. " - L"This is a bug. " - L"If you can reproduce it, please send a bug report to %s.", - __func__, - PACKAGE_BUGREPORT ); \ + L"function %s called on empty block stack.", + __func__); + bugreport(); return; } @@ -2521,9 +2513,7 @@ int eval( const wchar_t *cmd, io_data_t *io, int block_type ) { debug( 1, EVAL_NULL_ERR_MSG ); - debug( 1, - BUGREPORT_MSG, - PACKAGE_BUGREPORT ); + bugreport(); return 1; } @@ -2533,10 +2523,7 @@ int eval( const wchar_t *cmd, io_data_t *io, int block_type ) debug( 1, INVALID_SCOPE_ERR_MSG, parser_get_block_desc( block_type ) ); - - debug( 1, - BUGREPORT_MSG, - PACKAGE_BUGREPORT ); + bugreport(); return 1; } @@ -2570,9 +2557,7 @@ int eval( const wchar_t *cmd, io_data_t *io, int block_type ) { debug( 0, _(L"End of block mismatch. Program terminating.") ); - debug( 0, - BUGREPORT_MSG, - PACKAGE_BUGREPORT ); + bugreport(); exit(1); break; }