mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-03-26 05:45:22 +08:00
Removing some unnecessary calls to c_str(), and added str2wcstring(std::string) in common.cpp.
This commit is contained in:
parent
c9f4e91df8
commit
7b3d670e23
@ -239,6 +239,14 @@ wcstring str2wcstring( const char *in )
|
||||
return result;
|
||||
}
|
||||
|
||||
wcstring str2wcstring( const std::string &in )
|
||||
{
|
||||
wchar_t *tmp = str2wcs(in.c_str());
|
||||
wcstring result = tmp;
|
||||
free(tmp);
|
||||
return result;
|
||||
}
|
||||
|
||||
wchar_t *str2wcs_internal( const char *in, wchar_t *out )
|
||||
{
|
||||
size_t res=0;
|
||||
|
1
common.h
1
common.h
@ -225,6 +225,7 @@ wchar_t *str2wcs( const char *in );
|
||||
way using the private use area.
|
||||
*/
|
||||
wcstring str2wcstring( const char *in );
|
||||
wcstring str2wcstring( const std::string &in );
|
||||
|
||||
/**
|
||||
Converts the narrow character string \c in into it's wide
|
||||
|
@ -561,7 +561,7 @@ int complete_is_valid_option( const wchar_t *str,
|
||||
continue;
|
||||
}
|
||||
|
||||
if( wcsncmp( &opt[2], o.long_opt.c_str(), gnu_opt_len )==0)
|
||||
if( &opt[2] == o.long_opt )
|
||||
{
|
||||
gnu_match_set.insert(o.long_opt);
|
||||
if( (wcsncmp( &opt[2],
|
||||
|
@ -306,7 +306,7 @@ history_item_t history_t::decode_item(const char *base, size_t len) {
|
||||
goto done;
|
||||
|
||||
cursor += advance;
|
||||
cmd = str2wcstring(value.c_str());
|
||||
cmd = str2wcstring(value);
|
||||
|
||||
/* Read the remaining lines */
|
||||
for (;;) {
|
||||
@ -351,7 +351,7 @@ history_item_t history_t::decode_item(const char *base, size_t len) {
|
||||
/* Skip the leading dash-space and then store this path it */
|
||||
line.erase(0, 2);
|
||||
unescape_yaml(line);
|
||||
paths.push_front(str2wcstring(line.c_str()));
|
||||
paths.push_front(str2wcstring(line));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
8
path.cpp
8
path.cpp
@ -303,7 +303,7 @@ bool path_get_cdpath_string(const wcstring &dir_str, wcstring &result, const env
|
||||
append_path_component(whole_path, dir);
|
||||
|
||||
struct stat buf;
|
||||
if( wstat( whole_path.c_str(), &buf ) == 0 )
|
||||
if( wstat( whole_path, &buf ) == 0 )
|
||||
{
|
||||
if( S_ISDIR(buf.st_mode) )
|
||||
{
|
||||
@ -318,7 +318,7 @@ bool path_get_cdpath_string(const wcstring &dir_str, wcstring &result, const env
|
||||
}
|
||||
else
|
||||
{
|
||||
if( lwstat( whole_path.c_str(), &buf ) == 0 )
|
||||
if( lwstat( whole_path, &buf ) == 0 )
|
||||
{
|
||||
err = EROTTEN;
|
||||
}
|
||||
@ -451,7 +451,7 @@ bool path_get_config(wcstring &path)
|
||||
if( ! xdg_dir.missing() )
|
||||
{
|
||||
res = xdg_dir + L"/fish";
|
||||
if( !create_directory( res.c_str() ) )
|
||||
if( !create_directory( res ) )
|
||||
{
|
||||
done = 1;
|
||||
}
|
||||
@ -462,7 +462,7 @@ bool path_get_config(wcstring &path)
|
||||
if( ! home.missing() )
|
||||
{
|
||||
res = home + L"/.config/fish";
|
||||
if( !create_directory( res.c_str() ) )
|
||||
if( !create_directory( res ) )
|
||||
{
|
||||
done = 1;
|
||||
}
|
||||
|
@ -713,7 +713,7 @@ static void exec_prompt()
|
||||
{
|
||||
proc_push_interactive( 0 );
|
||||
|
||||
if( exec_subshell( data->prompt.c_str(), prompt_list ) == -1 )
|
||||
if( exec_subshell( data->prompt, prompt_list ) == -1 )
|
||||
{
|
||||
/* If executing the prompt fails, make sure we at least don't print any junk */
|
||||
prompt_list.clear();
|
||||
|
@ -338,10 +338,9 @@ static wcstring make_path(const wcstring &base_dir, const wcstring &name) {
|
||||
does not perform any caching, it directly calls the mimedb command
|
||||
to do a lookup.
|
||||
*/
|
||||
static wcstring complete_get_desc_suffix_internal( const wchar_t *suff_orig )
|
||||
static wcstring complete_get_desc_suffix_internal( const wcstring &suff )
|
||||
{
|
||||
|
||||
wcstring suff = suff_orig;
|
||||
wcstring cmd = wcstring(SUFFIX_CMD_STR) + suff;
|
||||
|
||||
wcstring_list_t lst;
|
||||
|
Loading…
x
Reference in New Issue
Block a user