From f891ea5713029484f30bdf12ed56de83162da33f Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Wed, 8 Feb 2012 23:53:23 -0800 Subject: [PATCH] Fixed named_arguments to be wcstring_list_t instead of al_list --- builtin.cpp | 15 +++++++++------ function.cpp | 11 +++-------- function.h | 2 +- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/builtin.cpp b/builtin.cpp index abce95d27..260a1722c 100644 --- a/builtin.cpp +++ b/builtin.cpp @@ -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 events; - array_list_t *named_arguments=0; + + std::auto_ptr 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; ievents.size(); i++ ) { diff --git a/function.cpp b/function.cpp index a09cb4a38..8933ebcbc 100644 --- a/function.cpp +++ b/function.cpp @@ -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; inamed_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; diff --git a/function.h b/function.h index 547100c7a..851cf8aac 100644 --- a/function.h +++ b/function.h @@ -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.