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

time-shift
Houtan Bastani 2017-11-14 12:16:32 +01:00
parent c958f4ac04
commit c258bad2ab
2 changed files with 14 additions and 15 deletions

View File

@ -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

View File

@ -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