[Python-checkins] CVS: python/dist/src/Objects fileobject.c,2.112.2.4,2.112.2.5 intobject.c,2.56.6.7,2.56.6.8 unicodeobject.c,2.87.2.5,2.87.2.6

Tim Peters tim_one@users.sourceforge.net
Fri, 20 Jul 2001 23:07:16 -0700


Update of /cvsroot/python/python/dist/src/Objects
In directory usw-pr-cvs1:/tmp/cvs-serv27169/descr/dist/src/Objects

Modified Files:
      Tag: descr-branch
	fileobject.c intobject.c unicodeobject.c 
Log Message:
Merge of trunk delta date2001-07-17b to date2001-07-21.  See PLAN.txt.


Index: fileobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/fileobject.c,v
retrieving revision 2.112.2.4
retrieving revision 2.112.2.5
diff -C2 -r2.112.2.4 -r2.112.2.5
*** fileobject.c	2001/07/07 22:55:30	2.112.2.4
--- fileobject.c	2001/07/21 06:07:13	2.112.2.5
***************
*** 474,478 ****
  {
  #ifdef HAVE_FSTAT
! 	long pos, end;
  	struct stat st;
  	if (fstat(fileno(f->f_fp), &st) == 0) {
--- 474,478 ----
  {
  #ifdef HAVE_FSTAT
! 	off_t pos, end;
  	struct stat st;
  	if (fstat(fileno(f->f_fp), &st) == 0) {

Index: intobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/intobject.c,v
retrieving revision 2.56.6.7
retrieving revision 2.56.6.8
diff -C2 -r2.56.6.7 -r2.56.6.8
*** intobject.c	2001/07/14 07:47:35	2.56.6.7
--- intobject.c	2001/07/21 06:07:13	2.56.6.8
***************
*** 646,650 ****
  		return PyInt_FromLong(0L);
  	}
! 	a = (unsigned long)a << b;
  	return PyInt_FromLong(a);
  }
--- 646,650 ----
  		return PyInt_FromLong(0L);
  	}
! 	a = (long)((unsigned long)a << b);
  	return PyInt_FromLong(a);
  }

Index: unicodeobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/unicodeobject.c,v
retrieving revision 2.87.2.5
retrieving revision 2.87.2.6
diff -C2 -r2.87.2.5 -r2.87.2.6
*** unicodeobject.c	2001/07/07 22:55:30	2.87.2.5
--- unicodeobject.c	2001/07/21 06:07:13	2.87.2.6
***************
*** 105,109 ****
  
  Py_UNICODE
