mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-27 20:25:12 +00:00
Minor code edits. Use CHECK instead of a few error messages, add a few comments, etc.
darcs-hash:20060721010831-ac50b-e9ad82a3885969f9a43e6219523e2bd1867e26ed.gz
This commit is contained in:
parent
8c4708b51e
commit
e280d10033
5 changed files with 66 additions and 37 deletions
|
@ -47,9 +47,10 @@ docdir = @docdir@
|
||||||
localedir = @localedir@
|
localedir = @localedir@
|
||||||
prefix = @prefix@
|
prefix = @prefix@
|
||||||
|
|
||||||
CFLAGS:=@CFLAGS@ -DLOCALEDIR=\"$(localedir)\" -DPREFIX=L\"$(prefix)\" -DDATADIR=L\"$(datadir)\" -DSYSCONFDIR=L\"$(sysconfdir)\"
|
MACROS=-DLOCALEDIR=\"$(localedir)\" -DPREFIX=L\"$(prefix)\" -DDATADIR=L\"$(datadir)\" -DSYSCONFDIR=L\"$(sysconfdir)\"
|
||||||
|
CFLAGS=@CFLAGS@ $(MACROS)
|
||||||
CPPFLAGS=@CPPFLAGS@
|
CPPFLAGS=@CPPFLAGS@
|
||||||
LDFLAGS:= @LIBS@ @LDFLAGS@
|
LDFLAGS= @LIBS@ @LDFLAGS@
|
||||||
|
|
||||||
|
|
||||||
#etc files to install
|
#etc files to install
|
||||||
|
@ -198,7 +199,7 @@ Makefile: Makefile.in configure
|
||||||
./config.status
|
./config.status
|
||||||
|
|
||||||
debug:
|
debug:
|
||||||
make fish CFLAGS="@CFLAGS@ -O0 -Wno-unused -Werror -g"
|
make fish CFLAGS="@CFLAGS@ $(MACROS) -O0 -Wno-unused -Werror -g"
|
||||||
.PHONY: debug
|
.PHONY: debug
|
||||||
|
|
||||||
# User documentation, describing the features of the fish shell.
|
# User documentation, describing the features of the fish shell.
|
||||||
|
|
42
expand.c
42
expand.c
|
@ -595,12 +595,9 @@ static int expand_pid( wchar_t *in,
|
||||||
array_list_t *out )
|
array_list_t *out )
|
||||||
{
|
{
|
||||||
|
|
||||||
if( !in || !out)
|
CHECK( in, 0 );
|
||||||
{
|
CHECK( out, 0 );
|
||||||
debug( 2, L"Got null string on line %d of file %s", __LINE__, __FILE__ );
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( *in != PROCESS_EXPAND )
|
if( *in != PROCESS_EXPAND )
|
||||||
{
|
{
|
||||||
al_push( out, in );
|
al_push( out, in );
|
||||||
|
@ -771,12 +768,9 @@ static int expand_variables( wchar_t *in, array_list_t *out, int last_idx )
|
||||||
static string_buffer_t *var_tmp = 0;
|
static string_buffer_t *var_tmp = 0;
|
||||||
static array_list_t *var_idx_list = 0;
|
static array_list_t *var_idx_list = 0;
|
||||||
|
|
||||||
if( !in || !out)
|
CHECK( in, 0 );
|
||||||
{
|
CHECK( out, 0 );
|
||||||
debug( 2, L"Got null string on line %d of file %s", __LINE__, __FILE__ );
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( !var_tmp )
|
if( !var_tmp )
|
||||||
{
|
{
|
||||||
var_tmp = sb_halloc( global_context );
|
var_tmp = sb_halloc( global_context );
|
||||||
|
@ -1064,13 +1058,10 @@ static int expand_brackets( wchar_t *in, int flags, array_list_t *out )
|
||||||
|
|
||||||
wchar_t *item_begin;
|
wchar_t *item_begin;
|
||||||
int len1, len2, tot_len;
|
int len1, len2, tot_len;
|
||||||
|
|
||||||
if( !in || !out)
|
|
||||||
{
|
|
||||||
debug( 2, L"Got null string on line %d of file %s", __LINE__, __FILE__ );
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
CHECK( in, 0 );
|
||||||
|
CHECK( out, 0 );
|
||||||
|
|
||||||
for( pos=in;
|
for( pos=in;
|
||||||
(*pos) && !syntax_error;
|
(*pos) && !syntax_error;
|
||||||
pos++ )
|
pos++ )
|
||||||
|
@ -1201,12 +1192,9 @@ static int expand_subshell( wchar_t *in, array_list_t *out )
|
||||||
int i, j;
|
int i, j;
|
||||||
const wchar_t *item_begin;
|
const wchar_t *item_begin;
|
||||||
|
|
||||||
if( !in || !out)
|
CHECK( in, 0 );
|
||||||
{
|
CHECK( out, 0 );
|
||||||
debug( 2, L"Got null string on line %d of file %s", __LINE__, __FILE__ );
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch( parse_util_locate_cmdsubst(in,
|
switch( parse_util_locate_cmdsubst(in,
|
||||||
¶n_begin,
|
¶n_begin,
|
||||||
¶n_end,
|
¶n_end,
|
||||||
|
@ -1308,6 +1296,8 @@ static wchar_t *expand_unescape( const wchar_t * in, int escape_special )
|
||||||
static wchar_t * expand_tilde_internal( wchar_t *in )
|
static wchar_t * expand_tilde_internal( wchar_t *in )
|
||||||
{
|
{
|
||||||
|
|
||||||
|
CHECK( in, 0 );
|
||||||
|
|
||||||
if( in[0] == HOME_DIRECTORY )
|
if( in[0] == HOME_DIRECTORY )
|
||||||
{
|
{
|
||||||
int tilde_error = 0;
|
int tilde_error = 0;
|
||||||
|
@ -1394,12 +1384,14 @@ wchar_t *expand_tilde( wchar_t *in)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Remove any internal separators. Also optionally convert wildcard characters to
|
Remove any internal separators. Also optionally convert wildcard characters to
|
||||||
regular equivalents. This is done to support EXPAN_SKIP_WILDCARDS.
|
regular equivalents. This is done to support EXPAND_SKIP_WILDCARDS.
|
||||||
*/
|
*/
|
||||||
static void remove_internal_separator( const void *s, int conv )
|
static void remove_internal_separator( const void *s, int conv )
|
||||||
{
|
{
|
||||||
wchar_t *in = (wchar_t *)s;
|
wchar_t *in = (wchar_t *)s;
|
||||||
wchar_t *out=in;
|
wchar_t *out=in;
|
||||||
|
|
||||||
|
CHECK( s, );
|
||||||
|
|
||||||
while( *in )
|
while( *in )
|
||||||
{
|
{
|
||||||
|
|
10
fallback.c
10
fallback.c
|
@ -2,6 +2,10 @@
|
||||||
This file only contains fallback implementations of functions which
|
This file only contains fallback implementations of functions which
|
||||||
have been found to be missing or broken by the configuration
|
have been found to be missing or broken by the configuration
|
||||||
scripts.
|
scripts.
|
||||||
|
|
||||||
|
Many of these functions are more or less broken and
|
||||||
|
incomplete. lrand28_r internally uses the regular (bad) rand_r
|
||||||
|
function, the gettext function doesn't actually do anything, etc.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
@ -65,7 +69,11 @@ int tputs(const char *str, int affcnt, int (*fish_putc)(tputs_arg_t))
|
||||||
|
|
||||||
#ifdef INTERNAL_FWPRINTF
|
#ifdef INTERNAL_FWPRINTF
|
||||||
|
|
||||||
void pad( void (*writer)(wchar_t), int count)
|
/**
|
||||||
|
Internal function for the wprintf fallbacks. USed to write the
|
||||||
|
specified number of spaces.
|
||||||
|
*/
|
||||||
|
static void pad( void (*writer)(wchar_t), int count)
|
||||||
{
|
{
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
|
|
36
parser.c
36
parser.c
|
@ -1372,7 +1372,8 @@ wchar_t *parser_current_line()
|
||||||
// lineno = current_tokenizer_pos;
|
// lineno = current_tokenizer_pos;
|
||||||
|
|
||||||
|
|
||||||
current_line_width=printed_width(whole_str+current_line_start, current_tokenizer_pos-current_line_start );
|
current_line_width=printed_width( whole_str+current_line_start,
|
||||||
|
current_tokenizer_pos-current_line_start );
|
||||||
|
|
||||||
if( (function_name = is_function()) )
|
if( (function_name = is_function()) )
|
||||||
{
|
{
|
||||||
|
@ -1696,8 +1697,9 @@ static void parse_job_main_loop( process_t *p,
|
||||||
tok_last( tok ) );
|
tok_last( tok ) );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
error( SYNTAX_ERROR,
|
error( SYNTAX_ERROR,
|
||||||
tok_get_pos( tok ),
|
tok_get_pos( tok ),
|
||||||
|
@ -1738,6 +1740,7 @@ static void parse_job_main_loop( process_t *p,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TOK_REDIRECT_FD:
|
case TOK_REDIRECT_FD:
|
||||||
|
{
|
||||||
if( wcscmp( target, L"-" ) == 0 )
|
if( wcscmp( target, L"-" ) == 0 )
|
||||||
{
|
{
|
||||||
new_io->io_mode = IO_CLOSE;
|
new_io->io_mode = IO_CLOSE;
|
||||||
|
@ -1760,6 +1763,8 @@ static void parse_job_main_loop( process_t *p,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1820,6 +1825,7 @@ static void parse_job_main_loop( process_t *p,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Fully parse a single job. Does not call exec on it, but any command substitutions in the job will be executed.
|
Fully parse a single job. Does not call exec on it, but any command substitutions in the job will be executed.
|
||||||
|
|
||||||
|
@ -2065,7 +2071,7 @@ static int parse_job( process_t *p,
|
||||||
*/
|
*/
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( use_function && !current_block->skip )
|
if( use_function && !current_block->skip )
|
||||||
{
|
{
|
||||||
int nxt_forbidden;
|
int nxt_forbidden;
|
||||||
|
@ -2757,7 +2763,7 @@ static const wchar_t *parser_get_block_command( int type )
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Test if this argument contains any errors. Detected errors include
|
Test if this argument contains any errors. Detected errors include
|
||||||
syntax errors in command substitutions, imporoper escaped
|
syntax errors in command substitutions, improperly escaped
|
||||||
characters and improper use of the variable expansion operator.
|
characters and improper use of the variable expansion operator.
|
||||||
*/
|
*/
|
||||||
static int parser_test_argument( const wchar_t *arg, string_buffer_t *out, const wchar_t *prefix, int offset )
|
static int parser_test_argument( const wchar_t *arg, string_buffer_t *out, const wchar_t *prefix, int offset )
|
||||||
|
@ -2967,17 +2973,39 @@ int parser_test( const wchar_t * buff,
|
||||||
int previous_pos=current_tokenizer_pos;
|
int previous_pos=current_tokenizer_pos;
|
||||||
static int block_pos[BLOCK_MAX_COUNT];
|
static int block_pos[BLOCK_MAX_COUNT];
|
||||||
static int block_type[BLOCK_MAX_COUNT];
|
static int block_type[BLOCK_MAX_COUNT];
|
||||||
|
|
||||||
|
/*
|
||||||
|
Set to 1 if the current command is inside a pipeline
|
||||||
|
*/
|
||||||
int is_pipeline = 0;
|
int is_pipeline = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Set to one if the currently specified process can not be used inside a pipeline
|
Set to one if the currently specified process can not be used inside a pipeline
|
||||||
*/
|
*/
|
||||||
int forbid_pipeline = 0;
|
int forbid_pipeline = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Set to one if an additional process specification is needed
|
Set to one if an additional process specification is needed
|
||||||
*/
|
*/
|
||||||
int needs_cmd=0;
|
int needs_cmd=0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
halloc context used for calls to expand() and other memory
|
||||||
|
allocations. Free'd at end of this function.
|
||||||
|
*/
|
||||||
void *context;
|
void *context;
|
||||||
|
|
||||||
|
/*
|
||||||
|
Counter on the number of arguments this function has encountered
|
||||||
|
so far. Is set to -1 when the count is unknown, i.e. after
|
||||||
|
encountering an argument that contains substitutions that can
|
||||||
|
expand to more/less arguemtns then 1.
|
||||||
|
*/
|
||||||
int arg_count=0;
|
int arg_count=0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
The currently validated command.
|
||||||
|
*/
|
||||||
wchar_t *cmd=0;
|
wchar_t *cmd=0;
|
||||||
|
|
||||||
CHECK( buff, 1 );
|
CHECK( buff, 1 );
|
||||||
|
|
8
wutil.c
8
wutil.c
|
@ -378,9 +378,9 @@ wchar_t *wrealpath(const wchar_t *pathname, wchar_t *resolved_path)
|
||||||
|
|
||||||
wchar_t *wrealpath(const wchar_t *pathname, wchar_t *resolved_path)
|
wchar_t *wrealpath(const wchar_t *pathname, wchar_t *resolved_path)
|
||||||
{
|
{
|
||||||
char *tmp =wutil_wcs2str(pathname);
|
char *tmp = wutil_wcs2str(pathname);
|
||||||
char narrow[PATH_MAX];
|
char narrow_buff[PATH_MAX];
|
||||||
char *narrow_res = realpath( tmp, narrow );
|
char *narrow_res = realpath( tmp, narrow_buff );
|
||||||
wchar_t *res;
|
wchar_t *res;
|
||||||
|
|
||||||
if( !narrow_res )
|
if( !narrow_res )
|
||||||
|
@ -466,7 +466,7 @@ static void wgettext_init()
|
||||||
|
|
||||||
wgettext_is_init = 1;
|
wgettext_is_init = 1;
|
||||||
|
|
||||||
for(i=0; i<BUFF_COUNT; i++ )
|
for( i=0; i<BUFF_COUNT; i++ )
|
||||||
{
|
{
|
||||||
sb_init( &buff[i] );
|
sb_init( &buff[i] );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue