Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
preprocessor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Dynare
preprocessor
Commits
2ff50f56
Verified
Commit
2ff50f56
authored
1 month ago
by
Sébastien Villemot
Browse files
Options
Downloads
Patches
Plain Diff
C++17 modernization: use std::regex::multiline in macro-processor expansion
Was not previously possible because it requires GCC 11.
parent
d37d81bc
No related branches found
No related tags found
No related merge requests found
Pipeline
#11846
passed
1 month ago
Stage: build
Stage: test
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/MacroExpandModFile.cc
+3
-10
3 additions, 10 deletions
src/MacroExpandModFile.cc
with
3 additions
and
10 deletions
src/MacroExpandModFile.cc
+
3
−
10
View file @
2ff50f56
/*
* Copyright © 2015-202
3
Dynare Team
* Copyright © 2015-202
5
Dynare Team
*
* This file is part of Dynare.
*
...
...
@@ -52,15 +52,8 @@ macroExpandModFile(const filesystem::path& filename, const istream& modfile, boo
string
str
(
macro_output
.
str
());
if
(
!
line_macro
)
{
/* Remove the @#line directives.
Unfortunately GCC 11 does not yet support std::regex::multiline
(despite it being in the C++17 standard), so we are forced to use
a trick to emulate the “usual” behaviour of the caret ^;
here, the latter only matches the beginning of file.
This also means that we are forced to remove the EOL before the
@#line, and not the one after it (matching the EOL before and the
EOL after in the same regexp does not work). */
str
=
regex_replace
(
str
,
regex
(
R"((^|\r?\n)@#line.*)"
),
""
);
// Remove the @#line directives.
str
=
regex_replace
(
str
,
regex
(
R"(^@#line.*$)"
,
std
::
regex
::
multiline
),
""
);
/* Remove the EOLs at the beginning of the output, the first one
being a remnant of the first @#line directive. */
str
=
regex_replace
(
str
,
regex
(
R"(^(\r?\n)+)"
),
""
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment