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
Sébastien Villemot
preprocessor
Commits
7c22fe16
Commit
7c22fe16
authored
7 years ago
by
Houtan
Browse files
Options
Downloads
Patches
Plain Diff
preprocessor: add option to remove empty lines from macro-expanded mod file. closes #1551
parent
9f8edf87
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
DynareMain.cc
+7
-3
7 additions, 3 deletions
DynareMain.cc
DynareMain1.cc
+10
-2
10 additions, 2 deletions
DynareMain1.cc
with
17 additions
and
5 deletions
DynareMain.cc
+
7
−
3
View file @
7c22fe16
...
...
@@ -50,12 +50,12 @@ void main2(stringstream &in, string &basename, bool debug, bool clear_all, bool
);
void
main1
(
string
&
modfile
,
string
&
basename
,
string
&
modfiletxt
,
bool
debug
,
bool
save_macro
,
string
&
save_macro_file
,
bool
no_line_macro
,
map
<
string
,
string
>
&
defines
,
vector
<
string
>
&
path
,
stringstream
&
macro_output
);
bool
no_line_macro
,
bool
no_empty_line_macro
,
map
<
string
,
string
>
&
defines
,
vector
<
string
>
&
path
,
stringstream
&
macro_output
);
void
usage
()
{
cerr
<<
"Dynare usage: dynare mod_file [debug] [noclearall] [onlyclearglobals] [savemacro[=macro_file]] [onlymacro] [nolinemacro] [notmpterms] [nolog] [warn_uninit]"
cerr
<<
"Dynare usage: dynare mod_file [debug] [noclearall] [onlyclearglobals] [savemacro[=macro_file]] [onlymacro] [nolinemacro]
[noemptylinemacro]
[notmpterms] [nolog] [warn_uninit]"
<<
" [console] [nograph] [nointeractive] [parallel[=cluster_name]] [conffile=parallel_config_path_and_filename] [parallel_slave_open_mode] [parallel_test]"
<<
" [-D<variable>[=<value>]] [-I/path] [nostrict] [stochastic] [fast] [minimal_workspace] [compute_xrefs] [output=dynamic|first|second|third] [language=C|C++|julia]"
<<
" [params_derivs_order=0|1|2]"
...
...
@@ -91,6 +91,7 @@ main(int argc, char **argv)
bool
no_tmp_terms
=
false
;
bool
only_macro
=
false
;
bool
no_line_macro
=
false
;
bool
no_empty_line_macro
=
false
;
bool
no_log
=
false
;
bool
no_warn
=
false
;
int
params_derivs_order
=
2
;
...
...
@@ -162,6 +163,8 @@ main(int argc, char **argv)
}
else
if
(
!
strcmp
(
argv
[
arg
],
"nolinemacro"
))
no_line_macro
=
true
;
else
if
(
!
strcmp
(
argv
[
arg
],
"noemptylinemacro"
))
no_empty_line_macro
=
true
;
else
if
(
!
strcmp
(
argv
[
arg
],
"notmpterms"
))
no_tmp_terms
=
true
;
else
if
(
!
strcmp
(
argv
[
arg
],
"nolog"
))
...
...
@@ -389,7 +392,8 @@ main(int argc, char **argv)
// Do macro processing
stringstream
macro_output
;
main1
(
modfile
,
basename
,
modfiletxt
,
debug
,
save_macro
,
save_macro_file
,
no_line_macro
,
defines
,
path
,
macro_output
);
main1
(
modfile
,
basename
,
modfiletxt
,
debug
,
save_macro
,
save_macro_file
,
no_line_macro
,
no_empty_line_macro
,
defines
,
path
,
macro_output
);
if
(
only_macro
)
return
EXIT_SUCCESS
;
...
...
This diff is collapsed.
Click to expand it.
DynareMain1.cc
+
10
−
2
View file @
7c22fe16
...
...
@@ -22,9 +22,13 @@
#include
"macro/MacroDriver.hh"
bool
compareNewline
(
int
i
,
int
j
)
{
return
i
==
'\n'
&&
j
==
'\n'
;
}
void
main1
(
string
&
modfile
,
string
&
basename
,
string
&
modfiletxt
,
bool
debug
,
bool
save_macro
,
string
&
save_macro_file
,
bool
no_line_macro
,
map
<
string
,
string
>
&
defines
,
vector
<
string
>
&
path
,
stringstream
&
macro_output
)
bool
no_line_macro
,
bool
no_empty_line_macro
,
map
<
string
,
string
>
&
defines
,
vector
<
string
>
&
path
,
stringstream
&
macro_output
)
{
// Do macro processing
MacroDriver
m
;
...
...
@@ -40,7 +44,11 @@ main1(string &modfile, string &basename, string &modfiletxt, bool debug, bool sa
cerr
<<
"Cannot open "
<<
save_macro_file
<<
" for macro output"
<<
endl
;
exit
(
EXIT_FAILURE
);
}
macro_output_file
<<
macro_output
.
str
();
string
str
(
macro_output
.
str
());
if
(
no_empty_line_macro
)
str
.
erase
(
unique
(
str
.
begin
(),
str
.
end
(),
compareNewline
),
str
.
end
());
macro_output_file
<<
str
;
macro_output_file
.
close
();
}
}
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