| OLD | NEW |
| 1 /* | 1 /* |
| 2 * xsltutils.c: Utilities for the XSL Transformation 1.0 engine | 2 * xsltutils.c: Utilities for the XSL Transformation 1.0 engine |
| 3 * | 3 * |
| 4 * Reference: | 4 * Reference: |
| 5 * http://www.w3.org/TR/1999/REC-xslt-19991116 | 5 * http://www.w3.org/TR/1999/REC-xslt-19991116 |
| 6 * | 6 * |
| 7 * See Copyright for the status of this software. | 7 * See Copyright for the status of this software. |
| 8 * | 8 * |
| 9 * daniel@veillard.com | 9 * daniel@veillard.com |
| 10 */ | 10 */ |
| (...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 512 } \ | 512 } \ |
| 513 } | 513 } |
| 514 /** | 514 /** |
| 515 * xsltGenericErrorDefaultFunc: | 515 * xsltGenericErrorDefaultFunc: |
| 516 * @ctx: an error context | 516 * @ctx: an error context |
| 517 * @msg: the message to display/transmit | 517 * @msg: the message to display/transmit |
| 518 * @...: extra parameters for the message display | 518 * @...: extra parameters for the message display |
| 519 * | 519 * |
| 520 * Default handler for out of context error messages. | 520 * Default handler for out of context error messages. |
| 521 */ | 521 */ |
| 522 static void | 522 static void LIBXSLT_ATTR_FORMAT(2,3) |
| 523 xsltGenericErrorDefaultFunc(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...) { | 523 xsltGenericErrorDefaultFunc(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...) { |
| 524 va_list args; | 524 va_list args; |
| 525 | 525 |
| 526 if (xsltGenericErrorContext == NULL) | 526 if (xsltGenericErrorContext == NULL) |
| 527 xsltGenericErrorContext = (void *) stderr; | 527 xsltGenericErrorContext = (void *) stderr; |
| 528 | 528 |
| 529 va_start(args, msg); | 529 va_start(args, msg); |
| 530 vfprintf((FILE *)xsltGenericErrorContext, msg, args); | 530 vfprintf((FILE *)xsltGenericErrorContext, msg, args); |
| 531 va_end(args); | 531 va_end(args); |
| 532 } | 532 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 558 } | 558 } |
| 559 | 559 |
| 560 /** | 560 /** |
| 561 * xsltGenericDebugDefaultFunc: | 561 * xsltGenericDebugDefaultFunc: |
| 562 * @ctx: an error context | 562 * @ctx: an error context |
| 563 * @msg: the message to display/transmit | 563 * @msg: the message to display/transmit |
| 564 * @...: extra parameters for the message display | 564 * @...: extra parameters for the message display |
| 565 * | 565 * |
| 566 * Default handler for out of context error messages. | 566 * Default handler for out of context error messages. |
| 567 */ | 567 */ |
| 568 static void | 568 static void LIBXSLT_ATTR_FORMAT(2,3) |
| 569 xsltGenericDebugDefaultFunc(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...) { | 569 xsltGenericDebugDefaultFunc(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...) { |
| 570 va_list args; | 570 va_list args; |
| 571 | 571 |
| 572 if (xsltGenericDebugContext == NULL) | 572 if (xsltGenericDebugContext == NULL) |
| 573 return; | 573 return; |
| 574 | 574 |
| 575 va_start(args, msg); | 575 va_start(args, msg); |
| 576 vfprintf((FILE *)xsltGenericDebugContext, msg, args); | 576 vfprintf((FILE *)xsltGenericDebugContext, msg, args); |
| 577 va_end(args); | 577 va_end(args); |
| 578 } | 578 } |
| (...skipping 1377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1956 * @ctxt: an XSLT context | 1956 * @ctxt: an XSLT context |
| 1957 * @output: a FILE * for saving the informations | 1957 * @output: a FILE * for saving the informations |
| 1958 * | 1958 * |
| 1959 * Save the profiling informations on @output | 1959 * Save the profiling informations on @output |
| 1960 */ | 1960 */ |
| 1961 void | 1961 void |
| 1962 xsltSaveProfiling(xsltTransformContextPtr ctxt, FILE *output) { | 1962 xsltSaveProfiling(xsltTransformContextPtr ctxt, FILE *output) { |
| 1963 int nb, i,j,k,l; | 1963 int nb, i,j,k,l; |
| 1964 int max; | 1964 int max; |
| 1965 int total; | 1965 int total; |
| 1966 long totalt; | 1966 unsigned long totalt; |
| 1967 xsltTemplatePtr *templates; | 1967 xsltTemplatePtr *templates; |
| 1968 xsltStylesheetPtr style; | 1968 xsltStylesheetPtr style; |
| 1969 xsltTemplatePtr templ1,templ2; | 1969 xsltTemplatePtr templ1,templ2; |
| 1970 int *childt; | 1970 int *childt; |
| 1971 | 1971 |
| 1972 if ((output == NULL) || (ctxt == NULL)) | 1972 if ((output == NULL) || (ctxt == NULL)) |
| 1973 return; | 1973 return; |
| 1974 if (ctxt->profile == 0) | 1974 if (ctxt->profile == 0) |
| 1975 return; | 1975 return; |
| 1976 | 1976 |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2069 } | 2069 } |
| 2070 } | 2070 } |
| 2071 } | 2071 } |
| 2072 } | 2072 } |
| 2073 childt[i] = 0; | 2073 childt[i] = 0; |
| 2074 | 2074 |
| 2075 fprintf(output, "\nindex %% time self children called name\n"); | 2075 fprintf(output, "\nindex %% time self children called name\n"); |
| 2076 | 2076 |
| 2077 for (i = 0; i < nb; i++) { | 2077 for (i = 0; i < nb; i++) { |
| 2078 char ix_str[20], timep_str[20], times_str[20], timec_str[20], called_str
[20]; | 2078 char ix_str[20], timep_str[20], times_str[20], timec_str[20], called_str
[20]; |
| 2079 int t; | 2079 unsigned long t; |
| 2080 | 2080 |
| 2081 templ1 = templates[i]; | 2081 templ1 = templates[i]; |
| 2082 /* callers */ | 2082 /* callers */ |
| 2083 for (j = 0; j < templ1->templNr; j++) { | 2083 for (j = 0; j < templ1->templNr; j++) { |
| 2084 templ2 = templ1->templCalledTab[j]; | 2084 templ2 = templ1->templCalledTab[j]; |
| 2085 for (k = 0; k < nb; k++) { | 2085 for (k = 0; k < nb; k++) { |
| 2086 if (templates[k] == templ2) | 2086 if (templates[k] == templ2) |
| 2087 break; | 2087 break; |
| 2088 } | 2088 } |
| 2089 t=templ2?templ2->time:totalt; | 2089 t=templ2?templ2->time:totalt; |
| 2090 sprintf(times_str,"%8.3f",(float)t/XSLT_TIMESTAMP_TICS_PER_SEC); | 2090 snprintf(times_str,sizeof(times_str),"%8.3f",(float)t/XSLT_TIMESTAMP
_TICS_PER_SEC); |
| 2091 sprintf(timec_str,"%8.3f",(float)childt[k]/XSLT_TIMESTAMP_TICS_PER_S
EC); | 2091 snprintf(timec_str,sizeof(timec_str),"%8.3f",(float)childt[k]/XSLT_T
IMESTAMP_TICS_PER_SEC); |
| 2092 sprintf(called_str,"%6d/%d", | 2092 snprintf(called_str,sizeof(called_str),"%6d/%d", |
| 2093 templ1->templCountTab[j], /* number of times caller calls 'this'
*/ | 2093 templ1->templCountTab[j], /* number of times caller calls 'this'
*/ |
| 2094 templ1->nbCalls); /* total number of calls to 'this' */ | 2094 templ1->nbCalls); /* total number of calls to 'this' */ |
| 2095 | 2095 |
| 2096 fprintf(output, " %-8s %-8s %-12s %s [%d]\n", | 2096 fprintf(output, " %-8s %-8s %-12s %s [%d]\n", |
| 2097 times_str,timec_str,called_str, | 2097 times_str,timec_str,called_str, |
| 2098 (templ2?(templ2->name?(char *)templ2->name:pretty_templ_match(te
mpl2)):"-"),k); | 2098 (templ2?(templ2->name?(char *)templ2->name:pretty_templ_match(te
mpl2)):"-"),k); |
| 2099 } | 2099 } |
| 2100 /* this */ | 2100 /* this */ |
| 2101 sprintf(ix_str,"[%d]",i); | 2101 snprintf(ix_str,sizeof(ix_str),"[%d]",i); |
| 2102 sprintf(timep_str,"%6.2f",(float)templ1->time*100.0/totalt); | 2102 snprintf(timep_str,sizeof(timep_str),"%6.2f",(float)templ1->time*100.0/t
otalt); |
| 2103 sprintf(times_str,"%8.3f",(float)templ1->time/XSLT_TIMESTAMP_TICS_PER_SE
C); | 2103 snprintf(times_str,sizeof(times_str),"%8.3f",(float)templ1->time/XSLT_TI
MESTAMP_TICS_PER_SEC); |
| 2104 sprintf(timec_str,"%8.3f",(float)childt[i]/XSLT_TIMESTAMP_TICS_PER_SEC); | 2104 snprintf(timec_str,sizeof(timec_str),"%8.3f",(float)childt[i]/XSLT_TIMES
TAMP_TICS_PER_SEC); |
| 2105 fprintf(output, "%-5s %-6s %-8s %-8s %6d %s [%d]\n", | 2105 fprintf(output, "%-5s %-6s %-8s %-8s %6d %s [%d]\n", |
| 2106 ix_str, timep_str,times_str,timec_str, | 2106 ix_str, timep_str,times_str,timec_str, |
| 2107 templ1->nbCalls, | 2107 templ1->nbCalls, |
| 2108 templ1->name?(char *)templ1->name:pretty_templ_match(templ1),i); | 2108 templ1->name?(char *)templ1->name:pretty_templ_match(templ1),i); |
| 2109 /* callees | 2109 /* callees |
| 2110 * - go over templates[0..nb] and their templCalledTab[] | 2110 * - go over templates[0..nb] and their templCalledTab[] |
| 2111 * - print those where we in the the call-stack | 2111 * - print those where we in the the call-stack |
| 2112 */ | 2112 */ |
| 2113 total = 0; | 2113 total = 0; |
| 2114 for (k = 0; k < nb; k++) { | 2114 for (k = 0; k < nb; k++) { |
| 2115 templ2 = templates[k]; | 2115 templ2 = templates[k]; |
| 2116 for (l = 0; l < templ2->templNr; l++) { | 2116 for (l = 0; l < templ2->templNr; l++) { |
| 2117 if (templ2->templCalledTab[l] == templ1) { | 2117 if (templ2->templCalledTab[l] == templ1) { |
| 2118 total+=templ2->templCountTab[l]; | 2118 total+=templ2->templCountTab[l]; |
| 2119 } | 2119 } |
| 2120 } | 2120 } |
| 2121 } | 2121 } |
| 2122 for (k = 0; k < nb; k++) { | 2122 for (k = 0; k < nb; k++) { |
| 2123 templ2 = templates[k]; | 2123 templ2 = templates[k]; |
| 2124 for (l = 0; l < templ2->templNr; l++) { | 2124 for (l = 0; l < templ2->templNr; l++) { |
| 2125 if (templ2->templCalledTab[l] == templ1) { | 2125 if (templ2->templCalledTab[l] == templ1) { |
| 2126 sprintf(times_str,"%8.3f",(float)templ2->time/XSLT_TIMESTAMP
_TICS_PER_SEC); | 2126 snprintf(times_str,sizeof(times_str),"%8.3f",(float)templ2->
time/XSLT_TIMESTAMP_TICS_PER_SEC); |
| 2127 sprintf(timec_str,"%8.3f",(float)childt[k]/XSLT_TIMESTAMP_TI
CS_PER_SEC); | 2127 snprintf(timec_str,sizeof(timec_str),"%8.3f",(float)childt[k
]/XSLT_TIMESTAMP_TICS_PER_SEC); |
| 2128 sprintf(called_str,"%6d/%d", | 2128 snprintf(called_str,sizeof(called_str),"%6d/%d", |
| 2129 templ2->templCountTab[l], /* number of times 'this' call
s callee */ | 2129 templ2->templCountTab[l], /* number of times 'this' call
s callee */ |
| 2130 total); /* total number of calls from
'this' */ | 2130 total); /* total number of calls from
'this' */ |
| 2131 fprintf(output, " %-8s %-8s %-12s %s [%d]\n"
, | 2131 fprintf(output, " %-8s %-8s %-12s %s [%d]\n"
, |
| 2132 times_str,timec_str,called_str, | 2132 times_str,timec_str,called_str, |
| 2133 templ2->name?(char *)templ2->name:pretty_templ_match(tem
pl2),k); | 2133 templ2->name?(char *)templ2->name:pretty_templ_match(tem
pl2),k); |
| 2134 } | 2134 } |
| 2135 } | 2135 } |
| 2136 } | 2136 } |
| 2137 fprintf(output, "-----------------------------------------------\n"); | 2137 fprintf(output, "-----------------------------------------------\n"); |
| 2138 } | 2138 } |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2238 | 2238 |
| 2239 /* | 2239 /* |
| 2240 * Generate a document corresponding to the results. | 2240 * Generate a document corresponding to the results. |
| 2241 */ | 2241 */ |
| 2242 ret = xmlNewDoc(BAD_CAST "1.0"); | 2242 ret = xmlNewDoc(BAD_CAST "1.0"); |
| 2243 root = xmlNewDocNode(ret, NULL, BAD_CAST "profile", NULL); | 2243 root = xmlNewDocNode(ret, NULL, BAD_CAST "profile", NULL); |
| 2244 xmlDocSetRootElement(ret, root); | 2244 xmlDocSetRootElement(ret, root); |
| 2245 | 2245 |
| 2246 for (i = 0; i < nb; i++) { | 2246 for (i = 0; i < nb; i++) { |
| 2247 child = xmlNewChild(root, NULL, BAD_CAST "template", NULL); | 2247 child = xmlNewChild(root, NULL, BAD_CAST "template", NULL); |
| 2248 sprintf(buf, "%d", i + 1); | 2248 snprintf(buf, sizeof(buf), "%d", i + 1); |
| 2249 xmlSetProp(child, BAD_CAST "rank", BAD_CAST buf); | 2249 xmlSetProp(child, BAD_CAST "rank", BAD_CAST buf); |
| 2250 xmlSetProp(child, BAD_CAST "match", BAD_CAST templates[i]->match); | 2250 xmlSetProp(child, BAD_CAST "match", BAD_CAST templates[i]->match); |
| 2251 xmlSetProp(child, BAD_CAST "name", BAD_CAST templates[i]->name); | 2251 xmlSetProp(child, BAD_CAST "name", BAD_CAST templates[i]->name); |
| 2252 xmlSetProp(child, BAD_CAST "mode", BAD_CAST templates[i]->mode); | 2252 xmlSetProp(child, BAD_CAST "mode", BAD_CAST templates[i]->mode); |
| 2253 | 2253 |
| 2254 sprintf(buf, "%d", templates[i]->nbCalls); | 2254 snprintf(buf, sizeof(buf), "%d", templates[i]->nbCalls); |
| 2255 xmlSetProp(child, BAD_CAST "calls", BAD_CAST buf); | 2255 xmlSetProp(child, BAD_CAST "calls", BAD_CAST buf); |
| 2256 | 2256 |
| 2257 sprintf(buf, "%ld", templates[i]->time); | 2257 snprintf(buf, sizeof(buf), "%ld", templates[i]->time); |
| 2258 xmlSetProp(child, BAD_CAST "time", BAD_CAST buf); | 2258 xmlSetProp(child, BAD_CAST "time", BAD_CAST buf); |
| 2259 | 2259 |
| 2260 sprintf(buf, "%ld", templates[i]->time / templates[i]->nbCalls); | 2260 snprintf(buf, sizeof(buf), "%ld", templates[i]->time / templates[i]->nbC
alls); |
| 2261 xmlSetProp(child, BAD_CAST "average", BAD_CAST buf); | 2261 xmlSetProp(child, BAD_CAST "average", BAD_CAST buf); |
| 2262 }; | 2262 }; |
| 2263 | 2263 |
| 2264 xmlFree(templates); | 2264 xmlFree(templates); |
| 2265 | 2265 |
| 2266 return ret; | 2266 return ret; |
| 2267 } | 2267 } |
| 2268 | 2268 |
| 2269 /************************************************************************ | 2269 /************************************************************************ |
| 2270 * * | 2270 * * |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2473 * | 2473 * |
| 2474 * Drop the topmost item off the call stack | 2474 * Drop the topmost item off the call stack |
| 2475 */ | 2475 */ |
| 2476 void | 2476 void |
| 2477 xslDropCall(void) | 2477 xslDropCall(void) |
| 2478 { | 2478 { |
| 2479 if (xsltDebuggerCurrentCallbacks.drop != NULL) | 2479 if (xsltDebuggerCurrentCallbacks.drop != NULL) |
| 2480 xsltDebuggerCurrentCallbacks.drop(); | 2480 xsltDebuggerCurrentCallbacks.drop(); |
| 2481 } | 2481 } |
| 2482 | 2482 |
| OLD | NEW |