OLD | NEW |
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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 if ((data == NULL) || (ch == NULL) || (URI == NULL) || (name == NULL)) | 105 if ((data == NULL) || (ch == NULL) || (URI == NULL) || (name == NULL)) |
106 return; | 106 return; |
107 | 107 |
108 if (ch->ctxt == NULL || ch->hash == NULL) | 108 if (ch->ctxt == NULL || ch->hash == NULL) |
109 return; | 109 return; |
110 | 110 |
111 /* Check if already present */ | 111 /* Check if already present */ |
112 func = (exsltFuncFunctionData*)xmlHashLookup2(ch->hash, URI, name); | 112 func = (exsltFuncFunctionData*)xmlHashLookup2(ch->hash, URI, name); |
113 if (func == NULL) { /* Not yet present - copy it in */ | 113 if (func == NULL) { /* Not yet present - copy it in */ |
114 func = exsltFuncNewFunctionData(); | 114 func = exsltFuncNewFunctionData(); |
| 115 if (func == NULL) |
| 116 return; |
115 memcpy(func, data, sizeof(exsltFuncFunctionData)); | 117 memcpy(func, data, sizeof(exsltFuncFunctionData)); |
116 if (xmlHashAddEntry2(ch->hash, URI, name, func) < 0) { | 118 if (xmlHashAddEntry2(ch->hash, URI, name, func) < 0) { |
117 xsltGenericError(xsltGenericErrorContext, | 119 xsltGenericError(xsltGenericErrorContext, |
118 "Failed to register function {%s}%s\n", | 120 "Failed to register function {%s}%s\n", |
119 URI, name); | 121 URI, name); |
120 } else { /* Do the registration */ | 122 } else { /* Do the registration */ |
121 xsltGenericDebug(xsltGenericDebugContext, | 123 xsltGenericDebug(xsltGenericDebugContext, |
122 "exsltFuncRegisterImportFunc: register {%s}%s\n", | 124 "exsltFuncRegisterImportFunc: register {%s}%s\n", |
123 URI, name); | 125 URI, name); |
124 xsltRegisterExtFunction(ch->ctxt, name, URI, | 126 xsltRegisterExtFunction(ch->ctxt, name, URI, |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 * retrieve func:function template | 296 * retrieve func:function template |
295 */ | 297 */ |
296 data = (exsltFuncData *) xsltGetExtData (tctxt, | 298 data = (exsltFuncData *) xsltGetExtData (tctxt, |
297 EXSLT_FUNCTIONS_NAMESPACE); | 299 EXSLT_FUNCTIONS_NAMESPACE); |
298 oldResult = data->result; | 300 oldResult = data->result; |
299 data->result = NULL; | 301 data->result = NULL; |
300 | 302 |
301 func = (exsltFuncFunctionData*) xmlHashLookup2 (data->funcs, | 303 func = (exsltFuncFunctionData*) xmlHashLookup2 (data->funcs, |
302 ctxt->context->functionURI, | 304 ctxt->context->functionURI, |
303 ctxt->context->function); | 305 ctxt->context->function); |
| 306 if (func == NULL) { |
| 307 /* Should never happen */ |
| 308 xsltGenericError(xsltGenericErrorContext, |
| 309 "{%s}%s: not found\n", |
| 310 ctxt->context->functionURI, ctxt->context->function); |
| 311 ctxt->error = XPATH_UNKNOWN_FUNC_ERROR; |
| 312 return; |
| 313 } |
304 | 314 |
305 /* | 315 /* |
306 * params handling | 316 * params handling |
307 */ | 317 */ |
308 if (nargs > func->nargs) { | 318 if (nargs > func->nargs) { |
309 xsltGenericError(xsltGenericErrorContext, | 319 xsltGenericError(xsltGenericErrorContext, |
310 "{%s}%s: called with too many arguments\n", | 320 "{%s}%s: called with too many arguments\n", |
311 ctxt->context->functionURI, ctxt->context->function); | 321 ctxt->context->functionURI, ctxt->context->function); |
312 ctxt->error = XPATH_INVALID_ARITY; | 322 ctxt->error = XPATH_INVALID_ARITY; |
313 return; | 323 return; |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
487 return; | 497 return; |
488 } | 498 } |
489 xmlFree(prefix); | 499 xmlFree(prefix); |
490 | 500 |
491 xsltParseTemplateContent(style, inst); | 501 xsltParseTemplateContent(style, inst); |
492 | 502 |
493 /* | 503 /* |
494 * Create function data | 504 * Create function data |
495 */ | 505 */ |
496 func = exsltFuncNewFunctionData(); | 506 func = exsltFuncNewFunctionData(); |
| 507 if (func == NULL) { |
| 508 xmlFree(name); |
| 509 return; |
| 510 } |
497 func->content = inst->children; | 511 func->content = inst->children; |
498 while (IS_XSLT_ELEM(func->content) && | 512 while (IS_XSLT_ELEM(func->content) && |
499 IS_XSLT_NAME(func->content, "param")) { | 513 IS_XSLT_NAME(func->content, "param")) { |
500 func->content = func->content->next; | 514 func->content = func->content->next; |
501 func->nargs++; | 515 func->nargs++; |
502 } | 516 } |
503 | 517 |
504 /* | 518 /* |
505 * Register the function data such that it can be retrieved | 519 * Register the function data such that it can be retrieved |
506 * by exslFuncFunctionFunction | 520 * by exslFuncFunctionFunction |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
772 (xsltStyleExtShutdownFunction) exsltFuncStyleShutdown); | 786 (xsltStyleExtShutdownFunction) exsltFuncStyleShutdown); |
773 | 787 |
774 xsltRegisterExtModuleTopLevel ((const xmlChar *) "function", | 788 xsltRegisterExtModuleTopLevel ((const xmlChar *) "function", |
775 EXSLT_FUNCTIONS_NAMESPACE, | 789 EXSLT_FUNCTIONS_NAMESPACE, |
776 exsltFuncFunctionComp); | 790 exsltFuncFunctionComp); |
777 xsltRegisterExtModuleElement ((const xmlChar *) "result", | 791 xsltRegisterExtModuleElement ((const xmlChar *) "result", |
778 EXSLT_FUNCTIONS_NAMESPACE, | 792 EXSLT_FUNCTIONS_NAMESPACE, |
779 (xsltPreComputeFunction)exsltFuncResultComp, | 793 (xsltPreComputeFunction)exsltFuncResultComp, |
780 (xsltTransformFunction) exsltFuncResultElem); | 794 (xsltTransformFunction) exsltFuncResultElem); |
781 } | 795 } |
OLD | NEW |