aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--output.c36
-rw-r--r--output.h4
-rw-r--r--parser.c64
-rw-r--r--proc.h1
4 files changed, 73 insertions, 32 deletions
diff --git a/output.c b/output.c
index 086951f9..f521fb9c 100644
--- a/output.c
+++ b/output.c
@@ -143,7 +143,9 @@ void set_color( int c, int c2 )
{
c = c2 = FISH_COLOR_NORMAL;
if( fg )
+ {
writembs( tparm( fg, 0 ) );
+ }
writembs( exit_attribute_mode );
return;
}
@@ -203,12 +205,14 @@ void set_color( int c, int c2 )
if( c==FISH_COLOR_NORMAL )
{
if( fg )
+ {
writembs( tparm( fg, 0 ) );
+ }
writembs( exit_attribute_mode );
last_color2 = FISH_COLOR_NORMAL;
}
- else if( ( c >= 0) && ( c < FISH_COLOR_NORMAL ) )
+ else if( ( c >= 0 ) && ( c < FISH_COLOR_NORMAL ) )
{
if( fg )
{
@@ -228,15 +232,15 @@ void set_color( int c, int c2 )
writembs( tparm( bg, 0 ) );
}
- writembs(exit_attribute_mode);
- if(( last_color != FISH_COLOR_NORMAL ) && fg )
+ writembs( exit_attribute_mode );
+ if( ( last_color != FISH_COLOR_NORMAL ) && fg )
{
- writembs(tparm( fg, last_color ));
+ writembs( tparm( fg, last_color ) );
}
last_color2 = c2;
}
- else if ((c2 >= 0 ) &&(c2 < FISH_COLOR_NORMAL))
+ else if ( ( c2 >= 0 ) && ( c2 < FISH_COLOR_NORMAL ) )
{
if( bg )
{
@@ -290,7 +294,9 @@ int writembs( char *str )
{
#ifdef TPUTS_KLUDGE
while( *str )
+ {
out( *str );
+ }
#else
tputs(str,1,writeb);
#endif
@@ -305,7 +311,9 @@ int writech( wint_t ch )
int i;
for( i=0; i<bytes; i++ )
+ {
out( buff[i] );
+ }
return 0;
}
@@ -335,14 +343,15 @@ void writestr( const wchar_t *str )
if( writestr_buff_sz < len )
{
if( !writestr_buff )
+ {
halloc_register_function_void( global_context, &output_destroy );
+ }
-
-
-
writestr_buff = realloc( writestr_buff, len );
if( !writestr_buff )
+ {
die_mem();
+ }
writestr_buff_sz = len;
}
@@ -357,8 +366,9 @@ void writestr( const wchar_t *str )
Write
*/
for( pos = writestr_buff; *pos; pos++ )
+ {
out( *pos );
-
+ }
}
@@ -377,7 +387,9 @@ void writestr_ellipsis( const wchar_t *str, int max_width )
{
int w = wcwidth( *str );
if( written+w+wcwidth( ellipsis_char )>max_width )
+ {
break;
+ }
written+=w;
writech( *(str++) );
}
@@ -438,7 +450,9 @@ int writespace( int c )
int i;
for( i=0; i<c; i++ )
+ {
out( ' ' );
+ }
}
return 0;
}
@@ -458,7 +472,11 @@ int output_color_code( const wchar_t *val )
}
if( color >= 0 )
+ {
return color;
+ }
else
+ {
return FISH_COLOR_NORMAL;
+ }
}
diff --git a/output.h b/output.h
index 9a948b8f..443dfe71 100644
--- a/output.h
+++ b/output.h
@@ -133,7 +133,9 @@ int writeb( tputs_arg_t b );
/**
Set the function used for writing in move_cursor, writespace and
- set_color. By default, writembs is used.
+ set_color and all other output functions in this library. By
+ default, the write call is used to give completely unbuffered
+ output to stdout.
*/
void output_set_writer( int (*writer)(char) );
diff --git a/parser.c b/parser.c
index 496ae195..bf339e77 100644
--- a/parser.c
+++ b/parser.c
@@ -345,8 +345,6 @@ void parser_push_block( int type )
new->src_lineno = parser_get_lineno();
new->src_filename = parser_current_filename()?intern(parser_current_filename()):0;
-// debug( 3, L"Block push %ls %d\n", parser_get_block_desc(type), block_count( current_block)+1 );
-
new->outer = current_block;
new->type = (current_block && current_block->skip)?FAKE:type;
@@ -357,9 +355,13 @@ void parser_push_block( int type )
*/
new->skip=current_block?current_block->skip:0;
if( type == TOP || type == SUBST )
+ {
new->skip = 0;
+ }
if( type == FAKE )
+ {
new->skip = 1;
+ }
new->job = 0;
new->loop_status=LOOP_NORMAL;
@@ -759,7 +761,9 @@ wchar_t *get_filename( const wchar_t *cmd )
if( wstat( new_cmd, &buff )==-1 )
{
if( errno != EACCES )
+ {
wperror( L"stat" );
+ }
continue;
}
if( S_ISREG(buff.st_mode) )
@@ -778,10 +782,12 @@ wchar_t *get_filename( const wchar_t *cmd )
case ENOTDIR:
break;
default:
+ {
debug( 1,
MISSING_COMMAND_ERR_MSG,
new_cmd );
wperror( L"access" );
+ }
}
}
}
@@ -814,8 +820,10 @@ static void print_profile( array_list_t *p,
int my_time;
if( pos >= al_get_count( p ) )
+ {
return;
-
+ }
+
me= (profile_element_t *)al_get( p, pos );
if( !me->skipped )
{
@@ -825,12 +833,20 @@ static void print_profile( array_list_t *p,
{
prev = (profile_element_t *)al_get( p, i );
if( prev->skipped )
+ {
continue;
-
+ }
+
if( prev->level <= me->level )
+ {
break;
+ }
+
if( prev->level > me->level+1 )
+ {
continue;
+ }
+
my_time -= prev->parse;
my_time -= prev->exec;
}
@@ -931,26 +947,20 @@ int eval_args( const wchar_t *line, array_list_t *args )
switch(tok_last_type( &tok ) )
{
case TOK_STRING:
- switch( expand_string( 0, wcsdup(tok_last( &tok )), args, 0 ) )
+ {
+ if( expand_string( 0, wcsdup(tok_last( &tok )), args, 0 ) == EXPAND_ERROR )
{
- case EXPAND_ERROR:
- {
- err_pos=tok_get_pos( &tok );
- do_loop=0;
- break;
- }
-
- default:
- {
- break;
- }
-
+ err_pos=tok_get_pos( &tok );
+ do_loop=0;
}
-
break;
+ }
+
case TOK_END:
+ {
break;
-
+ }
+
case TOK_ERROR:
{
error( SYNTAX_ERROR,
@@ -963,6 +973,7 @@ int eval_args( const wchar_t *line, array_list_t *args )
}
default:
+ {
error( SYNTAX_ERROR,
tok_get_pos( &tok ),
UNEXPECTED_TOKEN_ERR_MSG,
@@ -970,6 +981,7 @@ int eval_args( const wchar_t *line, array_list_t *args )
do_loop=0;
break;
+ }
}
}
@@ -1003,27 +1015,37 @@ void parser_stack_trace( block_t *b, string_buffer_t *buff)
switch( b->type)
{
case SOURCE:
+ {
sb_printf( buff, _(L"in . (source) call of file '%ls',\n"), b->param1.source_dest );
break;
+ }
case FUNCTION_CALL:
+ {
sb_printf( buff, _(L"in function '%ls',\n"), b->param1.function_name );
break;
+ }
case SUBST:
+ {
sb_printf( buff, _(L"in command substitution\n") );
break;
+ }
}
const wchar_t *file = b->src_filename;
if( file )
+ {
sb_printf( buff,
_(L"\tcalled on line %d of file '%ls',\n"),
b->src_lineno,
file );
+ }
else
+ {
sb_printf( buff,
_(L"\tcalled on standard input,\n") );
-
+ }
+
if( b->type == FUNCTION_CALL )
{
if( b->param2.function_call_process->argv[1] )
@@ -1975,7 +1997,7 @@ static int parse_job( process_t *p,
current_tokenizer_pos = tok_get_pos(tok);
fwprintf( stderr, L"%ls", parser_current_line() );
-
+
current_tokenizer_pos=tmp;
j->skip=1;
diff --git a/proc.h b/proc.h
index 405d4d45..98b365b0 100644
--- a/proc.h
+++ b/proc.h
@@ -298,7 +298,6 @@ int job_reap( int interactive );
*/
void job_handle_signal( int signal, siginfo_t *info, void *con );
-
#ifdef HAVE__PROC_SELF_STAT
/**
Use the procfs filesystem to look up how many jiffies of cpu time