Fixed named_arguments to be wcstring_list_t instead of al_list

This commit is contained in:
ridiculousfish 2012-02-08 23:53:23 -08:00
parent d3311c81e5
commit f891ea5713
3 changed files with 13 additions and 15 deletions

View file

@ -1456,7 +1456,9 @@ static int builtin_function( parser_t &parser, wchar_t **argv )
int res=STATUS_BUILTIN_OK;
wchar_t *desc=0;
std::vector<event_t> events;
array_list_t *named_arguments=0;
std::auto_ptr<wcstring_list_t> named_arguments(NULL);
wchar_t *name = 0;
int shadows = 1;
@ -1651,8 +1653,8 @@ static int builtin_function( parser_t &parser, wchar_t **argv )
}
case 'a':
if( !named_arguments )
named_arguments = al_halloc( parser.current_block );
if( named_arguments.get() == NULL )
named_arguments.reset(new wcstring_list_t);
break;
case 'S':
@ -1706,7 +1708,7 @@ static int builtin_function( parser_t &parser, wchar_t **argv )
name = argv[woptind++];
if( named_arguments )
if( named_arguments.get() )
{
while( woptind < argc )
{
@ -1720,7 +1722,7 @@ static int builtin_function( parser_t &parser, wchar_t **argv )
break;
}
al_push( named_arguments, halloc_wcsdup( parser.current_block, argv[woptind++] ) );
named_arguments->push_back(argv[woptind++]);
}
}
else if( woptind != argc )
@ -1773,8 +1775,9 @@ static int builtin_function( parser_t &parser, wchar_t **argv )
d->name=halloc_wcsdup( parser.current_block, name);
d->description=desc?halloc_wcsdup( parser.current_block, desc):0;
d->events.swap(events);
d->named_arguments = named_arguments;
d->shadows = shadows;
if (named_arguments.get())
d->named_arguments.swap(*named_arguments);
for( size_t i=0; i<d->events.size(); i++ )
{

View file

@ -173,14 +173,9 @@ void function_add( function_data_t *data, const parser_t &parser )
info->definition_offset = parse_util_lineno( parser.get_buffer(), parser.current_block->tok_pos )-1;
info->definition = data->definition;
if( data->named_arguments )
{
for( size_t i=0; i<al_get_count( data->named_arguments ); i++ )
{
info->named_arguments.push_back((wchar_t *)al_get( data->named_arguments, i ));
if (! data->named_arguments.empty()) {
info->named_arguments.insert(info->named_arguments.end(), data->named_arguments.begin(), data->named_arguments.end());
}
}
if (data->description)
info->description = data->description;

View file

@ -50,7 +50,7 @@ struct function_data_t
/**
List of all named arguments for this function
*/
array_list_t *named_arguments;
wcstring_list_t named_arguments;
/**
Set to non-zero if invoking this function shadows the variables
of the underlying function.