aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Veillard <veillard@src.gnome.org>2002-11-20 13:28:31 +0000
committerDaniel Veillard <veillard@src.gnome.org>2002-11-20 13:28:31 +0000
commitd076a20ea6254753201004ec444ac38728197a2d (patch)
treeaf0af37acfb55e03410efbb2685ccaf8aa0551d6
parent817e70b6ac0446d9abb6b832963c3473e71b640c (diff)
downloadandroid_external_libxml2-d076a20ea6254753201004ec444ac38728197a2d.tar.gz
android_external_libxml2-d076a20ea6254753201004ec444ac38728197a2d.tar.bz2
android_external_libxml2-d076a20ea6254753201004ec444ac38728197a2d.zip
fixed #99082 for xi:include encoding="..." support on text includes. added
* xinclude.c parserInternals.c encoding.c: fixed #99082 for xi:include encoding="..." support on text includes. * result/XInclude/tstencoding.xml test/XInclude/docs/tstencoding.xml test/XInclude/ents/isolatin.txt : added a specific regression test * python/generator.py python/libxml2class.txt: fixed the generator the new set of comments generated for doc/libxml2-api.xml were breaking the python generation. Daniel
-rw-r--r--ChangeLog10
-rw-r--r--encoding.c2
-rw-r--r--parserInternals.c8
-rwxr-xr-xpython/generator.py2
-rw-r--r--python/libxml2class.txt9
-rw-r--r--result/XInclude/tstencoding.xml6
-rw-r--r--test/XInclude/docs/tstencoding.xml5
-rw-r--r--test/XInclude/ents/isolatin.txt1
-rw-r--r--xinclude.c48
9 files changed, 76 insertions, 15 deletions
diff --git a/ChangeLog b/ChangeLog
index ec1a69ee..e99e421d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+Wed Nov 20 14:24:56 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+ * xinclude.c parserInternals.c encoding.c: fixed #99082
+ for xi:include encoding="..." support on text includes.
+ * result/XInclude/tstencoding.xml test/XInclude/docs/tstencoding.xml
+ test/XInclude/ents/isolatin.txt : added a specific regression test
+ * python/generator.py python/libxml2class.txt: fixed the generator
+ the new set of comments generated for doc/libxml2-api.xml were
+ breaking the python generation.
+
Tue Nov 19 23:25:47 CET 2002 Daniel Veillard <daniel@veillard.com>
* doc/Makefile.am: repair some problem if gtk-doc fail or such
diff --git a/encoding.c b/encoding.c
index 2faa7254..ebb1eeca 100644
--- a/encoding.c
+++ b/encoding.c
@@ -2120,7 +2120,7 @@ xmlCharEncInFunc(xmlCharEncodingHandler * handler, xmlBufferPtr out,
*/
if (ret == -3)
ret = 0;
- return (ret);
+ return (written);
}
/**
diff --git a/parserInternals.c b/parserInternals.c
index 656af842..b526e0a1 100644
--- a/parserInternals.c
+++ b/parserInternals.c
@@ -1436,9 +1436,11 @@ xmlStringCurrentChar(xmlParserCtxtPtr ctxt, const xmlChar * cur, int *len)
ctxt->sax->error(ctxt->userData,
"Char 0x%X out of allowed range\n",
val);
- ctxt->errNo = XML_ERR_INVALID_ENCODING;
- ctxt->wellFormed = 0;
- if (ctxt->recovery == 0) ctxt->disableSAX = 1;
+ if (ctxt != NULL) {
+ ctxt->errNo = XML_ERR_INVALID_ENCODING;
+ ctxt->wellFormed = 0;
+ if (ctxt->recovery == 0) ctxt->disableSAX = 1;
+ }
}
return (val);
} else {
diff --git a/python/generator.py b/python/generator.py
index a8a1b870..9cc3abc5 100755
--- a/python/generator.py
+++ b/python/generator.py
@@ -746,7 +746,7 @@ def writeDoc(name, args, indent, output):
output.write('\n ');
output.write(indent)
output.write(val);
- output.write('"""\n')
+ output.write(' """\n')
def buildWrappers():
global ctypes
diff --git a/python/libxml2class.txt b/python/libxml2class.txt
index e2cbb287..13f10347 100644
--- a/python/libxml2class.txt
+++ b/python/libxml2class.txt
@@ -150,6 +150,13 @@ validateNamesValue()
validateNmtokenValue()
validateNmtokensValue()
+# functions from module wincecompat
+close()
+getenv()
+read()
+strerror()
+write()
+
# functions from module xmlIO
checkFilename()
cleanupInputCallbacks()
@@ -302,7 +309,7 @@ uCSIsUnifiedCanadianAboriginalSyllabics()
uCSIsYiRadicals()
uCSIsYiSyllables()
-# functions from module xmlversion
+# functions from module xmlwin32version
checkVersion()
# functions from module xpathInternals
diff --git a/result/XInclude/tstencoding.xml b/result/XInclude/tstencoding.xml
new file mode 100644
index 00000000..a1c5179d
--- /dev/null
+++ b/result/XInclude/tstencoding.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<x xmlns:xinclude="http://www.w3.org/2001/XInclude">
+ <!-- Simple test of including another text document -->
+ test with accents in ISO-8859-1: À Á é è
+
+</x>
diff --git a/test/XInclude/docs/tstencoding.xml b/test/XInclude/docs/tstencoding.xml
new file mode 100644
index 00000000..b1309a9f
--- /dev/null
+++ b/test/XInclude/docs/tstencoding.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<x xmlns:xinclude="http://www.w3.org/2001/XInclude">
+ <!-- Simple test of including another text document -->
+ <xinclude:include href="../ents/isolatin.txt" encoding="ISO-8859-1" parse="text"/>
+</x>
diff --git a/test/XInclude/ents/isolatin.txt b/test/XInclude/ents/isolatin.txt
new file mode 100644
index 00000000..d1dbf707
--- /dev/null
+++ b/test/XInclude/ents/isolatin.txt
@@ -0,0 +1 @@
+test with accents in ISO-8859-1: À Á é è
diff --git a/xinclude.c b/xinclude.c
index b039ff5c..78ee0427 100644
--- a/xinclude.c
+++ b/xinclude.c
@@ -25,6 +25,7 @@
#include <libxml/xpointer.h>
#include <libxml/parserInternals.h>
#include <libxml/xmlerror.h>
+#include <libxml/encoding.h>
#include <libxml/globals.h>
#ifdef LIBXML_XINCLUDE_ENABLED
@@ -37,6 +38,7 @@
#define XINCLUDE_PARSE (const xmlChar *) "parse"
#define XINCLUDE_PARSE_XML (const xmlChar *) "xml"
#define XINCLUDE_PARSE_TEXT (const xmlChar *) "text"
+#define XINCLUDE_PARSE_ENCODING (const xmlChar *) "encoding"
/* #define DEBUG_XINCLUDE */
#ifdef DEBUG_XINCLUDE
@@ -1106,6 +1108,9 @@ xmlXIncludeLoadTxt(xmlXIncludeCtxtPtr ctxt, const xmlChar *url, int nr) {
xmlURIPtr uri;
xmlChar *URL;
int i;
+ xmlChar *encoding = NULL;
+ xmlCharEncoding enc = 0;
+
/*
* Check the URL and remove any fragment identifier
*/
@@ -1151,10 +1156,33 @@ xmlXIncludeLoadTxt(xmlXIncludeCtxtPtr ctxt, const xmlChar *url, int nr) {
}
}
/*
+ * Try to get the encoding if available
+ */
+ if ((ctxt->incTab[nr] != NULL) && (ctxt->incTab[nr]->ref != NULL)) {
+ encoding = xmlGetProp(ctxt->incTab[nr]->ref, XINCLUDE_PARSE_ENCODING);
+ }
+ if (encoding != NULL) {
+ /*
+ * TODO: we should not have to remap to the xmlCharEncoding
+ * predefined set, a better interface than
+ * xmlParserInputBufferCreateFilename should allow any
+ * encoding supported by iconv
+ */
+ enc = xmlParseCharEncoding((const char *) encoding);
+ if (enc == XML_CHAR_ENCODING_ERROR) {
+ xmlGenericError(xmlGenericErrorContext,
+ "XInclude: encoding %s not supported\n", encoding);
+ xmlFree(encoding);
+ xmlFree(URL);
+ return(-1);
+ }
+ xmlFree(encoding);
+ }
+
+ /*
* Load it.
- * Issue 62: how to detect the encoding
*/
- buf = xmlParserInputBufferCreateFilename((const char *)URL, 0);
+ buf = xmlParserInputBufferCreateFilename((const char *)URL, enc);
if (buf == NULL) {
xmlFree(URL);
return(-1);
@@ -1170,16 +1198,18 @@ xmlXIncludeLoadTxt(xmlXIncludeCtxtPtr ctxt, const xmlChar *url, int nr) {
content = xmlBufferContent(buf->buffer);
len = xmlBufferLength(buf->buffer);
- for (i = 0;i < len; i++) {
- /*
- * TODO: if the encoding issue is solved, scan UTF8 chars instead
- */
- if (!IS_CHAR(content[i])) {
+ for (i = 0;i < len;) {
+ int cur;
+ int l;
+
+ cur = xmlStringCurrentChar(NULL, &content[i], &l);
+ if (!IS_CHAR(cur)) {
xmlGenericError(xmlGenericErrorContext,
- "XInclude: %s contains invalid char %d\n", URL, content[i]);
+ "XInclude: %s contains invalid char %d\n", URL, cur);
} else {
- xmlNodeAddContentLen(node, &content[i], 1);
+ xmlNodeAddContentLen(node, &content[i], l);
}
+ i += l;
}
xmlBufferShrink(buf->buffer, len);
}