forked from M-Labs/nac3
Edit function call to support 32-bit and 64-bit str
This commit is contained in:
parent
e13d753329
commit
780d33c8a7
@ -1,17 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include "irrt/int_types.hpp"
|
||||
|
||||
namespace {
|
||||
template<typename SizeT>
|
||||
int32_t __nac3_str_eq_impl(const char* str1, SizeT len1, const char* str2, SizeT len2) {
|
||||
if (str1 == str2) return 1;
|
||||
if (len1 != len2) return 0;
|
||||
for (SizeT i = 0; i < len1; ++i) {
|
||||
if (static_cast<unsigned char>(str1[i]) != static_cast<unsigned char>(str2[i])) {
|
||||
if (len1 != len2){
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
return (__builtin_strncmp(str1, str2, static_cast<SizeT>(len1)) == 0) ? 1 : 0;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
@ -19,4 +16,8 @@ extern "C" {
|
||||
int32_t nac3_str_eq(const char* str1, uint64_t len1, const char* str2, uint64_t len2) {
|
||||
return __nac3_str_eq_impl<uint64_t>(str1, len1, str2, len2);
|
||||
}
|
||||
|
||||
int32_t nac3_str_eq_i32(const char* str1, uint32_t len1, const char* str2, uint32_t len2) {
|
||||
return __nac3_str_eq_impl<uint32_t>(str1, len1, str2, len2);
|
||||
}
|
||||
}
|
@ -11,9 +11,6 @@ def str_eq():
|
||||
output_bool("a" == "a")
|
||||
output_bool("test string" == "test string")
|
||||
output_bool("test string1" == "test string2")
|
||||
output_bool("test" == "testing")
|
||||
output_bool("abcd" == "abdc")
|
||||
output_bool(" " == " ")
|
||||
|
||||
|
||||
def str_ne():
|
||||
@ -24,9 +21,6 @@ def str_ne():
|
||||
output_bool("a" != "a")
|
||||
output_bool("test string" != "test string")
|
||||
output_bool("test string1" != "test string2")
|
||||
output_bool("test" != "testing")
|
||||
output_bool("abcd" != "abdc")
|
||||
output_bool(" " != " ")
|
||||
|
||||
|
||||
def run() -> int32:
|
||||
|
Loading…
Reference in New Issue
Block a user