From dec7d4fdb48d8cf75c6a8a783be7e24d25430636 Mon Sep 17 00:00:00 2001 From: Houtan Bastani Date: Tue, 3 Dec 2019 12:48:15 +0100 Subject: [PATCH] dynare.m: simplify code --- matlab/dynare.m | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/matlab/dynare.m b/matlab/dynare.m index 324261e43..10b28a9fc 100644 --- a/matlab/dynare.m +++ b/matlab/dynare.m @@ -206,8 +206,9 @@ end command = ['"' dynareroot 'preprocessor' arch_ext filesep 'dynare_m" ' fname] ; command = [ command ' mexext=' mexext ' "matlabroot=' matlabroot '"']; -for i=1:length(varargin) - command = [command ' ' varargin{i}]; +if ~isempty(varargin) + dynare_varargin = strjoin(varargin); + command = [command ' ' dynare_varargin]; end if preprocessoroutput @@ -216,7 +217,7 @@ if preprocessoroutput if isempty(varargin) disp('none') else - disp(strjoin(varargin)); + disp(dynare_varargin); end end @@ -252,17 +253,11 @@ if exist(fname(1:end-4),'dir') && exist([fname(1:end-4) filesep 'hooks'],'dir') end % Save preprocessor result in logfile (if `no_log' option not present) -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 +if ~ismember('nolog', varargin) ... + && isempty(regexp(firstline, '//\s*--\+\s*options:(|.*\s|.*,)nolog(|\s.*|,.*)\+--')) logname = [fname(1:end-4) '.log']; fid = fopen(logname, 'w'); fprintf(fid, '%s', result);