How to spend 6 hours finding a 3 line bug :-(
authorDaniel Veillard <veillard@src.gnome.org>
Mon, 7 May 2001 20:55:45 +0000 (20:55 +0000)
committerDaniel Veillard <veillard@src.gnome.org>
Mon, 7 May 2001 20:55:45 +0000 (20:55 +0000)
- libxslt/extra.c: add more debug to xsltDebug
- libxslt/transform.c: spent a few hours tracking down an ugly
  race like bug in xsltCopyTreeList() arghhh
- libxslt/xsltproc.c: call xmlInitMemory() explictely
Daniel

ChangeLog
libxslt/extra.c
libxslt/numbers.c
libxslt/transform.c
libxslt/xsltproc.c

index fe69950..3c20d73 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Mon May  7 22:27:03 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/extra.c: add more debug to xsltDebug
+       * libxslt/transform.c: spent a few hours tracking down an ugly
+         race like bug in xsltCopyTreeList() arghhh
+       * libxslt/xsltproc.c: call xmlInitMemory() explictely
+
 Mon May  7 11:38:54 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
 
        * doc/internals.html: more work done on the doc, mostly complete
index 354d2e6..380646a 100644 (file)
  * Process an debug node
  */
 void 
-xsltDebug(xsltTransformContextPtr ctxt ATTRIBUTE_UNUSED, xmlNodePtr node ATTRIBUTE_UNUSED,
+xsltDebug(xsltTransformContextPtr ctxt, xmlNodePtr node ATTRIBUTE_UNUSED,
          xmlNodePtr inst ATTRIBUTE_UNUSED, xsltStylePreCompPtr comp ATTRIBUTE_UNUSED) {
     int i, j;
 
     fprintf(stdout, "Templates:\n");
-    for (i = 0, j = ctxt->templNr - 1;((i < 5) && (j >= 0));i++,j--) {
+    for (i = 0, j = ctxt->templNr - 1;((i < 15) && (j >= 0));i++,j--) {
        fprintf(stdout, "#%d ", i);
        if (ctxt->templTab[j]->name != NULL)
            fprintf(stdout, "name %s ", ctxt->templTab[j]->name);
@@ -64,7 +64,7 @@ xsltDebug(xsltTransformContextPtr ctxt ATTRIBUTE_UNUSED, xmlNodePtr node ATTRIBU
        fprintf(stdout, "\n");
     }
     fprintf(stdout, "Variables:\n");
-    for (i = 0, j = ctxt->varsNr - 1;((i < 10) && (j >= 0));i++,j--) {
+    for (i = 0, j = ctxt->varsNr - 1;((i < 15) && (j >= 0));i++,j--) {
        xsltStackElemPtr cur;
 
        if (ctxt->varsTab[j] == NULL)
index 1251953..106b80c 100644 (file)
@@ -787,9 +787,10 @@ xsltFormatNumberConversion(xsltDecimalFormatPtr self,
 {
     xmlXPathError status = XPATH_EXPRESSION_OK;
     xmlBufferPtr buffer;
-    xmlChar *the_format, *prefix, *suffix, *nprefix, *nsuffix;
+    xmlChar *the_format, *prefix = NULL, *suffix = NULL;
+    xmlChar *nprefix, *nsuffix = NULL;
     xmlChar pchar;
-    int            prefix_length, suffix_length, nprefix_length, nsuffix_length;
+    int            prefix_length, suffix_length = 0, nprefix_length, nsuffix_length;
     double  scale;
     int            j;
     xsltFormatNumberInfo format_info;
index 2f54b19..2f9d9d4 100644 (file)
@@ -349,17 +349,13 @@ xsltCopyNode(xsltTransformContextPtr ctxt, xmlNodePtr node,
 static xmlNodePtr
 xsltCopyTreeList(xsltTransformContextPtr ctxt, xmlNodePtr list,
             xmlNodePtr insert) {
-    xmlNodePtr copy, ret = NULL, last = NULL;
+    xmlNodePtr copy, ret = NULL;
 
     while (list != NULL) {
        copy = xsltCopyTree(ctxt, list, insert);
        if (copy != NULL) {
            if (ret == NULL) {
                ret = copy;
-               last = ret;
-           } else {
-               last->next = copy;
-               last = copy;
            }
        }
        list = list->next;
@@ -387,6 +383,7 @@ xsltCopyTree(xsltTransformContextPtr ctxt, xmlNodePtr node,
     copy->doc = ctxt->output;
     if (copy != NULL) {
        xmlAddChild(insert, copy);
+       copy->next = NULL;
        /*
         * Add namespaces as they are needed
         */
@@ -1710,6 +1707,10 @@ xsltCopyOf(xsltTransformContextPtr ctxt, xmlNodePtr node,
     ctxt->xpathCtxt->contextSize = oldContextSize;
     if (res != NULL) {
        if (res->type == XPATH_NODESET) {
+#ifdef WITH_XSLT_DEBUG_PROCESS
+           xsltGenericDebug(xsltGenericDebugContext,
+                "xslcopyOf: result is a node set\n");
+#endif
            list = res->nodesetval;
            if (list != NULL) {
                /* sort the list in document order */
@@ -1731,6 +1732,10 @@ xsltCopyOf(xsltTransformContextPtr ctxt, xmlNodePtr node,
                }
            }
        } else if (res->type == XPATH_XSLT_TREE) {
+#ifdef WITH_XSLT_DEBUG_PROCESS
+           xsltGenericDebug(xsltGenericDebugContext,
+                "xslcopyOf: result is a result tree fragment\n");
+#endif
            list = res->nodesetval;
            if ((list != NULL) && (list->nodeTab != NULL) &&
                (list->nodeTab[0] != NULL)) {
index 291ff2d..6a98e48 100644 (file)
@@ -67,9 +67,10 @@ main(int argc, char **argv) {
        printf("      --docbook: the input document is SGML docbook\n");
 #endif
        printf("      --param name value\n");
+       printf("      --debug-mem use libxml memory debugging\n");
        return(0);
     }
-    /* --repeat : repeat 20 times, for timing or profiling */
+    xmlInitMemory();
     LIBXML_TEST_VERSION
     for (i = 1; i < argc ; i++) {
 #ifdef LIBXML_DEBUG_ENABLED