Add better debbuging information when writembs is called with null value.

darcs-hash:20070909140436-75c98-b6c925c441ebaa349f998b95314295296fb36252.gz
This commit is contained in:
liljencrantz 2007-09-10 00:04:36 +10:00
parent 370aeec44d
commit 76bb8e79b2
4 changed files with 124 additions and 74 deletions

View file

@ -1008,7 +1008,7 @@ static void init( int mangle_descriptors, int out )
struct sigaction act;
static struct termios pager_modes;
char *term;
if( mangle_descriptors )
{
@ -1093,12 +1093,21 @@ static void init( int mangle_descriptors, int out )
exit(1);
}
if( setupterm( 0, STDOUT_FILENO, 0) == ERR )
{
debug( 0, _(L"Could not set up terminal") );
exit(1);
}
term = getenv("TERM");
if( term )
{
wchar_t *wterm = str2wcs(term);
output_set_term( wterm );
free( wterm );
}
}
/**

View file

@ -1435,6 +1435,8 @@ int input_init()
debug( 0, _( L"Could not set up terminal" ) );
exit(1);
}
output_set_term( env_get( L"TERM" ) );
hash_init( &all_mappings, &hash_wcs_func, &hash_wcs_cmp );
/*

View file

@ -121,6 +121,9 @@ static char *writestr_buff = 0;
static int (*out)(char c) = &writeb_internal;
static wchar_t *current_term = 0;
/**
Cleanup function. Run automatically through halloc
*/
@ -366,7 +369,7 @@ int writeb( tputs_arg_t b )
return 0;
}
int writembs( char *str )
int writembs_internal( char *str )
{
CHECK( str, 1 );
@ -580,3 +583,15 @@ int output_color_code( const wchar_t *val )
return color | (is_bold?FISH_COLOR_BOLD:0) | (is_underline?FISH_COLOR_UNDERLINE:0);
}
void output_set_term( wchar_t *term )
{
current_term = halloc_wcsdup(global_context, term);
}
wchar_t *output_get_term()
{
return current_term ? current_term : L"<unknown>";
}

View file

@ -73,13 +73,34 @@ enum
void set_color( int c, int c2 );
#define writembs( mbs ) \
{ \
char *tmp = mbs; \
if( tmp ) \
{ \
writembs_internal( tmp ); \
} \
else \
{ \
debug( 0, \
_(L"Tried to use terminfo string %s on line %d of %s, which is undefined in terminal of type \"%ls\". Please report this error to %s"), \
#mbs, \
__LINE__, \
__FILE__, \
output_get_term(), \
PACKAGE_BUGREPORT); \
} \
}
/**
Write a char * narrow string to FD 1, needed for the terminfo
strings. This is usually just a wrapper aound tputs, using writeb
as the sending function. But a weird bug on PPC Linux means that on
this platform, write is instead used directly.
*/
int writembs( char *str );
int writembs_internal( char *str );
/**
Write a wide character using the output method specified using output_set_writer().
@ -126,4 +147,7 @@ void output_set_writer( int (*writer)(char) );
int (*output_get_writer())(char) ;
void output_set_term( wchar_t *term );
wchar_t *output_get_term();
#endif