mirror of https://github.com/python/cpython.git
Convert coding style to be internally consistent and similar to the
rest of the Python C code: space between "if", "for" and "(", no space between "(", ")" and function call parameters, etc.
This commit is contained in:
parent
cc1be2401e
commit
0582df98d3
|
@ -70,7 +70,8 @@ staticforward struct HandlerInfo handler_info[64];
|
||||||
|
|
||||||
/* Convert an array of attributes and their values into a Python dict */
|
/* Convert an array of attributes and their values into a Python dict */
|
||||||
|
|
||||||
static PyObject *conv_atts_using_string(XML_Char **atts)
|
static PyObject *
|
||||||
|
conv_atts_using_string(XML_Char **atts)
|
||||||
{
|
{
|
||||||
PyObject *attrs_obj = NULL;
|
PyObject *attrs_obj = NULL;
|
||||||
XML_Char **attrs_p, **attrs_k = NULL;
|
XML_Char **attrs_p, **attrs_k = NULL;
|
||||||
|
@ -105,7 +106,9 @@ static PyObject *conv_atts_using_string(XML_Char **atts)
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !(PY_MAJOR_VERSION == 1 && PY_MINOR_VERSION < 6)
|
#if !(PY_MAJOR_VERSION == 1 && PY_MINOR_VERSION < 6)
|
||||||
static PyObject *conv_atts_using_unicode( XML_Char **atts){
|
static PyObject *
|
||||||
|
conv_atts_using_unicode(XML_Char **atts)
|
||||||
|
{
|
||||||
PyObject *attrs_obj = NULL;
|
PyObject *attrs_obj = NULL;
|
||||||
XML_Char **attrs_p, **attrs_k = NULL;
|
XML_Char **attrs_p, **attrs_k = NULL;
|
||||||
int attrs_len;
|
int attrs_len;
|
||||||
|
@ -140,7 +143,8 @@ static PyObject *conv_atts_using_unicode( XML_Char **atts){
|
||||||
Py_DECREF(attr_str);
|
Py_DECREF(attr_str);
|
||||||
Py_DECREF(value_str);
|
Py_DECREF(value_str);
|
||||||
}
|
}
|
||||||
else attrs_k=attrs_p;
|
else
|
||||||
|
attrs_k = attrs_p;
|
||||||
}
|
}
|
||||||
finally:
|
finally:
|
||||||
return attrs_obj;
|
return attrs_obj;
|
||||||
|
@ -149,21 +153,31 @@ static PyObject *conv_atts_using_unicode( XML_Char **atts){
|
||||||
/* Convert a string of XML_Chars into a Unicode string.
|
/* Convert a string of XML_Chars into a Unicode string.
|
||||||
Returns None if str is a null pointer. */
|
Returns None if str is a null pointer. */
|
||||||
|
|
||||||
static PyObject *conv_string_to_unicode( XML_Char *str ) {
|
static PyObject *
|
||||||
|
conv_string_to_unicode(XML_Char *str)
|
||||||
|
{
|
||||||
/* XXX currently this code assumes that XML_Char is 8-bit,
|
/* XXX currently this code assumes that XML_Char is 8-bit,
|
||||||
and hence in UTF-8. */
|
and hence in UTF-8. */
|
||||||
/* UTF-8 from Expat, Unicode desired */
|
/* UTF-8 from Expat, Unicode desired */
|
||||||
if (str == NULL) {Py_INCREF(Py_None); return Py_None;}
|
if (str == NULL) {
|
||||||
|
Py_INCREF(Py_None);
|
||||||
|
return Py_None;
|
||||||
|
}
|
||||||
return PyUnicode_DecodeUTF8((const char *)str,
|
return PyUnicode_DecodeUTF8((const char *)str,
|
||||||
strlen((const char *)str),
|
strlen((const char *)str),
|
||||||
"strict");
|
"strict");
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *conv_string_len_to_unicode( const XML_Char *str, int len ) {
|
static PyObject *
|
||||||
|
conv_string_len_to_unicode(const XML_Char *str, int len)
|
||||||
|
{
|
||||||
/* XXX currently this code assumes that XML_Char is 8-bit,
|
/* XXX currently this code assumes that XML_Char is 8-bit,
|
||||||
and hence in UTF-8. */
|
and hence in UTF-8. */
|
||||||
/* UTF-8 from Expat, Unicode desired */
|
/* UTF-8 from Expat, Unicode desired */
|
||||||
if (str == NULL) {Py_INCREF(Py_None); return Py_None;}
|
if (str == NULL) {
|
||||||
|
Py_INCREF(Py_None);
|
||||||
|
return Py_None;
|
||||||
|
}
|
||||||
return PyUnicode_DecodeUTF8((const char *)str,
|
return PyUnicode_DecodeUTF8((const char *)str,
|
||||||
len,
|
len,
|
||||||
"strict");
|
"strict");
|
||||||
|
@ -407,13 +421,11 @@ read_other(xmlparseobject *self, char **s, int n) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* ---------------------------------------------------------------- */
|
/* ---------------------------------------------------------------- */
|
||||||
|
|
||||||
static char xmlparse_Parse__doc__[] =
|
static char xmlparse_Parse__doc__[] =
|
||||||
"(data [,isfinal]) - Parse XML data"
|
"Parse(data[, isfinal])
|
||||||
;
|
Parse XML data. `isfinal' should be true at end of input.";
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
xmlparse_Parse(xmlparseobject *self, PyObject *args)
|
xmlparse_Parse(xmlparseobject *self, PyObject *args)
|
||||||
|
@ -423,7 +435,7 @@ xmlparse_Parse( xmlparseobject *self, PyObject *args )
|
||||||
int isFinal = 0;
|
int isFinal = 0;
|
||||||
int rv;
|
int rv;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "s#|i", &s, &slen, &isFinal))
|
if (!PyArg_ParseTuple(args, "s#|i:Parse", &s, &slen, &isFinal))
|
||||||
return NULL;
|
return NULL;
|
||||||
rv = XML_Parse(self->itself, s, slen, isFinal);
|
rv = XML_Parse(self->itself, s, slen, isFinal);
|
||||||
if (PyErr_Occurred()) {
|
if (PyErr_Occurred()) {
|
||||||
|
@ -436,13 +448,14 @@ xmlparse_Parse( xmlparseobject *self, PyObject *args )
|
||||||
XML_GetErrorColumnNumber(self->itself));
|
XML_GetErrorColumnNumber(self->itself));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
return PyInt_FromLong(rv);
|
||||||
return Py_BuildValue("i", rv);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define BUF_SIZE 2048
|
#define BUF_SIZE 2048
|
||||||
|
|
||||||
int readinst(char *buf, int buf_size, PyObject *meth){
|
static int
|
||||||
|
readinst(char *buf, int buf_size, PyObject *meth)
|
||||||
|
{
|
||||||
PyObject *arg = NULL;
|
PyObject *arg = NULL;
|
||||||
PyObject *bytes = NULL;
|
PyObject *bytes = NULL;
|
||||||
PyObject *str = NULL;
|
PyObject *str = NULL;
|
||||||
|
@ -453,7 +466,6 @@ int readinst(char *buf, int buf_size, PyObject *meth){
|
||||||
PyErr_SetNone(PyExc_EOFError);
|
PyErr_SetNone(PyExc_EOFError);
|
||||||
goto finally;
|
goto finally;
|
||||||
}
|
}
|
||||||
|
|
||||||
UNLESS(arg)
|
UNLESS(arg)
|
||||||
UNLESS(arg = PyTuple_New(1))
|
UNLESS(arg = PyTuple_New(1))
|
||||||
goto finally;
|
goto finally;
|
||||||
|
@ -471,7 +483,6 @@ int readinst(char *buf, int buf_size, PyObject *meth){
|
||||||
str->ob_type->tp_name);
|
str->ob_type->tp_name);
|
||||||
goto finally;
|
goto finally;
|
||||||
}
|
}
|
||||||
|
|
||||||
len = PyString_GET_SIZE(str);
|
len = PyString_GET_SIZE(str);
|
||||||
if (len > buf_size) {
|
if (len > buf_size) {
|
||||||
PyErr_Format(PyExc_ValueError,
|
PyErr_Format(PyExc_ValueError,
|
||||||
|
@ -489,8 +500,8 @@ int readinst(char *buf, int buf_size, PyObject *meth){
|
||||||
}
|
}
|
||||||
|
|
||||||
static char xmlparse_ParseFile__doc__[] =
|
static char xmlparse_ParseFile__doc__[] =
|
||||||
"(file) - Parse XML data"
|
"ParseFile(file)
|
||||||
;
|
Parse XML data from file-like object.";
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
xmlparse_ParseFile(xmlparseobject *self, PyObject *args)
|
xmlparse_ParseFile(xmlparseobject *self, PyObject *args)
|
||||||
|
@ -500,12 +511,13 @@ xmlparse_ParseFile( xmlparseobject *self, PyObject *args )
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
PyObject *readmethod = NULL;
|
PyObject *readmethod = NULL;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "O", &f))
|
if (!PyArg_ParseTuple(args, "O:ParseFile", &f))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (PyFile_Check(f)) {
|
if (PyFile_Check(f)) {
|
||||||
fp = PyFile_AsFile(f);
|
fp = PyFile_AsFile(f);
|
||||||
}else{
|
}
|
||||||
|
else{
|
||||||
fp = NULL;
|
fp = NULL;
|
||||||
UNLESS(readmethod = PyObject_GetAttrString(f, "read")) {
|
UNLESS(readmethod = PyObject_GetAttrString(f, "read")) {
|
||||||
PyErr_Clear();
|
PyErr_Clear();
|
||||||
|
@ -514,14 +526,11 @@ xmlparse_ParseFile( xmlparseobject *self, PyObject *args )
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
int bytes_read;
|
int bytes_read;
|
||||||
void *buf = XML_GetBuffer(self->itself, BUF_SIZE);
|
void *buf = XML_GetBuffer(self->itself, BUF_SIZE);
|
||||||
if (buf == NULL) {
|
if (buf == NULL)
|
||||||
PyErr_SetString(PyExc_MemoryError, "out of memory");
|
return PyErr_NoMemory();
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fp) {
|
if (fp) {
|
||||||
bytes_read = fread(buf, sizeof(char), BUF_SIZE, fp);
|
bytes_read = fread(buf, sizeof(char), BUF_SIZE, fp);
|
||||||
|
@ -529,64 +538,51 @@ xmlparse_ParseFile( xmlparseobject *self, PyObject *args )
|
||||||
PyErr_SetFromErrno(PyExc_IOError);
|
PyErr_SetFromErrno(PyExc_IOError);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
bytes_read = readinst(buf, BUF_SIZE, readmethod);
|
bytes_read = readinst(buf, BUF_SIZE, readmethod);
|
||||||
if (bytes_read < 0)
|
if (bytes_read < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
rv = XML_ParseBuffer(self->itself, bytes_read, bytes_read == 0);
|
rv = XML_ParseBuffer(self->itself, bytes_read, bytes_read == 0);
|
||||||
if( PyErr_Occurred() ){
|
if (PyErr_Occurred())
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
if (!rv || bytes_read == 0)
|
if (!rv || bytes_read == 0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Py_BuildValue("i", rv);
|
return Py_BuildValue("i", rv);
|
||||||
}
|
}
|
||||||
|
|
||||||
static char xmlparse_SetBase__doc__[] =
|
static char xmlparse_SetBase__doc__[] =
|
||||||
"(base_url) - Base URL string"
|
"SetBase(base_url)
|
||||||
;
|
Set the base URL for the parser.";
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
xmlparse_SetBase( xmlparseobject *self, PyObject *args ){
|
xmlparse_SetBase(xmlparseobject *self, PyObject *args)
|
||||||
|
{
|
||||||
char *base;
|
char *base;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "s", &base))
|
if (!PyArg_ParseTuple(args, "s:SetBase", &base))
|
||||||
return NULL;
|
return NULL;
|
||||||
if (!XML_SetBase(self->itself, base)) {
|
if (!XML_SetBase(self->itself, base)) {
|
||||||
PyErr_SetNone(PyExc_MemoryError);
|
return PyErr_NoMemory();
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Py_INCREF(Py_None);
|
Py_INCREF(Py_None);
|
||||||
return Py_None;
|
return Py_None;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char xmlparse_GetBase__doc__[] =
|
static char xmlparse_GetBase__doc__[] =
|
||||||
"() - returns base URL string "
|
"GetBase() -> url
|
||||||
;
|
Return base URL string for the parser.";
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
xmlparse_GetBase( xmlparseobject *self, PyObject *args ){
|
xmlparse_GetBase(xmlparseobject *self, PyObject *args)
|
||||||
const XML_Char *base;
|
{
|
||||||
PyObject *rc;
|
if (!PyArg_ParseTuple(args, ":GetBase"))
|
||||||
|
|
||||||
if( PyTuple_Size( args )!=0 ){
|
|
||||||
PyArg_ParseTuple(args, "()" ); /* get good error reporting */
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
base=XML_GetBase( self->itself );
|
|
||||||
if( base ){
|
|
||||||
rc=Py_BuildValue("s", base);
|
|
||||||
}else{
|
|
||||||
Py_INCREF(Py_None);
|
|
||||||
rc=Py_None;
|
|
||||||
}
|
|
||||||
return rc;
|
|
||||||
|
|
||||||
|
return Py_BuildValue("z", XML_GetBase(self->itself));
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct PyMethodDef xmlparse_methods[] = {
|
static struct PyMethodDef xmlparse_methods[] = {
|
||||||
|
@ -605,7 +601,8 @@ static struct PyMethodDef xmlparse_methods[] = {
|
||||||
|
|
||||||
|
|
||||||
static xmlparseobject *
|
static xmlparseobject *
|
||||||
newxmlparseobject( char *encoding, char *namespace_separator){
|
newxmlparseobject(char *encoding, char *namespace_separator)
|
||||||
|
{
|
||||||
int i;
|
int i;
|
||||||
xmlparseobject *self;
|
xmlparseobject *self;
|
||||||
|
|
||||||
|
@ -624,25 +621,23 @@ newxmlparseobject( char *encoding, char *namespace_separator){
|
||||||
self->returns_unicode = 1;
|
self->returns_unicode = 1;
|
||||||
#endif
|
#endif
|
||||||
if (namespace_separator) {
|
if (namespace_separator) {
|
||||||
self->itself = XML_ParserCreateNS(encoding,
|
self->itself = XML_ParserCreateNS(encoding, *namespace_separator);
|
||||||
*namespace_separator);
|
}
|
||||||
}else{
|
else{
|
||||||
self->itself = XML_ParserCreate(encoding);
|
self->itself = XML_ParserCreate(encoding);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self->itself == NULL) {
|
if (self->itself == NULL) {
|
||||||
PyErr_SetString(PyExc_RuntimeError,
|
PyErr_SetString(PyExc_RuntimeError,
|
||||||
"XML_ParserCreate failed");
|
"XML_ParserCreate failed");
|
||||||
Py_DECREF(self);
|
Py_DECREF(self);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
XML_SetUserData(self->itself, (void *)self);
|
XML_SetUserData(self->itself, (void *)self);
|
||||||
|
|
||||||
for( i=0; handler_info[i].name!=NULL;i++);
|
for(i = 0; handler_info[i].name != NULL; i++)
|
||||||
|
/* do nothing */;
|
||||||
|
|
||||||
self->handlers = malloc(sizeof(PyObject *)*i);
|
self->handlers = malloc(sizeof(PyObject *)*i);
|
||||||
|
|
||||||
clear_handlers(self);
|
clear_handlers(self);
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
|
@ -669,7 +664,9 @@ xmlparse_dealloc( xmlparseobject *self )
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static int handlername2int( const char *name ){
|
static int
|
||||||
|
handlername2int(const char *name)
|
||||||
|
{
|
||||||
int i;
|
int i;
|
||||||
for (i=0; handler_info[i].name != NULL; i++) {
|
for (i=0; handler_info[i].name != NULL; i++) {
|
||||||
if (strcmp(name, handler_info[i].name) == 0) {
|
if (strcmp(name, handler_info[i].name) == 0) {
|
||||||
|
@ -704,7 +701,6 @@ xmlparse_getattr(xmlparseobject *self, char *name)
|
||||||
Py_INCREF(self->handlers[handlernum]);
|
Py_INCREF(self->handlers[handlernum]);
|
||||||
return self->handlers[handlernum];
|
return self->handlers[handlernum];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(name, "__members__") == 0) {
|
if (strcmp(name, "__members__") == 0) {
|
||||||
int i;
|
int i;
|
||||||
PyObject *rc = PyList_New(0);
|
PyObject *rc = PyList_New(0);
|
||||||
|
@ -719,11 +715,11 @@ xmlparse_getattr(xmlparseobject *self, char *name)
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Py_FindMethod(xmlparse_methods, (PyObject *)self, name);
|
return Py_FindMethod(xmlparse_methods, (PyObject *)self, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sethandler( xmlparseobject *self, const char *name, PyObject* v ){
|
static int sethandler(xmlparseobject *self, const char *name, PyObject* v)
|
||||||
|
{
|
||||||
int handlernum = handlername2int(name);
|
int handlernum = handlername2int(name);
|
||||||
if (handlernum != -1) {
|
if (handlernum != -1) {
|
||||||
Py_INCREF(v);
|
Py_INCREF(v);
|
||||||
|
@ -733,7 +729,6 @@ static int sethandler( xmlparseobject *self, const char *name, PyObject* v ){
|
||||||
handler_info[handlernum].handler);
|
handler_info[handlernum].handler);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -771,8 +766,7 @@ xmlparse_setattr( xmlparseobject *self, char *name, PyObject *v)
|
||||||
}
|
}
|
||||||
|
|
||||||
static char Xmlparsetype__doc__[] =
|
static char Xmlparsetype__doc__[] =
|
||||||
"XML parser"
|
"XML parser";
|
||||||
;
|
|
||||||
|
|
||||||
static PyTypeObject Xmlparsetype = {
|
static PyTypeObject Xmlparsetype = {
|
||||||
PyObject_HEAD_INIT(NULL)
|
PyObject_HEAD_INIT(NULL)
|
||||||
|
@ -804,32 +798,32 @@ static PyTypeObject Xmlparsetype = {
|
||||||
|
|
||||||
|
|
||||||
static char pyexpat_ParserCreate__doc__[] =
|
static char pyexpat_ParserCreate__doc__[] =
|
||||||
"([encoding, namespace_separator]) - Return a new XML parser object"
|
"ParserCreate([encoding[, namespace_separator]]) -> parser\n\
|
||||||
;
|
Return a new XML parser object.";
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
pyexpat_ParserCreate(PyObject *notused, PyObject *args, PyObject *kw) {
|
pyexpat_ParserCreate(PyObject *notused, PyObject *args, PyObject *kw)
|
||||||
char *encoding = NULL, *namespace_separator=NULL;
|
{
|
||||||
|
char *encoding = NULL;
|
||||||
|
char *namespace_separator = NULL;
|
||||||
static char *kwlist[] = {"encoding", "namespace_separator", NULL};
|
static char *kwlist[] = {"encoding", "namespace_separator", NULL};
|
||||||
|
|
||||||
if (!PyArg_ParseTupleAndKeywords(args, kw, "|zz", kwlist,
|
if (!PyArg_ParseTupleAndKeywords(args, kw, "|zz:ParserCreate", kwlist,
|
||||||
&encoding, &namespace_separator))
|
&encoding, &namespace_separator))
|
||||||
return NULL;
|
return NULL;
|
||||||
return (PyObject *)newxmlparseobject(encoding, namespace_separator);
|
return (PyObject *)newxmlparseobject(encoding, namespace_separator);
|
||||||
}
|
}
|
||||||
|
|
||||||
static char pyexpat_ErrorString__doc__[] =
|
static char pyexpat_ErrorString__doc__[] =
|
||||||
"(errno) Returns string error for given number"
|
"ErrorString(errno) -> string\n\
|
||||||
;
|
Returns string error for given number.";
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
pyexpat_ErrorString(self, args)
|
pyexpat_ErrorString(PyObject *self, PyObject *args)
|
||||||
PyObject *self; /* Not used */
|
|
||||||
PyObject *args;
|
|
||||||
{
|
{
|
||||||
long code;
|
long code = 0;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "l", &code))
|
if (!PyArg_ParseTuple(args, "l:ErrorString", &code))
|
||||||
return NULL;
|
return NULL;
|
||||||
return Py_BuildValue("z", XML_ErrorString((int)code));
|
return Py_BuildValue("z", XML_ErrorString((int)code));
|
||||||
}
|
}
|
||||||
|
@ -848,13 +842,13 @@ static struct PyMethodDef pyexpat_methods[] = {
|
||||||
/* Module docstring */
|
/* Module docstring */
|
||||||
|
|
||||||
static char pyexpat_module_documentation[] =
|
static char pyexpat_module_documentation[] =
|
||||||
"Python wrapper for Expat parser."
|
"Python wrapper for Expat parser.";
|
||||||
;
|
|
||||||
|
|
||||||
/* Initialization function for the module */
|
/* Initialization function for the module */
|
||||||
|
|
||||||
void
|
void
|
||||||
initpyexpat(){
|
initpyexpat(void)
|
||||||
|
{
|
||||||
PyObject *m, *d;
|
PyObject *m, *d;
|
||||||
char *rev = "$Revision$";
|
char *rev = "$Revision$";
|
||||||
PyObject *errors_module, *errors_dict;
|
PyObject *errors_module, *errors_dict;
|
||||||
|
@ -918,10 +912,11 @@ initpyexpat(){
|
||||||
Py_FatalError("can't initialize module pyexpat");
|
Py_FatalError("can't initialize module pyexpat");
|
||||||
}
|
}
|
||||||
|
|
||||||
void clear_handlers( xmlparseobject *self ){
|
void clear_handlers(xmlparseobject *self)
|
||||||
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
for( i=0;handler_info[i].name!=NULL;i++ ){
|
for (; handler_info[i].name!=NULL; i++) {
|
||||||
self->handlers[i]=NULL;
|
self->handlers[i]=NULL;
|
||||||
handler_info[i].setter( self->itself, NULL );
|
handler_info[i].setter( self->itself, NULL );
|
||||||
}
|
}
|
||||||
|
@ -932,75 +927,66 @@ typedef void (*pairsetter)( XML_Parser, void *handler1, void *handler2 );
|
||||||
void pyxml_UpdatePairedHandlers(xmlparseobject *self,
|
void pyxml_UpdatePairedHandlers(xmlparseobject *self,
|
||||||
int startHandler,
|
int startHandler,
|
||||||
int endHandler,
|
int endHandler,
|
||||||
pairsetter setter){
|
pairsetter setter)
|
||||||
|
{
|
||||||
void *start_handler=NULL;
|
void *start_handler=NULL;
|
||||||
void *end_handler=NULL;
|
void *end_handler=NULL;
|
||||||
|
|
||||||
if( self->handlers[startHandler] &&
|
if (self->handlers[startHandler]
|
||||||
self->handlers[endHandler]!=Py_None ){
|
&& self->handlers[endHandler]!=Py_None) {
|
||||||
start_handler=handler_info[startHandler].handler;
|
start_handler=handler_info[startHandler].handler;
|
||||||
}
|
}
|
||||||
if( self->handlers[EndElement] &&
|
if (self->handlers[EndElement]
|
||||||
self->handlers[EndElement] !=Py_None ){
|
&& self->handlers[EndElement] !=Py_None) {
|
||||||
end_handler=handler_info[endHandler].handler;
|
end_handler=handler_info[endHandler].handler;
|
||||||
}
|
}
|
||||||
|
setter(self->itself, start_handler, end_handler);
|
||||||
setter(self->itself,
|
|
||||||
start_handler,
|
|
||||||
end_handler);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void pyxml_SetStartElementHandler( XML_Parser *parser,
|
void pyxml_SetStartElementHandler(XML_Parser *parser, void *junk)
|
||||||
void *junk){
|
{
|
||||||
pyxml_UpdatePairedHandlers(
|
pyxml_UpdatePairedHandlers((xmlparseobject *)XML_GetUserData(parser),
|
||||||
(xmlparseobject *)XML_GetUserData( parser ),
|
|
||||||
StartElement, EndElement,
|
StartElement, EndElement,
|
||||||
(pairsetter)XML_SetElementHandler);
|
(pairsetter)XML_SetElementHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
void pyxml_SetEndElementHandler( XML_Parser *parser,
|
void pyxml_SetEndElementHandler(XML_Parser *parser, void *junk)
|
||||||
void *junk){
|
{
|
||||||
pyxml_UpdatePairedHandlers(
|
pyxml_UpdatePairedHandlers((xmlparseobject *)XML_GetUserData(parser),
|
||||||
(xmlparseobject *)XML_GetUserData( parser ),
|
|
||||||
StartElement, EndElement,
|
StartElement, EndElement,
|
||||||
(pairsetter)XML_SetElementHandler);
|
(pairsetter)XML_SetElementHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
void pyxml_SetStartNamespaceDeclHandler( XML_Parser *parser,
|
void pyxml_SetStartNamespaceDeclHandler(XML_Parser *parser, void *junk)
|
||||||
void *junk){
|
{
|
||||||
pyxml_UpdatePairedHandlers(
|
pyxml_UpdatePairedHandlers((xmlparseobject *)XML_GetUserData(parser),
|
||||||
(xmlparseobject *)XML_GetUserData( parser ),
|
|
||||||
StartNamespaceDecl, EndNamespaceDecl,
|
StartNamespaceDecl, EndNamespaceDecl,
|
||||||
(pairsetter)XML_SetNamespaceDeclHandler);
|
(pairsetter)XML_SetNamespaceDeclHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
void pyxml_SetEndNamespaceDeclHandler( XML_Parser *parser,
|
void pyxml_SetEndNamespaceDeclHandler(XML_Parser *parser, void *junk)
|
||||||
void *junk){
|
{
|
||||||
pyxml_UpdatePairedHandlers(
|
pyxml_UpdatePairedHandlers((xmlparseobject *)XML_GetUserData(parser),
|
||||||
(xmlparseobject *)XML_GetUserData( parser ),
|
|
||||||
StartNamespaceDecl, EndNamespaceDecl,
|
StartNamespaceDecl, EndNamespaceDecl,
|
||||||
(pairsetter)XML_SetNamespaceDeclHandler);
|
(pairsetter)XML_SetNamespaceDeclHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
void pyxml_SetStartCdataSection( XML_Parser *parser,
|
void pyxml_SetStartCdataSection(XML_Parser *parser, void *junk)
|
||||||
void *junk){
|
{
|
||||||
|
pyxml_UpdatePairedHandlers((xmlparseobject *)XML_GetUserData(parser),
|
||||||
pyxml_UpdatePairedHandlers(
|
|
||||||
(xmlparseobject *)XML_GetUserData( parser ),
|
|
||||||
StartCdataSection, EndCdataSection,
|
StartCdataSection, EndCdataSection,
|
||||||
(pairsetter)XML_SetCdataSectionHandler);
|
(pairsetter)XML_SetCdataSectionHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
void pyxml_SetEndCdataSection( XML_Parser *parser,
|
void pyxml_SetEndCdataSection(XML_Parser *parser, void *junk)
|
||||||
void *junk){
|
{
|
||||||
pyxml_UpdatePairedHandlers(
|
pyxml_UpdatePairedHandlers((xmlparseobject *)XML_GetUserData(parser),
|
||||||
(xmlparseobject *)XML_GetUserData( parser ),
|
|
||||||
StartCdataSection, EndCdataSection,
|
StartCdataSection, EndCdataSection,
|
||||||
(pairsetter)XML_SetCdataSectionHandler);
|
(pairsetter)XML_SetCdataSectionHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
statichere struct HandlerInfo handler_info[]=
|
statichere struct HandlerInfo handler_info[] = {
|
||||||
{{"StartElementHandler",
|
{"StartElementHandler",
|
||||||
pyxml_SetStartElementHandler,
|
pyxml_SetStartElementHandler,
|
||||||
(xmlhandler)my_StartElementHandler},
|
(xmlhandler)my_StartElementHandler},
|
||||||
{"EndElementHandler",
|
{"EndElementHandler",
|
||||||
|
|
Loading…
Reference in New Issue