mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-13 13:39:02 +00:00
Minor edits
darcs-hash:20051008020008-ac50b-401f0e36582075d177afb2f1573c765c572f1a97.gz
This commit is contained in:
parent
29d43269ee
commit
929519cb0f
3 changed files with 33 additions and 8 deletions
10
common.c
10
common.c
|
@ -275,7 +275,7 @@ void error_reset()
|
|||
char *wcs2str( const wchar_t *in )
|
||||
{
|
||||
c5++;
|
||||
|
||||
|
||||
char *res = malloc( MAX_UTF8_BYTES*wcslen(in)+1 );
|
||||
if( res == 0 )
|
||||
{
|
||||
|
@ -317,7 +317,7 @@ char **wcsv2strv( const wchar_t **in )
|
|||
wchar_t *wcsdupcat( const wchar_t *a, const wchar_t *b )
|
||||
{
|
||||
c1++;
|
||||
|
||||
|
||||
return wcsdupcat2( a, b, 0 );
|
||||
}
|
||||
|
||||
|
@ -580,13 +580,15 @@ wcslcpy(wchar_t *dst, const wchar_t *src, size_t siz)
|
|||
|
||||
wchar_t *wcsdup( const wchar_t *in )
|
||||
{
|
||||
wchar_t *out = malloc( sizeof( wchar_t)*(wcslen(in)+1));
|
||||
size_t len=wcslen(in);
|
||||
wchar_t *out = malloc( sizeof( wchar_t)*(len+1));
|
||||
if( out == 0 )
|
||||
{
|
||||
die_mem();
|
||||
|
||||
}
|
||||
wcscpy( out, in );
|
||||
|
||||
memcpy( out, in, sizeof( wchar_t)*(len+1));
|
||||
return out;
|
||||
|
||||
}
|
||||
|
|
21
parser.c
21
parser.c
|
@ -72,6 +72,9 @@ The fish parser. Contains functions for parsing code.
|
|||
*/
|
||||
#define RECURSION_ERR_MSG L"Maximum recursion depth reached. Accidental infinite loop?"
|
||||
|
||||
/**
|
||||
Error message used when the end of a block can't be located
|
||||
*/
|
||||
#define BLOCK_END_ERR_MSG L"Could not locate end of block. The 'end' command may be missing or misspelled."
|
||||
|
||||
/**
|
||||
|
@ -126,12 +129,20 @@ io_data_t *block_io;
|
|||
*/
|
||||
static array_list_t profile_data;
|
||||
|
||||
/**
|
||||
Keeps track of how many recursive eval calls have been made. Eval
|
||||
doesn't call itself directly, recursion happens on blocks and on
|
||||
command substitutions.
|
||||
*/
|
||||
static int eval_level=-1;
|
||||
|
||||
static int parse_job( process_t *p,
|
||||
job_t *j,
|
||||
tokenizer *tok );
|
||||
|
||||
/**
|
||||
Struct used to keep track of profiling data for a command
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
int exec, parse, level, skipped;
|
||||
|
@ -340,6 +351,9 @@ int parser_is_pipe_forbidden( wchar_t *word )
|
|||
(void *)0 );
|
||||
}
|
||||
|
||||
/**
|
||||
Search the text for the end of the current block
|
||||
*/
|
||||
static const wchar_t *parser_find_end( const wchar_t * buff )
|
||||
{
|
||||
tokenizer tok;
|
||||
|
@ -709,6 +723,9 @@ void parser_destroy()
|
|||
al_destroy( &forbidden_function );
|
||||
}
|
||||
|
||||
/**
|
||||
Print error message if an error has occured while parsing
|
||||
*/
|
||||
static void print_errors()
|
||||
{
|
||||
if( error_code )
|
||||
|
@ -1643,7 +1660,7 @@ static void eval_job( tokenizer *tok )
|
|||
long long t1=0, t2=0, t3=0;
|
||||
profile_element_t *p=0;
|
||||
int skip = 0;
|
||||
|
||||
|
||||
if( profile )
|
||||
{
|
||||
p=malloc( sizeof(profile_element_t));
|
||||
|
@ -1947,7 +1964,7 @@ int parser_test( wchar_t * buff,
|
|||
int require_additional_commands=0;
|
||||
|
||||
current_tokenizer = &tok;
|
||||
|
||||
|
||||
for( tok_init( &tok, buff, 0 );
|
||||
tok_has_next( &tok ) && !err;
|
||||
tok_next( &tok ) )
|
||||
|
|
10
tokenizer.c
10
tokenizer.c
|
@ -53,6 +53,12 @@
|
|||
|
||||
\return 0 if the system could not provide the memory needed, and 1 otherwise.
|
||||
*/
|
||||
|
||||
/**
|
||||
Maximum length of a string containing a file descriptor number
|
||||
*/
|
||||
#define FD_STR_MAX_LEN 16
|
||||
|
||||
const static wchar_t *tok_desc[] =
|
||||
{
|
||||
L"Tokenizer not yet initialized",
|
||||
|
@ -546,9 +552,9 @@ void tok_next( tokenizer *tok )
|
|||
tok_error( tok, PIPE_ERROR );
|
||||
return;
|
||||
}
|
||||
check_size( tok, 16 );
|
||||
check_size( tok, FD_STR_MAX_LEN );
|
||||
tok->buff++;
|
||||
swprintf( tok->last, 16, L"%d", fd );
|
||||
swprintf( tok->last, FD_STR_MAX_LEN, L"%d", fd );
|
||||
tok->last_type = TOK_PIPE;
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue