-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDepSubFun.m
More file actions
81 lines (73 loc) · 2.11 KB
/
DepSubFun.m
File metadata and controls
81 lines (73 loc) · 2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
function funnames = DepSubFun(CS,ExcludeRoot);
% DEPSUBFUN Locate dependent functions of an M-file.
% But, unlike DEPFUN, it will look *inside* m-files for
% *subfunctiosn* and the ability to excludes files that
% are in the MATLAB root (default).
%
% The intent of finding the subfunctions is to prevent
% repetition and to identify which functions need to be
% updated so if you fix one copy, then you will know there
% are other copies out there that need to be fixed.
%
% The intent of excluding files in the MATLAB root
% is to find which files must be included in a distribution
% so they may be uploaded to the MATLAB File Exchange.
%
% INPUTS:
% CS, a cellstring of file names (the files you want analysed)
% ExcludeRoot, 0 if you want all function names, 1 if you only
% want the ones not in the MATLAB root.
%
% OUTPUTS
% funnames, a cellstring of functions and subfunctions
%
% USAGE
% >>d=dir('*.m');
% >> DepSubFun({d.name})
%
% See DEPFUN
%
% Keyworkds depfun, dependent, function, subfunction, name
%
% It's not fancy, but it works
% REVISION HISTORY
% Version 1.00
% 4/13/05 [/] Created
% 4/14/05 [/] Nested for loop variable name changed
% Michael Robbins
% robbins@bloomberg.net
% MichaelRobbins1@yahoo.com
% MichaelRobbinsUsenet@yahoo.com
% CONSTANTS
TRUE = 1;
FALSE = 0;
EMPTYCELL = {};
% INITIALIZE
if nargin<2 ExcludeRoot=TRUE; end;
funnames = EMPTYCELL;
TESTREGEX = FALSE;
% FOR EACH FILE
for i=1:length(CS)
% GET DEPENDENT FUNCTIONS' FILENAMES
f = depfun(CS{i},'-quiet');
% ADD FUNCTIONS THAT ARE NOT IN MATALBROOT
if ExcludeRoot
foofiles = f(setdiff([1:length(f)],strmatch(matlabroot,f)));
else
foofiles = f;
end;
% LOOP THROUGH EACH FOOFILE
if ~isempty(foofiles)
for j=1:length(foofiles)
FID = fopen(foofiles{j},'r');
if FID ~=-1
foo = GetSubFunNames(FID);
funnames={funnames{:} foo{:}};
else
warning('DepFunInFile :: Bad FID');
end; % IF FID
end; % FOR
else
warning('DepFunInFile :: foofiles is empty');
end; % IF ~ISEMPTY
end;