From 337cb553d0c462b8765804063122fd8b9e34d6c2 Mon Sep 17 00:00:00 2001 From: Jesse Beder Date: Fri, 3 Dec 2010 21:52:04 +0000 Subject: [PATCH] Fixed emitting colon at end of scalar bug --- CMakeLists.txt | 4 ++-- src/regeximpl.h | 8 +++++++- test/emittertests.cpp | 17 +++++++++++++++++ 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 40154ec..893f137 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,8 +5,8 @@ project (YAML_CPP) set(LIB_TYPE SHARED) if(IPHONE) - set(CMAKE_OSX_SYSROOT iphoneos4.0) - set(CMAKE_OSX_ARCHITECTURES $(ARCHS_STANDARD_32_BIT)) + set(CMAKE_OSX_SYSROOT iphoneos4.2) + set(CMAKE_OSX_ARCHITECTURES "armv6;armv7") set(LIB_TYPE) endif(IPHONE) diff --git a/src/regeximpl.h b/src/regeximpl.h index 41a052e..c13f236 100644 --- a/src/regeximpl.h +++ b/src/regeximpl.h @@ -58,7 +58,13 @@ namespace YAML template<> inline bool RegEx::IsValidSource(const StringCharSource&source) const { - return source || m_op == REGEX_EMPTY; + switch(m_op) { + case REGEX_MATCH: + case REGEX_RANGE: + return source; + default: + return true; + } } template diff --git a/test/emittertests.cpp b/test/emittertests.cpp index cfbac82..b81ab68 100644 --- a/test/emittertests.cpp +++ b/test/emittertests.cpp @@ -726,6 +726,21 @@ namespace Test out << YAML::Binary("", 0); desiredOutput = "--- !!binary \"\""; } + + void ColonAtEndOfScalar(YAML::Emitter& out, std::string& desiredOutput) + { + out << "a:"; + desiredOutput = "--- \"a:\""; + } + + void ColonAsScalar(YAML::Emitter& out, std::string& desiredOutput) + { + out << YAML::BeginMap; + out << YAML::Key << "apple" << YAML::Value << ":"; + out << YAML::Key << "banana" << YAML::Value << ":"; + out << YAML::EndMap; + desiredOutput = "---\napple: \":\"\nbanana: \":\""; + } //////////////////////////////////////////////////////////////////////////////////////////////////////// // incorrect emitting @@ -916,6 +931,8 @@ namespace Test RunEmitterTest(&Emitter::Binary, "binary", passed, total); RunEmitterTest(&Emitter::LongBinary, "long binary", passed, total); RunEmitterTest(&Emitter::EmptyBinary, "empty binary", passed, total); + RunEmitterTest(&Emitter::ColonAtEndOfScalar, "colon at end of scalar", passed, total); + RunEmitterTest(&Emitter::ColonAsScalar, "colon as scalar", passed, total); RunEmitterErrorTest(&Emitter::ExtraEndSeq, "extra EndSeq", passed, total); RunEmitterErrorTest(&Emitter::ExtraEndMap, "extra EndMap", passed, total);