add streaming on memory regression tests, found bad bugs in the reader

* Makefile.am: add streaming on memory regression tests, found
  bad bugs in the reader interface
* xmlreader.c: fixing bugs w.r.t. very large names, and special
  condition in end of file.
* xmlIO.c tree.c include/libxml/tree.h include/libxml/xmlIO.h:
  adding immutable buffers, and parser input based on those,
  but this should not be used (yet) for general parsing
* parser.c: added a comment about using immutable buffers for
  general parsing.
* result/bigname.xml.rdr result/bigname2.xml.rdr: fixing the
  output of the regression tests
* xmllint.c: using the immutable buffers when streaming on
  mmaped file (--stream --memory)
Daniel
diff --git a/xmlIO.c b/xmlIO.c
index c318945..ff7c7ad 100644
--- a/xmlIO.c
+++ b/xmlIO.c
@@ -2012,6 +2012,52 @@
 }
 
 /**
+ * xmlParserInputBufferCreateStatic:
+ * @mem:  the memory input
+ * @size:  the length of the memory block
+ * @enc:  the charset encoding if known
+ *
+ * Create a buffered parser input for the progressive parsing for the input
+ * from an immutable memory area. This will not copy the memory area to
+ * the buffer, but the memory is expected to be available until the end of
+ * the parsing, this is useful for example when using mmap'ed file.
+ *
+ * Returns the new parser input or NULL
+ */
+xmlParserInputBufferPtr
+xmlParserInputBufferCreateStatic(const char *mem, int size,
+                                 xmlCharEncoding enc) {
+    xmlParserInputBufferPtr ret;
+
+    if (size <= 0) return(NULL);
+    if (mem == NULL) return(NULL);
+
+    ret = (xmlParserInputBufferPtr) xmlMalloc(sizeof(xmlParserInputBuffer));
+    if (ret == NULL) {
+        xmlGenericError(xmlGenericErrorContext,
+		"xmlParserInputBufferCreateStatic : out of memory!\n");
+	return(NULL);
+    }
+    memset(ret, 0, (size_t) sizeof(xmlParserInputBuffer));
+    ret->buffer = xmlBufferCreateStatic(mem, size);
+    if (ret->buffer == NULL) {
+        xmlFree(ret);
+	return(NULL);
+    }
+    ret->encoder = xmlGetCharEncodingHandler(enc);
+    if (ret->encoder != NULL)
+        ret->raw = xmlBufferCreateSize(2 * xmlDefaultBufferSize);
+    else
+        ret->raw = NULL;
+    ret->compressed = -1;
+    ret->context = (void *) mem;
+    ret->readcallback = NULL;
+    ret->closecallback = NULL;
+
+    return(ret);
+}
+
+/**
  * xmlOutputBufferCreateFd:
  * @fd:  a file descriptor number
  * @encoder:  the encoding converter or NULL
@@ -2265,6 +2311,9 @@
     /* xmlBufferEmpty(in->buffer); */
     if (in->readcallback != NULL)
 	return(xmlParserInputBufferGrow(in, len));
+    else if ((in->buffer != NULL) &&
+             (in->buffer->alloc == XML_BUFFER_ALLOC_IMMUTABLE))
+	return(0);
     else
         return(-1);
 }