[Python-checkins] CVS: python/dist/src/Modules pyexpat.c,2.57,2.58

Martin v. L?wis loewis@users.sourceforge.net
2002年2月11日 15:27:47 -0800


Update of /cvsroot/python/python/dist/src/Modules
In directory usw-pr-cvs1:/tmp/cvs-serv12582/Modules
Modified Files:
	pyexpat.c 
Log Message:
Use included Expat library. Drop support for older expat versions.
Index: pyexpat.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/pyexpat.c,v
retrieving revision 2.57
retrieving revision 2.58
diff -C2 -d -r2.57 -r2.58
*** pyexpat.c	8 Dec 2001 18:02:57 -0000	2.57
--- pyexpat.c	11 Feb 2002 23:27:45 -0000	2.58
***************
*** 7,27 ****
 #include "compile.h"
 #include "frameobject.h"
- #ifdef HAVE_EXPAT_H
 #include "expat.h"
- #ifdef XML_MAJOR_VERSION
- #define EXPAT_VERSION (0x10000 * XML_MAJOR_VERSION \
- + 0x100 * XML_MINOR_VERSION \
- + XML_MICRO_VERSION)
- #else
- /* Assume the oldest Expat that used expat.h and did not have version info */
- #define EXPAT_VERSION 0x015f00
- #endif
- #else /* !defined(HAVE_EXPAT_H) */
- #include "xmlparse.h"
- /* Assume Expat 1.1 unless told otherwise */
- #ifndef EXPAT_VERSION
- #define EXPAT_VERSION 0x010100
- #endif
- #endif /* !defined(HAVE_EXPAT_H) */
 
 #ifndef PyGC_HEAD_SIZE
--- 7,11 ----
***************
*** 53,70 ****
 NotStandalone,
 ExternalEntityRef,
- #if EXPAT_VERSION >= 0x010200
 StartDoctypeDecl,
 EndDoctypeDecl,
- #endif
- #if EXPAT_VERSION == 0x010200
- ExternalParsedEntityDecl,
- InternalParsedEntityDecl,
- #endif
- #if EXPAT_VERSION >= 0x015f00
 EntityDecl,
 XmlDecl,
 ElementDecl,
 AttlistDecl,
- #endif
 _DummyDecl
 };
--- 37,46 ----
***************
*** 143,234 ****
 
 
- #if EXPAT_VERSION == 0x010200
- /* Convert an array of attributes and their values into a Python dict */
- 
- static PyObject *
- conv_atts_using_string(XML_Char **atts)
- {
- PyObject *attrs_obj = NULL;
- XML_Char **attrs_p, **attrs_k = NULL;
- int attrs_len;
- PyObject *rv;
- 
- if ((attrs_obj = PyDict_New()) == NULL) 
- goto finally;
- for (attrs_len = 0, attrs_p = atts; 
- *attrs_p;
- attrs_p++, attrs_len++) {
- if (attrs_len % 2) {
- rv = PyString_FromString(*attrs_p); 
- if (!rv) {
- Py_DECREF(attrs_obj);
- attrs_obj = NULL;
- goto finally;
- }
- if (PyDict_SetItemString(attrs_obj,
- (char*)*attrs_k, rv) < 0) {
- Py_DECREF(attrs_obj);
- attrs_obj = NULL;
- goto finally;
- }
- Py_DECREF(rv);
- }
- else 
- attrs_k = attrs_p;
- }
- finally:
- return attrs_obj;
- }
- #endif
- 
 #ifdef Py_USING_UNICODE
- #if EXPAT_VERSION == 0x010200
- static PyObject *
- conv_atts_using_unicode(XML_Char **atts)
- {
- PyObject *attrs_obj;
- XML_Char **attrs_p, **attrs_k = NULL;
- int attrs_len;
- 
- if ((attrs_obj = PyDict_New()) == NULL) 
- goto finally;
- for (attrs_len = 0, attrs_p = atts; 
- *attrs_p;
- attrs_p++, attrs_len++) {
- if (attrs_len % 2) {
- PyObject *attr_str, *value_str;
- const char *p = (const char *) (*attrs_k);
- attr_str = PyUnicode_DecodeUTF8(p, strlen(p), "strict"); 
- if (!attr_str) {
- Py_DECREF(attrs_obj);
- attrs_obj = NULL;
- goto finally;
- }
- p = (const char *) *attrs_p;
- value_str = PyUnicode_DecodeUTF8(p, strlen(p), "strict");
- if (!value_str) {
- Py_DECREF(attrs_obj);
- Py_DECREF(attr_str);
- attrs_obj = NULL;
- goto finally;
- }
- if (PyDict_SetItem(attrs_obj, attr_str, value_str) < 0) {
- Py_DECREF(attrs_obj);
- Py_DECREF(attr_str);
- Py_DECREF(value_str);
- attrs_obj = NULL;
- goto finally;
- }
- Py_DECREF(attr_str);
- Py_DECREF(value_str);
- }
- else
- attrs_k = attrs_p;
- }
- finally:
- return attrs_obj;
- }
- #endif
- 
 /* Convert a string of XML_Chars into a Unicode string.
 Returns None if str is a null pointer. */
--- 119,123 ----
***************
*** 538,542 ****
 STRING_CONV_FUNC,notationName))
 
- #if EXPAT_VERSION >= 0x015f00
 #ifndef Py_USING_UNICODE
 VOID_HANDLER(EntityDecl,
--- 427,430 ----
***************
*** 651,655 ****
 STRING_CONV_FUNC,att_type, STRING_CONV_FUNC,dflt,
 isrequired))
- #endif
 
 VOID_HANDLER(NotationDecl, 
--- 539,542 ----
***************
*** 727,736 ****
 /* XXX UnknownEncodingHandler */
 
- #if EXPAT_VERSION == 0x010200
- VOID_HANDLER(StartDoctypeDecl,
- 	 (void *userData, const XML_Char *doctypeName),
- 	 ("(O&OOi)", STRING_CONV_FUNC,doctypeName,
- Py_None, Py_None, -1))
- #elif EXPAT_VERSION >= 0x015f00
 VOID_HANDLER(StartDoctypeDecl,
 (void *userData, const XML_Char *doctypeName,
--- 614,617 ----
***************
*** 740,765 ****
 STRING_CONV_FUNC,sysid, STRING_CONV_FUNC,pubid,
 has_internal_subset))
- #endif
 
- #if EXPAT_VERSION >= 0x010200
 VOID_HANDLER(EndDoctypeDecl, (void *userData), ("()"))
- #endif
- 
- #if EXPAT_VERSION == 0x010200
- VOID_HANDLER(ExternalParsedEntityDecl,
- 	 (void *userData, const XML_Char *entityName,
- 	 const XML_Char *base, const XML_Char *systemId,
- 	 const XML_Char *publicId),
- 	 ("(O&O&O&O&)", STRING_CONV_FUNC, entityName,
- 	 STRING_CONV_FUNC, base, STRING_CONV_FUNC, systemId,
- 	 STRING_CONV_FUNC, publicId))
- 
- VOID_HANDLER(InternalParsedEntityDecl,
- 	 (void *userData, const XML_Char *entityName,
- 	 const XML_Char *replacementText, int replacementTextLength),
- 	 ("(O&O&i)", STRING_CONV_FUNC, entityName,
- 	 STRING_CONV_FUNC, replacementText, replacementTextLength))
- 
- #endif /* Expat version 1.2 & better */
 
 /* ---------------------------------------------------------------- */
--- 621,626 ----
***************
*** 925,929 ****
 }
 
- #if EXPAT_VERSION >= 0x015f00
 static char xmlparse_GetInputContext__doc__[] =
 "GetInputContext() -> string\n\
--- 786,789 ----
***************
*** 957,961 ****
 return result;
 }
- #endif
 
 static char xmlparse_ExternalEntityParserCreate__doc__[] = 
--- 817,820 ----
***************
*** 1034,1039 ****
 }
 
- #if EXPAT_VERSION >= 0x010200
- 
 static char xmlparse_SetParamEntityParsing__doc__[] =
 "SetParamEntityParsing(flag) -> success\n\
--- 893,896 ----
***************
*** 1054,1059 ****
 }
 
