summaryrefslogtreecommitdiffstats
path: root/Objects/unicodeobject.c
diff options
context:
space:
mode:
Diffstat (limited to 'Objects/unicodeobject.c')
-rw-r--r--Objects/unicodeobject.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 83efa81..95f4761 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -3169,6 +3169,12 @@ unicode_center(PyUnicodeObject *self, PyObject *args)
return (PyObject*) pad(self, left, marg - left, ' ');
}
+#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: */
/* http://www-4.ibm.com/software/developer/library/utf16.html?dwzone=unicode */
@@ -3213,6 +3219,33 @@ unicode_compare(PyUnicodeObject *str1, PyUnicodeObject *str2)
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,
PyObject *right)
{