Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(71)

Side by Side Diff: third_party/libxslt/libexslt/functions.c

Issue 2777943003: Roll libxslt to ac341cbd792ee572941cc9a66e73800219a1a386 (Closed)
Patch Set: Update README.chromium. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/libxslt/libexslt/Makefile.in ('k') | third_party/libxslt/libxslt/Makefile.am » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #define IN_LIBEXSLT 1 #define IN_LIBEXSLT
2 #include "libexslt/libexslt.h" 2 #include "libexslt/libexslt.h"
3 3
4 #if defined(WIN32) && !defined (__CYGWIN__) && (!__MINGW32__) 4 #if defined(WIN32) && !defined (__CYGWIN__) && (!__MINGW32__)
5 #include <win32config.h> 5 #include <win32config.h>
6 #else 6 #else
7 #include "config.h" 7 #include "config.h"
8 #endif 8 #endif
9 9
10 #include <string.h> 10 #include <string.h>
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 else 325 else
326 paramNode = NULL; 326 paramNode = NULL;
327 if ((paramNode == NULL) && (func->nargs != 0)) { 327 if ((paramNode == NULL) && (func->nargs != 0)) {
328 xsltGenericError(xsltGenericErrorContext, 328 xsltGenericError(xsltGenericErrorContext,
329 "exsltFuncFunctionFunction: nargs != 0 and " 329 "exsltFuncFunctionFunction: nargs != 0 and "
330 "param == NULL\n"); 330 "param == NULL\n");
331 return; 331 return;
332 } 332 }
333 333
334 /* 334 /*
335 * When a function is called recursively during evaluation of its
336 * arguments, the recursion check in xsltApplySequenceConstructor
337 * isn't reached.
338 */
339 if (tctxt->depth >= tctxt->maxTemplateDepth) {
340 xsltTransformError(tctxt, NULL, NULL,
341 "exsltFuncFunctionFunction: Potentially infinite recursion "
342 "detected in function {%s}%s.\n",
343 ctxt->context->functionURI, ctxt->context->function);
344 tctxt->state = XSLT_STATE_STOPPED;
345 return;
346 }
347 tctxt->depth++;
348
349 /*
335 * We have a problem with the evaluation of function parameters. 350 * We have a problem with the evaluation of function parameters.
336 * The original library code did not evaluate XPath expressions until 351 * The original library code did not evaluate XPath expressions until
337 * the last moment. After version 1.1.17 of the libxslt, the logic 352 * the last moment. After version 1.1.17 of the libxslt, the logic
338 * of other parts of the library was changed, and the evaluation of 353 * of other parts of the library was changed, and the evaluation of
339 * XPath expressions within parameters now takes place as soon as the 354 * XPath expressions within parameters now takes place as soon as the
340 * parameter is parsed/evaluated (xsltParseStylesheetCallerParam). 355 * parameter is parsed/evaluated (xsltParseStylesheetCallerParam).
341 * This means that the parameters need to be evaluated in lexical 356 * This means that the parameters need to be evaluated in lexical
342 * order (since a variable is "in scope" as soon as it is declared). 357 * order (since a variable is "in scope" as soon as it is declared).
343 * However, on entry to this routine, the values (from the caller) are 358 * However, on entry to this routine, the values (from the caller) are
344 * in reverse order (held on the XPath context variable stack). To 359 * in reverse order (held on the XPath context variable stack). To
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 tctxt->insert = fake; 421 tctxt->insert = fake;
407 xsltApplyOneTemplate (tctxt, xmlXPathGetContextNode(ctxt), 422 xsltApplyOneTemplate (tctxt, xmlXPathGetContextNode(ctxt),
408 func->content, NULL, NULL); 423 func->content, NULL, NULL);
409 xsltLocalVariablePop(tctxt, tctxt->varsBase, -2); 424 xsltLocalVariablePop(tctxt, tctxt->varsBase, -2);
410 tctxt->insert = oldInsert; 425 tctxt->insert = oldInsert;
411 tctxt->varsBase = oldBase; /* restore original scope */ 426 tctxt->varsBase = oldBase; /* restore original scope */
412 if (params != NULL) 427 if (params != NULL)
413 xsltFreeStackElemList(params); 428 xsltFreeStackElemList(params);
414 429
415 if (data->error != 0) 430 if (data->error != 0)
416 » return; 431 goto error;
417 432
418 if (data->result != NULL) { 433 if (data->result != NULL) {
419 ret = data->result; 434 ret = data->result;
420 /* 435 /*
421 * IMPORTANT: This enables previously tree fragments marked as 436 * IMPORTANT: This enables previously tree fragments marked as
422 * being results of a function, to be garbage-collected after 437 * being results of a function, to be garbage-collected after
423 * the calling process exits. 438 * the calling process exits.
424 */ 439 */
425 xsltFlagRVTs(tctxt, ret, XSLT_RVT_LOCAL); 440 xsltFlagRVTs(tctxt, ret, XSLT_RVT_LOCAL);
426 } else 441 } else
427 ret = xmlXPathNewCString(""); 442 ret = xmlXPathNewCString("");
428 443
429 data->result = oldResult; 444 data->result = oldResult;
430 445
431 /* 446 /*
432 * It is an error if the instantiation of the template results in 447 * It is an error if the instantiation of the template results in
433 * the generation of result nodes. 448 * the generation of result nodes.
434 */ 449 */
435 if (fake->children != NULL) { 450 if (fake->children != NULL) {
436 #ifdef LIBXML_DEBUG_ENABLED 451 #ifdef LIBXML_DEBUG_ENABLED
437 xmlDebugDumpNode (stderr, fake, 1); 452 xmlDebugDumpNode (stderr, fake, 1);
438 #endif 453 #endif
439 xsltGenericError(xsltGenericErrorContext, 454 xsltGenericError(xsltGenericErrorContext,
440 "{%s}%s: cannot write to result tree while " 455 "{%s}%s: cannot write to result tree while "
441 "executing a function\n", 456 "executing a function\n",
442 ctxt->context->functionURI, ctxt->context->function); 457 ctxt->context->functionURI, ctxt->context->function);
443 xmlFreeNode(fake); 458 xmlFreeNode(fake);
444 » return; 459 » goto error;
445 } 460 }
446 xmlFreeNode(fake); 461 xmlFreeNode(fake);
447 valuePush(ctxt, ret); 462 valuePush(ctxt, ret);
463
464 error:
465 tctxt->depth--;
448 } 466 }
449 467
450 468
451 static void 469 static void
452 exsltFuncFunctionComp (xsltStylesheetPtr style, xmlNodePtr inst) { 470 exsltFuncFunctionComp (xsltStylesheetPtr style, xmlNodePtr inst) {
453 xmlChar *name, *prefix; 471 xmlChar *name, *prefix;
454 xmlNsPtr ns; 472 xmlNsPtr ns;
455 xmlHashTablePtr data; 473 xmlHashTablePtr data;
456 exsltFuncFunctionData *func; 474 exsltFuncFunctionData *func;
457 475
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
768 (xsltStyleExtShutdownFunction) exsltFuncStyleShutdown); 786 (xsltStyleExtShutdownFunction) exsltFuncStyleShutdown);
769 787
770 xsltRegisterExtModuleTopLevel ((const xmlChar *) "function", 788 xsltRegisterExtModuleTopLevel ((const xmlChar *) "function",
771 EXSLT_FUNCTIONS_NAMESPACE, 789 EXSLT_FUNCTIONS_NAMESPACE,
772 exsltFuncFunctionComp); 790 exsltFuncFunctionComp);
773 xsltRegisterExtModuleElement ((const xmlChar *) "result", 791 xsltRegisterExtModuleElement ((const xmlChar *) "result",
774 EXSLT_FUNCTIONS_NAMESPACE, 792 EXSLT_FUNCTIONS_NAMESPACE,
775 (xsltPreComputeFunction)exsltFuncResultComp, 793 (xsltPreComputeFunction)exsltFuncResultComp,
776 (xsltTransformFunction) exsltFuncResultElem); 794 (xsltTransformFunction) exsltFuncResultElem);
777 } 795 }
OLDNEW
« no previous file with comments | « third_party/libxslt/libexslt/Makefile.in ('k') | third_party/libxslt/libxslt/Makefile.am » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698