From f363c3da6b03b6fcdccb2828067949f67ba180fe Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien@dynare.org>
Date: Thu, 20 Dec 2018 11:07:09 +0100
Subject: [PATCH] Restore behavior of 'nolog' option

The option had been broken by 0e77815ece62be21f99338d45f217a535eccb4c4.

This option cannot be entirely handled at the preprocessor level, since the
main log file is created at the MATLAB/Octave level. Handle it via a dedicated
regular expression.
---
 matlab/dynare.m | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/matlab/dynare.m b/matlab/dynare.m
index 15869f75db..384a295f12 100644
--- a/matlab/dynare.m
+++ b/matlab/dynare.m
@@ -259,6 +259,12 @@ no_log = 0;
 for i=1:length(varargin)
     no_log = no_log || strcmp(varargin{i}, 'nolog');
 end
+fid = fopen(fname, 'r');
+firstline = fgetl(fid);
+fclose(fid);
+if ~isempty(regexp(firstline, '//\s*--\+\s*options:(|.*\s|.*,)nolog(|\s.*|,.*)\+--'))
+    no_log = 1;
+end
 if ~no_log
     logname = [fname(1:end-4) '.log'];
     fid = fopen(logname, 'w');
-- 
GitLab