diff --git a/libxslt/variables.c b/libxslt/variables.c index 09069aa3..07c17825 100644 --- a/libxslt/variables.c +++ b/libxslt/variables.c @@ -1403,28 +1403,21 @@ xsltRegisterGlobalVariable(xsltStylesheetPtr style, const xmlChar *name, elem->nameURI = xmlDictLookup(style->dict, ns_uri, -1); elem->tree = tree; tmp = style->variables; - if (tmp == NULL) { - elem->next = NULL; - style->variables = elem; - } else { - while (tmp != NULL) { - if ((elem->comp->type == XSLT_FUNC_VARIABLE) && - (tmp->comp->type == XSLT_FUNC_VARIABLE) && - (xmlStrEqual(elem->name, tmp->name)) && - ((elem->nameURI == tmp->nameURI) || - (xmlStrEqual(elem->nameURI, tmp->nameURI)))) - { - xsltTransformError(NULL, style, comp->inst, - "redefinition of global variable %s\n", elem->name); - style->errors++; - } - if (tmp->next == NULL) - break; - tmp = tmp->next; - } - elem->next = NULL; - tmp->next = elem; + while (tmp != NULL) { + if ((elem->comp->type == XSLT_FUNC_VARIABLE) && + (tmp->comp->type == XSLT_FUNC_VARIABLE) && + (xmlStrEqual(elem->name, tmp->name)) && + ((elem->nameURI == tmp->nameURI) || + (xmlStrEqual(elem->nameURI, tmp->nameURI)))) + { + xsltTransformError(NULL, style, comp->inst, + "redefinition of global variable %s\n", elem->name); + style->errors++; + } + tmp = tmp->next; } + elem->next = style->variables;; + style->variables = elem; if (value != NULL) { elem->computed = 1; elem->value = xmlXPathNewString(value); diff --git a/tests/general/bug-224.out b/tests/general/bug-224.out new file mode 100644 index 00000000..0a44197e --- /dev/null +++ b/tests/general/bug-224.out @@ -0,0 +1,9 @@ + + +id1 +id2 +id3 +id4 +id5 +id6 + diff --git a/tests/general/bug-224.xml b/tests/general/bug-224.xml new file mode 100644 index 00000000..da78efb2 --- /dev/null +++ b/tests/general/bug-224.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/tests/general/bug-224.xsl b/tests/general/bug-224.xsl new file mode 100644 index 00000000..f944c43b --- /dev/null +++ b/tests/general/bug-224.xsl @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + +