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

A.M. Kuchling python-dev@python.org
2000年7月11日 17:53:44 -0700


Update of /cvsroot/python/python/dist/src/Modules
In directory slayer.i.sourceforge.net:/tmp/cvs-serv19519
Modified Files:
	pyexpat.c 
Log Message:
Patch #100854 from jhylton: eliminate compiler warnings in pyexpat:
	The first two warnings seem harmless enough,
	but the last one looks like a potential bug: an
	uninitialized int is returned on error. (I also
	ended up reformatting some of the code,
	because it was hard to read.) 
Index: pyexpat.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/pyexpat.c,v
retrieving revision 2.8
retrieving revision 2.9
diff -C2 -r2.8 -r2.9
*** pyexpat.c	2000年07月04日 23:51:31	2.8
--- pyexpat.c	2000年07月12日 00:53:41	2.9
***************
*** 71,102 ****
 /* 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;
 	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:
--- 71,103 ----
 /* 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:
***************
*** 107,111 ****
 static PyObject *conv_atts_using_unicode( XML_Char **atts){
 PyObject *attrs_obj=NULL;
! XML_Char **attrs_p, **attrs_k;
 int attrs_len;
 
--- 108,112 ----
 static PyObject *conv_atts_using_unicode( XML_Char **atts){
 PyObject *attrs_obj=NULL;
! XML_Char **attrs_p, **attrs_k = NULL;
 int attrs_len;
 
***************
*** 446,454 ****
 	PyObject *bytes=NULL;
 	PyObject *str=NULL;
! 	int len;
 
 	UNLESS(bytes = PyInt_FromLong(buf_size)) {
 		if (!PyErr_Occurred())
! 		PyErr_SetNone(PyExc_EOFError);
 		goto finally;
 	}
--- 447,455 ----
 	PyObject *bytes=NULL;
 	PyObject *str=NULL;
! 	int len = 0;
 
 	UNLESS(bytes = PyInt_FromLong(buf_size)) {
 		if (!PyErr_Occurred())
! 			PyErr_SetNone(PyExc_EOFError);
 		goto finally;
 	}
***************
*** 468,474 ****
 		goto finally;
 
! 	len=PyString_GET_SIZE( str );
! 	strncpy( buf, PyString_AsString(str), len );
! 	Py_XDECREF( str );
 finally:
 	return len;
--- 469,475 ----
 		goto finally;
 
! 	len = PyString_GET_SIZE(str);
! 	strncpy(buf, PyString_AsString(str), len);
! 	Py_XDECREF(str);
 finally:
 	return len;

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