Merge pull request #1039 from atgeirr/replace-backslash-include
Replace backslash in INCLUDE paths
This commit is contained in:
commit
c410f99625
@ -372,6 +372,13 @@ boost::filesystem::path ParserState::getIncludeFilePath( std::string path ) cons
|
||||
boost::replace_all(path, pathKeywordPrefix + stringToFind, stringToReplace);
|
||||
}
|
||||
|
||||
// Check if there are any backslashes in the path...
|
||||
if (path.find('\\') != std::string::npos) {
|
||||
// ... if so, replace with slashes and create a warning.
|
||||
std::replace(path.begin(), path.end(), '\\', '/');
|
||||
deck.getMessageContainer().warning("Replaced one or more backslash with a slash in an INCLUDE path.");
|
||||
}
|
||||
|
||||
boost::filesystem::path includeFilePath(path);
|
||||
|
||||
if (includeFilePath.is_relative())
|
||||
|
@ -288,10 +288,20 @@ BOOST_AUTO_TEST_CASE( PATHS_has_global_scope ) {
|
||||
ParseContext parseContext;
|
||||
|
||||
parseContext.update( ParseContext::PARSE_MISSING_INCLUDE , Opm::InputError::THROW_EXCEPTION);
|
||||
parser.parseFile( "testdata/parser/PATHSInInclude.data", parseContext );
|
||||
const auto deck = parser.parseFile( "testdata/parser/PATHSInInclude.data", parseContext );
|
||||
BOOST_CHECK(deck.hasKeyword("OIL"));
|
||||
BOOST_CHECK_THROW( parser.parseFile( "testdata/parser/PATHSInIncludeInvalid.data", ParseContext() ), std::invalid_argument );
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( PATHS_with_backslashes ) {
|
||||
Parser parser;
|
||||
ParseContext parseContext;
|
||||
|
||||
parseContext.update( ParseContext::PARSE_MISSING_INCLUDE , Opm::InputError::THROW_EXCEPTION);
|
||||
const auto deck = parser.parseFile( "testdata/parser/PATHSWithBackslashes.data", parseContext );
|
||||
BOOST_CHECK(deck.hasKeyword("OIL"));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( handle_empty_title ) {
|
||||
const auto* input_deck = "RUNSPEC\n\n"
|
||||
"TITLE\n\n"
|
||||
|
7
testdata/parser/PATHSWithBackslashes.data
vendored
Normal file
7
testdata/parser/PATHSWithBackslashes.data
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
INCLUDE
|
||||
'include\foobackslash.inc'
|
||||
/
|
||||
|
||||
INCLUDE
|
||||
'$FOOPATH\foo_target.inc'
|
||||
/
|
3
testdata/parser/include/foobackslash.inc
vendored
Normal file
3
testdata/parser/include/foobackslash.inc
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
PATHS
|
||||
'FOOPATH' 'include\foopath' /
|
||||
/
|
Loading…
Reference in New Issue
Block a user