[Python-checkins] CVS: python/dist/src/Objects unicodeobject.c,2.95,2.96
Fredrik Lundh
effbot@users.sourceforge.net
Tue, 26 Jun 2001 09:39:38 -0700
Update of /cvsroot/python/python/dist/src/Objects
In directory usw-pr-cvs1:/tmp/cvs-serv21139/Objects
Modified Files:
unicodeobject.c
Log Message:
experimental UCS-4 support: made compare a bit more robust, in case
sizeof(Py_UNICODE) >= sizeof(long). also changed surrogate expansion
to work if sizeof(Py_UNICODE) > 2.
Index: unicodeobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/unicodeobject.c,v
retrieving revision 2.95
retrieving revision 2.96
diff -C2 -r2.95 -r2.96
*** unicodeobject.c 2001/06/26 15:11:00 2.95
--- unicodeobject.c 2001/06/26 16:39:36 2.96
***************
*** 788,792 ****
/* low surrogate = bottom 10 bits added to DC00 */
! *p++ = (Py_UNICODE)(0xDC00 + (ch & ~0xFC00));
break;
--- 788,792 ----
/* low surrogate = bottom 10 bits added to DC00 */
! *p++ = (Py_UNICODE)(0xDC00 + (ch & 0x03FF));
break;
***************
*** 1275,1279 ****
chr -= 0x10000L;
*p++ = 0xD800 + (Py_UNICODE) (chr >> 10);
! *p++ = 0xDC00 + (Py_UNICODE) (chr & ~0xFC00);
} else {
if (unicodeescape_decoding_error(
--- 1275,1279 ----
chr -= 0x10000L;
*p++ = 0xD800 + (Py_UNICODE) (chr >> 10);
! *p++ = 0xDC00 + (Py_UNICODE) (chr & 0x03FF);
} else {
if (unicodeescape_decoding_error(
***************
*** 3261,3277 ****
while (len1 > 0 && len2 > 0) {
Py_UNICODE c1, c2;
- long diff;
c1 = *s1++;
c2 = *s2++;
if (c1 > (1<<11) * 26)
c1 += utf16Fixup[c1>>11];
if (c2 > (1<<11) * 26)
c2 += utf16Fixup[c2>>11];
-
/* now c1 and c2 are in UTF-32-compatible order */
! diff = (long)c1 - (long)c2;
! if (diff)
! return (diff < 0) ? -1 : (diff != 0);
len1--; len2--;
}
--- 3261,3277 ----
while (len1 > 0 && len2 > 0) {
Py_UNICODE c1, c2;
c1 = *s1++;
c2 = *s2++;
+
if (c1 > (1<<11) * 26)
c1 += utf16Fixup[c1>>11];
if (c2 > (1<<11) * 26)
c2 += utf16Fixup[c2>>11];
/* now c1 and c2 are in UTF-32-compatible order */
!
! if (c1 != c2)
! return (c1 < c2) ? -1 : 1;
!
len1--; len2--;
}
***************
*** 3294,3302 ****
while (len1 > 0 && len2 > 0) {
! register long diff;
- diff = (long)*s1++ - (long)*s2++;
- if (diff)
- return (diff < 0) ? -1 : (diff != 0);
len1--; len2--;
}
--- 3294,3305 ----
while (len1 > 0 && len2 > 0) {
! Py_UNICODE c1, c2;
!
! c1 = *s1++;
! c2 = *s2++;
!
! if (c1 != c2)
! return (c1 < c2) ? -1 : 1;
len1--; len2--;
}