mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-03-15 23:22:53 +08:00
Use variable name as index for tables when autoloading functions and completions in order to better handle changes on path variable values
darcs-hash:20060219170116-ac50b-8f617c6f8960660e6227827914dc910a78655c13.gz
This commit is contained in:
parent
845e15876c
commit
7dc3934997
@ -343,12 +343,8 @@ void complete_destroy()
|
||||
suffix_hash=0;
|
||||
}
|
||||
|
||||
path = env_get( L"fish_complete_path" );
|
||||
parse_util_load_reset(L"fish_complete_path");
|
||||
|
||||
if( path )
|
||||
parse_util_load_reset( path );
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1463,7 +1459,7 @@ static void complete_load_handler( const wchar_t *cmd )
|
||||
|
||||
void complete_load( const wchar_t *name, int reload )
|
||||
{
|
||||
parse_util_load( name, env_get( L"fish_complete_path" ), &complete_load_handler, reload );
|
||||
parse_util_load( name, L"fish_complete_path", &complete_load_handler, reload );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -60,7 +60,7 @@ static int load( const wchar_t *name )
|
||||
|
||||
is_autoload = 1;
|
||||
res = parse_util_load( name,
|
||||
env_get( L"fish_function_path" ),
|
||||
L"fish_function_path",
|
||||
&function_remove,
|
||||
1 );
|
||||
is_autoload = was_autoload;
|
||||
|
11
parse_util.c
11
parse_util.c
@ -484,7 +484,7 @@ void parse_util_load_reset( const wchar_t *path_var )
|
||||
|
||||
|
||||
int parse_util_load( const wchar_t *cmd,
|
||||
const wchar_t *path_var,
|
||||
const wchar_t *path_var_name,
|
||||
void (*on_load)(const wchar_t *cmd),
|
||||
int reload )
|
||||
{
|
||||
@ -496,13 +496,15 @@ int parse_util_load( const wchar_t *cmd,
|
||||
int reloaded = 0;
|
||||
hash_table_t *loaded;
|
||||
|
||||
const wchar_t *path_var = env_get( path_var_name );
|
||||
|
||||
/*
|
||||
Do we know where to look
|
||||
*/
|
||||
|
||||
if( !path_var )
|
||||
return 0;
|
||||
|
||||
|
||||
if( !all_loaded )
|
||||
{
|
||||
all_loaded = malloc( sizeof( hash_table_t ) );
|
||||
@ -514,7 +516,7 @@ int parse_util_load( const wchar_t *cmd,
|
||||
hash_init( all_loaded, &hash_wcs_func, &hash_wcs_cmp );
|
||||
}
|
||||
|
||||
loaded = (hash_table_t *)hash_get( all_loaded, path_var );
|
||||
loaded = (hash_table_t *)hash_get( all_loaded, path_var_name );
|
||||
|
||||
if( !loaded )
|
||||
{
|
||||
@ -524,7 +526,7 @@ int parse_util_load( const wchar_t *cmd,
|
||||
die_mem();
|
||||
}
|
||||
hash_init( loaded, &hash_wcs_func, &hash_wcs_cmp );
|
||||
hash_put( all_loaded, wcsdup(path_var), loaded );
|
||||
hash_put( all_loaded, wcsdup(path_var_name), loaded );
|
||||
}
|
||||
|
||||
/*
|
||||
@ -551,7 +553,6 @@ int parse_util_load( const wchar_t *cmd,
|
||||
|
||||
if( !path_list )
|
||||
path_list = al_halloc( global_context);
|
||||
|
||||
|
||||
if( !path )
|
||||
path = sb_halloc( global_context );
|
||||
|
@ -90,17 +90,17 @@ int parse_util_lineno( const wchar_t *str, int len );
|
||||
not load it multiple times unless it's timestamp changes.
|
||||
|
||||
\param cmd the filename to search for. The suffix '.fish' is always added to this name
|
||||
\param path_var a list of paths to search in.
|
||||
\param path_var_name the name of an environment variable containing a search path
|
||||
\param on_load a callback function to run if a suitable file is found, which has not already been run
|
||||
\param reload wheter to recheck file timestamps on already loaded files
|
||||
*/
|
||||
int parse_util_load( const wchar_t *cmd,
|
||||
const wchar_t *path_var,
|
||||
const wchar_t *path_var_name,
|
||||
void (*on_load)(const wchar_t *cmd),
|
||||
int reload );
|
||||
|
||||
/**
|
||||
Reset the loader for the specified path value
|
||||
Reset the loader for the specified path variable
|
||||
*/
|
||||
void parse_util_load_reset( const wchar_t *path_var );
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user