mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 04:43:10 +00:00
More work towards getting function.h off of shared_ptr
This commit is contained in:
parent
86645b32e1
commit
da6295c428
4 changed files with 17 additions and 19 deletions
12
builtin.cpp
12
builtin.cpp
|
@ -1085,8 +1085,8 @@ static int builtin_generic( parser_t &parser, wchar_t **argv )
|
|||
*/
|
||||
static void functions_def( const wcstring &name, wcstring &out )
|
||||
{
|
||||
const wchar_t *desc = function_get_desc( name );
|
||||
wcstring def;
|
||||
wcstring desc, def;
|
||||
function_get_desc(name, &desc);
|
||||
function_get_definition(name, &def);
|
||||
|
||||
event_t search(EVENT_ANY);
|
||||
|
@ -1099,13 +1099,11 @@ static void functions_def( const wcstring &name, wcstring &out )
|
|||
out.append(L"function ");
|
||||
out.append(name);
|
||||
|
||||
if( desc && wcslen(desc) )
|
||||
if (! desc.empty())
|
||||
{
|
||||
wchar_t *esc_desc = escape( desc, 1 );
|
||||
|
||||
wcstring esc_desc = escape_string(desc, true);
|
||||
out.append(L" --description ");
|
||||
out.append( esc_desc );
|
||||
free( esc_desc );
|
||||
out.append(esc_desc);
|
||||
}
|
||||
|
||||
if( !function_get_shadows( name ) )
|
||||
|
|
|
@ -986,14 +986,10 @@ void completer_t::complete_cmd_desc( const wcstring &str )
|
|||
static wcstring complete_function_desc( const wcstring &fn )
|
||||
{
|
||||
wcstring result;
|
||||
|
||||
const wchar_t *res = function_get_desc( fn );
|
||||
if (res) {
|
||||
result = res;
|
||||
} else {
|
||||
bool has_description = function_get_desc(fn, &result);
|
||||
if (! has_description) {
|
||||
function_get_definition(fn, &result);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -273,14 +273,15 @@ int function_get_shadows( const wcstring &name )
|
|||
}
|
||||
|
||||
|
||||
const wchar_t *function_get_desc( const wcstring &name )
|
||||
bool function_get_desc( const wcstring &name, wcstring *out_desc )
|
||||
{
|
||||
/* Empty length string goes to NULL */
|
||||
shared_ptr<function_info_t> func = function_get(name);
|
||||
if (func && func->description.size()) {
|
||||
return _(func->description.c_str());
|
||||
if (out_desc && func && ! func->description.empty()) {
|
||||
out_desc->assign(_(func->description.c_str()));
|
||||
return true;
|
||||
} else {
|
||||
return NULL;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -109,9 +109,10 @@ void function_remove( const wcstring &name );
|
|||
bool function_get_definition( const wcstring &name, wcstring *out_definition );
|
||||
|
||||
/**
|
||||
Returns the description of the function with the name \c name.
|
||||
Returns by reference the description of the function with the name \c name.
|
||||
Returns true if the function exists and has a nonempty description, false if it does not.
|
||||
*/
|
||||
const wchar_t *function_get_desc( const wcstring &name );
|
||||
bool function_get_desc( const wcstring &name, wcstring *out_desc );
|
||||
|
||||
/**
|
||||
Sets the description of the function with the name \c name.
|
||||
|
@ -141,6 +142,8 @@ wcstring_list_t function_get_names( int get_hidden );
|
|||
|
||||
This function does not autoload functions, it will only work on
|
||||
functions that have already been defined.
|
||||
|
||||
This returns an intern'd string.
|
||||
*/
|
||||
const wchar_t *function_get_definition_file( const wcstring &name );
|
||||
|
||||
|
|
Loading…
Reference in a new issue