diff --git a/numexpr/interp_body.cpp b/numexpr/interp_body.cpp index ec7e529a..8c47581f 100644 --- a/numexpr/interp_body.cpp +++ b/numexpr/interp_body.cpp @@ -241,7 +241,7 @@ case OP_GT_BSS: VEC_ARG2(b_dest = (stringcmp(s1, s2, ss1, ss2) > 0)); case OP_GE_BSS: VEC_ARG2(b_dest = (stringcmp(s1, s2, ss1, ss2) >= 0)); - case OP_EQ_BSS: VEC_ARG2(b_dest = (stringcmp(s1, s2, ss1, ss2) == 0)); + case OP_EQ_BSS: VEC_ARG2(b_dest = (stringequal(s1, s2, ss1, ss2) == 0)); case OP_NE_BSS: VEC_ARG2(b_dest = (stringcmp(s1, s2, ss1, ss2) != 0)); case OP_CONTAINS_BSS: VEC_ARG2(b_dest = stringcontains(s1, s2, ss1, ss2)); diff --git a/numexpr/interpreter.cpp b/numexpr/interpreter.cpp index 7c399d0c..e9ebb041 100644 --- a/numexpr/interpreter.cpp +++ b/numexpr/interpreter.cpp @@ -515,6 +515,21 @@ stringcmp(const char *s1, const char *s2, npy_intp maxlen1, npy_intp maxlen2) return 0; } +static int +stringequal(const char *s1, const char *s2, npy_intp maxlen1, npy_intp maxlen2) +{ + int s1len, s2len; + if (1) { + s1len = strnlen(s1, maxlen1); + s2len = strnlen(s2, maxlen2); + if (s1len != s2len) return -1; + /* They are equal in length, so check until the common length */ + return strncmp(s1, s2, s2len); + } + else { + return stringcmp(s1, s2, maxlen1, maxlen2); + } +} /* contains(str1, str2) function for string columns.