mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-03 06:41:14 -03:00
Drop the init and shutdown function for the completion code
darcs-hash:20060722101651-ac50b-45f840a5b2f7461d976a8f5b859aa99bfa472274.gz
This commit is contained in:
78
complete.c
78
complete.c
@@ -233,6 +233,51 @@ static hash_table_t *condition_cache=0;
|
||||
*/
|
||||
static string_buffer_t *get_desc_buff=0;
|
||||
|
||||
|
||||
static void complete_free_entry( complete_entry *c );
|
||||
static void clear_hash_entry( void *key, void *data );
|
||||
|
||||
|
||||
/**
|
||||
Destroys various structures used for tab-completion and free()s the memory used by them.
|
||||
*/
|
||||
static void complete_destroy()
|
||||
{
|
||||
complete_entry *i=first_entry, *prev;
|
||||
|
||||
while( i )
|
||||
{
|
||||
prev = i;
|
||||
i=i->next;
|
||||
complete_free_entry( prev );
|
||||
}
|
||||
first_entry = 0;
|
||||
|
||||
if( suffix_hash )
|
||||
{
|
||||
hash_foreach( suffix_hash, &clear_hash_entry );
|
||||
hash_destroy( suffix_hash );
|
||||
free( suffix_hash );
|
||||
suffix_hash=0;
|
||||
}
|
||||
|
||||
parse_util_load_reset( L"fish_complete_path", 0 );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
Make sure complete_destroy is called on exit
|
||||
*/
|
||||
static void complete_init()
|
||||
{
|
||||
static int is_init = 0;
|
||||
if( !is_init )
|
||||
{
|
||||
is_init = 1;
|
||||
halloc_register_function_void( global_context, &complete_destroy );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
This command clears the cache of condition tests created by \c condition_test().
|
||||
*/
|
||||
@@ -329,34 +374,6 @@ static void clear_hash_entry( void *key, void *data )
|
||||
free( (void *)data );
|
||||
}
|
||||
|
||||
void complete_init()
|
||||
{
|
||||
}
|
||||
|
||||
void complete_destroy()
|
||||
{
|
||||
complete_entry *i=first_entry, *prev;
|
||||
|
||||
while( i )
|
||||
{
|
||||
prev = i;
|
||||
i=i->next;
|
||||
complete_free_entry( prev );
|
||||
}
|
||||
first_entry = 0;
|
||||
|
||||
if( suffix_hash )
|
||||
{
|
||||
hash_foreach( suffix_hash, &clear_hash_entry );
|
||||
hash_destroy( suffix_hash );
|
||||
free( suffix_hash );
|
||||
suffix_hash=0;
|
||||
}
|
||||
|
||||
parse_util_load_reset( L"fish_complete_path", 0 );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
Search for an exactly matching completion entry
|
||||
*/
|
||||
@@ -390,6 +407,8 @@ void complete_add( const wchar_t *cmd,
|
||||
|
||||
CHECK( cmd, );
|
||||
|
||||
complete_init();
|
||||
|
||||
c = complete_find_exact_entry( cmd, cmd_type );
|
||||
|
||||
if( c == 0 )
|
||||
@@ -934,6 +953,7 @@ const wchar_t *complete_get_desc( const wchar_t *filename )
|
||||
|
||||
if( !get_desc_buff )
|
||||
{
|
||||
complete_init();
|
||||
get_desc_buff = sb_halloc( global_context);
|
||||
}
|
||||
else
|
||||
@@ -1965,6 +1985,8 @@ void complete( const wchar_t *cmd,
|
||||
CHECK( cmd, );
|
||||
CHECK( comp, );
|
||||
|
||||
complete_init();
|
||||
|
||||
// debug( 1, L"Complete '%ls'", cmd );
|
||||
|
||||
cursor_pos = wcslen(cmd );
|
||||
|
||||
@@ -66,15 +66,6 @@
|
||||
*/
|
||||
#define PROG_COMPLETE_SEP L'\t'
|
||||
|
||||
/**
|
||||
Initializes various structures used for tab-completion.
|
||||
*/
|
||||
void complete_init();
|
||||
|
||||
/**
|
||||
Destroys various structures used for tab-completion and free()s the memory used by them.
|
||||
*/
|
||||
void complete_destroy();
|
||||
|
||||
/**
|
||||
|
||||
|
||||
@@ -696,7 +696,6 @@ int main( int argc, char **argv )
|
||||
parser_init();
|
||||
function_init();
|
||||
builtin_init();
|
||||
complete_init();
|
||||
reader_init();
|
||||
env_init();
|
||||
|
||||
@@ -713,7 +712,6 @@ int main( int argc, char **argv )
|
||||
// say( L"Testing performance" );
|
||||
// perf_complete();
|
||||
|
||||
complete_destroy();
|
||||
env_destroy();
|
||||
reader_destroy();
|
||||
parser_destroy();
|
||||
|
||||
43
main.c
43
main.c
@@ -184,13 +184,17 @@ int main( int argc, char **argv )
|
||||
switch( opt )
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
case 'c':
|
||||
{
|
||||
cmd = optarg;
|
||||
is_interactive_session = 0;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
case 'd':
|
||||
{
|
||||
char *end;
|
||||
@@ -208,35 +212,49 @@ int main( int argc, char **argv )
|
||||
}
|
||||
|
||||
case 'h':
|
||||
{
|
||||
cmd = "help";
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
case 'i':
|
||||
{
|
||||
force_interactive = 1;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
case 'l':
|
||||
{
|
||||
is_login=1;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
case 'n':
|
||||
{
|
||||
no_exec=1;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
case 'p':
|
||||
{
|
||||
profile = optarg;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
case 'v':
|
||||
{
|
||||
fwprintf( stderr,
|
||||
_(L"%s, version %s\n"),
|
||||
PACKAGE_NAME,
|
||||
PACKAGE_VERSION );
|
||||
exit( 0 );
|
||||
|
||||
}
|
||||
|
||||
case '?':
|
||||
{
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -266,7 +284,6 @@ int main( int argc, char **argv )
|
||||
builtin_init();
|
||||
function_init();
|
||||
env_init();
|
||||
complete_init();
|
||||
reader_init();
|
||||
history_init();
|
||||
|
||||
@@ -340,10 +357,9 @@ int main( int argc, char **argv )
|
||||
|
||||
proc_fire_event( L"PROCESS_EXIT", EVENT_EXIT, getpid(), res );
|
||||
|
||||
|
||||
history_destroy();
|
||||
complete_destroy();
|
||||
proc_destroy();
|
||||
env_destroy();
|
||||
builtin_destroy();
|
||||
function_destroy();
|
||||
reader_destroy();
|
||||
@@ -352,6 +368,9 @@ int main( int argc, char **argv )
|
||||
event_destroy();
|
||||
|
||||
halloc_util_destroy();
|
||||
|
||||
env_destroy();
|
||||
|
||||
intern_free_all();
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user