0001 function out = findInc(fileName)
0002
0003
0004
0005
0006
0007
0008
0009 fid = fopen(fileName);
0010 if fid<0,
0011 error(sprintf('Cannot open "%s"!', fileName));
0012 end
0013
0014 lineNum = 1;
0015 while 1
0016 line = fgetl(fid);
0017 if ~isstr(line), break, end
0018 contents{lineNum} = xlate(line);
0019 lineNum = lineNum+1;
0020 end
0021 fclose(fid);
0022
0023 out = {};
0024 for i=1:length(contents),
0025 line = contents{i};
0026 if ~isempty(line),
0027 pos = findstr(line, '#include "');
0028 if ~isempty(pos) & pos==1,
0029 temp = split(line, '"');
0030 out = {out{:}, temp{2}};
0031 end
0032 end
0033 end
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045 function tokenList = split(str, delimiter)
0046
0047
0048
0049
0050
0051
0052 tokenList = {};
0053 remain = str;
0054 i = 1;
0055 while ~isempty(remain),
0056 [token, remain] = strtok(remain, delimiter);
0057 tokenList{i} = token;
0058 i = i+1;
0059 end