argList: avoid relative cases ending in '..' - makes for very ugly names
- this stop problems caused by a "-case .." specification Previously args.globalCaseName() + ".Ext" resulted in silly names eg, "...png", or "surface-...stl"
This commit is contained in:
parent
35986a3972
commit
4ebca29890
@ -147,6 +147,8 @@
|
||||
processing command-line options.
|
||||
+ Export *new* environment variable =FOAM_CASENAME= that contains the
|
||||
name part of the =FOAM_CASE= environment variable
|
||||
+ Resolve relative cases ending in =..= to avoid potentially bad/ugly
|
||||
case names being used.
|
||||
|
||||
*** Misc. improvements
|
||||
+ Improved consistency and interoperability between =face= and =triFace= classes.
|
||||
|
@ -66,14 +66,14 @@ bool Foam::argList::regroupArgv(int& argc, char**& argv)
|
||||
|
||||
// note: we also re-write directly into args_
|
||||
// and use a second pass to sort out args/options
|
||||
for (int argi=0; argi < argc; argi++)
|
||||
for (int argI = 0; argI < argc; argI++)
|
||||
{
|
||||
if (strcmp(argv[argi], "(") == 0)
|
||||
if (strcmp(argv[argI], "(") == 0)
|
||||
{
|
||||
level++;
|
||||
tmpString += "(";
|
||||
}
|
||||
else if (strcmp(argv[argi], ")") == 0)
|
||||
else if (strcmp(argv[argI], ")") == 0)
|
||||
{
|
||||
if (level >= 1)
|
||||
{
|
||||
@ -87,19 +87,19 @@ bool Foam::argList::regroupArgv(int& argc, char**& argv)
|
||||
}
|
||||
else
|
||||
{
|
||||
args_[nArgs++] = argv[argi];
|
||||
args_[nArgs++] = argv[argI];
|
||||
}
|
||||
}
|
||||
else if (level)
|
||||
{
|
||||
// quote each string element
|
||||
tmpString += "\"";
|
||||
tmpString += argv[argi];
|
||||
tmpString += argv[argI];
|
||||
tmpString += "\"";
|
||||
}
|
||||
else
|
||||
{
|
||||
args_[nArgs++] = argv[argi];
|
||||
args_[nArgs++] = argv[argI];
|
||||
}
|
||||
}
|
||||
|
||||
@ -129,12 +129,18 @@ void Foam::argList::getRootCase()
|
||||
casePath = iter();
|
||||
casePath.clean();
|
||||
|
||||
// handle degenerate form and '-case .' like no -case specified
|
||||
if (casePath.empty() || casePath == ".")
|
||||
{
|
||||
// handle degenerate form and '-case .' like no -case specified
|
||||
casePath = cwd();
|
||||
options_.erase("case");
|
||||
}
|
||||
else if (casePath[0] != '/' && casePath.name() == "..")
|
||||
{
|
||||
// avoid relative cases ending in '..' - makes for very ugly names
|
||||
casePath = cwd()/casePath;
|
||||
casePath.clean();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -169,11 +175,11 @@ Foam::argList::argList
|
||||
{
|
||||
// Check if this run is a parallel run by searching for any parallel option
|
||||
// If found call runPar (might filter argv)
|
||||
for (int argi=0; argi<argc; argi++)
|
||||
for (int argI = 0; argI < argc; argI++)
|
||||
{
|
||||
if (argv[argi][0] == '-')
|
||||
if (argv[argI][0] == '-')
|
||||
{
|
||||
const char *optionName = &argv[argi][1];
|
||||
const char *optionName = &argv[argI][1];
|
||||
|
||||
if (validParOptions.found(optionName))
|
||||
{
|
||||
@ -195,14 +201,14 @@ Foam::argList::argList
|
||||
int nArgs = 1;
|
||||
string argListString = args_[0];
|
||||
|
||||
for (int argi = 1; argi < args_.size(); argi++)
|
||||
for (int argI = 1; argI < args_.size(); argI++)
|
||||
{
|
||||
argListString += ' ';
|
||||
argListString += args_[argi];
|
||||
argListString += args_[argI];
|
||||
|
||||
if (args_[argi][0] == '-')
|
||||
if (args_[argI][0] == '-')
|
||||
{
|
||||
const char *optionName = &args_[argi][1];
|
||||
const char *optionName = &args_[argI][1];
|
||||
|
||||
if
|
||||
(
|
||||
@ -216,8 +222,8 @@ Foam::argList::argList
|
||||
)
|
||||
)
|
||||
{
|
||||
argi++;
|
||||
if (argi >= args_.size())
|
||||
argI++;
|
||||
if (argI >= args_.size())
|
||||
{
|
||||
FatalError
|
||||
<< "option " << "'-" << optionName << '\''
|
||||
@ -226,8 +232,8 @@ Foam::argList::argList
|
||||
}
|
||||
|
||||
argListString += ' ';
|
||||
argListString += args_[argi];
|
||||
options_.insert(optionName, args_[argi]);
|
||||
argListString += args_[argI];
|
||||
options_.insert(optionName, args_[argI]);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -236,9 +242,9 @@ Foam::argList::argList
|
||||
}
|
||||
else
|
||||
{
|
||||
if (nArgs != argi)
|
||||
if (nArgs != argI)
|
||||
{
|
||||
args_[nArgs] = args_[argi];
|
||||
args_[nArgs] = args_[argI];
|
||||
}
|
||||
nArgs++;
|
||||
}
|
||||
@ -529,21 +535,19 @@ Foam::argList::argList
|
||||
// Set the case and case-name as an environment variable
|
||||
if (rootPath_[0] == '/')
|
||||
{
|
||||
// absolute path
|
||||
// absolute path - use as-is
|
||||
setEnv("FOAM_CASE", rootPath_/globalCase_, true);
|
||||
}
|
||||
else if (rootPath_ == ".")
|
||||
{
|
||||
// relative to the current working directory
|
||||
setEnv("FOAM_CASE", cwd()/globalCase_, true);
|
||||
setEnv("FOAM_CASENAME", globalCase_, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
// qualify relative path
|
||||
setEnv("FOAM_CASE", cwd()/rootPath_/globalCase_, true);
|
||||
}
|
||||
setEnv("FOAM_CASENAME", globalCase_, true);
|
||||
fileName casePath = cwd()/rootPath_/globalCase_;
|
||||
casePath.clean();
|
||||
|
||||
setEnv("FOAM_CASE", casePath, true);
|
||||
setEnv("FOAM_CASENAME", casePath.name(), true);
|
||||
}
|
||||
|
||||
// Switch on signal trapping. We have to wait until after Pstream::init
|
||||
// since this sets up its own ones.
|
||||
|
Loading…
Reference in New Issue
Block a user