diff --git a/doc/dynare.texi b/doc/dynare.texi index f21d06f0c39bd330638b48e2ad20ea1f040081e5..9bbeacb18ad9f376d3444bf5d2cb9eb010672f83 100644 --- a/doc/dynare.texi +++ b/doc/dynare.texi @@ -1006,10 +1006,10 @@ of the @code{.mod} file. They can alternatively be defined in the first line of the @file{.mod} file, this avoids typing them on the command line each time a @file{.mod} file is to be run. This line must be a Dynare comment (@emph{ie} must begin with @code{//}) and the options must be comma separated between -@code{--+ options:} and @code{+--}. As in the command line, if an option admits -a value the equal symbol must not be surrounded by spaces. For instance -@code{json = compute} is not correct, and should be written -@code{json=compute}. +@code{--+ options:} and @code{+--}. Note that any text after the @code{+--} +will be discarded. As with the command line, if an option admits a value the +equal symbol must not be surrounded by spaces. For instance @code{json = +compute} is not correct, and should be written @code{json=compute}. @outputhead diff --git a/matlab/dynare.m b/matlab/dynare.m index e6cef01075439f617a1cea1eee85323f5a8d0579..cbd5f1ac01abcbace81171bbc4c68895bfb76bb3 100644 --- a/matlab/dynare.m +++ b/matlab/dynare.m @@ -196,18 +196,17 @@ end fid = fopen(fname, 'r'); firstline = fgetl(fid); fclose(fid); -if isequal(regexp(firstline, '\s*\/\/'), 1) - % First line is commented. +if regexp(firstline, '\s*\/\/', 'once') == 1 firstline = regexprep(firstline, '\s*\/\/', ''); - if ~isempty(regexp(firstline, '(^\s+\-\-\+\s+options:)')) % Commented line begins with --+ options: - if ~isempty(regexp(firstline, '(\s+\+\-\-\s*$)')) % Commented line ends with +-- - dynoption = strsplit(firstline, {'--+', '+--', 'options:', ' ', ','}); - dynoption(find(cellfun( @(x) isempty(x), dynoption))) = []; - if isequal(nargin, 1) - varargin = dynoption; - else - varargin = union(varargin, dynoption); - end + if ~isempty(regexp(firstline, '(^\s*\-\-\+\s*options:\s*)', 'once')) ... + && ~isempty(regexp(firstline, '(\s*\+\-\-(\s*\w*\s*)*$)', 'once')) + firstline = regexprep(firstline, '(^\s*\-\-\+\s*options:\s*)', ''); + firstline = regexprep(firstline, '(\s*\+\-\-(\s*\w*\s*)*$)', ''); + dynoption = strsplit(firstline, {' ', ','}); + if isequal(nargin, 1) + varargin = dynoption; + else + varargin = union(varargin, dynoption); end end end