Commit c258bad2 authored by Houtan Bastani's avatar Houtan Bastani

dynare command line: be less strict in accepting macros from .mod file

parent c958f4ac
......@@ -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
......
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment