mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-01-19 16:02:44 +08:00
More work towards getting function.h off of shared_ptr
This commit is contained in:
parent
86645b32e1
commit
da6295c428
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 )
|
static void functions_def( const wcstring &name, wcstring &out )
|
||||||
{
|
{
|
||||||
const wchar_t *desc = function_get_desc( name );
|
wcstring desc, def;
|
||||||
wcstring def;
|
function_get_desc(name, &desc);
|
||||||
function_get_definition(name, &def);
|
function_get_definition(name, &def);
|
||||||
|
|
||||||
event_t search(EVENT_ANY);
|
event_t search(EVENT_ANY);
|
||||||
|
@ -1099,13 +1099,11 @@ static void functions_def( const wcstring &name, wcstring &out )
|
||||||
out.append(L"function ");
|
out.append(L"function ");
|
||||||
out.append(name);
|
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(L" --description ");
|
||||||
out.append( esc_desc );
|
out.append(esc_desc);
|
||||||
free( esc_desc );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !function_get_shadows( name ) )
|
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 )
|
static wcstring complete_function_desc( const wcstring &fn )
|
||||||
{
|
{
|
||||||
wcstring result;
|
wcstring result;
|
||||||
|
bool has_description = function_get_desc(fn, &result);
|
||||||
const wchar_t *res = function_get_desc( fn );
|
if (! has_description) {
|
||||||
if (res) {
|
|
||||||
result = res;
|
|
||||||
} else {
|
|
||||||
function_get_definition(fn, &result);
|
function_get_definition(fn, &result);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 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 */
|
/* Empty length string goes to NULL */
|
||||||
shared_ptr<function_info_t> func = function_get(name);
|
shared_ptr<function_info_t> func = function_get(name);
|
||||||
if (func && func->description.size()) {
|
if (out_desc && func && ! func->description.empty()) {
|
||||||
return _(func->description.c_str());
|
out_desc->assign(_(func->description.c_str()));
|
||||||
|
return true;
|
||||||
} else {
|
} 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 );
|
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.
|
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
|
This function does not autoload functions, it will only work on
|
||||||
functions that have already been defined.
|
functions that have already been defined.
|
||||||
|
|
||||||
|
This returns an intern'd string.
|
||||||
*/
|
*/
|
||||||
const wchar_t *function_get_definition_file( const wcstring &name );
|
const wchar_t *function_get_definition_file( const wcstring &name );
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user