STYLE: emit warning about using deprecated "~OpenFOAM" expansion

- Within strings it is preferable to use the "<etc>" instead.
  Most use cases for the old "~OpenFOAM" expansion have been obsoleted
  by the #includeEtc directive.
This commit is contained in:
Mark Olesen
2018-11-23 13:12:33 +01:00
parent ac03307258
commit 1456a8ca1d
6 changed files with 34 additions and 11 deletions

View File

@ -69,7 +69,7 @@ int main(int argc, char *argv[])
argList::addNote argList::addNote
( (
"Locate user/group/other file with semantics similar to the " "Locate user/group/other file with semantics similar to the "
"~OpenFOAM/fileName expansion." "<etc>/fileName expansion."
); );
argList args(argc, argv, false, true); argList args(argc, argv, false, true);

View File

@ -33,8 +33,8 @@
# - requires rsync # - requires rsync
# #
# Note # Note
# The foamCopySettings.rc (found with the ~OpenFOAM expansion) can be used # The foamCopySettings.rc (found via foamEtcFile) can be used to add any
# to add any custom rsync options. # custom rsync options.
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
Script=${0##*/} Script=${0##*/}
@ -51,8 +51,8 @@ Usage: $Script srcDir dstDir
- requires rsync - requires rsync
Note Note
The $Script.rc (found via the ~OpenFOAM expansion - see foamEtcFile) The $Script.rc (found via foamEtcFile) can be used to add any
can be used to add any custom rsync options. custom rsync options.
USAGE USAGE
exit 1 exit 1

View File

@ -162,7 +162,7 @@ bool Foam::dynamicCode::resolveTemplates
} }
} }
// Not found - fallback to ~OpenFOAM expansion // Not found - fallback to <etc> expansion
if (file.empty()) if (file.empty())
{ {
file = findEtcFile(codeTemplateDirName/templateName); file = findEtcFile(codeTemplateDirName/templateName);
@ -423,7 +423,7 @@ bool Foam::dynamicCode::copyOrCreateFiles(const bool verbose) const
<< "Could not find the code template(s): " << "Could not find the code template(s): "
<< badFiles << nl << badFiles << nl
<< "Under the $" << codeTemplateEnvName << "Under the $" << codeTemplateEnvName
<< " directory or via via the ~OpenFOAM/" << " directory or via via the <etc>/"
<< codeTemplateDirName << " expansion" << codeTemplateDirName << " expansion"
<< exit(FatalError); << exit(FatalError);
} }

View File

@ -76,7 +76,7 @@ Description
Note Note
- The document browser used is defined by the \b FOAM_DOC_BROWSER - The document browser used is defined by the \b FOAM_DOC_BROWSER
environment variable or the <tt>Documentation/docBrowser</tt> entry environment variable or the <tt>Documentation/docBrowser</tt> entry
in the <tt>~OpenFOAM/controlDict</tt> file. in the <tt>\<etc\>/controlDict</tt> file.
The \%f token is used as a placeholder for the file name. The \%f token is used as a placeholder for the file name.
- The valid (mandatory) arguments can be adjusted - The valid (mandatory) arguments can be adjusted
via the addArgument static method instead of directly via the addArgument static method instead of directly

View File

@ -26,6 +26,7 @@ License
#include "stringOps.H" #include "stringOps.H"
#include "typeInfo.H" #include "typeInfo.H"
#include "etcFiles.H" #include "etcFiles.H"
#include "Pstream.H"
#include "StringStream.H" #include "StringStream.H"
#include "OSstream.H" #include "OSstream.H"
#include "OSspecific.H" #include "OSspecific.H"
@ -92,8 +93,8 @@ static void expandLeadingTag(std::string& s, const char b, const char e)
// Expand a leading tilde // Expand a leading tilde
// ~/ => home directory // ~/ => home directory
// ~OpenFOAM => user/group/other OpenFOAM directory
// ~user => home directory for specified user // ~user => home directory for specified user
// Deprecated ~OpenFOAM => <etc> instead
static void expandLeadingTilde(std::string& s) static void expandLeadingTilde(std::string& s)
{ {
if (s[0] != '~') if (s[0] != '~')
@ -121,6 +122,24 @@ static void expandLeadingTilde(std::string& s)
if (user == "OpenFOAM") if (user == "OpenFOAM")
{ {
// Compat Warning
const int version(1806);
// Single warning (on master) with guard to avoid Pstream::master()
// when Pstream has not yet been initialized
if (Pstream::parRun() ? Pstream::master() : true)
{
std::cerr
<< nl
<< "--> FOAM Warning :" << nl
<< " Found [v" << version << "] '"
<< "~OpenFOAM" << "' string expansion instead of '"
<< "<etc>" << "' in string\n\"" << s << "\"\n" << nl
<< std::endl;
error::warnAboutAge("expansion", version);
}
s = findEtcFile(file); s = findEtcFile(file);
} }
else else

View File

@ -228,7 +228,6 @@ namespace stringOps
// -# tilde expansion // -# tilde expansion
// - leading "~/" : home directory // - leading "~/" : home directory
// - leading "~user" : home directory for specified user // - leading "~user" : home directory for specified user
// - leading "~OpenFOAM" : user/group/other OpenFOAM directory
// //
// Supports default and alternative values as per the POSIX shell. // Supports default and alternative values as per the POSIX shell.
// \code // \code
@ -245,6 +244,9 @@ namespace stringOps
// - Malformed entries (eg, brace mismatch, sigil followed by bad chars) // - Malformed entries (eg, brace mismatch, sigil followed by bad chars)
// are left as is. // are left as is.
// //
// \note Deprecated(2018-11) Use "<etc>" instead of the rarely used
// "~OpenFOAM" expansion
//
// \sa // \sa
// Foam::findEtcFile // Foam::findEtcFile
string expand string expand
@ -268,7 +270,6 @@ namespace stringOps
// -# tilde expansion // -# tilde expansion
// - leading "~/" : home directory // - leading "~/" : home directory
// - leading "~user" : home directory for specified user // - leading "~user" : home directory for specified user
// - leading "~OpenFOAM" : user/group/other OpenFOAM directory
// //
// Supports default and alternative values as per the POSIX shell. // Supports default and alternative values as per the POSIX shell.
// \code // \code
@ -285,6 +286,9 @@ namespace stringOps
// - Malformed entries (eg, brace mismatch, sigil followed by bad chars) // - Malformed entries (eg, brace mismatch, sigil followed by bad chars)
// are left as is. // are left as is.
// //
// \note Deprecated(2018-11) Use "<etc>" instead of the rarely used
// "~OpenFOAM" expansion
//
// \sa // \sa
// Foam::findEtcFile // Foam::findEtcFile
void inplaceExpand void inplaceExpand