applied patch from Aswin to fix tree skipping fixed a comment and added a

* xmlreader.c: applied patch from Aswin to fix tree skipping
* include/libxml/entities.h entities.c: fixed a comment and
  added a new xmlNewEntity() entry point
* runtest.c: be less verbose
* tree.c: space and tabs cleanups
daniel

svn path=/trunk/; revision=3774
diff --git a/runtest.c b/runtest.c
index bda8c53..c7d11fa 100644
--- a/runtest.c
+++ b/runtest.c
@@ -129,7 +129,7 @@
     int len;
 
     if ((pattern == NULL) || (pglob == NULL)) return(-1);
-    
+
     strncpy(directory, pattern, 499);
     for (len = strlen(directory);len >= 0;len--) {
         if (directory[len] == '/') {
@@ -141,12 +141,12 @@
     if (len <= 0)
         len = 0;
 
-    
+
     ret = pglob;
     memset(ret, 0, sizeof(glob_t));
-    
+
     hFind = FindFirstFileA(pattern, &FindFileData);
-    if (hFind == INVALID_HANDLE_VALUE) 
+    if (hFind == INVALID_HANDLE_VALUE)
         return(0);
     nb_paths = 20;
     ret->gl_pathv = (char **) malloc(nb_paths * sizeof(char *));
@@ -181,14 +181,14 @@
     FindClose(hFind);
     return(0);
 }
- 
+
 
 
 static void globfree(glob_t *pglob) {
     unsigned int i;
     if (pglob == NULL)
         return;
-    
+
     for (i = 0;i < pglob->gl_pathc;i++) {
          if (pglob->gl_pathv[i] != NULL)
              free(pglob->gl_pathv[i]);
@@ -222,7 +222,7 @@
  * which is shared to the current running test. We also don't want to have
  * network downloads modifying tests.
  */
-static xmlParserInputPtr 
+static xmlParserInputPtr
 testExternalEntityLoader(const char *URL, const char *ID,
 			 xmlParserCtxtPtr ctxt) {
     xmlParserInputPtr ret;
@@ -234,7 +234,7 @@
 	ret = xmlNoNetExternalEntityLoader(URL, ID, ctxt);
 	extraMemoryFromResolver += xmlMemUsed() - memused;
     }
-      
+
     return(ret);
 }
 
@@ -292,12 +292,12 @@
 /**
  * xmlParserPrintFileContext:
  * @input:  an xmlParserInputPtr input
- * 
+ *
  * Displays current context within the input content for error tracking
  */
 
 static void
-xmlParserPrintFileContextInternal(xmlParserInputPtr input , 
+xmlParserPrintFileContextInternal(xmlParserInputPtr input ,
 		xmlGenericErrorFunc chanl, void *data ) {
     const xmlChar *cur, *base;
     unsigned int n, col;	/* GCC warns if signed, because compared with sizeof() */
@@ -313,8 +313,8 @@
     }
     n = 0;
     /* search backwards for beginning-of-line (to max buff size) */
-    while ((n++ < (sizeof(content)-1)) && (cur > base) && 
-    	   (*(cur) != '\n') && (*(cur) != '\r'))
+    while ((n++ < (sizeof(content)-1)) && (cur > base) &&
+   (*(cur) != '\n') && (*(cur) != '\r'))
         cur--;
     if ((*(cur) == '\n') || (*(cur) == '\r')) cur++;
     /* calculate the error position in terms of the current position */
@@ -323,8 +323,8 @@
     n = 0;
     ctnt = content;
     /* copy selected text to our buffer */
-    while ((*cur != 0) && (*(cur) != '\n') && 
-    	   (*(cur) != '\r') && (n < sizeof(content)-1)) {
+    while ((*cur != 0) && (*(cur) != '\n') &&
+   (*(cur) != '\r') && (n < sizeof(content)-1)) {
 		*ctnt++ = *cur++;
 	n++;
     }
@@ -573,7 +573,7 @@
 	(filename[4] == '/'))
 	filename = &filename[5];
  *************/
-    
+
     base = baseFilename(filename);
     if (suffix == NULL)
         suffix = ".tmp";
@@ -650,7 +650,7 @@
     int idx = 0;
     struct stat info;
 
-    if (stat(filename, &info) < 0) 
+    if (stat(filename, &info) < 0)
 	return(-1);
     if (info.st_size != size)
         return(-1);
@@ -661,7 +661,7 @@
         res = read(fd, bytes, 4096);
 	if (res <= 0)
 	    break;
-	if (res + idx > size) 
+	if (res + idx > size)
 	    break;
 	if (memcmp(bytes, &mem[idx], res) != 0) {
 	    int ix;
@@ -683,7 +683,7 @@
     struct stat info;
     char *base;
     int siz = 0;
-    if (stat(filename, &info) < 0) 
+    if (stat(filename, &info) < 0)
 	return(-1);
     base = malloc(info.st_size + 1);
     if (base == NULL)
@@ -893,7 +893,7 @@
 	return(NULL);
     /* xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; */
 
-    
+
     fprintf(SAXdebug, "SAX.resolveEntity(");
     if (publicId != NULL)
 	fprintf(SAXdebug, "%s", (char *)publicId);
@@ -953,8 +953,8 @@
 /**
  * entityDeclDebug:
  * @ctxt:  An XML parser context
- * @name:  the entity name 
- * @type:  the entity type 
+ * @name:  the entity name
+ * @type:  the entity type
  * @publicId: The public ID of the entity
  * @systemId: The system ID of the entity
  * @content: the entity value (without processing).
@@ -983,8 +983,8 @@
 /**
  * attributeDeclDebug:
  * @ctxt:  An XML parser context
- * @name:  the attribute name 
- * @type:  the attribute type 
+ * @name:  the attribute name
+ * @type:  the attribute type
  *
  * An attribute definition has been parsed
  */
@@ -1008,8 +1008,8 @@
 /**
  * elementDeclDebug:
  * @ctxt:  An XML parser context
- * @name:  the element name 
- * @type:  the element type 
+ * @name:  the element name
+ * @type:  the element type
  * @content: the element value (without processing).
  *
  * An element definition has been parsed
@@ -1195,7 +1195,7 @@
  * @ctxt:  An XML parser context
  * @name:  The entity name
  *
- * called when an entity reference is detected. 
+ * called when an entity reference is detected.
  */
 static void
 referenceDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name)
@@ -1431,7 +1431,7 @@
     else
 	fprintf(SAXdebug, ", '%s'", (char *) URI);
     fprintf(SAXdebug, ", %d", nb_namespaces);
-    
+
     if (namespaces != NULL) {
         for (i = 0;i < nb_namespaces * 2;i++) {
 	    fprintf(SAXdebug, ", xmlns");
@@ -1707,7 +1707,7 @@
     } else
     unlink(temp);
     free(temp);
-    
+
     /* switch back to structured error handling */
     xmlSetGenericErrorFunc(NULL, NULL);
     xmlSetStructuredErrorFunc(NULL, testStructuredErrorHandler);
@@ -1814,7 +1814,7 @@
         fprintf(stderr, "Failed to load %s\n", filename);
 	return(-1);
     }
-    
+
 #ifdef LIBXML_HTML_ENABLED
     if (options & XML_PARSE_HTML)
 	ctxt = htmlCreatePushParserCtxt(NULL, NULL, base + cur, 4, filename,
@@ -1911,7 +1911,7 @@
         fprintf(stderr, "Failed to load %s\n", filename);
 	return(-1);
     }
-    
+
     doc = xmlReadMemory(base, size, filename, NULL, 0);
     unloadMem(base);
     if (doc == NULL) {
@@ -2076,8 +2076,8 @@
 
     value = xmlTextReaderConstValue(reader);
 
-    
-    fprintf(out, "%d %d %s %d %d", 
+
+    fprintf(out, "%d %d %s %d %d",
 	    xmlTextReaderDepth(reader),
 	    type,
 	    name,
@@ -2265,7 +2265,7 @@
 testXPath(const char *str, int xptr, int expr) {
     xmlXPathObjectPtr res;
     xmlXPathContextPtr ctxt;
-    
+
     nb_tests++;
 #if defined(LIBXML_XPTR_ENABLED)
     if (xptr) {
@@ -2336,10 +2336,10 @@
     while (fgets(expression, 4500, input) != NULL) {
 	len = strlen(expression);
 	len--;
-	while ((len >= 0) && 
+	while ((len >= 0) &&
 	       ((expression[len] == '\n') || (expression[len] == '\t') ||
 		(expression[len] == '\r') || (expression[len] == ' '))) len--;
-	expression[len + 1] = 0;      
+	expression[len + 1] = 0;
 	if (len >= 0) {
 	    fprintf(xpathOutput,
 	            "\n========================\nExpression: %s\n",
@@ -3217,7 +3217,7 @@
  * @result: the file with expected result
  * @err: the file with error messages
  *
- * Parse a set of files with streaming, applying an RNG schemas 
+ * Parse a set of files with streaming, applying an RNG schemas
  *
  * Returns 0 in case of success, an error code otherwise
  */
@@ -3257,7 +3257,7 @@
      * hack is also done in the Makefile
      */
     if ((!strcmp(prefix, "tutor10_1")) || (!strcmp(prefix, "tutor10_2")) ||
-        (!strcmp(prefix, "tutor3_2")) || (!strcmp(prefix, "307377"))) 
+        (!strcmp(prefix, "tutor3_2")) || (!strcmp(prefix, "307377")))
 	disable_err = 1;
 
     snprintf(pattern, 499, "./test/relaxng/%s_?.xml", prefix);
@@ -3321,7 +3321,7 @@
 
     type = xmlTextReaderNodeType(reader);
     empty = xmlTextReaderIsEmptyElement(reader);
-	
+
     if (type == XML_READER_TYPE_ELEMENT) {
 	/* do the check only on element start */
 	match = xmlPatternMatch(patternc, xmlTextReaderCurrentNode(reader));
@@ -3353,9 +3353,9 @@
 			"  pattern %s node %s\n",
 			pattern, path);
 	    }
-	    
 
-	} 
+
+	}
 	if ((type == XML_READER_TYPE_END_ELEMENT) ||
 	    ((type == XML_READER_TYPE_ELEMENT) && (empty))) {
 	    ret = xmlStreamPop(patstream);
@@ -3376,7 +3376,7 @@
  * @result: the file with expected result
  * @err: the file with error messages
  *
- * Parse a set of files with streaming, applying an RNG schemas 
+ * Parse a set of files with streaming, applying an RNG schemas
  *
  * Returns 0 in case of success, an error code otherwise
  */
@@ -3525,13 +3525,13 @@
  ************************************************************************/
 static xmlXPathObjectPtr
 load_xpath_expr (xmlDocPtr parent_doc, const char* filename) {
-    xmlXPathObjectPtr xpath; 
+    xmlXPathObjectPtr xpath;
     xmlDocPtr doc;
     xmlChar *expr;
-    xmlXPathContextPtr ctx; 
+    xmlXPathContextPtr ctx;
     xmlNodePtr node;
     xmlNsPtr ns;
-    
+
     /*
      * load XPath expr as a file
      */
@@ -3543,10 +3543,10 @@
 	fprintf(stderr, "Error: unable to parse file \"%s\"\n", filename);
 	return(NULL);
     }
-    
+
     /*
      * Check the document is of the right kind
-     */    
+     */
     if(xmlDocGetRootElement(doc) == NULL) {
         fprintf(stderr,"Error: empty document for file \"%s\"\n", filename);
 	xmlFreeDoc(doc);
@@ -3557,8 +3557,8 @@
     while(node != NULL && !xmlStrEqual(node->name, (const xmlChar *)"XPath")) {
 	node = node->next;
     }
-    
-    if(node == NULL) {   
+
+    if(node == NULL) {
         fprintf(stderr,"Error: XPath element expected in the file  \"%s\"\n", filename);
 	xmlFreeDoc(doc);
 	return(NULL);
@@ -3574,8 +3574,8 @@
     ctx = xmlXPathNewContext(parent_doc);
     if(ctx == NULL) {
         fprintf(stderr,"Error: unable to create new context\n");
-        xmlFree(expr); 
-        xmlFreeDoc(doc); 
+        xmlFree(expr);
+        xmlFreeDoc(doc);
         return(NULL);
     }
 
@@ -3586,31 +3586,31 @@
     while(ns != NULL) {
 	if(xmlXPathRegisterNs(ctx, ns->prefix, ns->href) != 0) {
 	    fprintf(stderr,"Error: unable to register NS with prefix=\"%s\" and href=\"%s\"\n", ns->prefix, ns->href);
-    	    xmlFree(expr); 
-	    xmlXPathFreeContext(ctx); 
-	    xmlFreeDoc(doc); 
+    xmlFree(expr);
+	    xmlXPathFreeContext(ctx);
+	    xmlFreeDoc(doc);
 	    return(NULL);
 	}
 	ns = ns->next;
     }
 
-    /*  
+    /*
      * Evaluate xpath
      */
     xpath = xmlXPathEvalExpression(expr, ctx);
     if(xpath == NULL) {
         fprintf(stderr,"Error: unable to evaluate xpath expression\n");
-    	xmlFree(expr); 
-        xmlXPathFreeContext(ctx); 
-        xmlFreeDoc(doc); 
+xmlFree(expr);
+        xmlXPathFreeContext(ctx);
+        xmlFreeDoc(doc);
         return(NULL);
     }
 
     /* print_xpath_nodes(xpath->nodesetval); */
 
-    xmlFree(expr); 
-    xmlXPathFreeContext(ctx); 
-    xmlFreeDoc(doc); 
+    xmlFree(expr);
+    xmlXPathFreeContext(ctx);
+    xmlFreeDoc(doc);
     return(xpath);
 }
 
@@ -3620,7 +3620,7 @@
 #define xxx_growBufferReentrant() {						\
     buffer_size *= 2;							\
     buffer = (xmlChar **)						\
-    		xmlRealloc(buffer, buffer_size * sizeof(xmlChar*));	\
+	xmlRealloc(buffer, buffer_size * sizeof(xmlChar*));	\
     if (buffer == NULL) {						\
 	perror("realloc failed");					\
 	return(NULL);							\
@@ -3654,7 +3654,7 @@
 	return(NULL);
     }
     out = buffer;
-    
+
     while(*str != '\0') {
 	if (out - buffer > buffer_size - 10) {
 	    int indx = out - buffer;
@@ -3670,12 +3670,12 @@
     return buffer;
 }
 
-static int 
+static int
 c14nRunTest(const char* xml_filename, int with_comments, int exclusive,
 	    const char* xpath_filename, const char *ns_filename,
 	    const char* result_file) {
     xmlDocPtr doc;
-    xmlXPathObjectPtr xpath = NULL; 
+    xmlXPathObjectPtr xpath = NULL;
     xmlChar *result = NULL;
     int ret;
     xmlChar **inclusive_namespaces = NULL;
@@ -3695,24 +3695,24 @@
 	fprintf(stderr, "Error: unable to parse file \"%s\"\n", xml_filename);
 	return(-1);
     }
-    
+
     /*
      * Check the document is of the right kind
-     */    
+     */
     if(xmlDocGetRootElement(doc) == NULL) {
         fprintf(stderr,"Error: empty document for file \"%s\"\n", xml_filename);
 	xmlFreeDoc(doc);
 	return(-1);
     }
 
-    /* 
-     * load xpath file if specified 
+    /*
+     * load xpath file if specified
      */
     if(xpath_filename) {
 	xpath = load_xpath_expr(doc, xpath_filename);
 	if(xpath == NULL) {
 	    fprintf(stderr,"Error: unable to evaluate xpath expression\n");
-	    xmlFreeDoc(doc); 
+	    xmlFreeDoc(doc);
 	    return(-1);
 	}
     }
@@ -3721,7 +3721,7 @@
         if (loadMem(ns_filename, &nslist, &nssize)) {
 	    fprintf(stderr,"Error: unable to evaluate xpath expression\n");
 	    if(xpath != NULL) xmlXPathFreeObject(xpath);
-	    xmlFreeDoc(doc); 
+	    xmlFreeDoc(doc);
 	    return(-1);
 	}
         inclusive_namespaces = parse_list((xmlChar *) nslist);
@@ -3729,10 +3729,10 @@
 
     /*
      * Canonical form
-     */      
+     */
     /* fprintf(stderr,"File \"%s\" loaded: start canonization\n", xml_filename); */
-    ret = xmlC14NDocDumpMemory(doc, 
-	    (xpath) ? xpath->nodesetval : NULL, 
+    ret = xmlC14NDocDumpMemory(doc,
+	    (xpath) ? xpath->nodesetval : NULL,
 	    exclusive, inclusive_namespaces,
 	    with_comments, &result);
     if (ret >= 0) {
@@ -3746,15 +3746,15 @@
 	fprintf(stderr,"Error: failed to canonicalize XML file \"%s\" (ret=%d)\n", xml_filename, ret);
 	ret = -1;
     }
-        
+
     /*
      * Cleanup
-     */ 
+     */
     if (result != NULL) xmlFree(result);
     if(xpath != NULL) xmlXPathFreeObject(xpath);
     if (inclusive_namespaces != NULL) xmlFree(inclusive_namespaces);
     if (nslist != NULL) free((char *) nslist);
-    xmlFreeDoc(doc);    
+    xmlFreeDoc(doc);
 
     return(ret);
 }
@@ -3917,7 +3917,7 @@
     void *results[MAX_ARGC];
     int ret;
     int res = 0;
-    
+
     xmlInitParser();
 
     for (repeat = 0; repeat < 500; repeat++) {
@@ -3993,7 +3993,7 @@
             DWORD useless;
 
             tid[i] = CreateThread(NULL, 0,
-                                  win32_thread_specific_data, 
+                                  win32_thread_specific_data,
 				  (void *) testfiles[i], 0,
                                   &useless);
             if (tid[i] == NULL) {
@@ -4091,7 +4091,7 @@
     return (-1);
 }
 #endif
-static int 
+static int
 threadsTest(const char *filename ATTRIBUTE_UNUSED,
 	    const char *resul ATTRIBUTE_UNUSED,
 	    const char *err ATTRIBUTE_UNUSED,
@@ -4392,7 +4392,6 @@
 
     initializeLibxml2();
 
-    
     for (a = 1; a < argc;a++) {
         if (!strcmp(argv[a], "-v"))
 	    verbose = 1;