Mercurial > hg > octave-avbm
changeset 2234:a174011c96f2
[project @ 1996-05-17 17:51:20 by jwe]
author | jwe |
---|---|
date | Fri, 17 May 1996 17:52:28 +0000 |
parents | 0da2c91573d9 |
children | 896966940135 |
files | src/input.cc src/utils.cc |
diffstat | 2 files changed, 88 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/input.cc +++ b/src/input.cc @@ -1196,6 +1196,65 @@ return retval; } +DEFUN (completion_matches, args, nargout, + "completion_matches (HINT): generate possible completions given HINT") +{ + string_vector retval; + + int nargin = args.length (); + + if (nargin == 1) + { + string hint_string = args(0).string_value (); + + if (! error_state) + { + int n = 32; + + string_vector list (n); + + const char *hint = hint_string.c_str (); + + int k = 0; + + for (;;) + { + const char *cmd = command_generator (hint, k); + + if (cmd) + { + if (k > n) + { + n *= 2; + list.resize (n); + } + + list[k++] = cmd; + } + else + { + list.resize (k); + break; + } + } + + if (nargout > 0) + retval = list; + else + { + int len = list.length (); + + for (int i = 0; i < len; i++) + octave_stdout << list[i] << "\n"; + } + } + } + else + print_usage ("completion_matches"); + + return retval; +} + static int ps1 (void) {
--- a/src/utils.cc +++ b/src/utils.cc @@ -208,6 +208,35 @@ return status; } +// Return non-zero if either NR or NC is zero. Return -1 if this +// should be considered fatal; return 1 if this is ok. + +int +empty_arg (const char *name, int nr, int nc) +{ + int is_empty = 0; + + if (nr == 0 || nc == 0) + { + int flag = Vpropagate_empty_matrices; + + if (flag < 0) + { + gripe_empty_arg (name, 0); + is_empty = 1; + } + else if (flag == 0) + { + gripe_empty_arg (name, 1); + is_empty = -1; + } + else + is_empty = 1; + } + + return is_empty; +} + // See if the given file is in the path. string