Minor code edits - add a few braces, a few minor safety checks, etc.

darcs-hash:20060608235719-ac50b-bec405da5ae101ff50bb3390bb83ef8b0948e4e9.gz
This commit is contained in:
axel 2006-06-09 09:57:19 +10:00
parent 5855f78010
commit af8cb6fe87
2 changed files with 20 additions and 5 deletions

View file

@ -1902,7 +1902,10 @@ static int builtin_exit( wchar_t **argv )
switch( argc ) switch( argc )
{ {
case 1: case 1:
{
break; break;
}
case 2: case 2:
{ {
wchar_t *end; wchar_t *end;
@ -1921,13 +1924,15 @@ static int builtin_exit( wchar_t **argv )
} }
default: default:
{
sb_printf( sb_err, sb_printf( sb_err,
BUILTIN_ERR_TOO_MANY_ARGUMENTS, BUILTIN_ERR_TOO_MANY_ARGUMENTS,
argv[0] ); argv[0] );
builtin_print_help( argv[0], sb_err ); builtin_print_help( argv[0], sb_err );
return 1; return 1;
}
} }
reader_exit( 1, 0 ); reader_exit( 1, 0 );
return ec; return ec;
@ -1983,10 +1988,12 @@ static int builtin_cd( wchar_t **argv )
argv[0], argv[0],
dir_in ); dir_in );
if( !is_interactive ) if( !is_interactive )
{
sb_append2( sb_err, sb_append2( sb_err,
parser_current_line(), parser_current_line(),
(void *)0 ); (void *)0 );
}
return 1; return 1;
} }
@ -1997,9 +2004,11 @@ static int builtin_cd( wchar_t **argv )
argv[0], argv[0],
dir ); dir );
if( !is_interactive ) if( !is_interactive )
{
sb_append2( sb_err, sb_append2( sb_err,
parser_current_line(), parser_current_line(),
(void *)0 ); (void *)0 );
}
free( dir ); free( dir );
@ -2116,7 +2125,9 @@ static void make_first( job_t *j )
if( curr == j ) if( curr == j )
{ {
if( prev == 0 ) if( prev == 0 )
{
return; return;
}
else else
{ {
prev->next = curr->next; prev->next = curr->next;
@ -2144,7 +2155,9 @@ static int builtin_fg( wchar_t **argv )
{ {
if( j->constructed && (!job_is_completed(j)) && if( j->constructed && (!job_is_completed(j)) &&
( (job_is_stopped(j) || !j->fg) && (j->job_control) ) ) ( (job_is_stopped(j) || !j->fg) && (j->job_control) ) )
{
break; break;
}
} }
if( !j ) if( !j )
{ {
@ -2307,9 +2320,11 @@ static int builtin_bg( wchar_t **argv )
for( j=first_job; j; j=j->next ) for( j=first_job; j; j=j->next )
{ {
if( job_is_stopped(j) && j->job_control && (!job_is_completed(j)) ) if( job_is_stopped(j) && j->job_control && (!job_is_completed(j)) )
{
break; break;
}
} }
if( !j ) if( !j )
{ {
sb_printf( sb_err, sb_printf( sb_err,

View file

@ -76,7 +76,7 @@ The fish parser. Contains functions for parsing code.
/** /**
Error message for short circuit command error. Error message for short circuit command error.
*/ */
#define COND_ERR_MSG _( L"Pipe or short circuit command requires additional command") #define COND_ERR_MSG _( L"An additional command is required" )
/** /**
Error message on reaching maximum recusrion depth Error message on reaching maximum recusrion depth
@ -1232,7 +1232,7 @@ static int printed_width( const wchar_t *str, int len )
{ {
int res=0; int res=0;
int i; int i;
for( i=0; i<len; i++ ) for( i=0; str[i] && i<len; i++ )
{ {
if( str[i] == L'\t' ) if( str[i] == L'\t' )
{ {