From 41b1e897569763c6688894597b7cab0cbb14a83d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= Date: Thu, 16 Jun 2022 16:44:01 +0200 Subject: [PATCH] =?UTF-8?q?Macro-processor:=20when=20a=20variable=20is=20d?= =?UTF-8?q?efined=20without=20a=20value,=20set=20it=20to=20=E2=80=9Ctrue?= =?UTF-8?q?=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously it was set to 1. Also do the same change for variable defined on the command-line, for consistency. Closes: #43 --- src/DynareMain.cc | 2 +- src/macro/Parser.yy | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/DynareMain.cc b/src/DynareMain.cc index 23fea237..f2d6182b 100644 --- a/src/DynareMain.cc +++ b/src/DynareMain.cc @@ -290,7 +290,7 @@ main(int argc, char **argv) equal_index != string::npos) defines.emplace_back(s.substr(2, equal_index-2), s.substr(equal_index+1)); else - defines.emplace_back(s.substr(2), "1"); + defines.emplace_back(s.substr(2), "true"); } else if (s.substr(0, 2) == "-I") { diff --git a/src/macro/Parser.yy b/src/macro/Parser.yy index be7cc71e..7370324e 100644 --- a/src/macro/Parser.yy +++ b/src/macro/Parser.yy @@ -135,10 +135,7 @@ directive_one_line : INCLUDE expr | INCLUDEPATH expr { $$ = make_shared($2, @$); } | DEFINE symbol - { - auto tmp = make_shared("1", @$); - $$ = make_shared($2, tmp, @$); - } + { $$ = make_shared($2, make_shared(true, @$), @$); } | DEFINE symbol EQUAL expr { $$ = make_shared($2, $4, @$); } | DEFINE function EQUAL expr