mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
check for empty word/expression in keyType and wordRe IO
This commit is contained in:
@ -58,12 +58,22 @@ Foam::Istream& Foam::operator>>(Istream& is, keyType& w)
|
||||
{
|
||||
// Assign from string. Sets regular expression.
|
||||
w = t.stringToken();
|
||||
|
||||
// flag empty strings as an error
|
||||
if (w.empty())
|
||||
{
|
||||
is.setBad();
|
||||
FatalIOErrorIn("operator>>(Istream&, keyType&)", is)
|
||||
<< "empty word/expression "
|
||||
<< exit(FatalIOError);
|
||||
return is;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
is.setBad();
|
||||
FatalIOErrorIn("operator>>(Istream&, keyType&)", is)
|
||||
<< "wrong token type - expected word or string found "
|
||||
<< "wrong token type - expected word or string, found "
|
||||
<< t.info()
|
||||
<< exit(FatalIOError);
|
||||
|
||||
|
||||
@ -55,7 +55,7 @@ Foam::Istream& Foam::operator>>(Istream& is, string& s)
|
||||
{
|
||||
is.setBad();
|
||||
FatalIOErrorIn("operator>>(Istream&, string&)", is)
|
||||
<< "wrong token type - expected string found " << t.info()
|
||||
<< "wrong token type - expected string, found " << t.info()
|
||||
<< exit(FatalIOError);
|
||||
|
||||
return is;
|
||||
|
||||
@ -65,7 +65,8 @@ Foam::Istream& Foam::operator>>(Istream& is, word& w)
|
||||
{
|
||||
is.setBad();
|
||||
FatalIOErrorIn("operator>>(Istream&, word&)", is)
|
||||
<< "wrong token type - expected word found non-word characters "
|
||||
<< "wrong token type - expected word, found "
|
||||
"non-word characters "
|
||||
<< t.info()
|
||||
<< exit(FatalIOError);
|
||||
return is;
|
||||
@ -75,7 +76,7 @@ Foam::Istream& Foam::operator>>(Istream& is, word& w)
|
||||
{
|
||||
is.setBad();
|
||||
FatalIOErrorIn("operator>>(Istream&, word&)", is)
|
||||
<< "wrong token type - expected word found "
|
||||
<< "wrong token type - expected word, found "
|
||||
<< t.info()
|
||||
<< exit(FatalIOError);
|
||||
|
||||
|
||||
@ -57,12 +57,22 @@ Foam::Istream& Foam::operator>>(Istream& is, wordRe& w)
|
||||
{
|
||||
// Auto-tests for regular expression
|
||||
w = t.stringToken();
|
||||
|
||||
// flag empty strings as an error
|
||||
if (w.empty())
|
||||
{
|
||||
is.setBad();
|
||||
FatalIOErrorIn("operator>>(Istream&, wordRe&)", is)
|
||||
<< "empty word/expression "
|
||||
<< exit(FatalIOError);
|
||||
return is;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
is.setBad();
|
||||
FatalIOErrorIn("operator>>(Istream&, wordRe&)", is)
|
||||
<< "wrong token type - expected word or string found "
|
||||
<< "wrong token type - expected word or string, found "
|
||||
<< t.info()
|
||||
<< exit(FatalIOError);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user