]> granicus.if.org Git - python/commitdiff
Changed STRINGLIB_CMP from an inline function to a macro in order to avoid a 'defined...
authorEric Smith <eric@trueblade.com>
Tue, 28 Aug 2007 09:45:15 +0000 (09:45 +0000)
committerEric Smith <eric@trueblade.com>
Tue, 28 Aug 2007 09:45:15 +0000 (09:45 +0000)
Objects/stringlib/unicodedefs.h

index 1fac2c3d52976e453cf6677262027b3bdd97a5d1..a50a3f283f37a92cb7ff87900d2d2e186ef43b67 100644 (file)
@@ -21,6 +21,8 @@
 #define STRINGLIB_CHECK          PyUnicode_Check
 #define STRINGLIB_TOSTR          PyObject_Unicode
 
+/* STRINGLIB_CMP was defined as:
+
 Py_LOCAL_INLINE(int)
 STRINGLIB_CMP(const Py_UNICODE* str, const Py_UNICODE* other, Py_ssize_t len)
 {
@@ -29,4 +31,13 @@ STRINGLIB_CMP(const Py_UNICODE* str, const Py_UNICODE* other, Py_ssize_t len)
     return memcmp((void*) str, (void*) other, len * sizeof(Py_UNICODE));
 }
 
+but unfortunately that gives a error if the function isn't used in a file that
+includes this file.  So, reluctantly convert it to a macro instead. */
+
+#define STRINGLIB_CMP(str, other, len) \
+    (((str)[0] != (other)[0]) ? \
+     1 : \
+     memcmp((void*) (str), (void*) (other), (len) * sizeof(Py_UNICODE)))
+
+
 #endif /* !STRINGLIB_UNICODEDEFS_H */