Skip to content

Commit efc01aa

Browse files
authored
fix build break in PSX for iswspace (#955)
1 parent fa35b7a commit efc01aa

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

Include/json_cpp/details/json_parsing.hpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@
1111
* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
1212
****/
1313

14+
#include <cctype>
1415
#include <cstdlib>
1516
#include <array>
17+
#include <cwctype>
18+
#include <type_traits>
1619
#include "../json.h"
1720

1821
#if defined(_MSC_VER)
@@ -198,6 +201,17 @@ typename std::char_traits<CharType>::int_type eof()
198201
return std::char_traits<CharType>::eof();
199202
}
200203

204+
template <typename CharType>
205+
bool is_whitespace_character(typename std::char_traits<CharType>::int_type ch)
206+
{
207+
if constexpr (std::is_same<CharType, wchar_t>::value)
208+
{
209+
return std::iswspace(static_cast<wint_t>(ch)) != 0;
210+
}
211+
212+
return std::isspace(static_cast<unsigned char>(ch)) != 0;
213+
}
214+
201215
template <typename CharType>
202216
class JSON_StreamParser : public JSON_Parser<CharType>
203217
{
@@ -305,7 +319,7 @@ typename JSON_Parser<CharType>::int_type JSON_Parser<CharType>::EatWhitespace()
305319
{
306320
auto ch = NextCharacter();
307321

308-
while ( ch != eof<CharType>() && iswspace(static_cast<wint_t>(ch)))
322+
while ( ch != eof<CharType>() && is_whitespace_character<CharType>(ch))
309323
{
310324
ch = NextCharacter();
311325
}

0 commit comments

Comments
 (0)