added UTF-8 string checking, raise a problem, need debug Daniel

* debugXML.c include/libxml/xmlerror.h: added UTF-8 string checking,
  raise a problem, need debug
Daniel
diff --git a/ChangeLog b/ChangeLog
index 25125af..a4ec2b6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Fri Oct 15 10:48:30 EDT 2004 Daniel Veillard <daniel@veillard.com>
+
+	* debugXML.c include/libxml/xmlerror.h: added UTF-8 string checking,
+	  raise a problem, need debug
+
 Wed Oct 13 02:17:36 CEST 2004 Daniel Veillard <daniel@veillard.com>
 
 	* python/Makefile.am: applied patch from Thomas Fitzsimmons fixing
diff --git a/config.h.in b/config.h.in
index 8a65287..7973970 100644
--- a/config.h.in
+++ b/config.h.in
@@ -255,7 +255,7 @@
 /* Define to the version of this package. */
 #undef PACKAGE_VERSION
 
-/* Define to 1 if the C compiler supports function prototypes. */
+/* Define if compiler has function prototypes */
 #undef PROTOTYPES
 
 /* Determine what socket length (socklen_t) data type is */
@@ -273,9 +273,6 @@
 /* Using the Win32 Socket implementation */
 #undef _WINSOCKAPI_
 
-/* Define like PROTOTYPES; this can be used by system headers. */
-#undef __PROTOTYPES
-
 /* Win32 Std C name mangling work-around */
 #undef snprintf
 
diff --git a/debugXML.c b/debugXML.c
index 3728470..9b7163d 100644
--- a/debugXML.c
+++ b/debugXML.c
@@ -164,7 +164,7 @@
 		    msg, extra);
 }
 static void
-xmlDebugErr3(xmlDebugCtxtPtr ctxt, int error, const char *msg, char *extra)
+xmlDebugErr3(xmlDebugCtxtPtr ctxt, int error, const char *msg, const char *extra)
 {
     ctxt->errors++;
     __xmlRaiseError(NULL, NULL, NULL,
@@ -208,6 +208,25 @@
     }
 }
 
+/**
+ * xmlCtxtCheckString:
+ * @ctxt: the debug context
+ * @str: the string
+ *
+ * Do debugging on the string, currently it just checks the UTF-8 content
+ */
+static void
+xmlCtxtCheckString(xmlDebugCtxtPtr ctxt, const xmlChar * str)
+{
+    if (str == NULL) return;
+    if (ctxt->check) {
+        if (!xmlCheckUTF8(str)) {
+	    xmlDebugErr3(ctxt, XML_CHECK_NOT_DTD,
+			 "String is not UTF-8 %s", (const char *) str);
+	}
+    }
+}
+
 static void
 xmlCtxtGenericNodeCheck(xmlDebugCtxtPtr ctxt, xmlNodePtr node) {
     if (node->parent == NULL)
@@ -263,6 +282,12 @@
 	    xmlCtxtNsCheckScope(ctxt, node, node->ns);
     }
 
+    if ((node->type != XML_ELEMENT_NODE) &&
+        (node->type != XML_HTML_DOCUMENT_NODE) &&
+        (node->type != XML_DOCUMENT_NODE)) {
+	if (node->content != NULL)
+	    xmlCtxtCheckString(ctxt, (const char *) node->content);
+    }
 }
 
 static void
@@ -270,8 +295,9 @@
 {
     int i;
 
-    if (ctxt->check)
+    if (ctxt->check) {
         return;
+    }
     /* TODO: check UTF8 content of the string */
     if (str == NULL) {
         fprintf(ctxt->output, "(NULL)");
diff --git a/include/libxml/xmlerror.h b/include/libxml/xmlerror.h
index e9e605e..61a5ece 100644
--- a/include/libxml/xmlerror.h
+++ b/include/libxml/xmlerror.h
@@ -777,7 +777,7 @@
     XML_CHECK_WRONG_PARENT,/* 5029 */
     XML_CHECK_NS_SCOPE, /* 5030 */
     XML_CHECK_NS_ANCESTOR, /* 5031 */
-    XML_CHECK_ /* 5032 */
+    XML_CHECK_NOT_UTF8 /* 5032 */
 #if 0
     XML_CHECK_, /* 5033 */
     XML_CHECK_X /* 503 */