mirror of
https://github.com/fish-shell/fish-shell
synced 2024-11-11 07:34:32 +00:00
Use cpp macro to avoid manually adding sentinel value to varargs functions
darcs-hash:20070416214041-ac50b-f682569c0d29ab3519bb59335debba525a640175.gz
This commit is contained in:
parent
2efb88a30a
commit
91ca8610ee
4 changed files with 51 additions and 56 deletions
2
common.h
2
common.h
|
@ -140,6 +140,8 @@ extern wchar_t *program_name;
|
|||
*/
|
||||
#define N_(wstr) wstr
|
||||
|
||||
#define CONTAINS( str,... ) contains_str( str, __VA_ARGS__, (void *)0 )
|
||||
|
||||
/*
|
||||
Print a stack trace to stderr
|
||||
*/
|
||||
|
|
99
parser.c
99
parser.c
|
@ -519,10 +519,9 @@ const wchar_t *parser_get_block_desc( int block )
|
|||
*/
|
||||
static int parser_skip_arguments( const wchar_t *cmd )
|
||||
{
|
||||
return contains_str( cmd,
|
||||
L"else",
|
||||
L"begin",
|
||||
(void *)0 );
|
||||
return CONTAINS( cmd,
|
||||
L"else",
|
||||
L"begin" );
|
||||
}
|
||||
|
||||
int parser_is_switch( const wchar_t *cmd )
|
||||
|
@ -538,42 +537,40 @@ int parser_is_subcommand( const wchar_t *cmd )
|
|||
{
|
||||
|
||||
return parser_skip_arguments( cmd ) ||
|
||||
contains_str( cmd,
|
||||
L"command",
|
||||
L"builtin",
|
||||
L"while",
|
||||
L"exec",
|
||||
L"if",
|
||||
L"and",
|
||||
L"or",
|
||||
L"not",
|
||||
(void *)0 );
|
||||
CONTAINS( cmd,
|
||||
L"command",
|
||||
L"builtin",
|
||||
L"while",
|
||||
L"exec",
|
||||
L"if",
|
||||
L"and",
|
||||
L"or",
|
||||
L"not" );
|
||||
|
||||
}
|
||||
|
||||
int parser_is_block( const wchar_t *word)
|
||||
{
|
||||
return contains_str( word,
|
||||
L"for",
|
||||
L"while",
|
||||
L"if",
|
||||
L"function",
|
||||
L"switch",
|
||||
L"begin",
|
||||
(void *)0 );
|
||||
return CONTAINS( word,
|
||||
L"for",
|
||||
L"while",
|
||||
L"if",
|
||||
L"function",
|
||||
L"switch",
|
||||
L"begin" );
|
||||
}
|
||||
|
||||
int parser_is_reserved( const wchar_t *word)
|
||||
{
|
||||
return parser_is_block(word) ||
|
||||
parser_is_subcommand( word ) ||
|
||||
contains_str( word,
|
||||
L"end",
|
||||
L"case",
|
||||
L"else",
|
||||
L"return",
|
||||
L"continue",
|
||||
L"break",
|
||||
(void *)0 );
|
||||
CONTAINS( word,
|
||||
L"end",
|
||||
L"case",
|
||||
L"else",
|
||||
L"return",
|
||||
L"continue",
|
||||
L"break" );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -581,13 +578,12 @@ int parser_is_reserved( const wchar_t *word)
|
|||
*/
|
||||
static int parser_is_pipe_forbidden( wchar_t *word )
|
||||
{
|
||||
return contains_str( word,
|
||||
L"exec",
|
||||
L"case",
|
||||
L"break",
|
||||
L"return",
|
||||
L"continue",
|
||||
(void *)0 );
|
||||
return CONTAINS( word,
|
||||
L"exec",
|
||||
L"case",
|
||||
L"break",
|
||||
L"return",
|
||||
L"continue" );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1827,14 +1823,13 @@ static int parse_job( process_t *p,
|
|||
|
||||
mark = tok_get_pos( tok );
|
||||
|
||||
if( contains_str( nxt,
|
||||
L"command",
|
||||
L"builtin",
|
||||
L"not",
|
||||
L"and",
|
||||
L"or",
|
||||
L"exec",
|
||||
(void *)0 ) )
|
||||
if( CONTAINS( nxt,
|
||||
L"command",
|
||||
L"builtin",
|
||||
L"not",
|
||||
L"and",
|
||||
L"or",
|
||||
L"exec" ) )
|
||||
{
|
||||
int sw;
|
||||
int is_exec = (wcscmp( L"exec", nxt )==0);
|
||||
|
@ -3005,9 +3000,8 @@ int parser_test( const wchar_t * buff,
|
|||
command is needed, such as after 'and' or
|
||||
'while'
|
||||
*/
|
||||
if( contains_str( cmd,
|
||||
L"end",
|
||||
(void *)0 ) )
|
||||
if( CONTAINS( cmd,
|
||||
L"end" ) )
|
||||
{
|
||||
err=1;
|
||||
if( out )
|
||||
|
@ -3080,10 +3074,9 @@ int parser_test( const wchar_t * buff,
|
|||
had_cmd = 0;
|
||||
}
|
||||
|
||||
if( contains_str( cmd,
|
||||
L"or",
|
||||
L"and",
|
||||
(void *)0 ) )
|
||||
if( CONTAINS( cmd,
|
||||
L"or",
|
||||
L"and" ) )
|
||||
{
|
||||
/*
|
||||
'or' and 'and' can not be used inside pipelines
|
||||
|
@ -3215,7 +3208,7 @@ int parser_test( const wchar_t * buff,
|
|||
/*
|
||||
Test that break and continue are only used within loop blocks
|
||||
*/
|
||||
if( contains_str( cmd, L"break", L"continue", (void *)0 ) )
|
||||
if( CONTAINS( cmd, L"break", L"continue" ) )
|
||||
{
|
||||
int found_loop=0;
|
||||
int i;
|
||||
|
|
2
path.c
2
path.c
|
@ -52,7 +52,7 @@ wchar_t *path_get_path( void *context, const wchar_t *cmd )
|
|||
path = env_get(L"PATH");
|
||||
if( path == 0 )
|
||||
{
|
||||
if( contains_str( PREFIX L"/bin", L"/bin", L"/usr/bin", (void *)0 ) )
|
||||
if( CONTAINS( PREFIX L"/bin", L"/bin", L"/usr/bin" ) )
|
||||
{
|
||||
path = L"/bin" ARRAY_SEP_STR L"/usr/bin";
|
||||
}
|
||||
|
|
4
reader.c
4
reader.c
|
@ -553,11 +553,11 @@ void reader_write_title()
|
|||
don't. Since we can't see the underlying terminal below screen
|
||||
there is no way to fix this.
|
||||
*/
|
||||
if( !term || !contains_str( term, L"xterm", L"screen", L"nxterm", L"rxvt", (wchar_t *)0 ) )
|
||||
if( !term || !CONTAINS( term, L"xterm", L"screen", L"nxterm", L"rxvt" ) )
|
||||
{
|
||||
char *n = ttyname( STDIN_FILENO );
|
||||
|
||||
if( contains_str( term, L"linux", (void *)0 ) )
|
||||
if( CONTAINS( term, L"linux" ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue