From 2a7b18f2bab26331de1fadfcabc35d95997f95c6 Mon Sep 17 00:00:00 2001 From: goodale Date: Mon, 3 May 2004 16:11:13 +0000 Subject: Give error when trying to treat a non-array parameter as an array parameter. Fixes PR Cactus/1607. git-svn-id: http://svn.cactuscode.org/flesh/trunk@3684 17b73243-c579-4c4c-a9d2-2d5706c11dac --- src/main/Parameters.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/main/Parameters.c') diff --git a/src/main/Parameters.c b/src/main/Parameters.c index 7db92017..42373e04 100644 --- a/src/main/Parameters.c +++ b/src/main/Parameters.c @@ -1110,8 +1110,10 @@ static t_param *ParameterFind (const char *name, char *basename; int array_index; + /* Split an array parameter into its name and index */ GetBaseName(name, &basename, &array_index); + /* Find the parameter */ node = ParameterPTreeNodeFind (paramtree, basename); free(basename); @@ -1120,6 +1122,7 @@ static t_param *ParameterFind (const char *name, if (node) { + /* Parameter exists for some thorn; check thorn */ for (list = node->paramlist; list; list = list->next) { if (! thorn) @@ -1144,21 +1147,30 @@ static t_param *ParameterFind (const char *name, } } + /* Now get the correct parameter structure */ if(list) { - if(list->param->array && array_index > -1) + if(!list->param->array && array_index > -1) { + /* Trying to treat a non-array parameter as an array */ + retval = NULL; + } + else if(list->param->array && array_index > -1) + { + /* It's an array parameter */ if(array_index < list->param->props->array_size) { retval = &(list->param->array[array_index]); } else { + /* It's out of bounds */ retval = NULL; } } else { + /* Just a normal parameter */ retval = list->param; } } -- cgit v1.2.3