diff --git a/input.c b/input.c index a67ecd644..84ba51202 100644 --- a/input.c +++ b/input.c @@ -61,6 +61,7 @@ implementation in fish is as of yet incomplete. #include "signal.h" #include "translate.h" #include "output.h" +#include "intern.h" static void input_read_inputrc( wchar_t *fn ); @@ -71,9 +72,9 @@ static void input_read_inputrc( wchar_t *fn ); typedef struct { - wchar_t *seq; /**< Character sequence which generates this event */ - wchar_t *seq_desc; /**< Description of the character sequence suitable for printing on-screen */ - wchar_t *command; /**< command that should be evaluated by this mapping */ + const wchar_t *seq; /**< Character sequence which generates this event */ + const wchar_t *seq_desc; /**< Description of the character sequence suitable for printing on-screen */ + const wchar_t *command; /**< command that should be evaluated by this mapping */ } mapping; @@ -237,7 +238,7 @@ static int inputrc_error = 0; */ static int is_init = 0; -wchar_t input_get_code( wchar_t *name ) +wchar_t input_get_code( const wchar_t *name ) { int i; @@ -340,18 +341,16 @@ void add_mapping( const wchar_t *mode, mapping *m = (mapping *)al_get( mappings, i ); if( wcscmp( m->seq, s ) == 0 ) { - free( m->command ); - free( m->seq_desc ); - m->seq_desc = wcsdup(d ); - m->command=wcsdup(c); + m->seq_desc = intern(d); + m->command = intern(c); return; } } mapping *m = malloc( sizeof( mapping ) ); - m->seq = wcsdup( s ); - m->seq_desc = wcsdup(d ); - m->command=wcsdup(c); + m->seq = intern( s ); + m->seq_desc = intern(d ); + m->command = intern(c); al_push( mappings, m ); } @@ -1427,20 +1426,11 @@ int input_init() */ static void destroy_mapping( void *key, void *val ) { - int i; array_list_t *mappings = (array_list_t *)val; - for( i=0; iseq ); - free( m->seq_desc ); - - free( m->command ); - free(m ); - } - + al_foreach( mappings, &free ); al_destroy( mappings ); + free((void *)key); free((void *)val); } diff --git a/input.h b/input.h index 8b3a3175e..ff6bb1cb1 100644 --- a/input.h +++ b/input.h @@ -111,6 +111,6 @@ void input_parse_inputrc_line( wchar_t *cmd ); /** Returns the function for the given function name. */ -wchar_t input_get_code( wchar_t *name ); +wchar_t input_get_code( const wchar_t *name ); #endif diff --git a/main.c b/main.c index 8cbdcc479..5c3b32cfd 100644 --- a/main.c +++ b/main.c @@ -117,6 +117,8 @@ int main( int argc, char **argv ) char *cmd=0; + halloc_util_init(); + wsetlocale( LC_ALL, L"" ); is_interactive_session=1; program_name=L"fish"; @@ -258,7 +260,6 @@ int main( int argc, char **argv ) no_exec = 0; } - halloc_util_init(); proc_init(); event_init(); diff --git a/reader.c b/reader.c index 4c7a7475c..b39b44426 100644 --- a/reader.c +++ b/reader.c @@ -2080,7 +2080,7 @@ int reader_get_cursor_pos() } -void reader_run_command( wchar_t *cmd ) +void reader_run_command( const wchar_t *cmd ) { wchar_t *ft; diff --git a/reader.h b/reader.h index ec67266d6..2c6c0c1f7 100644 --- a/reader.h +++ b/reader.h @@ -72,7 +72,7 @@ void repaint(); Run the specified command with the correct terminal modes, and while taking care to perform job notification, set the title, etc. */ -void reader_run_command( wchar_t *buff ); +void reader_run_command( const wchar_t *buff ); /** Get the string of character currently entered into the command