comparison scripts/miscellaneous/what.m @ 11587:c792872f8942

all script files: untabify and strip trailing whitespace
author John W. Eaton <jwe@octave.org>
date Thu, 20 Jan 2011 17:35:29 -0500
parents fd0a3ac60b0e
children b0084095098e
comparison
equal deleted inserted replaced
11586:12df7854fa7c 11587:c792872f8942
15 ## You should have received a copy of the GNU General Public License 15 ## You should have received a copy of the GNU General Public License
16 ## along with Octave; see the file COPYING. If not, see 16 ## along with Octave; see the file COPYING. If not, see
17 ## <http://www.gnu.org/licenses/>. 17 ## <http://www.gnu.org/licenses/>.
18 18
19 ## -*- texinfo -*- 19 ## -*- texinfo -*-
20 ## @deftypefn {Command} {} what 20 ## @deftypefn {Command} {} what
21 ## @deftypefnx {Command} {} what @var{dir} 21 ## @deftypefnx {Command} {} what @var{dir}
22 ## @deftypefnx {Function File} {w =} what (@var{dir}) 22 ## @deftypefnx {Function File} {w =} what (@var{dir})
23 ## List the Octave specific files in a directory. If the variable @var{dir} 23 ## List the Octave specific files in a directory. If the variable @var{dir}
24 ## is given then check that directory rather than the current directory. If 24 ## is given then check that directory rather than the current directory. If
25 ## a return argument is requested, the files found are returned in the 25 ## a return argument is requested, the files found are returned in the
26 ## structure @var{w}. 26 ## structure @var{w}.
27 ## @seealso{which} 27 ## @seealso{which}
28 ## @end deftypefn 28 ## @end deftypefn
29 29
30 function ret = what (d) 30 function ret = what (d)
61 continue; 61 continue;
62 else 62 else
63 ## Ignore mdl and p files 63 ## Ignore mdl and p files
64 [dummy, f, e] = fileparts (n); 64 [dummy, f, e] = fileparts (n);
65 if (strcmp (e, ".m")) 65 if (strcmp (e, ".m"))
66 w.m{end+1} = n; 66 w.m{end+1} = n;
67 elseif (strcmp (e, mexext ())) 67 elseif (strcmp (e, mexext ()))
68 w.mex{end+1} = n; 68 w.mex{end+1} = n;
69 elseif (strcmp (e, ".oct")) 69 elseif (strcmp (e, ".oct"))
70 w.oct{end+1} = n; 70 w.oct{end+1} = n;
71 elseif (strcmp (e, ".mat")) 71 elseif (strcmp (e, ".mat"))
72 w.mat{end+1} = n; 72 w.mat{end+1} = n;
73 elseif(strcmp (n(1), "@")) 73 elseif(strcmp (n(1), "@"))
74 w.classes{end+1} = n; 74 w.classes{end+1} = n;
75 endif 75 endif
76 endif 76 endif
77 endfor 77 endfor
88 endfunction 88 endfunction
89 89
90 function __display_filenames__ (msg, p, f) 90 function __display_filenames__ (msg, p, f)
91 if (length (f) > 0) 91 if (length (f) > 0)
92 printf ("%s %s:\n\n", msg, p) 92 printf ("%s %s:\n\n", msg, p)
93 93
94 maxlen = max (cellfun (@length, f)); 94 maxlen = max (cellfun (@length, f));
95 ncols = max (1, floor (terminal_size()(2) / (maxlen + 3))); 95 ncols = max (1, floor (terminal_size()(2) / (maxlen + 3)));
96 fmt = ""; 96 fmt = "";
97 for i = 1: ncols 97 for i = 1: ncols
98 fmt = sprintf ("%s %%-%ds", fmt, maxlen); 98 fmt = sprintf ("%s %%-%ds", fmt, maxlen);
99 endfor 99 endfor
100 fmt = [fmt, "\n"]; 100 fmt = [fmt, "\n"];
101 101
102 nrows = ceil (length (f) / ncols); 102 nrows = ceil (length (f) / ncols);
103 for i = 1 : nrows 103 for i = 1 : nrows
104 args = f(i:nrows:end); 104 args = f(i:nrows:end);
105 if (length (args) < ncols) 105 if (length (args) < ncols)
106 args(end + 1 : ncols) = {""}; 106 args(end + 1 : ncols) = {""};
107 endif 107 endif