From: William M. Brack Date: Wed, 12 Nov 2003 10:20:03 +0000 (+0000) Subject: applied patch for param visibility from Shaun McCance. Changed variable X-Git-Tag: v1.1.28~560 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0cd2f0c0e9ed0600d29cecb4b24bd47a080083aa;p=platform%2Fupstream%2Flibxslt.git applied patch for param visibility from Shaun McCance. Changed variable * libexslt/functions.c: applied patch for param visibility from Shaun McCance. Changed variable scoping in accordance with Shaun's suggestions. This fixed problem reported on the list by Bernd Lang * tests/exslt/functions/function.8.[xml,xsl,out], Makefile.am: regression test for above --- diff --git a/ChangeLog b/ChangeLog index 8febe8d..25a22ea 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +Tue Nov 12 18:17:24 HKT 2003 William Brack + + * libexslt/functions.c: applied patch for param visibility from + Shaun McCance. Changed variable scoping in accordance with + Shaun's suggestions. This fixed problem reported on the list + by Bernd Lang + * tests/exslt/functions/function.8.[xml,xsl,out], Makefile.am: + regression test for above + Sat Nov 8 13:27:12 CET 2003 Daniel Veillard * libexslt/libexslt.3: applied improvement patch from Jonathan Wakely diff --git a/libexslt/functions.c b/libexslt/functions.c index efa6713..d4ab48c 100644 --- a/libexslt/functions.c +++ b/libexslt/functions.c @@ -262,7 +262,8 @@ exsltFuncFunctionFunction (xmlXPathParserContextPtr ctxt, int nargs) { xmlXPathObjectPtr obj, oldResult, ret; exsltFuncData *data; exsltFuncFunctionData *func; - xmlNodePtr paramNode, oldInsert, fake; + xmlNodePtr paramNode, oldInsert, fake, content = NULL; + int oldBase; xsltStackElemPtr params = NULL, param; xsltTransformContextPtr tctxt = xsltXPathGetTransformContext(ctxt); int i; @@ -289,8 +290,10 @@ exsltFuncFunctionFunction (xmlXPathParserContextPtr ctxt, int nargs) { ctxt->error = XPATH_INVALID_ARITY; return; } - if (func->content != NULL) + if (func->content != NULL) { paramNode = func->content->prev; + content = func->content; + } else paramNode = NULL; if ((paramNode == NULL) && (func->nargs != 0)) { @@ -299,14 +302,13 @@ exsltFuncFunctionFunction (xmlXPathParserContextPtr ctxt, int nargs) { "param == NULL\n"); return; } - /* defaulted params */ + + /* set params */ for (i = func->nargs; (i > nargs) && (paramNode != NULL); i--) { - param = xsltParseStylesheetCallerParam (tctxt, paramNode); - param->next = params; - params = param; paramNode = paramNode->prev; + if (content != NULL) + content = content->prev; } - /* set params */ while ((i-- > 0) && (paramNode != NULL)) { obj = valuePop(ctxt); /* FIXME: this is a bit hackish */ @@ -327,9 +329,16 @@ exsltFuncFunctionFunction (xmlXPathParserContextPtr ctxt, int nargs) { (const xmlChar *)"fake", NULL); oldInsert = tctxt->insert; tctxt->insert = fake; + /* + * In order to give the function variables a new 'scope' we + * change varsBase in the context. + */ + oldBase = tctxt->varsBase; + tctxt->varsBase = tctxt->varsNr; xsltApplyOneTemplate (tctxt, xmlXPathGetContextNode(ctxt), - func->content, NULL, params); + content, NULL, params); tctxt->insert = oldInsert; + tctxt->varsBase = oldBase; /* restore original scope */ if (params != NULL) xsltFreeStackElemList(params); diff --git a/tests/exslt/functions/Makefile.am b/tests/exslt/functions/Makefile.am index ff2e91d..d2c27c0 100644 --- a/tests/exslt/functions/Makefile.am +++ b/tests/exslt/functions/Makefile.am @@ -9,7 +9,9 @@ EXTRA_DIST = \ function.3.out function.3.xml function.3.xsl \ function.4.out function.4.xml function.4.xsl \ function.5.out function.5.xml function.5.xsl \ - function.6.out function.6.xml function.6.xsl + function.6.out function.6.xml function.6.xsl \ + function.7.out function.7.xml function.7.xsl \ + function.8.out function.8.xml function.8.xsl all: diff --git a/tests/exslt/functions/function.8.out b/tests/exslt/functions/function.8.out new file mode 100644 index 0000000..745ace7 --- /dev/null +++ b/tests/exslt/functions/function.8.out @@ -0,0 +1,2 @@ +typedef struct Pcmdb_TestHeadDatabase Pcmdb_TestHeadDatabase; + diff --git a/tests/exslt/functions/function.8.xml b/tests/exslt/functions/function.8.xml new file mode 100644 index 0000000..8eee16d --- /dev/null +++ b/tests/exslt/functions/function.8.xml @@ -0,0 +1,22 @@ + + + + + + Test Head Database + pcmdb + + Max Mueller + August 16, 2002 + + This adt holds relevant information regarding the test head + of the tester. + + There is only one instance of the adt in the system, and you can + query the adt regarding parameters of the current installed test + head. + + + diff --git a/tests/exslt/functions/function.8.xsl b/tests/exslt/functions/function.8.xsl new file mode 100644 index 0000000..5d46af1 --- /dev/null +++ b/tests/exslt/functions/function.8.xsl @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +