[Python-checkins] CVS: python/dist/src/Objects unicodeobject.c,2.124.6.2,2.124.6.3

M.-A. Lemburg lemburg@users.sourceforge.net
Mon, 25 Feb 2002 06:51:02 -0800


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

Modified Files:
      Tag: release22-maint
	unicodeobject.c 
Log Message:
Whitespace normalization and minor cosmetics.



Index: unicodeobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/unicodeobject.c,v
retrieving revision 2.124.6.2
retrieving revision 2.124.6.3
diff -C2 -d -r2.124.6.2 -r2.124.6.3
*** unicodeobject.c	25 Feb 2002 14:30:49 -0000	2.124.6.2
--- unicodeobject.c	25 Feb 2002 14:51:00 -0000	2.124.6.3
***************
*** 1167,1172 ****
  
  PyObject *PyUnicode_EncodeUTF8(const Py_UNICODE *s,
! 			       int size,
! 			       const char *errors)
  {
      PyObject *v;
--- 1167,1172 ----
  
  PyObject *PyUnicode_EncodeUTF8(const Py_UNICODE *s,
!                                int size,
!                                const char *errors)
  {
      PyObject *v;
***************
*** 1186,1196 ****
      while (i < size) {
          Py_UCS4 ch = s[i++];
!         if (ch < 0x80) {
              *p++ = (char) ch;
!         }
          else if (ch < 0x0800) {
              *p++ = 0xc0 | (ch >> 6);
              *p++ = 0x80 | (ch & 0x3f);
          }
          else if (ch < 0x10000) {
              /* Check for high surrogate */
--- 1186,1197 ----
      while (i < size) {
          Py_UCS4 ch = s[i++];
!         if (ch < 0x80)
              *p++ = (char) ch;
! 
          else if (ch < 0x0800) {
              *p++ = 0xc0 | (ch >> 6);
              *p++ = 0x80 | (ch & 0x3f);
          }
+ 
          else if (ch < 0x10000) {
              /* Check for high surrogate */
***************
*** 1201,1215 ****
                          
                          if ((p - q) >= (cbAllocated - 4)) {
! 			    /* Provide enough room for some more
! 			       surrogates */
! 			    cbAllocated += 4*10;
                              if (_PyString_Resize(&v, cbAllocated))
! 				goto onError;
! 			    p = PyString_AS_STRING(v) + (p - q);
                          }
! 
                          /* combine the two values */
                          ch = ((ch - 0xD800)<<10 | (ch2-0xDC00))+0x10000;
!                     
                          *p++ = (char)((ch >> 18) | 0xf0);
                          *p++ = (char)(0x80 | ((ch >> 12) & 0x3f));
--- 1202,1216 ----
                          
                          if ((p - q) >= (cbAllocated - 4)) {
!                             /* Provide enough room for some more
!                                surrogates */
!                             cbAllocated += 4*10;
                              if (_PyString_Resize(&v, cbAllocated))
!                                 goto onError;
!                             p = PyString_AS_STRING(v) + (p - q);
                          }
!                         
                          /* combine the two values */
                          ch = ((ch - 0xD800)<<10 | (ch2-0xDC00))+0x10000;
!                         
                          *p++ = (char)((ch >> 18) | 0xf0);
                          *p++ = (char)(0x80 | ((ch >> 12) & 0x3f));
***************
*** 1218,1235 ****
                  }
              }
!             else {
                  *p++ = (char)(0xe0 | (ch >> 12));
!             }
              *p++ = (char)(0x80 | ((ch >> 6) & 0x3f));
              *p++ = (char)(0x80 | (ch & 0x3f));
          } else {
              if ((p - q) >= (cbAllocated - 4)) {
! 	        /* Provide enough room for some more
! 	           surrogates */
! 		    cbAllocated += 4*10;
! 		    if (_PyString_Resize(&v, cbAllocated))
! 			    goto onError;
! 	        p = PyString_AS_STRING(v) + (p - q);
! 	    }
  
              *p++ = 0xf0 | (ch>>18);
--- 1219,1237 ----
                  }
              }
!             else
                  *p++ = (char)(0xe0 | (ch >> 12));
! 
              *p++ = (char)(0x80 | ((ch >> 6) & 0x3f));
              *p++ = (char)(0x80 | (ch & 0x3f));
+ 
          } else {
              if ((p - q) >= (cbAllocated - 4)) {
!                 /* Provide enough room for some more
!                    surrogates */
!                 cbAllocated += 4*10;
!                 if (_PyString_Resize(&v, cbAllocated))
!                     goto onError;
!                 p = PyString_AS_STRING(v) + (p - q);
!             }
  
              *p++ = 0xf0 | (ch>>18);
***************
*** 1237,1245 ****
              *p++ = 0x80 | ((ch>>6) & 0x3f);
              *p++ = 0x80 | (ch & 0x3f);
! 	}
      }
      *p = '\0';
      if (_PyString_Resize(&v, p - q))
! 	goto onError;
      return v;
  
--- 1239,1247 ----
              *p++ = 0x80 | ((ch>>6) & 0x3f);
              *p++ = 0x80 | (ch & 0x3f);
!         }
      }
      *p = '\0';
      if (_PyString_Resize(&v, p - q))
!         goto onError;
      return v;