[Python-checkins] CVS: python/dist/src/Python bltinmodule.c,2.183,2.184

A.M. Kuchling python-dev@python.org
Wed, 20 Dec 2000 06:36:58 -0800


Update of /cvsroot/python/python/dist/src/Python
In directory usw-pr-cvs1:/tmp/cvs-serv17873

Modified Files:
	bltinmodule.c 
Log Message:
Patch #102955, fixing one of the warnings in bug #121479:
Simplifies ord()'s logic at the cost of some code duplication, removing a 
    " `ord' might be used uninitialized in this function" warning


Index: bltinmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/bltinmodule.c,v
retrieving revision 2.183
retrieving revision 2.184
diff -C2 -r2.183 -r2.184
*** bltinmodule.c	2000/12/04 15:42:11	2.183
--- bltinmodule.c	2000/12/20 14:36:56	2.184
***************
*** 1,3 ****
! 
  /* Built-in functions */
  
--- 1,3 ----
! fo
  /* Built-in functions */
  
***************
*** 1513,1522 ****
  	if (PyString_Check(obj)) {
  		size = PyString_GET_SIZE(obj);
! 		if (size == 1)
  			ord = (long)((unsigned char)*PyString_AS_STRING(obj));
  	} else if (PyUnicode_Check(obj)) {
  		size = PyUnicode_GET_SIZE(obj);
! 		if (size == 1)
  			ord = (long)*PyUnicode_AS_UNICODE(obj);
  	} else {
  		PyErr_Format(PyExc_TypeError,
--- 1513,1526 ----
  	if (PyString_Check(obj)) {
  		size = PyString_GET_SIZE(obj);
! 		if (size == 1) {
  			ord = (long)((unsigned char)*PyString_AS_STRING(obj));
+ 			return PyInt_FromLong(ord);
+ 		}
  	} else if (PyUnicode_Check(obj)) {
  		size = PyUnicode_GET_SIZE(obj);
! 		if (size == 1) {
  			ord = (long)*PyUnicode_AS_UNICODE(obj);
+ 			return PyInt_FromLong(ord);
+ 		}
  	} else {
  		PyErr_Format(PyExc_TypeError,
***************
*** 1525,1530 ****
  		return NULL;
  	}
- 	if (size == 1)
- 		return PyInt_FromLong(ord);
  
  	PyErr_Format(PyExc_TypeError, 
--- 1529,1532 ----