%DOLI		MLINT a file with various options
%
%SYNTAX
%-------------------------------------------------------------------------------
%		R = DOLI(FNAM);
%			use MLINT
%
%		R = DOLI(FNAM,1);
%			use MLINTMEX
%
%OUTPUT
%-------------------------------------------------------------------------------
% R	:	output struct with fieldnames == MLINT option
%		and content of output
%		retrieve messages, eg,
%			[R.calls.message]
%
% other help removed for posting

%-------------------------------------------------------------------------------
function	r=doli(varargin)

% created:
%	us	12-Feb-2001 us@neurol.unizh.ch
% modified:
%	us	23-Jun-2010 15:43:22
%
% localid:	us@USZ|ws-nos-36362|x86|Windows XP|7.10.0.499.R2010a

		opt={
		%	option		remarks
		%	-------------------------------
			'-all'
			'-allmsg'
			'-amb'
			'-body'
			'-callops'
			'-calls'
			'-com'
			'-cyc'
% 			'-db'		% == -set + -ud + -tab
			'-dty'
			'-edit'
			'-en'		% messages in english
			'-id'
			'-ja'		% messages in japanese
			'-lex'
			'-m0'		% + other opt
			'-m1'		% + other opt
			'-m2'		% + other opt
			'-m3'		% + other opt
			'-mess'
			'-msg'
			'-notok'
			'-pf'
			'-set'
			'-spmd'
			'-stmt'
			'-tab'
			'-tmtree'
			'-tmw'		% not valid anymore
			'-toks'
			'-tree'
			'-ty'
			'-ud'
			'-yacc'		% ONLY: !mlint FILE -yacc -...

% default behavior of DOLI
%			'-struct'	% output -> struct
		};

		r.o=opt;
	if	~nargin
		help(mfilename);
		return;
	end
	if	nargin > 1
		eng=@mlint;
	else
		eng=@mlintmex;
	end
		fnam=which(varargin{1});
	if	isempty(fnam)
		disp(sprintf('DOLI> file not found %s',varargin{1}));
		return;
	end

		fmt=max(cellfun('length',opt(:,1)));
		fmt=sprintf('%%-6s>   %%-%d.%ds   %%d',fmt,fmt);

		disp(sprintf('%s >   %s','MLINT',fnam))
	for	i=1:size(opt,1);
		copt=opt{i,1};
		sopt=copt(2:end);
	if	strcmp(sopt,'yacc')
		[tmp,tmp]=system(sprintf('mlint %s -yacc -m3',fnam));	%#ok
	else
		tmp=eng(fnam,copt,'-struct');
	end
	if	iscell(tmp)
		tmp=tmp{:};
	end
		disp(sprintf(fmt,'OPTION',copt,numel(tmp)));
		r.(sopt)=tmp;
	end
end
%-------------------------------------------------------------------------------