diff --git a/complete.c b/complete.c index 90e4173e7..6caf5f9ad 100644 --- a/complete.c +++ b/complete.c @@ -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 ); } /** diff --git a/function.c b/function.c index 02f034961..8e77de3a3 100644 --- a/function.c +++ b/function.c @@ -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; diff --git a/parse_util.c b/parse_util.c index 26c641a61..75b67d3b6 100644 --- a/parse_util.c +++ b/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 ); diff --git a/parse_util.h b/parse_util.h index 0dcd0edb4..19591f838 100644 --- a/parse_util.h +++ b/parse_util.h @@ -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 );