[Python-checkins] CVS: python/dist/src/Objects floatobject.c,2.81.6.6,2.81.6.7 unicodeobject.c,2.87.2.6,2.87.2.7

Tim Peters tim_one@users.sourceforge.net
2001年7月27日 22:03:01 -0700


Update of /cvsroot/python/python/dist/src/Objects
In directory usw-pr-cvs1:/tmp/cvs-serv14630/descr/dist/src/Objects
Modified Files:
 Tag: descr-branch
	floatobject.c unicodeobject.c 
Log Message:
Merge of trunk tags date2001-07-21 to date2001-07-28.
Index: floatobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/floatobject.c,v
retrieving revision 2.81.6.6
retrieving revision 2.81.6.7
diff -C2 -d -r2.81.6.6 -r2.81.6.7
*** floatobject.c	2001年07月10日 16:33:53	2.81.6.6
--- floatobject.c	2001年07月28日 05:02:59	2.81.6.7
***************
*** 607,617 ****
 {
 	double x = PyFloat_AsDouble(v);
! 	if (x < 0 ? (x = ceil(x)) < (double)LONG_MIN
! 	 : (x = floor(x)) > (double)LONG_MAX) {
! 		PyErr_SetString(PyExc_OverflowError,
! 				"float too large to convert");
! 		return NULL;
! 	}
! 	return PyInt_FromLong((long)x);
 }
 
--- 607,623 ----
 {
 	double x = PyFloat_AsDouble(v);
! 	double wholepart;	/* integral portion of x, rounded toward 0 */
! 	long aslong;		/* (long)wholepart */
! 
! 	(void)modf(x, &wholepart);
! 	/* doubles may have more bits than longs, or vice versa; and casting
! 	 to long may yield gibberish in either case. What really matters
! 	 is whether converting back to double again reproduces what we
! 	 started with. */
! 	aslong = (long)wholepart;
! 	if ((double)aslong == wholepart)
! 		return PyInt_FromLong(aslong);
! 	PyErr_SetString(PyExc_OverflowError, "float too large to convert");
! 	return NULL;
 }
 
Index: unicodeobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/unicodeobject.c,v
retrieving revision 2.87.2.6
retrieving revision 2.87.2.7
diff -C2 -d -r2.87.2.6 -r2.87.2.7
*** unicodeobject.c	2001年07月21日 06:07:13	2.87.2.6
--- unicodeobject.c	2001年07月28日 05:02:59	2.87.2.7
***************
*** 1416,1420 ****
 PyObject *repr;
 char *p;
- char *q;
 
 static const char *hexdigit = "0123456789abcdef";
--- 1416,1419 ----
***************
*** 1424,1428 ****
 return NULL;
 
! p = q = PyString_AS_STRING(repr);
 
 if (quotes) {
--- 1423,1427 ----
 return NULL;
 
! p = PyString_AS_STRING(repr);
 
 if (quotes) {
***************
*** 1433,1444 ****
 while (size-- > 0) {
 Py_UNICODE ch = *s++;
 /* Escape quotes */
! if (quotes && (ch == (Py_UNICODE) q[1] || ch == '\\')) {
 *p++ = '\\';
 *p++ = (char) ch;
 } 
 #ifdef Py_UNICODE_WIDE
 /* Map 21-bit characters to '\U00xxxxxx' */
 else if (ch >= 0x10000) {
 *p++ = '\\';
 *p++ = 'U';
--- 1432,1455 ----
 while (size-- > 0) {
 Py_UNICODE ch = *s++;
+ 
 /* Escape quotes */
! if (quotes && 
! 	 (ch == (Py_UNICODE) PyString_AS_STRING(repr)[1] || ch == '\\')) {
 *p++ = '\\';
 *p++ = (char) ch;
 } 
+ 
 #ifdef Py_UNICODE_WIDE
 /* Map 21-bit characters to '\U00xxxxxx' */
 else if (ch >= 0x10000) {
+ 	 int offset = p - PyString_AS_STRING(repr);
+ 	 
+ 	 /* Resize the string if necessary */
+ 	 if (offset + 12 > PyString_GET_SIZE(repr)) {
+ 		if (_PyString_Resize(&repr, PyString_GET_SIZE(repr) + 100))
+ 		 goto onError;
+ 		p = PyString_AS_STRING(repr) + offset;
+ 	 }
+ 
 *p++ = '\\';
 *p++ = 'U';
***************
*** 1450,1454 ****
 *p++ = hexdigit[(ch >> 8) & 0x0000000F];
 *p++ = hexdigit[(ch >> 4) & 0x0000000F];
! *p++ = hexdigit[ch & 15];
 }
 #endif
--- 1461,1466 ----
 *p++ = hexdigit[(ch >> 8) & 0x0000000F];
 *p++ = hexdigit[(ch >> 4) & 0x0000000F];
! *p++ = hexdigit[ch & 0x0000000F];
! 	 continue;
 }
 #endif
***************
*** 1488,1491 ****
--- 1500,1504 ----
 *p++ = hexdigit[ch & 0x000F];
 }
+ 
 /* Map special whitespace to '\t', \n', '\r' */
 else if (ch == '\t') {
***************
*** 1501,1504 ****
--- 1514,1518 ----
 *p++ = 'r';
 }
+ 
 /* Map non-printable US ASCII to '\xhh' */
 else if (ch < ' ' || ch >= 128) {
***************
*** 1508,1511 ****
--- 1522,1526 ----
 *p++ = hexdigit[ch & 0x000F];
 } 
+ 
 /* Copy everything else as-is */
 else
***************
*** 1513,1520 ****
 }
 if (quotes)
! *p++ = q[1];
 
 *p = '0円';
! if (_PyString_Resize(&repr, p - q))
 	goto onError;
 
--- 1528,1535 ----
 }
 if (quotes)
! *p++ = PyString_AS_STRING(repr)[1];
 
 *p = '0円';
! if (_PyString_Resize(&repr, p - PyString_AS_STRING(repr)))
 	goto onError;
 

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