mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-31 03:51:14 -03:00
Fix broken debug in non-interactive mode
darcs-hash:20051020113001-ac50b-5a2517bbdc728070bc1fb9f22c5ed38717e85a5c.gz
This commit is contained in:
117
common.c
117
common.c
@@ -815,75 +815,84 @@ void debug( int level, wchar_t *msg, ... )
|
|||||||
sb_printf( &sb, L"%ls: ", program_name );
|
sb_printf( &sb, L"%ls: ", program_name );
|
||||||
sb_vprintf( &sb, msg, va );
|
sb_vprintf( &sb, msg, va );
|
||||||
va_end( va );
|
va_end( va );
|
||||||
|
|
||||||
|
|
||||||
start = pos = (wchar_t *)sb.buff;
|
if( screen_width )
|
||||||
while( 1 )
|
|
||||||
{
|
{
|
||||||
int overflow = 0;
|
start = pos = (wchar_t *)sb.buff;
|
||||||
|
while( 1 )
|
||||||
|
{
|
||||||
|
int overflow = 0;
|
||||||
|
|
||||||
tok_width=0;
|
tok_width=0;
|
||||||
|
|
||||||
/*
|
|
||||||
Tokenize on whitespace, and also calculate the width of the token
|
|
||||||
*/
|
|
||||||
while( *pos && ( !wcschr( L" \n\r\t", *pos ) ) )
|
|
||||||
{
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Check is token is wider than one line.
|
Tokenize on whitespace, and also calculate the width of the token
|
||||||
If so we mark it as an overflow and break the token.
|
|
||||||
*/
|
*/
|
||||||
if((tok_width + wcwidth(*pos)) > (screen_width-1))
|
while( *pos && ( !wcschr( L" \n\r\t", *pos ) ) )
|
||||||
{
|
{
|
||||||
overflow = 1;
|
|
||||||
break;
|
/*
|
||||||
}
|
Check is token is wider than one line.
|
||||||
|
If so we mark it as an overflow and break the token.
|
||||||
|
*/
|
||||||
|
if((tok_width + wcwidth(*pos)) > (screen_width-1))
|
||||||
|
{
|
||||||
|
overflow = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
tok_width += wcwidth( *pos );
|
tok_width += wcwidth( *pos );
|
||||||
pos++;
|
pos++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
If token is zero character long, we don't do anything
|
|
||||||
*/
|
|
||||||
if( pos == start )
|
|
||||||
{
|
|
||||||
start = pos = pos+1;
|
|
||||||
}
|
|
||||||
else if( overflow )
|
|
||||||
{
|
|
||||||
/*
|
/*
|
||||||
In case of overflow, we print a newline, except if we alreade are at position 0
|
If token is zero character long, we don't do anything
|
||||||
*/
|
*/
|
||||||
wchar_t *token = wcsndup( start, pos-start );
|
if( pos == start )
|
||||||
if( line_width != 0 )
|
|
||||||
putwc( L'\n', stderr );
|
|
||||||
fwprintf( stderr, L"%ls-\n", token );
|
|
||||||
free( token );
|
|
||||||
line_width=0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
Print the token
|
|
||||||
*/
|
|
||||||
wchar_t *token = wcsndup( start, pos-start );
|
|
||||||
if( (line_width + (line_width!=0?1:0) + tok_width) > screen_width )
|
|
||||||
{
|
{
|
||||||
putwc( L'\n', stderr );
|
start = pos = pos+1;
|
||||||
|
}
|
||||||
|
else if( overflow )
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
In case of overflow, we print a newline, except if we alreade are at position 0
|
||||||
|
*/
|
||||||
|
wchar_t *token = wcsndup( start, pos-start );
|
||||||
|
if( line_width != 0 )
|
||||||
|
putwc( L'\n', stderr );
|
||||||
|
fwprintf( stderr, L"%ls-\n", token );
|
||||||
|
free( token );
|
||||||
line_width=0;
|
line_width=0;
|
||||||
}
|
}
|
||||||
fwprintf( stderr, L"%ls%ls", line_width?L" ":L"", token );
|
else
|
||||||
free( token );
|
{
|
||||||
line_width += (line_width!=0?1:0) + tok_width;
|
/*
|
||||||
}
|
Print the token
|
||||||
/*
|
*/
|
||||||
Break on end of string
|
wchar_t *token = wcsndup( start, pos-start );
|
||||||
*/
|
if( (line_width + (line_width!=0?1:0) + tok_width) > screen_width )
|
||||||
if( !*pos )
|
{
|
||||||
break;
|
putwc( L'\n', stderr );
|
||||||
|
line_width=0;
|
||||||
|
}
|
||||||
|
fwprintf( stderr, L"%ls%ls", line_width?L" ":L"", token );
|
||||||
|
free( token );
|
||||||
|
line_width += (line_width!=0?1:0) + tok_width;
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
Break on end of string
|
||||||
|
*/
|
||||||
|
if( !*pos )
|
||||||
|
break;
|
||||||
|
|
||||||
|
start=pos;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fwprintf( stderr, L"%ls", sb.buff );
|
||||||
|
|
||||||
start=pos;
|
|
||||||
}
|
}
|
||||||
putwc( L'\n', stderr );
|
putwc( L'\n', stderr );
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user