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:
axel 2006-07-21 11:08:31 +10:00
parent 8c4708b51e
commit e280d10033
5 changed files with 66 additions and 37 deletions

View file

@ -47,9 +47,10 @@ docdir = @docdir@
localedir = @localedir@
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@
LDFLAGS:= @LIBS@ @LDFLAGS@
LDFLAGS= @LIBS@ @LDFLAGS@
#etc files to install
@ -198,7 +199,7 @@ Makefile: Makefile.in configure
./config.status
debug:
make fish CFLAGS="@CFLAGS@ -O0 -Wno-unused -Werror -g"
make fish CFLAGS="@CFLAGS@ $(MACROS) -O0 -Wno-unused -Werror -g"
.PHONY: debug
# User documentation, describing the features of the fish shell.

View file

@ -595,11 +595,8 @@ static int expand_pid( wchar_t *in,
array_list_t *out )
{
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 );
if( *in != PROCESS_EXPAND )
{
@ -771,11 +768,8 @@ static int expand_variables( wchar_t *in, array_list_t *out, int last_idx )
static string_buffer_t *var_tmp = 0;
static array_list_t *var_idx_list = 0;
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 );
if( !var_tmp )
{
@ -1065,11 +1059,8 @@ static int expand_brackets( wchar_t *in, int flags, array_list_t *out )
wchar_t *item_begin;
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;
(*pos) && !syntax_error;
@ -1201,11 +1192,8 @@ static int expand_subshell( wchar_t *in, array_list_t *out )
int i, j;
const wchar_t *item_begin;
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 );
switch( parse_util_locate_cmdsubst(in,
&paran_begin,
@ -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 )
{
CHECK( in, 0 );
if( in[0] == HOME_DIRECTORY )
{
int tilde_error = 0;
@ -1394,13 +1384,15 @@ wchar_t *expand_tilde( wchar_t *in)
/**
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 )
{
wchar_t *in = (wchar_t *)s;
wchar_t *out=in;
CHECK( s, );
while( *in )
{
switch( *in )

View file

@ -2,6 +2,10 @@
This file only contains fallback implementations of functions which
have been found to be missing or broken by the configuration
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"
@ -65,7 +69,11 @@ int tputs(const char *str, int affcnt, int (*fish_putc)(tputs_arg_t))
#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;

View file

@ -1372,7 +1372,8 @@ wchar_t *parser_current_line()
// 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()) )
{
@ -1696,8 +1697,9 @@ static void parse_job_main_loop( process_t *p,
tok_last( tok ) );
}
}
break;
}
default:
error( SYNTAX_ERROR,
tok_get_pos( tok ),
@ -1738,6 +1740,7 @@ static void parse_job_main_loop( process_t *p,
break;
case TOK_REDIRECT_FD:
{
if( wcscmp( target, L"-" ) == 0 )
{
new_io->io_mode = IO_CLOSE;
@ -1761,6 +1764,8 @@ static void parse_job_main_loop( process_t *p,
}
break;
}
}
}
j->io = io_add( j->io, new_io );
@ -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.
@ -2757,7 +2763,7 @@ static const wchar_t *parser_get_block_command( int type )
/**
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.
*/
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;
static int block_pos[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;
/*
Set to one if the currently specified process can not be used inside a pipeline
*/
int forbid_pipeline = 0;
/*
Set to one if an additional process specification is needed
*/
int needs_cmd=0;
/*
halloc context used for calls to expand() and other memory
allocations. Free'd at end of this function.
*/
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;
/*
The currently validated command.
*/
wchar_t *cmd=0;
CHECK( buff, 1 );

View file

@ -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)
{
char *tmp =wutil_wcs2str(pathname);
char narrow[PATH_MAX];
char *narrow_res = realpath( tmp, narrow );
char *tmp = wutil_wcs2str(pathname);
char narrow_buff[PATH_MAX];
char *narrow_res = realpath( tmp, narrow_buff );
wchar_t *res;
if( !narrow_res )
@ -466,7 +466,7 @@ static void wgettext_init()
wgettext_is_init = 1;
for(i=0; i<BUFF_COUNT; i++ )
for( i=0; i<BUFF_COUNT; i++ )
{
sb_init( &buff[i] );
}