mirror of
https://github.com/fish-shell/fish-shell
synced 2024-11-10 23:24:39 +00:00
Rename function expand_variable_array to tokenize_variable_array and move it from expand.c to common.c, since it is used by fish_pager, which should not depend on expand.o
darcs-hash:20060529111342-ac50b-315d7dcf04e05fa8f32e16801e6793ac4e4e022e.gz
This commit is contained in:
parent
79b466441b
commit
d46dade284
9 changed files with 44 additions and 44 deletions
|
@ -682,7 +682,7 @@ int builtin_set( wchar_t **argv )
|
|||
array_list_t result;
|
||||
al_init(&result);
|
||||
|
||||
expand_variable_array( env_get(dest), &result );
|
||||
tokenize_variable_array( env_get(dest), &result );
|
||||
if( erase )
|
||||
{
|
||||
erase_values(&result, &indexes);
|
||||
|
|
26
common.c
26
common.c
|
@ -1403,3 +1403,29 @@ int common_get_height()
|
|||
return termsize.ws_row;
|
||||
}
|
||||
|
||||
void tokenize_variable_array( const wchar_t *val, array_list_t *out )
|
||||
{
|
||||
if( val )
|
||||
{
|
||||
wchar_t *cpy = wcsdup( val );
|
||||
wchar_t *pos, *start;
|
||||
|
||||
if( !cpy )
|
||||
{
|
||||
die_mem();
|
||||
}
|
||||
|
||||
for( start=pos=cpy; *pos; pos++ )
|
||||
{
|
||||
if( *pos == ARRAY_SEP )
|
||||
{
|
||||
*pos=0;
|
||||
al_push( out, start==cpy?cpy:wcsdup(start) );
|
||||
start=pos+1;
|
||||
}
|
||||
}
|
||||
al_push( out, start==cpy?cpy:wcsdup(start) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
10
common.h
10
common.h
|
@ -296,6 +296,16 @@ void common_handle_winch( int signal );
|
|||
*/
|
||||
void write_screen( const wchar_t *msg, string_buffer_t *buff );
|
||||
|
||||
/**
|
||||
Tokenize the specified string into the specified array_list_t.
|
||||
Each new element is allocated using malloc and must be freed by the
|
||||
caller.
|
||||
|
||||
\param val the input string. The contents of this string is not changed.
|
||||
\param out the list in which to place the elements.
|
||||
*/
|
||||
void tokenize_variable_array( const wchar_t *val, array_list_t *out );
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
4
env.c
4
env.c
|
@ -396,7 +396,7 @@ static void setup_path()
|
|||
al_init( &l );
|
||||
|
||||
if( path )
|
||||
expand_variable_array( path, &l );
|
||||
tokenize_variable_array( path, &l );
|
||||
|
||||
for( j=0; path_el[j]; j++ )
|
||||
{
|
||||
|
@ -438,7 +438,7 @@ static void setup_path()
|
|||
al_foreach( &l, (void (*)(const void *))&free );
|
||||
path = env_get( L"PATH" );
|
||||
al_truncate( &l, 0 );
|
||||
expand_variable_array( path, &l );
|
||||
tokenize_variable_array( path, &l );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
30
expand.c
30
expand.c
|
@ -130,32 +130,6 @@ static wchar_t *expand_var( wchar_t *in )
|
|||
return env_get( in );
|
||||
}
|
||||
|
||||
void expand_variable_array( const wchar_t *val, array_list_t *out )
|
||||
{
|
||||
if( val )
|
||||
{
|
||||
wchar_t *cpy = wcsdup( val );
|
||||
wchar_t *pos, *start;
|
||||
|
||||
if( !cpy )
|
||||
{
|
||||
die_mem();
|
||||
}
|
||||
|
||||
for( start=pos=cpy; *pos; pos++ )
|
||||
{
|
||||
if( *pos == ARRAY_SEP )
|
||||
{
|
||||
*pos=0;
|
||||
al_push( out, start==cpy?cpy:wcsdup(start) );
|
||||
start=pos+1;
|
||||
}
|
||||
}
|
||||
al_push( out, start==cpy?cpy:wcsdup(start) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Test if the specified string does not contain character which can
|
||||
not be used inside a quoted string.
|
||||
|
@ -188,7 +162,7 @@ wchar_t *expand_escape_variable( const wchar_t *in )
|
|||
string_buffer_t buff;
|
||||
|
||||
al_init( &l );
|
||||
expand_variable_array( in, &l );
|
||||
tokenize_variable_array( in, &l );
|
||||
sb_init( &buff );
|
||||
|
||||
switch( al_get_count( &l) )
|
||||
|
@ -834,7 +808,7 @@ static int expand_variables( wchar_t *in, array_list_t *out, int last_idx )
|
|||
|
||||
if( is_ok )
|
||||
{
|
||||
expand_variable_array( var_val, &var_item_list );
|
||||
tokenize_variable_array( var_val, &var_item_list );
|
||||
if( !all_vars )
|
||||
{
|
||||
int j;
|
||||
|
|
10
expand.h
10
expand.h
|
@ -178,16 +178,6 @@ wchar_t *expand_escape_variable( const wchar_t *in );
|
|||
wchar_t *expand_tilde(wchar_t *in);
|
||||
|
||||
|
||||
/**
|
||||
Tokenize the specified string into the specified array_list_t.
|
||||
Each new element is allocated using malloc and must be freed by the
|
||||
caller.
|
||||
|
||||
\param val the input string. The contents of this string is not changed.
|
||||
\param out the list in which to place the elements.
|
||||
*/
|
||||
void expand_variable_array( const wchar_t *val, array_list_t *out );
|
||||
|
||||
/**
|
||||
Test if the specified argument is clean, i.e. it does not contain
|
||||
any tokens which need to be expanded or otherwise altered. Clean
|
||||
|
|
|
@ -87,7 +87,7 @@ static void autoload_names( array_list_t *out, int get_hidden )
|
|||
|
||||
al_init( &path_list );
|
||||
|
||||
expand_variable_array( path_var, &path_list );
|
||||
tokenize_variable_array( path_var, &path_list );
|
||||
for( i=0; i<al_get_count( &path_list ); i++ )
|
||||
{
|
||||
wchar_t *ndir = (wchar_t *)al_get( &path_list, i );
|
||||
|
|
2
output.c
2
output.c
|
@ -524,7 +524,7 @@ int output_color_code( const wchar_t *val )
|
|||
return FISH_COLOR_NORMAL;
|
||||
|
||||
al_init( &el );
|
||||
expand_variable_array( val, &el );
|
||||
tokenize_variable_array( val, &el );
|
||||
|
||||
for( j=0; j<al_get_count( &el ); j++ )
|
||||
{
|
||||
|
|
|
@ -558,7 +558,7 @@ int parse_util_load( const wchar_t *cmd,
|
|||
else
|
||||
sb_clear( path );
|
||||
|
||||
expand_variable_array( path_var, path_list );
|
||||
tokenize_variable_array( path_var, path_list );
|
||||
|
||||
/*
|
||||
Iterate over path searching for suitable completion files
|
||||
|
|
Loading…
Reference in a new issue