[Python-checkins] python/dist/src/Python bltinmodule.c,2.295,2.296

jhylton at users.sourceforge.net jhylton at users.sourceforge.net
Mon Sep 15 23:11:02 EDT 2003


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

Modified Files:
	bltinmodule.c 
Log Message:
Reflow long lines and reformat.


Index: bltinmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/bltinmodule.c,v
retrieving revision 2.295
retrieving revision 2.296
diff -C2 -d -r2.295 -r2.296
*** bltinmodule.c	18 Aug 2003 18:28:45 -0000	2.295
--- bltinmodule.c	16 Sep 2003 03:10:59 -0000	2.296
***************
*** 2364,2383 ****
  			int reslen;
  			if (!PyUnicode_Check(item)) {
! 				PyErr_SetString(PyExc_TypeError, "can't filter unicode to unicode:"
! 					" __getitem__ returned different type");
  				Py_DECREF(item);
  				goto Fail_1;
  			}
  			reslen = PyUnicode_GET_SIZE(item);
! 			if (reslen == 1) {
  				PyUnicode_AS_UNICODE(result)[j++] =
  					PyUnicode_AS_UNICODE(item)[0];
! 			} else {
  				/* do we need more space? */
! 				int need = j + reslen + len-i-1;
  				if (need > outlen) {
! 					/* overallocate, to avoid reallocations */
! 					if (need<2*outlen)
! 						need = 2*outlen;
  					if (PyUnicode_Resize(&result, need)) {
  						Py_DECREF(item);
--- 2364,2385 ----
  			int reslen;
  			if (!PyUnicode_Check(item)) {
! 				PyErr_SetString(PyExc_TypeError, 
! 				"can't filter unicode to unicode:"
! 				" __getitem__ returned different type");
  				Py_DECREF(item);
  				goto Fail_1;
  			}
  			reslen = PyUnicode_GET_SIZE(item);
! 			if (reslen == 1) 
  				PyUnicode_AS_UNICODE(result)[j++] =
  					PyUnicode_AS_UNICODE(item)[0];
! 			else {
  				/* do we need more space? */
! 				int need = j + reslen + len - i - 1;
  				if (need > outlen) {
! 					/* overallocate, 
! 					   to avoid reallocations */
! 					if (need < 2 * outlen)
! 						need = 2 * outlen;
  					if (PyUnicode_Resize(&result, need)) {
  						Py_DECREF(item);
***************
*** 2386,2394 ****
  					outlen = need;
  				}
! 				memcpy(
! 					PyUnicode_AS_UNICODE(result) + j,
! 					PyUnicode_AS_UNICODE(item),
! 					reslen*sizeof(Py_UNICODE)
! 				);
  				j += reslen;
  			}
--- 2388,2394 ----
  					outlen = need;
  				}
! 				memcpy(PyUnicode_AS_UNICODE(result) + j,
! 				       PyUnicode_AS_UNICODE(item),
! 				       reslen*sizeof(Py_UNICODE));
  				j += reslen;
  			}





More information about the Python-checkins mailing list