diff --git a/src/OpenFOAM/primitives/Scalar/Scalar.C b/src/OpenFOAM/primitives/Scalar/Scalar.C index cdd94c7b15..4445a52767 100644 --- a/src/OpenFOAM/primitives/Scalar/Scalar.C +++ b/src/OpenFOAM/primitives/Scalar/Scalar.C @@ -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; diff --git a/src/OpenFOAM/primitives/bools/Switch/SwitchIO.C b/src/OpenFOAM/primitives/bools/Switch/SwitchIO.C index d1c43ee858..81757e8952 100644 --- a/src/OpenFOAM/primitives/bools/Switch/SwitchIO.C +++ b/src/OpenFOAM/primitives/bools/Switch/SwitchIO.C @@ -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; diff --git a/src/OpenFOAM/primitives/ints/int/intIO.C b/src/OpenFOAM/primitives/ints/int/intIO.C index b7a70228c0..17f4d1a1f6 100644 --- a/src/OpenFOAM/primitives/ints/int/intIO.C +++ b/src/OpenFOAM/primitives/ints/int/intIO.C @@ -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; diff --git a/src/OpenFOAM/primitives/ints/long/longIO.C b/src/OpenFOAM/primitives/ints/long/longIO.C index 2b7320164d..7ea56d0e2e 100644 --- a/src/OpenFOAM/primitives/ints/long/longIO.C +++ b/src/OpenFOAM/primitives/ints/long/longIO.C @@ -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; diff --git a/src/OpenFOAM/primitives/ints/uint/uintIO.C b/src/OpenFOAM/primitives/ints/uint/uintIO.C index 1d24188c91..7388266f4f 100644 --- a/src/OpenFOAM/primitives/ints/uint/uintIO.C +++ b/src/OpenFOAM/primitives/ints/uint/uintIO.C @@ -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; diff --git a/src/OpenFOAM/primitives/ints/ulong/ulongIO.C b/src/OpenFOAM/primitives/ints/ulong/ulongIO.C index 58d6900e11..63db00c1a1 100644 --- a/src/OpenFOAM/primitives/ints/ulong/ulongIO.C +++ b/src/OpenFOAM/primitives/ints/ulong/ulongIO.C @@ -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; diff --git a/src/OpenFOAM/primitives/strings/keyType/keyTypeIO.C b/src/OpenFOAM/primitives/strings/keyType/keyTypeIO.C index 72859abfc8..0e2f1d1133 100644 --- a/src/OpenFOAM/primitives/strings/keyType/keyTypeIO.C +++ b/src/OpenFOAM/primitives/strings/keyType/keyTypeIO.C @@ -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); diff --git a/src/OpenFOAM/primitives/strings/string/stringIO.C b/src/OpenFOAM/primitives/strings/string/stringIO.C index 89694173ae..6cb4791b4a 100644 --- a/src/OpenFOAM/primitives/strings/string/stringIO.C +++ b/src/OpenFOAM/primitives/strings/string/stringIO.C @@ -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; diff --git a/src/OpenFOAM/primitives/strings/word/wordIO.C b/src/OpenFOAM/primitives/strings/word/wordIO.C index 093a282846..20a2a216d1 100644 --- a/src/OpenFOAM/primitives/strings/word/wordIO.C +++ b/src/OpenFOAM/primitives/strings/word/wordIO.C @@ -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); diff --git a/src/OpenFOAM/primitives/strings/wordRe/wordReIO.C b/src/OpenFOAM/primitives/strings/wordRe/wordReIO.C index dab1542b27..c849b4237d 100644 --- a/src/OpenFOAM/primitives/strings/wordRe/wordReIO.C +++ b/src/OpenFOAM/primitives/strings/wordRe/wordReIO.C @@ -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);