BUG: bad '#line' directives for dynamicCode (fixes #1282)

- now suppress any '#line' if the input number number is invalid
  (ie, an empty set of tokens)
This commit is contained in:
Mark Olesen 2019-04-15 12:42:29 +02:00 committed by Andrew Heather
parent 53d01c8a0a
commit cd7748f8e4
2 changed files with 13 additions and 7 deletions

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation
@ -124,11 +124,16 @@ Foam::dynamicCodeContext::dynamicCodeContext(const dictionary& dict)
void Foam::dynamicCodeContext::addLineDirective
(
string& code,
const label lineNum,
label lineNum,
const fileName& name
)
{
code = "#line " + Foam::name(lineNum + 1) + " \"" + name + "\"\n" + code;
++lineNum; // Change from 0-based to 1-based
if (lineNum > 0 && !name.empty())
{
code = "#line " + Foam::name(lineNum) + " \"" + name + "\"\n" + code;
}
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation
@ -80,7 +80,7 @@ public:
// Constructors
//- Construct from a dictionary
dynamicCodeContext(const dictionary&);
dynamicCodeContext(const dictionary& dict);
// Member functions
@ -128,10 +128,11 @@ public:
}
//- Helper: add \#line directive
// The lineNum is 0-based. No-op if the lineNum is negative.
static void addLineDirective
(
string&,
const label lineNum,
string& code,
label lineNum,
const fileName& name
);
};