diff --git a/include/rapidjson/schema.h b/include/rapidjson/schema.h index 40e78ac..99ef053 100644 --- a/include/rapidjson/schema.h +++ b/include/rapidjson/schema.h @@ -18,8 +18,6 @@ #include "document.h" #include // HUGE_VAL, abs, floor -#define RAPIDJSON_SCHEMA_USE_STDREGEX 0 - #if !defined(RAPIDJSON_SCHEMA_USE_STDREGEX) && (__cplusplus >=201103L || (defined(_MSC_VER) && _MSC_VER >= 1800)) #define RAPIDJSON_SCHEMA_USE_STDREGEX 1 #else @@ -30,6 +28,12 @@ #include #endif +#if RAPIDJSON_SCHEMA_USE_STDREGEX +#define RAPIDJSON_SCHEMA_HAS_REGEX 1 +#else +#define RAPIDJSON_SCHEMA_HAS_REGEX 0 +#endif + #if defined(__GNUC__) RAPIDJSON_DIAG_PUSH RAPIDJSON_DIAG_OFF(effc++) @@ -669,7 +673,7 @@ private: static bool IsPatternMatch(const std::basic_regex* pattern, const Ch *str, SizeType length) { std::match_results r; - return std::regex_search(str, str + length, r, pattern); + return std::regex_search(str, str + length, r, *pattern); } #else template diff --git a/test/unittest/schematest.cpp b/test/unittest/schematest.cpp index 7db33f8..dd1e163 100644 --- a/test/unittest/schematest.cpp +++ b/test/unittest/schematest.cpp @@ -385,6 +385,7 @@ TEST(SchemaValidator, Object_SchemaDependencies) { VALIDATE(s, "{\"name\": \"John Doe\", \"billing_address\" : \"555 Debtor's Lane\"}", true); } +#if RAPIDJSON_SCHEMA_HAS_REGEX TEST(SchemaValidator, Object_PatternProperties) { Document sd; sd.Parse( @@ -424,6 +425,7 @@ TEST(SchemaValidator, Object_PatternProperties_AdditionalProperties) { VALIDATE(s, "{ \"keyword\": \"value\" }", true); VALIDATE(s, "{ \"keyword\": 42 }", false); } +#endif TEST(SchemaValidator, Array) { Document sd;