Skip to content
Snippets Groups Projects
Commit cd7748f8 authored by Mark OLESEN's avatar Mark OLESEN Committed by Andrew Heather
Browse files

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)
parent 53d01c8a
No related merge requests found
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | \\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation | Copyright (C) 2011-2016 OpenFOAM Foundation
...@@ -124,11 +124,16 @@ Foam::dynamicCodeContext::dynamicCodeContext(const dictionary& dict) ...@@ -124,11 +124,16 @@ Foam::dynamicCodeContext::dynamicCodeContext(const dictionary& dict)
void Foam::dynamicCodeContext::addLineDirective void Foam::dynamicCodeContext::addLineDirective
( (
string& code, string& code,
const label lineNum, label lineNum,
const fileName& name 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;
}
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | \\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation | Copyright (C) 2011-2016 OpenFOAM Foundation
...@@ -80,7 +80,7 @@ public: ...@@ -80,7 +80,7 @@ public:
// Constructors // Constructors
//- Construct from a dictionary //- Construct from a dictionary
dynamicCodeContext(const dictionary&); dynamicCodeContext(const dictionary& dict);
// Member functions // Member functions
...@@ -128,10 +128,11 @@ public: ...@@ -128,10 +128,11 @@ public:
} }
//- Helper: add \#line directive //- Helper: add \#line directive
// The lineNum is 0-based. No-op if the lineNum is negative.
static void addLineDirective static void addLineDirective
( (
string&, string& code,
const label lineNum, label lineNum,
const fileName& name const fileName& name
); );
}; };
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment