fix cstring, cwchar

This commit is contained in:
bolero-MURAKAMI 2012-12-22 01:02:49 +09:00
parent 8227569c43
commit 0670013702
17 changed files with 172 additions and 127 deletions

View file

@ -3,19 +3,19 @@
#include <cstddef>
#include <sprout/config.hpp>
#include <sprout/iterator/ptr_index_iterator.hpp>
#include <sprout/algorithm/tristate_lexicographical_compare.hpp>
#include <sprout/cstring/strlen.hpp>
#include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT
namespace sprout {
// Copyright (C) 2011 RiSK (sscrisk)
// 7.21.4.4 strncmp ŠÖ<C5A0>
inline SPROUT_CONSTEXPR int
strncmp(char const* s1, char const* s2, std::size_t n) {
return !n || (!*s1 && !*s2) ? 0
: !*s1 ? -1
: !*s2 ? 1
: *s1 == *s2 ? sprout::strncmp(s1 + 1, s2 + 1, n - 1)
: static_cast<unsigned char>(*s1) - static_cast<unsigned char>(*s2)
;
return sprout::tristate_lexicographical_compare(
sprout::as_iterator(s1), sprout::as_iterator(s1, sprout::strlen(s1, n)),
sprout::as_iterator(s2), sprout::as_iterator(s2, sprout::strlen(s2, n))
);
}
} // namespace sprout