From cee0974abdeda5d6c0d452478794ff5109571f9a Mon Sep 17 00:00:00 2001 From: jbeder Date: Thu, 3 Mar 2011 20:01:32 +0000 Subject: [PATCH] Refactored parse.cpp so that VS doesn't complain, added MinSizeRel build setting, and fixed numbering in the spec tests --- CMakeLists.txt | 1 + test/spectests.cpp | 4 ++-- util/parse.cpp | 23 +++++++++++++++-------- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 639af91..ea20cfb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -113,6 +113,7 @@ if(CMAKE_COMPILER_IS_GNUCXX) set(CMAKE_CXX_FLAGS_RELEASE "-O2") set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g") set(CMAKE_CXX_FLAGS_DEBUG "-g") + set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os") # set(GCC_EXTRA_OPTIONS "") # diff --git a/test/spectests.cpp b/test/spectests.cpp index 719dea2..844939b 100644 --- a/test/spectests.cpp +++ b/test/spectests.cpp @@ -2155,8 +2155,8 @@ namespace Test { RunSpecTest(&Spec::BlockIndentationHeader, "8.2", "Block Indentation Header", passed, total); RunSpecTest(&Spec::InvalidBlockScalarIndentationIndicators, "8.3", "Invalid Block Scalar Indentation Indicators", passed, total); RunSpecTest(&Spec::ChompingFinalLineBreak, "8.4", "Chomping Final Line Break", passed, total); - RunSpecTest(&Spec::ChompingTrailingLines, "8.4", "Chomping Trailing Lines", passed, total); - RunSpecTest(&Spec::EmptyScalarChomping, "8.4", "Empty Scalar Chomping", passed, total); + RunSpecTest(&Spec::ChompingTrailingLines, "8.5", "Chomping Trailing Lines", passed, total); + RunSpecTest(&Spec::EmptyScalarChomping, "8.6", "Empty Scalar Chomping", passed, total); std::cout << "Spec tests: " << passed << "/" << total << " passed\n"; return passed == total; diff --git a/util/parse.cpp b/util/parse.cpp index 8f194f0..499dab9 100644 --- a/util/parse.cpp +++ b/util/parse.cpp @@ -34,15 +34,8 @@ public: virtual void OnMapEnd() {} }; -int main(int argc, char **argv) +void parse(std::istream& input) { - Params p = ParseArgs(argc, argv); - - std::ifstream fin; - if(argc > 1) - fin.open(argv[1]); - - std::istream& input = (argc > 1 ? fin : std::cin); try { YAML::Parser parser(input); YAML::Node doc; @@ -55,5 +48,19 @@ int main(int argc, char **argv) } catch(const YAML::Exception& e) { std::cerr << e.what() << "\n"; } +} + +int main(int argc, char **argv) +{ + Params p = ParseArgs(argc, argv); + + if(argc > 1) { + std::ifstream fin; + fin.open(argv[1]); + parse(fin); + } else { + parse(std::cin); + } + return 0; }