From: William M. Brack Date: Wed, 24 Nov 2004 02:54:35 +0000 (+0000) Subject: enhanced the evaluation of global variables to take account of possible X-Git-Tag: v1.1.28~355 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=38c93a398f80f5dde5100299f02c5b0fcb680bb6;p=platform%2Fupstream%2Flibxslt.git enhanced the evaluation of global variables to take account of possible * libxslt/variables.c, libxslt/xsltInternals.h: enhanced the evaluation of global variables to take account of possible changes to the current document (bug 158372). --- diff --git a/ChangeLog b/ChangeLog index 589d941..a104683 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Wed Nov 24 10:51:51 HKT 2004 William Brack + + * libxslt/variables.c, libxslt/xsltInternals.h: enhanced the + evaluation of global variables to take account of possible + changes to the current document (bug 158372). + Mon Nov 22 08:10:18 HKT 2004 William Brack * libxslt/pattern.c: small change to previous fix for bug 153137, diff --git a/libxslt/variables.c b/libxslt/variables.c index a6181e7..bcbcc32 100644 --- a/libxslt/variables.c +++ b/libxslt/variables.c @@ -570,7 +570,8 @@ xsltEvalGlobalVariable(xsltStackElemPtr elem, xsltTransformContextPtr ctxt) { if ((ctxt == NULL) || (elem == NULL)) return(NULL); - if (elem->computed) + /* For pre-computation, need to correlate with the current document */ + if ((elem->computed) && (elem->doc == ctxt->xpathCtxt->doc)) return(elem->value); @@ -579,6 +580,12 @@ xsltEvalGlobalVariable(xsltStackElemPtr elem, xsltTransformContextPtr ctxt) { "Evaluating global variable %s\n", elem->name)); #endif + /* If document has changed, destroy the old value */ + if (elem->value != NULL) { + xmlXPathFreeObject(elem->value); + elem->value = NULL; + } + #ifdef WITH_DEBUGGER if ((ctxt->debugStatus != XSLT_DEBUG_NONE) && elem->comp && elem->comp->inst) @@ -687,6 +694,7 @@ xsltEvalGlobalVariable(xsltStackElemPtr elem, xsltTransformContextPtr ctxt) { if (result != NULL) { elem->value = result; elem->computed = 1; + elem->doc = ctxt->xpathCtxt->doc; } elem->name = name; return(result); diff --git a/libxslt/xsltInternals.h b/libxslt/xsltInternals.h index 3629b9a..7b6f99a 100644 --- a/libxslt/xsltInternals.h +++ b/libxslt/xsltInternals.h @@ -311,6 +311,7 @@ struct _xsltStackElem { const xmlChar *select; /* the eval string */ xmlNodePtr tree; /* the tree if no eval string or the location */ xmlXPathObjectPtr value; /* The value if computed */ + xmlDocPtr doc; /* The document used to compute the value */ }; /*