mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-31 20:31:19 -03:00
Use cpp macro to avoid manually adding sentinel value to varargs functions
darcs-hash:20070416214041-ac50b-f682569c0d29ab3519bb59335debba525a640175.gz
This commit is contained in:
2
common.h
2
common.h
@@ -140,6 +140,8 @@ extern wchar_t *program_name;
|
|||||||
*/
|
*/
|
||||||
#define N_(wstr) wstr
|
#define N_(wstr) wstr
|
||||||
|
|
||||||
|
#define CONTAINS( str,... ) contains_str( str, __VA_ARGS__, (void *)0 )
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Print a stack trace to stderr
|
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 )
|
static int parser_skip_arguments( const wchar_t *cmd )
|
||||||
{
|
{
|
||||||
return contains_str( cmd,
|
return CONTAINS( cmd,
|
||||||
L"else",
|
L"else",
|
||||||
L"begin",
|
L"begin" );
|
||||||
(void *)0 );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int parser_is_switch( const wchar_t *cmd )
|
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 ) ||
|
return parser_skip_arguments( cmd ) ||
|
||||||
contains_str( cmd,
|
CONTAINS( cmd,
|
||||||
L"command",
|
L"command",
|
||||||
L"builtin",
|
L"builtin",
|
||||||
L"while",
|
L"while",
|
||||||
L"exec",
|
L"exec",
|
||||||
L"if",
|
L"if",
|
||||||
L"and",
|
L"and",
|
||||||
L"or",
|
L"or",
|
||||||
L"not",
|
L"not" );
|
||||||
(void *)0 );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int parser_is_block( const wchar_t *word)
|
int parser_is_block( const wchar_t *word)
|
||||||
{
|
{
|
||||||
return contains_str( word,
|
return CONTAINS( word,
|
||||||
L"for",
|
L"for",
|
||||||
L"while",
|
L"while",
|
||||||
L"if",
|
L"if",
|
||||||
L"function",
|
L"function",
|
||||||
L"switch",
|
L"switch",
|
||||||
L"begin",
|
L"begin" );
|
||||||
(void *)0 );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int parser_is_reserved( const wchar_t *word)
|
int parser_is_reserved( const wchar_t *word)
|
||||||
{
|
{
|
||||||
return parser_is_block(word) ||
|
return parser_is_block(word) ||
|
||||||
parser_is_subcommand( word ) ||
|
parser_is_subcommand( word ) ||
|
||||||
contains_str( word,
|
CONTAINS( word,
|
||||||
L"end",
|
L"end",
|
||||||
L"case",
|
L"case",
|
||||||
L"else",
|
L"else",
|
||||||
L"return",
|
L"return",
|
||||||
L"continue",
|
L"continue",
|
||||||
L"break",
|
L"break" );
|
||||||
(void *)0 );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -581,13 +578,12 @@ int parser_is_reserved( const wchar_t *word)
|
|||||||
*/
|
*/
|
||||||
static int parser_is_pipe_forbidden( wchar_t *word )
|
static int parser_is_pipe_forbidden( wchar_t *word )
|
||||||
{
|
{
|
||||||
return contains_str( word,
|
return CONTAINS( word,
|
||||||
L"exec",
|
L"exec",
|
||||||
L"case",
|
L"case",
|
||||||
L"break",
|
L"break",
|
||||||
L"return",
|
L"return",
|
||||||
L"continue",
|
L"continue" );
|
||||||
(void *)0 );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1827,14 +1823,13 @@ static int parse_job( process_t *p,
|
|||||||
|
|
||||||
mark = tok_get_pos( tok );
|
mark = tok_get_pos( tok );
|
||||||
|
|
||||||
if( contains_str( nxt,
|
if( CONTAINS( nxt,
|
||||||
L"command",
|
L"command",
|
||||||
L"builtin",
|
L"builtin",
|
||||||
L"not",
|
L"not",
|
||||||
L"and",
|
L"and",
|
||||||
L"or",
|
L"or",
|
||||||
L"exec",
|
L"exec" ) )
|
||||||
(void *)0 ) )
|
|
||||||
{
|
{
|
||||||
int sw;
|
int sw;
|
||||||
int is_exec = (wcscmp( L"exec", nxt )==0);
|
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
|
command is needed, such as after 'and' or
|
||||||
'while'
|
'while'
|
||||||
*/
|
*/
|
||||||
if( contains_str( cmd,
|
if( CONTAINS( cmd,
|
||||||
L"end",
|
L"end" ) )
|
||||||
(void *)0 ) )
|
|
||||||
{
|
{
|
||||||
err=1;
|
err=1;
|
||||||
if( out )
|
if( out )
|
||||||
@@ -3080,10 +3074,9 @@ int parser_test( const wchar_t * buff,
|
|||||||
had_cmd = 0;
|
had_cmd = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( contains_str( cmd,
|
if( CONTAINS( cmd,
|
||||||
L"or",
|
L"or",
|
||||||
L"and",
|
L"and" ) )
|
||||||
(void *)0 ) )
|
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
'or' and 'and' can not be used inside pipelines
|
'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
|
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 found_loop=0;
|
||||||
int i;
|
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");
|
path = env_get(L"PATH");
|
||||||
if( path == 0 )
|
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";
|
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
|
don't. Since we can't see the underlying terminal below screen
|
||||||
there is no way to fix this.
|
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 );
|
char *n = ttyname( STDIN_FILENO );
|
||||||
|
|
||||||
if( contains_str( term, L"linux", (void *)0 ) )
|
if( CONTAINS( term, L"linux" ) )
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user