From 7fd78606aebd5976ee16fbc72e169356a025b080 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien@dynare.org>
Date: Tue, 12 Jul 2022 14:31:30 +0200
Subject: [PATCH] Fix bug in MATLAB/Octave output introduced in
 3e1f9dbb8209e45e42fcd82a67f47355acb8ba1f

---
 src/DynamicModel.cc | 13 +++++++------
 src/StaticModel.cc  | 11 ++++++-----
 2 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/src/DynamicModel.cc b/src/DynamicModel.cc
index 9a10ad93..21624ba4 100644
--- a/src/DynamicModel.cc
+++ b/src/DynamicModel.cc
@@ -4106,13 +4106,14 @@ DynamicModel::writeSetAuxiliaryVariables(const string &basename, bool julia) con
          << comment << " Status : Computes Auxiliary variables of the dynamic model and returns a dseries" << endl
          << comment << endl
          << comment << " Warning : this file is generated automatically by Dynare" << endl
-         << comment << "           from model file (.mod)" << endl << endl
-         << "@inbounds begin" << endl    
-         << output_func_body.str()
-    	 << "end" << endl
-     << "end" << endl;
+         << comment << "           from model file (.mod)" << endl << endl;
   if (julia)
-    output << "end" << endl;
+    output << "@inbounds begin" << endl;
+  output << output_func_body.str()
+         << "end" << endl;
+  if (julia)
+    output << "end" << endl
+           << "end" << endl;
 
   writeToFileIfModified(output, julia ? basename + "DynamicSetAuxiliarySeries.jl" : packageDir(basename) + "/" + func_name + ".m");
 }
diff --git a/src/StaticModel.cc b/src/StaticModel.cc
index 6dc463b7..26da724d 100644
--- a/src/StaticModel.cc
+++ b/src/StaticModel.cc
@@ -1751,13 +1751,14 @@ StaticModel::writeSetAuxiliaryVariables(const string &basename, bool julia) cons
          << comment << " Status : Computes static model for Dynare" << endl
          << comment << endl
          << comment << " Warning : this file is generated automatically by Dynare" << endl
-         << comment << "           from model file (.mod)" << endl << endl
-	 << "@inbounds begin" << endl
-         << output_func_body.str()
-         << "end" << endl
+         << comment << "           from model file (.mod)" << endl << endl;
+  if (julia)
+    output << "@inbounds begin" << endl;
+  output << output_func_body.str()
          << "end" << endl;
   if (julia)
-    output << "end" << endl;
+    output << "end" << endl
+           << "end" << endl;
 
   writeToFileIfModified(output, julia ? basename + "SetAuxiliaryVariables.jl" : packageDir(basename) + "/" + func_name + ".m");
 }
-- 
GitLab