Closed jfcap closed 10 years ago
This is something that was added by https://github.com/jsolman (Jeff).
I did not test this thing out as most of his code seems fine. I propose we just use the libc version which is already defined in cdef.lua, which probably also are faster:
int strcasecmp(const char *s1, const char *s2);
so basically:
function util.strcasecmp(str1, str2)
return tonumber(ffi.C.strcasecmp(str1, str2))
end
--or for added safety:
function util.strcasecmp(str1, str2)
assert(type(str1)=="string" and type(str2)=="string", "Invalid arguments.")
return tonumber(ffi.C.strcasecmp(str1, str2))
end
Any reasons not to do this jsolman?
Fixed now.
Sorry for introducing that bug, it did need to break the loop if r ~=0. I must not have tested it properly myself.
I don't know if it is actually faster or not, might depend on your libc, but since it is available might as well have used it as you did.
IMHO util.strcasecmp function is bugged