Skip to content
Snippets Groups Projects
Commit 545e7ef9 authored by Mark OLESEN's avatar Mark OLESEN
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 2a9c6c97
Branches
Tags
No related merge requests found
......@@ -2,8 +2,10 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2011, 2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -122,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;
}
}
......
......@@ -2,8 +2,10 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2011, 2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -78,7 +80,7 @@ public:
// Constructors
//- Construct from a dictionary
dynamicCodeContext(const dictionary&);
dynamicCodeContext(const dictionary& dict);
// Member functions
......@@ -126,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
);
};
......
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