Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: check if user is running Octave #19

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 31 additions & 25 deletions tb_optparse.m
Original file line number Diff line number Diff line change
Expand Up @@ -114,32 +114,35 @@
end

assert(iscell(argv), 'SMTB:tboptparse:badargs', 'input must be a cell array');

if ~verLessThan('matlab', '9.1')
% is only appeared in 2016b

% handle new style string inputs
% quick and dirty solution is to convert any string to a char array and
% then carry on as before

% convert any passed strings to character arrays
for i=1:length(argv)
if isstring(argv{i}) && length(argv{i}) == 1
argv{i} = char(argv{i});
end
end
% convert strings in opt struct to character arrays
if ~isempty(in)
fields = fieldnames(in);
for i=1:length(fields)
field = fields{i};
% simple string elements
if isstring(in.(field))
in.(field) = char(in.(field));

is_octave = exist('OCTAVE_VERSION', 'builtin') ~= 0;
if ~is_octave
if ~verLessThan('matlab', '9.1')
% is only appeared in 2016b

% handle new style string inputs
% quick and dirty solution is to convert any string to a char array and
% then carry on as before

% convert any passed strings to character arrays
for i=1:length(argv)
if isstring(argv{i}) && length(argv{i}) == 1
argv{i} = char(argv{i});
end
% strings in cell array elements
if iscell(in.(field))
in.(field) = cellfun(@(x) char(x), in.(field), 'UniformOutput', false);
end
% convert strings in opt struct to character arrays
if ~isempty(in)
fields = fieldnames(in);
for i=1:length(fields)
field = fields{i};
% simple string elements
if isstring(in.(field))
in.(field) = char(in.(field));
end
% strings in cell array elements
if iscell(in.(field))
in.(field) = cellfun(@(x) char(x), in.(field), 'UniformOutput', false);
end
end
end
end
Expand Down Expand Up @@ -396,3 +399,6 @@
elseif nargout == 2
others = arglist;
end

end