Index: skin_parser.c =================================================================== --- skin_parser.c (revision 26458) +++ skin_parser.c (working copy) @@ -407,25 +407,27 @@ star = 1; tag_args++; } - /* If this tag has no arguments, we can bail out now */ if(strlen(tag_args) == 0 - || (tag_args[0] == '|' && *cursor != ARGLISTOPENSYM)) + || (tag_args[0] == '|' && *cursor != ARGLISTOPENSYM) + || (star && *cursor != ARGLISTOPENSYM)) { *document = cursor; return 1; } + star = 0; /* Checking the number of arguments and allocating args */ if(*cursor != ARGLISTOPENSYM && tag_args[0] != '|') { - skin_error(ARGLIST_EXPECTED); + skin_error(ARGLIST_EXPECTED, tag_name); return 0; } else { cursor++; } + for(bookmark = cursor; *cursor != '\n' && *cursor != '\0' && *cursor != ARGLISTCLOSESYM; cursor++) @@ -455,24 +457,10 @@ element->params_count = num_args; element->params = skin_alloc_params(num_args); - /* Now we have to actually parse each argument */ - for(i = 0; i < num_args; i++) + i=0; /* found tags */ + while (*tag_args && iparams[i].type_code = *tag_args; + is_default = (*cursor == DEFAULTSYM); + + switch (*tag_args) + { + case '|': + optional = 1; + tag_args++; + continue; + case 'i': + if (is_default) + { + skin_error(DEFAULT_NOT_ALLOWED, ""); + return 0; + } + case 'I': + if (!is_default) + { + /* Scanning an int argument */ + if(!isdigit(*cursor)) + { + skin_error(INT_EXPECTED, ""); + return 0; + } - /* Checking a nullable argument for null */ - if(*cursor == DEFAULTSYM) + element->params[i].type = NUMERIC; + element->params[i].data.numeric = scan_int(&cursor); + } + else + { + element->params[i].type = DEFAULT; + } + break; + case 's': + case 'f': + if (is_default) + { + skin_error(DEFAULT_NOT_ALLOWED, ""); + return 0; + } + case 'S': + case 'F': + /* Scanning a string argument */ + if (!is_default) + { + element->params[i].type = STRING; + element->params[i].data.text = scan_string(&cursor); + } + else + { + element->params[i].type = DEFAULT; + } + break; + case 'c': + if (is_default) + { + skin_error(DEFAULT_NOT_ALLOWED, ""); + return 0; + } + case 'C': + /* Recursively parsing a code argument */ + element->params[i].type = CODE; + element->params[i].data.code = skin_parse_code_as_arg(&cursor); + if(!element->params[i].data.code) + return 0; + break; + } /* switch (*tag_args) */ + tag_args++; + i++; + + if (*cursor == ARGLISTCLOSESYM) { - if(islower(*tag_args)) + if (!optional && *tag_args && *tag_args != '|') { - element->params[i].type = DEFAULT; - cursor++; - } - else - { - skin_error(DEFAULT_NOT_ALLOWED); + skin_error(INSUFFICIENT_ARGS, tag_name); return 0; } } - else if(tolower(*tag_args) == 'i') + else if (*cursor == ARGLISTSEPERATESYM) { - /* Scanning an int argument */ - if(!isdigit(*cursor)) + if (!*tag_args) { - skin_error(INT_EXPECTED); + skin_error(TOO_MANY_ARGS, tag_name); return 0; } - - element->params[i].type = NUMERIC; - element->params[i].data.numeric = scan_int(&cursor); } - else if(tolower(*tag_args) == 's' || tolower(*tag_args) == 'f') + else { - /* Scanning a string argument */ - element->params[i].type = STRING; - element->params[i].data.text = scan_string(&cursor); - - } - else if(tolower(*tag_args) == 'c') - { - /* Recursively parsing a code argument */ - element->params[i].type = CODE; - element->params[i].data.code = skin_parse_code_as_arg(&cursor); - if(!element->params[i].data.code) - return 0; - } - - skip_whitespace(&cursor); - - if(*cursor != ARGLISTSEPERATESYM && i < num_args - 1) - { - skin_error(SEPERATOR_EXPECTED); + skin_error(SEPERATOR_EXPECTED, ""); return 0; } - else if(*cursor != ARGLISTCLOSESYM && i == num_args - 1) - { - skin_error(CLOSE_EXPECTED); - return 0; - } - else - { - cursor++; - } - - tag_args++; - - /* Checking for the optional bar */ - if(*tag_args == '|') - { - optional = 1; - req_args = i + 1; - tag_args++; - } - + cursor++; } - /* Checking for a premature end */ - if(*tag_args != '\0' && !(optional && (!star || num_args == req_args))) - { - skin_error(INSUFFICIENT_ARGS); - return 0; - } - *document = cursor; return 1;