make the parser case-insensitive
i.e., make keywords ALL_UPPERCASE before using them because Eclipse seems to be case-insensitive (although this is one of its undocumented features...)
This commit is contained in:
parent
fff0c9cdf0
commit
ead7e0a8c9
@ -206,7 +206,7 @@ namespace Opm {
|
|||||||
if (name.length() > ParserConst::maxKeywordLength)
|
if (name.length() > ParserConst::maxKeywordLength)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!isupper(name[0]))
|
if (!isalpha(name[0]))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -242,13 +242,17 @@ namespace Opm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool ParserKeyword::validDeckName(const std::string& name) {
|
bool ParserKeyword::validDeckName(const std::string& name) {
|
||||||
if (!validNameStart(name))
|
// make the keyword string ALL_UPPERCASE because Eclipse seems
|
||||||
|
// to be case-insensitive (although this is one of its
|
||||||
|
// undocumented features...)
|
||||||
|
std::string upperCaseName = boost::to_upper_copy(name);
|
||||||
|
|
||||||
|
if (!validNameStart(upperCaseName))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
for (size_t i = 1; i < name.length(); i++) {
|
for (size_t i = 1; i < upperCaseName.length(); i++) {
|
||||||
char c = name[i];
|
char c = upperCaseName[i];
|
||||||
if (!isupper(c) &&
|
if (!isalnum(c) &&
|
||||||
!isdigit(c) &&
|
|
||||||
c != '-' &&
|
c != '-' &&
|
||||||
c != '_' &&
|
c != '_' &&
|
||||||
c != '+')
|
c != '+')
|
||||||
|
@ -65,7 +65,7 @@ BOOST_AUTO_TEST_CASE(ParserKeyword_withOtherSize_SizeTypeOTHER) {
|
|||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(ParserKeyword_validDeckName) {
|
BOOST_AUTO_TEST_CASE(ParserKeyword_validDeckName) {
|
||||||
BOOST_CHECK_EQUAL( true , ParserKeyword::validDeckName("SUMMARY"));
|
BOOST_CHECK_EQUAL( true , ParserKeyword::validDeckName("SUMMARY"));
|
||||||
BOOST_CHECK_EQUAL( false , ParserKeyword::validDeckName("MixeCase"));
|
BOOST_CHECK_EQUAL( true , ParserKeyword::validDeckName("MixeCase"));
|
||||||
BOOST_CHECK_EQUAL( false , ParserKeyword::validDeckName("NAMETOOLONG"));
|
BOOST_CHECK_EQUAL( false , ParserKeyword::validDeckName("NAMETOOLONG"));
|
||||||
BOOST_CHECK_EQUAL( true , ParserKeyword::validDeckName("STRING88"));
|
BOOST_CHECK_EQUAL( true , ParserKeyword::validDeckName("STRING88"));
|
||||||
BOOST_CHECK_EQUAL( false , ParserKeyword::validDeckName("88STRING"));
|
BOOST_CHECK_EQUAL( false , ParserKeyword::validDeckName("88STRING"));
|
||||||
|
@ -131,6 +131,12 @@ namespace Opm {
|
|||||||
|
|
||||||
// white space is for dicks!
|
// white space is for dicks!
|
||||||
result = boost::trim_right_copy_if(result.substr(0, 8), boost::is_any_of(" \t"));
|
result = boost::trim_right_copy_if(result.substr(0, 8), boost::is_any_of(" \t"));
|
||||||
|
|
||||||
|
// make the keyword string ALL_UPPERCASE because Eclipse seems
|
||||||
|
// to be case-insensitive (although this is one of its
|
||||||
|
// undocumented features...)
|
||||||
|
boost::to_upper(result);
|
||||||
|
|
||||||
if (isValidKeyword(result))
|
if (isValidKeyword(result))
|
||||||
return true;
|
return true;
|
||||||
else
|
else
|
||||||
|
@ -62,7 +62,7 @@ BOOST_AUTO_TEST_CASE(RawKeywordSetKeywordInitialWhitespaceInKeywordThrows) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(constructor_mixedCaseName_throws) {
|
BOOST_AUTO_TEST_CASE(constructor_mixedCaseName_throws) {
|
||||||
BOOST_CHECK_THROW(RawKeyword("Test", Raw::SLASH_TERMINATED , "FILE" , 10U), std::invalid_argument);
|
BOOST_CHECK_NO_THROW(RawKeyword("Test", Raw::SLASH_TERMINATED , "FILE" , 10U));
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(RawKeywordSetKeywordInitialTabInKeywordThrows) {
|
BOOST_AUTO_TEST_CASE(RawKeywordSetKeywordInitialTabInKeywordThrows) {
|
||||||
|
Loading…
Reference in New Issue
Block a user