1
0
Fork 0
mirror of https://github.com/bolero-MURAKAMI/Sprout synced 2025-08-03 12:49:50 +00:00

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,18 +3,21 @@
#include <cstddef>
#include <sprout/config.hpp>
#include <sprout/iterator/ptr_index_iterator.hpp>
#include <sprout/algorithm/tristate_lexicographical_compare.hpp>
#include <sprout/cwchar/wcslen.hpp>
#include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT
namespace sprout {
// Copyright (C) 2011 RiSK (sscrisk)
//
// wcsncmp
//
inline SPROUT_CONSTEXPR int
wcsncmp(wchar_t const* s1, wchar_t const* s2, std::size_t n) {
return !n || (!*s1 && !*s2) ? 0
: !*s1 ? -1
: !*s2 ? 1
: *s1 == *s2 ? sprout::wcsncmp(s1 + 1, s2 + 1, n - 1)
: *s1 - *s2
;
return sprout::tristate_lexicographical_compare(
sprout::as_iterator(s1), sprout::as_iterator(s1, sprout::wcslen(s1, n)),
sprout::as_iterator(s2), sprout::as_iterator(s2, sprout::wcslen(s2, n))
);
}
} // namespace sprout