From 747a643288adb858abfc41dda79f02d60d2080bb Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Sun, 23 Jun 2019 12:09:54 +0200 Subject: [PATCH] Ignore character SOH (ASCII 1) while parsing --- opm/parser/eclipse/RawDeck/RawConsts.hpp | 4 ++-- tests/parser/ParserTests.cpp | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/opm/parser/eclipse/RawDeck/RawConsts.hpp b/opm/parser/eclipse/RawDeck/RawConsts.hpp index e2759ebff..d130abc78 100644 --- a/opm/parser/eclipse/RawDeck/RawConsts.hpp +++ b/opm/parser/eclipse/RawDeck/RawConsts.hpp @@ -48,7 +48,7 @@ namespace Opm { */ constexpr bool sep_table[ 128 ] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, + 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -60,7 +60,7 @@ namespace Opm { struct is_separator { /* - * ch is space, comma, \r, \n, \t, \v or \f => true + * ch is SOH (ASCII 1), space, comma, \r, \n, \t, \v or \f => true * else false */ constexpr bool operator()( int ch ) const { diff --git a/tests/parser/ParserTests.cpp b/tests/parser/ParserTests.cpp index af84740c5..50bb0e80d 100644 --- a/tests/parser/ParserTests.cpp +++ b/tests/parser/ParserTests.cpp @@ -1980,6 +1980,25 @@ DENSITY BOOST_CHECK( pbub.defaultApplied( 0 ) ); } +BOOST_AUTO_TEST_CASE(IGNORE_SOH) { + // Check that parsing RSCONSTT does not bleed into next keyword. + + const auto deck_string = std::string { R"( +FIELD +TABDIMS + 1* 2 +/ +-- The ^A should be here - that is ASCII character 1 which is sometimes +-- inserted by the windows editor Notepad++ +PROPS +RSCONSTT + 0.35 932 / + 0.40 945 / +)" }; + + const auto deck = Parser{}.parseString( deck_string ); +} + BOOST_AUTO_TEST_CASE(ParseRSConstT) { // Check that parsing RSCONSTT does not bleed into next keyword.