mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-27 05:13:10 +00:00
Migrate some more off of al_list
This commit is contained in:
parent
b67eaa3abd
commit
9cd279e0e9
3 changed files with 22 additions and 18 deletions
11
common.cpp
11
common.cpp
|
@ -1765,6 +1765,17 @@ int common_get_height()
|
|||
return termsize.ws_row;
|
||||
}
|
||||
|
||||
void tokenize_variable_array2( const wcstring &val, std::vector<wcstring> &out)
|
||||
{
|
||||
size_t pos = 0, end = val.size();
|
||||
while (pos < end) {
|
||||
size_t next_pos = val.find(ARRAY_SEP, pos);
|
||||
if (next_pos == wcstring::npos) next_pos = end;
|
||||
out.push_back(val.substr(pos, next_pos - pos));
|
||||
pos = next_pos + 1; //skip the separator
|
||||
}
|
||||
}
|
||||
|
||||
void tokenize_variable_array( const wchar_t *val, array_list_t *out )
|
||||
{
|
||||
if( val )
|
||||
|
|
1
common.h
1
common.h
|
@ -530,6 +530,7 @@ void write_screen( const wchar_t *msg, string_buffer_t *buff );
|
|||
\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, std::vector<wcstring> &out);
|
||||
|
||||
/**
|
||||
Make sure the specified direcotry exists. If needed, try to create
|
||||
|
|
|
@ -819,7 +819,7 @@ static int parse_util_load_internal( const wchar_t *cmd,
|
|||
void (*on_load)(const wchar_t *cmd),
|
||||
int reload,
|
||||
autoload_t *loaded,
|
||||
array_list_t *path_list );
|
||||
const std::vector<wcstring> &path_list );
|
||||
|
||||
|
||||
int parse_util_load( const wchar_t *cmd,
|
||||
|
@ -827,8 +827,6 @@ int parse_util_load( const wchar_t *cmd,
|
|||
void (*on_load)(const wchar_t *cmd),
|
||||
int reload )
|
||||
{
|
||||
array_list_t *path_list=0;
|
||||
|
||||
autoload_t *loaded;
|
||||
|
||||
wchar_t *path_var;
|
||||
|
@ -917,12 +915,10 @@ int parse_util_load( const wchar_t *cmd,
|
|||
loaded->old_path = wcsdup( path_var );
|
||||
}
|
||||
|
||||
std::vector<wcstring> path_list;
|
||||
tokenize_variable_array2( path_var, path_list );
|
||||
|
||||
path_list = (array_list_t *)al_new();
|
||||
|
||||
tokenize_variable_array( path_var, path_list );
|
||||
|
||||
c = al_get_count( path_list );
|
||||
c = path_list.size();
|
||||
|
||||
hash_put( &loaded->is_loading, cmd, cmd );
|
||||
|
||||
|
@ -941,11 +937,7 @@ int parse_util_load( const wchar_t *cmd,
|
|||
hash_remove( &loaded->is_loading, cmd, 0, 0 );
|
||||
}
|
||||
|
||||
c2 = al_get_count( path_list );
|
||||
|
||||
al_foreach( path_list, &free );
|
||||
al_destroy( path_list );
|
||||
free( path_list );
|
||||
c2 = path_list.size();
|
||||
|
||||
/**
|
||||
Make sure we didn't 'drop' something
|
||||
|
@ -966,11 +958,11 @@ static int parse_util_load_internal( const wchar_t *cmd,
|
|||
void (*on_load)(const wchar_t *cmd),
|
||||
int reload,
|
||||
autoload_t *loaded,
|
||||
array_list_t *path_list )
|
||||
const std::vector<wcstring> &path_list )
|
||||
{
|
||||
static string_buffer_t *path=0;
|
||||
time_t *tm;
|
||||
int i;
|
||||
size_t i;
|
||||
int reloaded = 0;
|
||||
|
||||
/*
|
||||
|
@ -1009,12 +1001,12 @@ static int parse_util_load_internal( const wchar_t *cmd,
|
|||
/*
|
||||
Iterate over path searching for suitable completion files
|
||||
*/
|
||||
for( i=0; i<al_get_count( path_list ); i++ )
|
||||
for( i=0; i<path_list.size(); i++ )
|
||||
{
|
||||
struct stat buf;
|
||||
wchar_t *next = (wchar_t *)al_get( path_list, i );
|
||||
wcstring next = path_list.at(i);
|
||||
sb_clear( path );
|
||||
sb_append( path, next, L"/", cmd, L".fish", NULL );
|
||||
sb_append( path, next.c_str(), L"/", cmd, L".fish", NULL );
|
||||
|
||||
if( (wstat( (wchar_t *)path->buff, &buf )== 0) &&
|
||||
(waccess( (wchar_t *)path->buff, R_OK ) == 0) )
|
||||
|
|
Loading…
Reference in a new issue