- #endif /* Expat version 1.2 or better */
- 
 static struct PyMethodDef xmlparse_methods[] = {
 {"Parse",	 (PyCFunction)xmlparse_Parse,
--- 911,914 ----
***************
*** 1067,1078 ****
 {"ExternalEntityParserCreate", (PyCFunction)xmlparse_ExternalEntityParserCreate,
 	 	 METH_VARARGS, xmlparse_ExternalEntityParserCreate__doc__},
- #if EXPAT_VERSION >= 0x010200
 {"SetParamEntityParsing", (PyCFunction)xmlparse_SetParamEntityParsing,
 		 METH_VARARGS, xmlparse_SetParamEntityParsing__doc__},
- #endif
- #if EXPAT_VERSION >= 0x015f00
 {"GetInputContext", (PyCFunction)xmlparse_GetInputContext,
 		 METH_VARARGS, xmlparse_GetInputContext__doc__},
- #endif
 	{NULL,		NULL}		/* sentinel */
 };
--- 922,929 ----
***************
*** 1573,1577 ****
 
 PyModule_AddObject(m, "__version__", get_version_string());
- #if EXPAT_VERSION >= 0x015f02
 PyModule_AddStringConstant(m, "EXPAT_VERSION",
 (char *) XML_ExpatVersion());
--- 1424,1427 ----
***************
*** 1582,1586 ****
 info.minor, info.micro));
 }
- #endif
 #ifdef Py_USING_UNICODE
 init_template_buffer();
--- 1432,1435 ----
***************
*** 1650,1654 ****
 #undef MYCONST
 
- #if EXPAT_VERSION >= 0x010200
 #define MYCONST(c) PyModule_AddIntConstant(m, #c, c)
 MYCONST(XML_PARAM_ENTITY_PARSING_NEVER);
--- 1499,1502 ----
***************
*** 1656,1662 ****
 MYCONST(XML_PARAM_ENTITY_PARSING_ALWAYS);
 #undef MYCONST
- #endif
 
- #if EXPAT_VERSION >= 0x015f00
 #define MYCONST(c) PyModule_AddIntConstant(model_module, #c, c)
 PyModule_AddStringConstant(model_module, "__doc__",
--- 1504,1508 ----
***************
*** 1675,1679 ****
 MYCONST(XML_CQUANT_PLUS);
 #undef MYCONST
- #endif
 }
 
--- 1521,1524 ----
***************
*** 1766,1771 ****
 }
 
- #if EXPAT_VERSION >= 0x010200
- 
 static void
 pyxml_SetStartDoctypeDeclHandler(XML_Parser *parser, void *junk)
--- 1611,1614 ----
***************
*** 1784,1789 ****
 }
 
- #endif
- 
 statichere struct HandlerInfo handler_info[] = {
 {"StartElementHandler", 
--- 1627,1630 ----
***************
*** 1832,1836 ****
 (xmlhandlersetter)XML_SetExternalEntityRefHandler,
 (xmlhandler)my_ExternalEntityRefHandler },
- #if EXPAT_VERSION >= 0x010200
 {"StartDoctypeDeclHandler",
 pyxml_SetStartDoctypeDeclHandler,
--- 1673,1676 ----
***************
*** 1839,1852 ****
 pyxml_SetEndDoctypeDeclHandler,
 (xmlhandler)my_EndDoctypeDeclHandler},
- #endif
- #if EXPAT_VERSION == 0x010200
- {"ExternalParsedEntityDeclHandler",
- (xmlhandlersetter)XML_SetExternalParsedEntityDeclHandler,
- (xmlhandler)my_ExternalParsedEntityDeclHandler},
- {"InternalParsedEntityDeclHandler",
- (xmlhandlersetter)XML_SetInternalParsedEntityDeclHandler,
- (xmlhandler)my_InternalParsedEntityDeclHandler},
- #endif
- #if EXPAT_VERSION >= 0x015f00
 {"EntityDeclHandler",
 (xmlhandlersetter)XML_SetEntityDeclHandler,
--- 1679,1682 ----
***************
*** 1861,1865 ****
 (xmlhandlersetter)XML_SetAttlistDeclHandler,
 (xmlhandler)my_AttlistDeclHandler},
- #endif /* Expat version 1.95 or better */
 
 {NULL, NULL, NULL} /* sentinel */
--- 1691,1694 ----

AltStyle によって変換されたページ (->オリジナル) /