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/xmlreader.c b/xmlreader.c
index 9592008..f325352 100644
--- a/xmlreader.c
+++ b/xmlreader.c
@@ -765,12 +765,25 @@
 	     */
 	    if (reader->mode != XML_TEXTREADER_MODE_EOF) {
 		val = xmlParserInputBufferRead(reader->input, 4096);
-		if (val <= 0) {
+		if ((val == 0) &&
+		    (inbuf->alloc == XML_BUFFER_ALLOC_IMMUTABLE)) {
+		    if (inbuf->use == reader->cur) {
+			reader->mode = XML_TEXTREADER_MODE_EOF;
+			reader->state = oldstate;
+			if ((oldstate != XML_TEXTREADER_START) ||
+			    (reader->ctxt->myDoc != NULL))
+			    return(val);
+		    }
+		} else if (val < 0) {
 		    reader->mode = XML_TEXTREADER_MODE_EOF;
 		    reader->state = oldstate;
 		    if ((oldstate != XML_TEXTREADER_START) ||
 			(reader->ctxt->myDoc != NULL))
 			return(val);
+		} else if (val == 0) {
+		    /* mark the end of the stream and process the remains */
+		    reader->mode = XML_TEXTREADER_MODE_EOF;
+		    break;
 		}
 
 	    } else 
@@ -1572,8 +1585,10 @@
     ret->mode = XML_TEXTREADER_MODE_INITIAL;
     ret->node = NULL;
     ret->curnode = NULL;
-    val = xmlParserInputBufferRead(input, 4);
-    if (val >= 4) {
+    if (ret->input->buffer->use < 4) {
+	val = xmlParserInputBufferRead(input, 4);
+    }
+    if (ret->input->buffer->use >= 4) {
 	ret->ctxt = xmlCreatePushParserCtxt(ret->sax, NULL,
 			(const char *) ret->input->buffer->content, 4, URI);
 	ret->base = 0;