Skip to content

Commit 3f6bfed

Browse files
author
fangq
committed
making options case insensitive
git-svn-id: http://svn.code.sf.net/p/iso2mesh/code/trunk/jsonlab@484 786e58fb-9377-0410-9ff7-e4ac0ac0635c
1 parent e2a5b44 commit 3f6bfed

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

jsonopt.m

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@
2626
val=default;
2727
if(nargin<=2) return; end
2828
opt=varargin{1};
29-
if(isstruct(opt) && isfield(opt,key))
30-
val=getfield(opt,key);
29+
if(isstruct(opt))
30+
if(isfield(opt,key))
31+
val=getfield(opt,key);
32+
elseif(isfield(opt,lower(key)))
33+
val=getfield(opt,lower(key));
34+
end
3135
end
32-

varargin2struct.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
if(isstruct(varargin{i}))
3131
opt=mergestruct(opt,varargin{i});
3232
elseif(ischar(varargin{i}) && i<len)
33-
opt=setfield(opt,varargin{i},varargin{i+1});
33+
opt=setfield(opt,lower(varargin{i}),varargin{i+1});
3434
i=i+1;
3535
else
3636
error('input must be in the form of ...,''name'',value,... pairs or structs');

0 commit comments

Comments
 (0)