diff --git a/complete.cpp b/complete.cpp index b75b940a1..2e0894b63 100644 --- a/complete.cpp +++ b/complete.cpp @@ -907,15 +907,11 @@ static void complete_strings( std::vector &comp_out, std::vector &possible_comp, int flags ) { - wchar_t *wc, *tmp; - - tmp = expand_one( 0, - wcsdup(wc_escaped), EXPAND_SKIP_CMDSUBST | EXPAND_SKIP_WILDCARDS); - if(!tmp) - return; - - wc = parse_util_unescape_wildcards( tmp ); - free(tmp); + wcstring tmp = wc_escaped; + if (! expand_one(tmp, EXPAND_SKIP_CMDSUBST | EXPAND_SKIP_WILDCARDS)) + return; + + const wchar_t *wc = parse_util_unescape_wildcards( tmp.c_str() ); for( size_t i=0; i< possible_comp.size(); i++ ) { @@ -928,7 +924,7 @@ static void complete_strings( std::vector &comp_out, } } - free( wc ); + free( (void *)wc ); } /** diff --git a/expand.cpp b/expand.cpp index cd678d8af..b0fbcf97a 100644 --- a/expand.cpp +++ b/expand.cpp @@ -2585,7 +2585,7 @@ int expand_string( void *context, } */ -wchar_t *expand_one( void *context, wchar_t *string, int flags ) +wchar_t *expand_one( void *context, const wchar_t *string, int flags ) { std::vector l; int res; @@ -2595,8 +2595,8 @@ wchar_t *expand_one( void *context, wchar_t *string, int flags ) if( (!(flags & ACCEPT_INCOMPLETE)) && expand_is_clean( string ) ) { - halloc_register( context, string ); - return string; + halloc_register( context, (void *)string ); + return (wchar_t *)string; } // al_init( &l ); @@ -2625,5 +2625,17 @@ wchar_t *expand_one( void *context, wchar_t *string, int flags ) halloc_register( context, one ); return one; } + +bool expand_one( wcstring &in, int flag ) { + bool result = false; + wchar_t *res = expand_one(NULL, in.c_str(), flag); + if (res) { + in = res; + free(res); + result = true; + } + return result; +} + diff --git a/expand.h b/expand.h index 0d235ea55..255b985bc 100644 --- a/expand.h +++ b/expand.h @@ -165,7 +165,10 @@ __warn_unused int expand_string2( const wcstring &input, std::vectortype = INTERNAL_BLOCK; completion_t data_to_push;