fixed problem with detecting external dtd encoding (bug 135229). minor

* parser.c: fixed problem with detecting external dtd
  encoding (bug 135229).
* Makefile.am: minor change to test label
diff --git a/ChangeLog b/ChangeLog
index c5e9c83..beb6de3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Fri Apr 16 23:58:42 HKT 2004 William Brack <wbrack@mmm.com.hk>
+
+	* parser.c: fixed problem with detecting external dtd
+	  encoding (bug 135229).
+	* Makefile.am: minor change to test label
+
 Fri Apr 16 16:09:31 HKT 2004 William Brack <wbrack@mmm.com.hk>
 
 	* xinclude.c: fixed problem causing duplicate fallback
diff --git a/Makefile.am b/Makefile.am
index e567c86..2dd69a3 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -899,7 +899,7 @@
 		      diff $(srcdir)/result/relaxng/"$$name"_"$$xno".err \
 			   err.$$name | grep -v "error detected at";\
 		  fi ; grep Unimplemented err.$$name`; \
-	          if [ -n "$$log" ] ; then echo $$name result ; echo $$log ; fi ; \
+	          if [ -n "$$log" ] ; then echo "$$name"_"$$xno" result ; echo $$log ; fi ; \
 	          rm res.$$name err.$$name ; \
 	       fi ; fi ; \
 	  done; done)
diff --git a/parser.c b/parser.c
index bbec0be..7662929 100644
--- a/parser.c
+++ b/parser.c
@@ -1825,9 +1825,13 @@
 		     * Get the 4 first bytes and decode the charset
 		     * if enc != XML_CHAR_ENCODING_NONE
 		     * plug some encoding conversion routines.
+		     * Note that, since we may have some non-UTF8
+		     * encoding (like UTF16, bug 135229), the 'length'
+		     * is not known, but we can calculate based upon
+		     * the amount of data in the buffer.
 		     */
 		    GROW
-	            if (entity->length >= 4) {
+		    if ((ctxt->input->end - ctxt->input->cur)>=4) {
 			start[0] = RAW;
 			start[1] = NXT(1);
 			start[2] = NXT(2);