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

Michael Hudson mwh@users.sourceforge.net
Fri, 22 Feb 2002 05:44:45 -0800


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

Modified Files:
      Tag: release22-maint
	unicodeobject.c 
Log Message:
Fix the problem reported in 

[ #495401 ] Build troubles: --with-pymalloc

in a slightly different manner to the trunk, as discussed on python-dev.



Index: unicodeobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/unicodeobject.c,v
retrieving revision 2.124
retrieving revision 2.124.6.1
diff -C2 -d -r2.124 -r2.124.6.1
*** unicodeobject.c	6 Dec 2001 20:03:56 -0000	2.124
--- unicodeobject.c	22 Feb 2002 13:44:43 -0000	2.124.6.1
***************
*** 1172,1176 ****
      PyObject *v;
      char *p;
-     char *q;
      Py_UCS4 ch2;
      unsigned int cbAllocated = 3 * size;
--- 1172,1175 ----
***************
*** 1184,1188 ****
          return v;
  
!     p = q = PyString_AS_STRING(v);
      while (i < size) {
          Py_UCS4 ch = s[i++];
--- 1183,1187 ----
          return v;
  
!     p = PyString_AS_STRING(v);
      while (i < size) {
          Py_UCS4 ch = s[i++];
***************
*** 1209,1212 ****
--- 1208,1212 ----
                              if (_PyString_Resize(&v, cbAllocated))
  				goto onError;
+ 			    p = PyString_AS_STRING(v) + cbWritten;
                          }
  
***************
*** 1228,1231 ****
--- 1228,1238 ----
              *p++ = (char)(0x80 | (ch & 0x3f));
          } else {
+ 	    if (cbWritten >= (cbAllocated - 4)) {
+ 		    /* Provide enough room for some more large characters. */
+ 		    cbAllocated += 4*10;
+ 		    if (_PyString_Resize(&v, cbAllocated))
+ 			    goto onError;
+ 		    p = PyString_AS_STRING(v) + cbWritten;
+ 	    }
              *p++ = 0xf0 | (ch>>18);
              *p++ = 0x80 | ((ch>>12) & 0x3f);
***************
*** 1236,1240 ****
      }
      *p = '\0';
!     if (_PyString_Resize(&v, p - q))
  	goto onError;
      return v;
--- 1243,1247 ----
      }
      *p = '\0';
!     if (_PyString_Resize(&v, cbWritten))
  	goto onError;
      return v;