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:
@ -84,7 +84,7 @@ Istream& operator>>(Istream& is, Scalar& s)
|
||||
{
|
||||
is.setBad();
|
||||
FatalIOErrorIn("operator>>(Istream&, Scalar&)", is)
|
||||
<< "wrong token type - expected Scalar found " << t.info()
|
||||
<< "wrong token type - expected Scalar, found " << t.info()
|
||||
<< exit(FatalIOError);
|
||||
|
||||
return is;
|
||||
|
||||
@ -74,7 +74,7 @@ Foam::Istream& Foam::operator>>(Istream& is, Switch& s)
|
||||
{
|
||||
is.setBad();
|
||||
FatalIOErrorIn("operator>>(Istream&, bool/Switch&)", is)
|
||||
<< "wrong token type - expected bool found " << t
|
||||
<< "wrong token type - expected bool, found " << t
|
||||
<< exit(FatalIOError);
|
||||
|
||||
return is;
|
||||
|
||||
@ -67,7 +67,7 @@ Foam::Istream& Foam::operator>>(Istream& is, int& i)
|
||||
{
|
||||
is.setBad();
|
||||
FatalIOErrorIn("operator>>(Istream&, int&)", is)
|
||||
<< "wrong token type - expected int found " << t.info()
|
||||
<< "wrong token type - expected int, found " << t.info()
|
||||
<< exit(FatalIOError);
|
||||
|
||||
return is;
|
||||
|
||||
@ -65,7 +65,7 @@ Foam::Istream& Foam::operator>>(Istream& is, long& l)
|
||||
{
|
||||
is.setBad();
|
||||
FatalIOErrorIn("operator>>(Istream&, long&)", is)
|
||||
<< "wrong token type - expected long found " << t.info()
|
||||
<< "wrong token type - expected long, found " << t.info()
|
||||
<< exit(FatalIOError);
|
||||
|
||||
return is;
|
||||
|
||||
@ -66,7 +66,7 @@ Foam::Istream& Foam::operator>>(Istream& is, unsigned int& i)
|
||||
{
|
||||
is.setBad();
|
||||
FatalIOErrorIn("operator>>(Istream&, unsigned int&)", is)
|
||||
<< "wrong token type - expected unsigned int found " << t.info()
|
||||
<< "wrong token type - expected unsigned int, found " << t.info()
|
||||
<< exit(FatalIOError);
|
||||
|
||||
return is;
|
||||
|
||||
@ -63,7 +63,7 @@ Foam::Istream& Foam::operator>>(Istream& is, unsigned long& val)
|
||||
{
|
||||
is.setBad();
|
||||
FatalIOErrorIn("operator>>(Istream&, unsigned long&)", is)
|
||||
<< "wrong token type - expected unsigned long found " << t.info()
|
||||
<< "wrong token type - expected unsigned long, found " << t.info()
|
||||
<< exit(FatalIOError);
|
||||
|
||||
return is;
|
||||
|
||||
@ -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