summaryrefslogtreecommitdiff
path: root/numpy/core/src/arrayobject.c
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2008-02-10 04:53:58 +0000
committerCharles Harris <charlesr.harris@gmail.com>2008-02-10 04:53:58 +0000
commit43901a8e104f861b6c763d3cb0f5e1192a829616 (patch)
tree8a0b9f14fdfe3ded7d86f895f9190806639dc1ad /numpy/core/src/arrayobject.c
parent16aff17e96d88f474ea41a3570e22bde803d9dec (diff)
downloadnumpy-43901a8e104f861b6c763d3cb0f5e1192a829616.tar.gz
Add PyArray_CompareString function, but don't add it to the OBJECT_API yet. A
function not used warning will be issued during compile, but it is harmless.
Diffstat (limited to 'numpy/core/src/arrayobject.c')
-rw-r--r--numpy/core/src/arrayobject.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/numpy/core/src/arrayobject.c b/numpy/core/src/arrayobject.c
index d93f82bd0..95b4ae92d 100644
--- a/numpy/core/src/arrayobject.c
+++ b/numpy/core/src/arrayobject.c
@@ -4280,6 +4280,24 @@ PyArray_CompareUCS4(npy_ucs4 *s1, npy_ucs4 *s2, register size_t len)
return 0;
}
+/*
+ */
+static int
+PyArray_CompareString(char *s1, char *s2, size_t len)
+{
+ const unsigned char *c1 = (unsigned char *)s1;
+ const unsigned char *c2 = (unsigned char *)s2;
+ size_t i;
+
+ for(i = 0; i < len; ++i) {
+ if (c1[i] != c2[i]) {
+ return (c1[i] > c2[i]) ? 1 : -1;
+ }
+ }
+ return 0;
+}
+
+
/* This also handles possibly mis-aligned data */
/* Compare s1 and s2 which are not necessarily NULL-terminated.
s1 is of length len1