! PyUnicode_GetMax()
  {
  #ifdef Py_UNICODE_WIDE
--- 105,109 ----
  
  Py_UNICODE
! PyUnicode_GetMax(void)
  {
  #ifdef Py_UNICODE_WIDE
***************
*** 1082,1096 ****
  	    if (0xDC00 <= ch2 && ch2 <= 0xDFFF) {
  #ifndef Py_UNICODE_WIDE
! 		/* This is valid data (a UTF-16 surrogate pair), but
! 		   we are not able to store this information since our
! 		   Py_UNICODE type only has 16 bits... this might
! 		   change someday, even though it's unlikely. */
! 		errmsg = "code pairs are not supported";
! 		goto utf16Error;
  #else
  		*p++ = (((ch & 0x3FF)<<10) | (ch2 & 0x3FF)) + 0x10000;
- 		continue;
  #endif
! 		
  	    }
  	    else {
--- 1082,1091 ----
  	    if (0xDC00 <= ch2 && ch2 <= 0xDFFF) {
  #ifndef Py_UNICODE_WIDE
! 		*p++ = ch;
! 		*p++ = ch2;
  #else
  		*p++ = (((ch & 0x3FF)<<10) | (ch2 & 0x3FF)) + 0x10000;
  #endif
! 		continue;
  	    }
  	    else {
***************
*** 1326,1330 ****
                  *p++ = (Py_UNICODE) chr;
              else if (chr <= 0x10ffff) {
!                 /* UCS-4 character. Either store directly, or as surrogate pair. */
  #ifdef Py_UNICODE_WIDE
                  *p++ = chr;
--- 1321,1326 ----
                  *p++ = (Py_UNICODE) chr;
              else if (chr <= 0x10ffff) {
!                 /* UCS-4 character. Either store directly, or as
! 		   surrogate pair. */
  #ifdef Py_UNICODE_WIDE
                  *p++ = chr;
***************
*** 1442,1466 ****
              *p++ = (char) ch;
          } 
          /* Map 21-bit characters to '\U00xxxxxx' */
          else if (ch >= 0x10000) {
              *p++ = '\\';
              *p++ = 'U';
!             *p++ = hexdigit[(ch >> 28) & 0xf];
!             *p++ = hexdigit[(ch >> 24) & 0xf];
!             *p++ = hexdigit[(ch >> 20) & 0xf];
!             *p++ = hexdigit[(ch >> 16) & 0xf];
!             *p++ = hexdigit[(ch >> 12) & 0xf];
!             *p++ = hexdigit[(ch >> 8) & 0xf];
!             *p++ = hexdigit[(ch >> 4) & 0xf];
              *p++ = hexdigit[ch & 15];
          }
          /* Map 16-bit characters to '\uxxxx' */
!         else if (ch >= 256) {
              *p++ = '\\';
              *p++ = 'u';
!             *p++ = hexdigit[(ch >> 12) & 0xf];
!             *p++ = hexdigit[(ch >> 8) & 0xf];
!             *p++ = hexdigit[(ch >> 4) & 0xf];
!             *p++ = hexdigit[ch & 15];
          }
          /* Map special whitespace to '\t', \n', '\r' */
--- 1438,1490 ----
              *p++ = (char) ch;
          } 
+ #ifdef Py_UNICODE_WIDE
          /* Map 21-bit characters to '\U00xxxxxx' */
          else if (ch >= 0x10000) {
              *p++ = '\\';
              *p++ = 'U';
!             *p++ = hexdigit[(ch >> 28) & 0x0000000F];
!             *p++ = hexdigit[(ch >> 24) & 0x0000000F];
!             *p++ = hexdigit[(ch >> 20) & 0x0000000F];
!             *p++ = hexdigit[(ch >> 16) & 0x0000000F];
!             *p++ = hexdigit[(ch >> 12) & 0x0000000F];
!             *p++ = hexdigit[(ch >> 8) & 0x0000000F];
!             *p++ = hexdigit[(ch >> 4) & 0x0000000F];
              *p++ = hexdigit[ch & 15];
          }
+ #endif
+ 	/* Map UTF-16 surrogate pairs to Unicode \UXXXXXXXX escapes */
+ 	else if (ch >= 0xD800 && ch < 0xDC00) {
+ 	    Py_UNICODE ch2;
+ 	    Py_UCS4 ucs;
+ 	    
+ 	    ch2 = *s++;
+ 	    size--;
+ 	    if (ch2 >= 0xDC00 && ch2 <= 0xDFFF) {
+ 		ucs = (((ch & 0x03FF) << 10) | (ch2 & 0x03FF)) + 0x00010000;
+ 		*p++ = '\\';
+ 		*p++ = 'U';
+ 		*p++ = hexdigit[(ucs >> 28) & 0x0000000F];
+ 		*p++ = hexdigit[(ucs >> 24) & 0x0000000F];
+ 		*p++ = hexdigit[(ucs >> 20) & 0x0000000F];
+ 		*p++ = hexdigit[(ucs >> 16) & 0x0000000F];
+ 		*p++ = hexdigit[(ucs >> 12) & 0x0000000F];
+ 		*p++ = hexdigit[(ucs >> 8) & 0x0000000F];
+ 		*p++ = hexdigit[(ucs >> 4) & 0x0000000F];
+ 		*p++ = hexdigit[ucs & 0x0000000F];
+ 		continue;
+ 	    }
+ 	    /* Fall through: isolated surrogates are copied as-is */
+ 	    s--;
+ 	    size++;
+ 	}
+ 
          /* Map 16-bit characters to '\uxxxx' */
!         if (ch >= 256) {
              *p++ = '\\';
              *p++ = 'u';
!             *p++ = hexdigit[(ch >> 12) & 0x000F];
!             *p++ = hexdigit[(ch >> 8) & 0x000F];
!             *p++ = hexdigit[(ch >> 4) & 0x000F];
!             *p++ = hexdigit[ch & 0x000F];
          }
          /* Map special whitespace to '\t', \n', '\r' */
***************
*** 1481,1486 ****
              *p++ = '\\';
              *p++ = 'x';
!             *p++ = hexdigit[(ch >> 4) & 0xf];
!             *p++ = hexdigit[ch & 15];
          } 
          /* Copy everything else as-is */
--- 1505,1510 ----
              *p++ = '\\';
              *p++ = 'x';
!             *p++ = hexdigit[(ch >> 4) & 0x000F];
!             *p++ = hexdigit[ch & 0x000F];
          } 
          /* Copy everything else as-is */