diff --git a/autoload.cpp b/autoload.cpp index 2cbce79b3..9617ec35c 100644 --- a/autoload.cpp +++ b/autoload.cpp @@ -111,7 +111,7 @@ int autoload_t::load( const wcstring &cmd, bool reload ) /* Get the list of paths from which we will try to load */ std::vector path_list; - tokenize_variable_array2( path_var, path_list ); + tokenize_variable_array( path_var, path_list ); /* Try loading it */ res = this->locate_file_and_maybe_load_it( cmd, true, reload, path_list ); @@ -131,7 +131,7 @@ bool autoload_t::can_load( const wcstring &cmd, const env_vars &vars ) const wcstring path_var(path_var_ptr); std::vector path_list; - tokenize_variable_array2( path_var, path_list ); + tokenize_variable_array( path_var, path_list ); return this->locate_file_and_maybe_load_it( cmd, false, false, path_list ); } diff --git a/builtin_set.cpp b/builtin_set.cpp index 4ac6e92ec..f316ce4a0 100644 --- a/builtin_set.cpp +++ b/builtin_set.cpp @@ -273,7 +273,7 @@ static int update_values( wcstring_list_t &list, { /* The '- 1' below is because the indices in fish are - one-based, but the array_list_t uses zero-based indices + one-based, but the vector uses zero-based indices */ long ind = indexes[i] - 1; const wcstring newv = values[ i ]; @@ -592,7 +592,7 @@ static int builtin_set( parser_t &parser, wchar_t **argv ) // al_init( &indexes ); env_var_t dest_str = env_get_string(dest); if (! dest_str.missing()) - tokenize_variable_array2( dest_str, result ); + tokenize_variable_array( dest_str, result ); if( !parse_index( indexes, arg, dest, result.size() ) ) { @@ -706,7 +706,7 @@ static int builtin_set( parser_t &parser, wchar_t **argv ) const env_var_t dest_str = env_get_string(dest); if (! dest_str.missing()) - tokenize_variable_array2( dest_str, result ); + tokenize_variable_array( dest_str, result ); for( ; woptind &list ) { wcstring_list_t strings; @@ -219,24 +202,6 @@ int fgetws2( wchar_t **b, int *len, FILE *f ) } -/** - Wrapper for wcsfilecmp -*/ -static int str_cmp( const void *a, const void *b ) -{ - wchar_t *c= *((wchar_t **)a); - wchar_t *d= *((wchar_t **)b); - return wcsfilecmp( c, d ); -} - -void sort_list( array_list_t *comp ) -{ - qsort( comp->arr, - al_get_count( comp ), - sizeof( void*), - &str_cmp ); -} - static bool string_sort_predicate(const wcstring& d1, const wcstring& d2) { return wcsfilecmp(d1.c_str(), d2.c_str()) < 0; @@ -1799,7 +1764,7 @@ int common_get_height() return termsize.ws_row; } -void tokenize_variable_array2( const wcstring &val, std::vector &out) +void tokenize_variable_array( const wcstring &val, std::vector &out) { size_t pos = 0, end = val.size(); while (pos < end) { @@ -1811,39 +1776,6 @@ void tokenize_variable_array2( const wcstring &val, std::vector &out) out.push_back(val.substr(pos, end - pos)); } -void tokenize_variable_array( const wchar_t *val, array_list_t *out ) -{ - if( val ) - { - wchar_t *cpy = wcsdup( val ); - wchar_t *pos, *start; - wchar_t *next; - - if( !cpy ) - { - DIE_MEM(); - } - - for( start=pos=cpy; *pos; pos++ ) - { - if( *pos == ARRAY_SEP ) - { - - *pos=0; - next = start==cpy?cpy:wcsdup(start); - if( !next ) - DIE_MEM(); - al_push( out, next ); - start=pos+1; - } - } - next = start==cpy?cpy:wcsdup(start); - if( !next ) - DIE_MEM(); - al_push( out, next ); - } -} - bool string_prefixes_string(const wcstring &proposed_prefix, const wcstring &value) { size_t prefix_size = proposed_prefix.size(); return prefix_size <= value.size() && value.compare(0, prefix_size, proposed_prefix) == 0; diff --git a/common.h b/common.h index 50d033a03..970f8acd7 100644 --- a/common.h +++ b/common.h @@ -188,12 +188,6 @@ extern const wchar_t *program_name; */ void show_stackframe(); -/** - Take an array_list_t containing wide strings and converts them to a - single null-terminated wchar_t **. The array is allocated using - malloc, and needs to be fred's by the caller. -*/ -wchar_t **list_to_char_arr( array_list_t *l ); wcstring_list_t completions_to_wcstring_list( const std::vector &completions ); @@ -210,12 +204,6 @@ wcstring_list_t completions_to_wcstring_list( const std::vector &c */ int fgetws2( wchar_t **buff, int *len, FILE *f ); -/** - Sorts an array_list of wide strings according to the - wcsfilecmp-function from the util library -*/ -void sort_list( array_list_t *comp ); - void sort_strings( std::vector &strings); void sort_completions( std::vector &strings); @@ -566,8 +554,7 @@ void write_screen( const wchar_t *msg, string_buffer_t *buff ); \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 ); -void tokenize_variable_array2( const wcstring &val, wcstring_list_t &out); +void tokenize_variable_array( const wcstring &val, wcstring_list_t &out); /** Make sure the specified direcotry exists. If needed, try to create diff --git a/env.cpp b/env.cpp index 5a794c939..d540ea0af 100644 --- a/env.cpp +++ b/env.cpp @@ -427,7 +427,7 @@ static void setup_path() if( !path.missing() ) { - tokenize_variable_array2( path, lst ); + tokenize_variable_array( path, lst ); } for( j=0; path_el[j]; j++ ) @@ -470,7 +470,7 @@ static void setup_path() path = env_get_string( L"PATH" ); lst.resize(0); - tokenize_variable_array2( path, lst ); + tokenize_variable_array( path, lst ); } } } diff --git a/expand.cpp b/expand.cpp index 49a186d67..e16ea5f0b 100644 --- a/expand.cpp +++ b/expand.cpp @@ -187,7 +187,7 @@ wcstring expand_escape_variable( const wcstring &in ) wcstring_list_t lst; wcstring buff; - tokenize_variable_array2( in, lst ); + tokenize_variable_array( in, lst ); switch( lst.size() ) { @@ -882,7 +882,7 @@ static int expand_variables_internal( parser_t &parser, wchar_t * const in, std: if( is_ok ) { - tokenize_variable_array2( var_val, var_item_list ); + tokenize_variable_array( var_val, var_item_list ); if( !all_vars ) { diff --git a/function.cpp b/function.cpp index 0a6553cad..926865e5a 100644 --- a/function.cpp +++ b/function.cpp @@ -118,7 +118,7 @@ static void autoload_names( std::set &names, int get_hidden ) wcstring_list_t path_list; - tokenize_variable_array2( path_var, path_list ); + tokenize_variable_array( path_var, path_list ); for( i=0; iarr ); -} - /** Real implementation of all al_push_* versions. Pushes arbitrary element to end of list. diff --git a/util.h b/util.h index 2ca5431d1..ae3771dd9 100644 --- a/util.h +++ b/util.h @@ -315,16 +315,6 @@ int hash_ptr_cmp( void *a, void *b ); -/** - Initialize the list. -*/ -void al_init( array_list_t *l ); - -/** - Destroy the list and free memory used by it. -*/ -void al_destroy( array_list_t *l ); - /** Append element to list