[Numpy-svn] r4781 - trunk/numpy/core/src

numpy-svn@scip... numpy-svn@scip...
Sat Feb 9 22:54:00 CST 2008


Author: charris
Date: 2008-02-09 22:53:58 -0600 (Sat, 09 Feb 2008)
New Revision: 4781

Modified:
   trunk/numpy/core/src/arrayobject.c
Log:
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.


Modified: trunk/numpy/core/src/arrayobject.c
===================================================================
--- trunk/numpy/core/src/arrayobject.c	2008-02-09 18:08:40 UTC (rev 4780)
+++ trunk/numpy/core/src/arrayobject.c	2008-02-10 04:53:58 UTC (rev 4781)
@@ -4280,6 +4280,24 @@
     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



More information about the Numpy-svn mailing list