[Python-checkins] CVS: python/dist/src/Modules pyexpat.c,2.22,2.23
Lars Marius Garshol
python-dev@python.org
Sun, 24 Sep 2000 13:50:56 -0700
- Previous message: [Python-checkins] CVS: python/dist/src/Lib/xml/sax __init__.py,1.10,1.11 expatreader.py,1.9,1.10 handler.py,1.5,1.6 xmlreader.py,1.7,1.8
- Next message: [Python-checkins] CVS: python/dist/src/Lib/xml/sax expatreader.py,1.10,1.11
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/python/python/dist/src/Modules
In directory slayer.i.sourceforge.net:/tmp/cvs-serv29272
Modified Files:
pyexpat.c
Log Message:
Added ExternalEntityParserCreate method (patch 101635).
Index: pyexpat.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/pyexpat.c,v
retrieving revision 2.22
retrieving revision 2.23
diff -C2 -r2.22 -r2.23
*** pyexpat.c 2000/09/23 04:55:48 2.22
--- pyexpat.c 2000/09/24 20:50:52 2.23
***************
*** 536,539 ****
--- 536,603 ----
}
+ static char xmlparse_ExternalEntityParserCreate__doc__[] =
+ "ExternalEntityParserCreate(context, encoding)\n\
+ Create a parser for parsing an external entity based on the
+ information passed to the ExternalEntityRefHandler.";
+
+ static PyObject *
+ xmlparse_ExternalEntityParserCreate(xmlparseobject *self, PyObject *args)
+ {
+ char *context;
+ char *encoding = NULL;
+ xmlparseobject *new_parser;
+ int i;
+
+ if (!PyArg_ParseTuple(args, "s|s:ExternalEntityParserCreate", &context,
+ &encoding)) {
+ return NULL;
+ }
+
+ #if PY_MAJOR_VERSION == 1 && PY_MINOR_VERSION < 6
+ new_parser = PyObject_NEW(xmlparseobject, &Xmlparsetype);
+ if (new_parser == NULL)
+ return NULL;
+
+ new_parser->returns_unicode = 0;
+ #else
+ /* Code for versions 1.6 and later */
+ new_parser = PyObject_New(xmlparseobject, &Xmlparsetype);
+ if (new_parser == NULL)
+ return NULL;
+
+ new_parser->returns_unicode = 1;
+ #endif
+
+ new_parser->itself = XML_ExternalEntityParserCreate(self->itself, context,
+ encoding);
+ if (!new_parser) {
+ Py_DECREF(new_parser);
+ return PyErr_NoMemory();
+ }
+
+ XML_SetUserData(new_parser->itself, (void *)new_parser);
+
+ /* allocate and clear handlers first */
+ for(i = 0; handler_info[i].name != NULL; i++)
+ /* do nothing */;
+
+ new_parser->handlers = malloc(sizeof(PyObject *)*i);
+ clear_handlers(new_parser);
+
+ /* then copy handlers from self */
+ for (i = 0; handler_info[i].name != NULL; i++) {
+ if (self->handlers[i]) {
+ Py_INCREF(self->handlers[i]);
+ new_parser->handlers[i] = self->handlers[i];
+ handler_info[i].setter(new_parser->itself,
+ handler_info[i].handler);
+ }
+ }
+
+ return new_parser;
+ }
+
+
+
static struct PyMethodDef xmlparse_methods[] = {
{"Parse", (PyCFunction)xmlparse_Parse,
***************
*** 545,548 ****
--- 609,614 ----
{"GetBase", (PyCFunction)xmlparse_GetBase,
METH_VARARGS, xmlparse_GetBase__doc__},
+ {"ExternalEntityParserCreate", (PyCFunction)xmlparse_ExternalEntityParserCreate,
+ METH_VARARGS, xmlparse_ExternalEntityParserCreate__doc__},
{NULL, NULL} /* sentinel */
};
- Previous message: [Python-checkins] CVS: python/dist/src/Lib/xml/sax __init__.py,1.10,1.11 expatreader.py,1.9,1.10 handler.py,1.5,1.6 xmlreader.py,1.7,1.8
- Next message: [Python-checkins] CVS: python/dist/src/Lib/xml/sax expatreader.py,1.10,1.11
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]