[4suite-checkins] In 4Suite/Ft/Xml/src, files StreamWriter.c,
common.h, xmlstring.h
Jeremy Kloth
jkloth at 4suite.org
Wed Dec 20 23:13:36 MST 2006
- Previous message: [4suite-checkins] In 4Suite/Ft/Xml/Xslt/src, files RtfWriter.c
- Next message: [4suite-checkins] In 4Suite/Ft/Xml/src/domlette, files attr.c,
attr.h, characterdata.c, characterdata.h, comment.c, comment.h,
content_model.c, document.c, document.h, documentfragment.c,
documentfragment.h, domimplementation.c, domimplementation.h,
domlette.c, domlette.h, domlette_interface.h, element.c,
element.h, expat_interface.h, expat_module.c, expat_module.h,
namednodemap.c, node.c, node.h, nss.c, nss.h,
parse_event_handler.c, parse_event_handler.h,
processinginstruction.c, processinginstruction.h, refcounts.c,
text.c, text.h, xmlparser.c, xpathnamespace.c, xpathnamespace.h
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Modified Files:
StreamWriter.c common.h xmlstring.h
Log Message:
- Domlette nodes no longer require an ownerDocument. This means now that
ownerDocument may be None for any or all Nodes if they have yet to be
appended to a tree rooted at a Document.
- Also in these changes, DocumentFragments have been removed as the Document
node type supports the same types of children that DocumentFragments did.
- Saxlette now fully supports the EntityResolver interface, and defaults
to the previous behavior of using the InputSource if no resolver has been
registered.
ViewCVS diff:
http://cvs.4suite.org/viewcvs/4Suite/Ft/Xml/src/StreamWriter.c.diff?r1=1.15&r2=1.16
ViewCVS view:
http://cvs.4suite.org/viewcvs/4Suite/Ft/Xml/src/StreamWriter.c?rev=1.16&content-type=text/vnd.viewcvs-markup
Index: StreamWriter.c
===================================================================
RCS file: /var/local/cvsroot/4Suite/Ft/Xml/src/StreamWriter.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -U2 -r1.15 -r1.16
--- StreamWriter.c 25 Sep 2006 17:33:10 -0000 1.15
+++ StreamWriter.c 21 Dec 2006 06:13:36 -0000 1.16
@@ -23,5 +23,5 @@
typedef struct PyStreamWriterObject {
PyObject_HEAD
-
+
PyObject *stream;
PyObject *encoding;
@@ -53,5 +53,5 @@
}
-static int write_file(PyStreamWriterObject *self, const char *s, int n)
+static int write_file(PyStreamWriterObject *self, const char *s, int n)
{
int byteswritten;
@@ -69,5 +69,5 @@
}
-static int write_cStringIO(PyStreamWriterObject *self, const char *s, int n)
+static int write_cStringIO(PyStreamWriterObject *self, const char *s, int n)
{
if (PycStringIO->cwrite((PyObject *)self->stream, (char *)s, n) != n) {
@@ -94,5 +94,5 @@
{
PyObject *args, *result, *data;
-
+
/* create the arguments tuple */
args = PyTuple_New((Py_ssize_t)1);
@@ -108,10 +108,10 @@
Py_DECREF(args);
if (!result) return NULL;
-
+
if (!PyTuple_Check(result) || PyTuple_GET_SIZE(result) != 2) {
PyErr_SetString(PyExc_TypeError,
"encoder must return a tuple (object,integer)");
}
-
+
/* borrowed reference */
data = PyTuple_GET_ITEM(result, 0);
@@ -151,5 +151,5 @@
return -1;
}
-
+
PyErr_Format(PyExc_ValueError, "Invalid character in %s %s",
PyString_AS_STRING(str), PyString_AS_STRING(repr));
@@ -159,6 +159,6 @@
return -1;
}
-
- result = self->write_func(self, PyString_AS_STRING(data),
+
+ result = self->write_func(self, PyString_AS_STRING(data),
PyString_GET_SIZE(data));
Py_DECREF(data);
@@ -288,5 +288,5 @@
}
}
-
+
if (strcasecmp(PyString_AS_STRING(encoding), "utf-16") == 0) {
/* use either utf-16le or utf-16be to prevent BOM on every encode */
@@ -343,5 +343,5 @@
if (self->write_bom) {
- if (self->write_func(self,
+ if (self->write_func(self,
(self->write_bom == -1) ? "\xff\xfe" : "\xfe\xff",
2) < 0) {
@@ -374,5 +374,5 @@
if (self->write_bom) {
- if (self->write_func(self,
+ if (self->write_func(self,
(self->write_bom == -1) ? "\xff\xfe" : "\xfe\xff",
2) < 0) {
@@ -410,5 +410,5 @@
#define LEGAL_XML_CHAR LEGAL_UCS2
#endif
-
+
static PyObject *writer_writeEscape(PyStreamWriterObject *self, PyObject *args)
{
@@ -424,5 +424,5 @@
if (self->write_bom) {
- if (self->write_func(self,
+ if (self->write_func(self,
(self->write_bom == -1) ? "\xff\xfe" : "\xfe\xff",
2) < 0) {
@@ -477,5 +477,5 @@
Py_DECREF(newstr);
}
-
+
/* the entities are stored as PyStrings or callable objects */
if (PyString_Check(repl)) {
@@ -484,5 +484,5 @@
} else {
/* a callable that generates the replacement string */
- repl = PyObject_CallFunction(repl, "Oi", string,
+ repl = PyObject_CallFunction(repl, "Oi", string,
(p - PyUnicode_AS_UNICODE(string)));
if (repl == NULL) {
@@ -491,5 +491,5 @@
} else if (!PyString_Check(repl)) {
PyErr_Format(PyExc_TypeError,
- "expected string, but %.200s found",
+ "expected string, but %.200s found",
repl->ob_type->tp_name);
Py_DECREF(repl);
@@ -498,5 +498,5 @@
}
}
-
+
/* write the replacement string */
if (write_ascii(self, repl) < 0) {
@@ -524,5 +524,5 @@
Py_DECREF(newstr);
}
-
+
Py_DECREF(string);
Py_INCREF(Py_None);
@@ -538,5 +538,5 @@
{NULL, NULL}
};
-
+
static void writer_dealloc(PyStreamWriterObject *self)
{
@@ -559,5 +559,5 @@
return self->encoding;
}
-
+
else if (strcmp(name, "__members__") == 0) {
PyObject *members = PyList_New((Py_ssize_t)0);
@@ -592,5 +592,5 @@
if (!repr) return NULL;
- sprintf(buf, "<%s at %p, stream=%.256s, encoding='%.128s'>",
+ sprintf(buf, "<%s at %p, stream=%.256s, encoding='%.128s'>",
self->ob_type->tp_name, self, PyString_AsString(repr),
PyString_AsString(self->encoding));
@@ -668,5 +668,5 @@
return NULL;
}
-
+
/* find the largest character ordinal also do validation */
for (i = 0; i < PyTuple_GET_SIZE(seq); i++) {
@@ -695,10 +695,10 @@
} else {
PyErr_Format(PyExc_TypeError,
- "expected string of length 1, but %.200s found",
+ "expected string of length 1, but %.200s found",
key->ob_type->tp_name);
Py_DECREF(self);
return NULL;
}
-
+
if (ord > self->max_entity) self->max_entity = ord;
@@ -709,6 +709,6 @@
return NULL;
} else if (!(PyString_Check(value) || PyCallable_Check(value))) {
- PyErr_Format(PyExc_TypeError,
- "expected string or callable object, but %.200s found",
+ PyErr_Format(PyExc_TypeError,
+ "expected string or callable object, but %.200s found",
value->ob_type->tp_name);
Py_DECREF(value);
@@ -722,6 +722,5 @@
/* create the access table */
- self->entity_table = (PyObject **)calloc(self->max_entity + 1,
- sizeof(PyObject *));
+ self->entity_table = PyMem_New(PyObject *, self->max_entity+1);
if (self->entity_table == NULL) {
Py_DECREF(seq);
@@ -729,4 +728,5 @@
return PyErr_NoMemory();
}
+ memset(self->entity_table, 0, (self->max_entity + 1) * sizeof(PyObject *));
for (i = 0; i < PyTuple_GET_SIZE(seq); i++) {
@@ -734,7 +734,7 @@
if (PyString_Check(key)) {
- ord = (Py_UNICODE)((unsigned char)*PyString_AS_STRING(key));
+ ord = (Py_UNICODE)(PyString_AS_STRING(key)[0]);
} else {
- ord = *PyUnicode_AS_UNICODE(key);
+ ord = PyUnicode_AS_UNICODE(key)[0];
}
@@ -762,5 +762,5 @@
Py_XDECREF(self->entity_table[i]);
}
- free(self->entity_table);
+ PyMem_Del(self->entity_table);
}
@@ -794,5 +794,5 @@
}
return entities;
- }
+ }
else if (strcmp(name, "__members__") == 0) {
return Py_BuildValue("[s]", "entities");
@@ -893,5 +893,5 @@
module = Py_InitModule3("cStreamWriter", module_methods, module_doc);
if (!module) return;
-
+
PycString_IMPORT;
return;
ViewCVS diff:
http://cvs.4suite.org/viewcvs/4Suite/Ft/Xml/src/common.h.diff?r1=1.3&r2=1.4
ViewCVS view:
http://cvs.4suite.org/viewcvs/4Suite/Ft/Xml/src/common.h?rev=1.4&content-type=text/vnd.viewcvs-markup
Index: common.h
===================================================================
RCS file: /var/local/cvsroot/4Suite/Ft/Xml/src/common.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -U2 -r1.3 -r1.4
--- common.h 2 Dec 2006 22:17:21 -0000 1.3
+++ common.h 21 Dec 2006 06:13:36 -0000 1.4
@@ -6,4 +6,5 @@
typedef int Py_ssize_t;
# define PY_FORMAT_SIZE_T ""
+# define PY_ARG_SSIZE_T "i"
# define PY_SSIZE_T_MAX INT_MAX
# define PY_SSIZE_T_MIN INT_MIN
@@ -65,5 +66,5 @@
# define YY_FORMAT_SIZE_T PY_FORMAT_SIZE_T
-
+# define PY_ARG_SSIZE_T "n"
#endif
ViewCVS diff:
http://cvs.4suite.org/viewcvs/4Suite/Ft/Xml/src/xmlstring.h.diff?r1=1.5&r2=1.6
ViewCVS view:
http://cvs.4suite.org/viewcvs/4Suite/Ft/Xml/src/xmlstring.h?rev=1.6&content-type=text/vnd.viewcvs-markup
Index: xmlstring.h
===================================================================
RCS file: /var/local/cvsroot/4Suite/Ft/Xml/src/xmlstring.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -U2 -r1.5 -r1.6
--- xmlstring.h 24 Nov 2006 21:34:47 -0000 1.5
+++ xmlstring.h 21 Dec 2006 06:13:36 -0000 1.6
@@ -28,4 +28,6 @@
#define XmlString_NullCheck(op) ((op) == Py_None || XmlString_Check(op))
+#define XmlString_FromASCII(s) PyUnicode_DecodeASCII((s), strlen(s), NULL)
+
#ifndef XmlString_BUILDING_MODULE
- Previous message: [4suite-checkins] In 4Suite/Ft/Xml/Xslt/src, files RtfWriter.c
- Next message: [4suite-checkins] In 4Suite/Ft/Xml/src/domlette, files attr.c,
attr.h, characterdata.c, characterdata.h, comment.c, comment.h,
content_model.c, document.c, document.h, documentfragment.c,
documentfragment.h, domimplementation.c, domimplementation.h,
domlette.c, domlette.h, domlette_interface.h, element.c,
element.h, expat_interface.h, expat_module.c, expat_module.h,
namednodemap.c, node.c, node.h, nss.c, nss.h,
parse_event_handler.c, parse_event_handler.h,
processinginstruction.c, processinginstruction.h, refcounts.c,
text.c, text.h, xmlparser.c, xpathnamespace.c, xpathnamespace.h
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the 4suite-checkins
mailing list