diff --git a/builtin.cpp b/builtin.cpp index be6b06bd2..49231af67 100644 --- a/builtin.cpp +++ b/builtin.cpp @@ -3894,9 +3894,13 @@ void builtin_get_names( array_list_t *list ) } void builtin_get_names2(std::vector &list) { - for (int i=0;i &l ) } for( i=0; i< l.size(); i++ ) { - res[i] = (wchar_t *)l.at(i).completion.c_str(); + res[i] = const_cast(l.at(i).completion.c_str()); } res[i]='\0'; return res; diff --git a/complete.cpp b/complete.cpp index 63bf6d64c..8389e852b 100644 --- a/complete.cpp +++ b/complete.cpp @@ -1131,7 +1131,7 @@ static void complete_cmd( const wchar_t *cmd, { continue; } - + add_slash = nxt_path[path_len-1]!=L'/'; nxt_completion = wcsdupcat( nxt_path, add_slash?L"/":L"", diff --git a/exec.cpp b/exec.cpp index f82e66e3a..b66782999 100644 --- a/exec.cpp +++ b/exec.cpp @@ -1745,7 +1745,7 @@ int exec_subshell( const wchar_t *cmd, CHECK( cmd, -1 ); // ifs = env_get(L"IFS"); - const env_var_t ifs = env_get_string(L"IFS").empty()?NULL:env_get_string(L"IFS").c_str(); + const env_var_t ifs = env_get_string(L"IFS"); if( ! ifs.missing_or_empty() ) { diff --git a/expand.cpp b/expand.cpp index 90dffae1d..5b45e25a6 100644 --- a/expand.cpp +++ b/expand.cpp @@ -691,7 +691,7 @@ static int expand_pid( wchar_t *in, if( wcscmp( (in+1), SELF_STR )==0 ) { wchar_t *str= (wchar_t *)malloc( sizeof(wchar_t)*32); -// free(in); + free(in); swprintf( str, 32, L"%d", getpid() ); completion_t data_to_push; @@ -1787,7 +1787,8 @@ static int expand_cmdsubst2( const wcstring &input, std::vector &o const wchar_t * const in = input.c_str(); completion_t data_to_push; - switch( parse_util_locate_cmdsubst(in, + int parse_ret; + switch( parse_ret = parse_util_locate_cmdsubst(in, ¶n_begin, ¶n_end, 0 ) ) @@ -2059,7 +2060,7 @@ static void remove_internal_separator2( wcstring &s, int conv ) int expand_string2( const wcstring &input, std::vector &output, int flags ) { - std::vector list1, list2; + std::vector list1, list2; std::vector *in, *out; size_t i; @@ -2127,7 +2128,7 @@ int expand_string2( const wcstring &input, std::vector &output, in } else { - if(!expand_variables2( next.empty()?NULL:const_cast(next.c_str()), *out, next.size() - 1 )) + if(!expand_variables2( const_cast(next.c_str()), *out, next.size() - 1 )) { return EXPAND_ERROR; } @@ -2143,7 +2144,7 @@ int expand_string2( const wcstring &input, std::vector &output, in { wcstring next = in->at(i).completion; - if( !expand_brackets( const_cast(next.c_str()), flags, *out )) + if( !expand_brackets( wcsdup(next.c_str()), flags, *out )) { return EXPAND_ERROR; } @@ -2169,7 +2170,7 @@ int expand_string2( const wcstring &input, std::vector &output, in interested in other completions, so we short-circut and return */ - expand_pid( const_cast(next.c_str()), flags, output ); + expand_pid( wcsdup(next.c_str()), flags, output ); return EXPAND_OK; } else @@ -2181,7 +2182,7 @@ int expand_string2( const wcstring &input, std::vector &output, in } else { - if( !expand_pid( const_cast(next.c_str()), flags, *out ) ) + if( !expand_pid( wcsdup(next.c_str()), flags, *out ) ) { return EXPAND_ERROR; } diff --git a/reader.cpp b/reader.cpp index 8b0ad5034..7580f6acd 100644 --- a/reader.cpp +++ b/reader.cpp @@ -1225,14 +1225,14 @@ static void run_pager( wchar_t *prefix, int is_quoted, const std::vector(foo_wstr.c_str()); + foo = wcsdup(foo_wstr.c_str()); } } if( !el.description.empty() ) { wcstring baz_wstr = escape_string( el.description, 1 ); - baz = baz_wstr.empty()?NULL:const_cast(baz_wstr.c_str()); + baz = wcsdup(baz_wstr.c_str()); } if( !foo ) @@ -1254,8 +1254,8 @@ static void run_pager( wchar_t *prefix, int is_quoted, const std::vectorcomplete_func( buffcpy, comp ); - sort_completion_list( comp ); remove_duplicates( comp ); diff --git a/wildcard.cpp b/wildcard.cpp index 3435037b6..698418958 100644 --- a/wildcard.cpp +++ b/wildcard.cpp @@ -810,7 +810,7 @@ static int wildcard_expand_internal( const wchar_t *wc, return -1; } - if( !wc || !base_dir || out.empty()) + if( !wc || !base_dir ) { debug( 2, L"Got null string on line %d of file %s", __LINE__, __FILE__ ); return 0;