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

M.-A. Lemburg python-dev@python.org
Tue, 8 Aug 2000 01:04:32 -0700


Update of /cvsroot/python/python/dist/src/Objects
In directory slayer.i.sourceforge.net:/tmp/cvs-serv25638/Objects

Modified Files:
	unicodeobject.c 
Log Message:
Removing UTF-16 aware Unicode comparison code. This kind of compare
function (together with other locale aware ones) should into a new collation
support module. See python-dev for a discussion of this removal.

Note: This patch should also be applied to the 1.6 branch.

Index: unicodeobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/unicodeobject.c,v
retrieving revision 2.55
retrieving revision 2.56
diff -C2 -r2.55 -r2.56
*** unicodeobject.c	2000/08/03 18:44:28	2.55
--- unicodeobject.c	2000/08/08 08:04:29	2.56
***************
*** 3170,3173 ****
--- 3170,3179 ----
  }
  
+ #if 0
+ 
+ /* This code should go into some future Unicode collation support
+    module. The basic comparison should compare ordinals on a naive
+    basis (this is what Java does and thus JPython too).
+ 
  /* speedy UTF-16 code point order comparison */
  /* gleaned from: */
***************
*** 3213,3216 ****
--- 3219,3249 ----
      return (len1 < len2) ? -1 : (len1 != len2);
  }
+ 
+ #else
+ 
+ static int
+ unicode_compare(PyUnicodeObject *str1, PyUnicodeObject *str2)
+ {
+     register int len1, len2;
+ 
+     Py_UNICODE *s1 = str1->str;
+     Py_UNICODE *s2 = str2->str;
+ 
+     len1 = str1->length;
+     len2 = str2->length;
+     
+     while (len1 > 0 && len2 > 0) {
+ 	register long diff;
+ 
+         diff = (long)*s1++ - (long)*s2++;
+         if (diff)
+             return (diff < 0) ? -1 : (diff != 0);
+         len1--; len2--;
+     }
+ 
+     return (len1 < len2) ? -1 : (len1 != len2);
+ }
+ 
+ #endif
  
  int PyUnicode_Compare(PyObject *left,