mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Merge branch 'master' of ssh://noisy/home/noisy3/OpenFOAM/OpenFOAM-dev
This commit is contained in:
@ -1,13 +1,12 @@
|
||||
#!/bin/sh
|
||||
cd ${0%/*} || exit 1 # run from this directory
|
||||
|
||||
if [ "$PWD" != "$WM_PROJECT_DIR/src" ]
|
||||
then
|
||||
wmakeCheckPwd "$WM_PROJECT_DIR/src" || {
|
||||
echo "Error: Current directory is not \$WM_PROJECT_DIR/src"
|
||||
echo " The environment variables are inconsistent with the installation."
|
||||
echo " Check the OpenFOAM entries in your dot-files and source them."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
set -x
|
||||
|
||||
|
||||
@ -102,7 +102,7 @@ char Foam::ISstream::nextValid()
|
||||
|
||||
Foam::Istream& Foam::ISstream::read(token& t)
|
||||
{
|
||||
static char numberBuffer[100];
|
||||
static char charBuffer[128];
|
||||
|
||||
// Return the put back token if it exists
|
||||
if (Istream::getBack(t))
|
||||
@ -113,7 +113,7 @@ Foam::Istream& Foam::ISstream::read(token& t)
|
||||
// Assume that the streams supplied are in working order.
|
||||
// Lines are counted by '\n'
|
||||
|
||||
// Get next 'valid character': i.e. proceed through any white space
|
||||
// Get next 'valid character': i.e. proceed through any whitespace
|
||||
// and/or comments until a semantically valid character is hit upon.
|
||||
|
||||
char c = nextValid();
|
||||
@ -144,7 +144,7 @@ Foam::Istream& Foam::ISstream::read(token& t)
|
||||
case token::COMMA :
|
||||
case token::ASSIGN :
|
||||
case token::ADD :
|
||||
// case token::SUBTRACT : // Handled later as the posible start of a number
|
||||
// case token::SUBTRACT : // Handled later as the possible start of a number
|
||||
case token::MULTIPLY :
|
||||
case token::DIVIDE :
|
||||
{
|
||||
@ -152,6 +152,7 @@ Foam::Istream& Foam::ISstream::read(token& t)
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
// Strings: enclosed by double quotes.
|
||||
case token::BEGIN_STRING :
|
||||
{
|
||||
@ -170,43 +171,104 @@ Foam::Istream& Foam::ISstream::read(token& t)
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
// Numbers: do not distinguish at this point between Types.
|
||||
//
|
||||
// ideally match the equivalent of this regular expression
|
||||
//
|
||||
// /^[-+]?([0-9]+\.?[0-9]*|\.[0-9]+)([Ee][-+]?[0-9]+)?$/
|
||||
//
|
||||
case '-' :
|
||||
case '.' :
|
||||
case '0' : case '1' : case '2' : case '3' : case '4' :
|
||||
case '5' : case '6' : case '7' : case '8' : case '9' :
|
||||
{
|
||||
bool isScalar = false;
|
||||
// has a digit
|
||||
bool hasDigit = isdigit(c);
|
||||
|
||||
if (c == '.')
|
||||
// has contents that cannot be label
|
||||
bool notLabel = (c == '.');
|
||||
|
||||
// has contents that cannot be scalar
|
||||
bool notScalar = false;
|
||||
|
||||
unsigned int nChar = 0;
|
||||
charBuffer[nChar++] = c;
|
||||
|
||||
// the location of the last '[Ee]' exponent
|
||||
unsigned int exponent = 0;
|
||||
|
||||
while (is_.get(c))
|
||||
{
|
||||
isScalar = true;
|
||||
}
|
||||
|
||||
int i=0;
|
||||
numberBuffer[i++] = c;
|
||||
|
||||
while
|
||||
(
|
||||
is_.get(c)
|
||||
&& (
|
||||
isdigit(c)
|
||||
|| c == '.'
|
||||
|| c == 'e'
|
||||
|| c == 'E'
|
||||
|| c == '+'
|
||||
|| c == '-'
|
||||
)
|
||||
)
|
||||
{
|
||||
numberBuffer[i++] = c;
|
||||
|
||||
if (!isdigit(c))
|
||||
if (isdigit(c))
|
||||
{
|
||||
isScalar = true;
|
||||
hasDigit = true;
|
||||
}
|
||||
else if (isalpha(c))
|
||||
{
|
||||
notLabel = true;
|
||||
|
||||
if (c == 'E' || c == 'e')
|
||||
{
|
||||
if (exponent || !hasDigit)
|
||||
{
|
||||
// mantissa had no digits,
|
||||
// or already saw '[Ee]' before
|
||||
notScalar = true;
|
||||
}
|
||||
|
||||
// remember this location
|
||||
exponent = nChar;
|
||||
}
|
||||
else
|
||||
{
|
||||
notScalar = true;
|
||||
}
|
||||
}
|
||||
else if (c == '+' || c == '-')
|
||||
{
|
||||
notLabel = true;
|
||||
|
||||
// only allowed once in exponent
|
||||
if (!exponent || exponent+1 != nChar)
|
||||
{
|
||||
notScalar = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// require some digits again
|
||||
hasDigit = false;
|
||||
}
|
||||
}
|
||||
else if (c == '.')
|
||||
{
|
||||
// notLabel means we already saw '.' or '[Ee]' before
|
||||
// cannot have '.' again
|
||||
if (notLabel)
|
||||
{
|
||||
notScalar = true;
|
||||
}
|
||||
notLabel = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
charBuffer[nChar++] = c;
|
||||
if (nChar >= sizeof(charBuffer))
|
||||
{
|
||||
// runaway argument - avoid buffer overflow
|
||||
t.setBad();
|
||||
return *this;
|
||||
}
|
||||
}
|
||||
numberBuffer[i] = '\0';
|
||||
charBuffer[nChar] = '\0';
|
||||
|
||||
if (!hasDigit)
|
||||
{
|
||||
notLabel = notScalar = true;
|
||||
}
|
||||
|
||||
setState(is_.rdstate());
|
||||
|
||||
@ -214,26 +276,37 @@ Foam::Istream& Foam::ISstream::read(token& t)
|
||||
{
|
||||
is_.putback(c);
|
||||
|
||||
if (i == 1 && numberBuffer[0] == '-')
|
||||
if (nChar == 1 && charBuffer[0] == '-')
|
||||
{
|
||||
// a single '-' is punctuation
|
||||
t = token::punctuationToken(token::SUBTRACT);
|
||||
}
|
||||
else if (isScalar)
|
||||
else if (notScalar)
|
||||
{
|
||||
t = scalar(atof(numberBuffer));
|
||||
// not label or scalar: must be a word
|
||||
t = new word(charBuffer);
|
||||
}
|
||||
else if (notLabel)
|
||||
{
|
||||
// not label: must be a scalar
|
||||
t = scalar(atof(charBuffer));
|
||||
}
|
||||
else if (hasDigit)
|
||||
{
|
||||
// has digit: treat as a label
|
||||
long lt = atol(charBuffer);
|
||||
t = label(lt);
|
||||
|
||||
// return as a scalar if doesn't fit in a label
|
||||
if (t.labelToken() != lt)
|
||||
{
|
||||
t = scalar(atof(charBuffer));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
long lt = atol(numberBuffer);
|
||||
t = label(lt);
|
||||
|
||||
// If the integer is too large to be represented as a label
|
||||
// return it as a scalar
|
||||
if (t.labelToken() != lt)
|
||||
{
|
||||
isScalar = true;
|
||||
t = scalar(atof(numberBuffer));
|
||||
}
|
||||
// some else: must be a word
|
||||
t = new word(charBuffer);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -244,6 +317,7 @@ Foam::Istream& Foam::ISstream::read(token& t)
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
// Should be a word (which can be a single character)
|
||||
default:
|
||||
{
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -28,6 +28,7 @@ Class
|
||||
Description
|
||||
A class for handling file names.
|
||||
|
||||
A fileName is a string of characters without whitespace or quotes.
|
||||
A fileName can be
|
||||
- constructed from a char*, a string or a word
|
||||
- concatenated by adding a '/' separator
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -28,9 +28,8 @@ Class
|
||||
Description
|
||||
A class for handling words, derived from string.
|
||||
|
||||
A word is a string of characters containing no whitespace and may be
|
||||
constructed from a string by removing whitespace. Words are delimited
|
||||
by whitespace.
|
||||
A word is a string of characters without whitespace, quotes, slashes,
|
||||
semicolons or brace brackets. Words are delimited by whitespace.
|
||||
|
||||
SourceFiles
|
||||
word.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);
|
||||
|
||||
|
||||
@ -29,7 +29,7 @@ Description
|
||||
A wordRe is a word, but can also have a regular expression for matching
|
||||
words.
|
||||
|
||||
By default the constructors will generally preserve the argument as
|
||||
By default the constructors will generally preserve the argument as a
|
||||
string literal and the assignment operators will use the wordRe::DETECT
|
||||
compOption to scan the string for regular expression meta characters
|
||||
and/or invalid word characters and react accordingly.
|
||||
|
||||
@ -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