Mercurial > octave-nkf
diff src/sysdep.cc @ 1750:fd0d12493223
[project @ 1996-01-13 09:31:07 by jwe]
author | jwe |
---|---|
date | Sat, 13 Jan 1996 09:31:07 +0000 |
parents | a02f140ed897 |
children | 3a9462b655f1 |
line wrap: on
line diff
--- a/src/sysdep.cc Sat Jan 13 09:31:07 1996 +0000 +++ b/src/sysdep.cc Sat Jan 13 09:31:07 1996 +0000 @@ -68,6 +68,7 @@ #endif #include <readline/readline.h> +#include <readline/tilde.h> extern char *term_clrpag; extern "C" void _rl_output_character_function (); @@ -680,6 +681,43 @@ } #endif +// The check for error state allows us to do this: +// +// string foo = oct_tilde_expand (args(0).string_value ()); +// +// without having to use a temporary and check error_state before +// calling oct_tilde_expand. + +string +oct_tilde_expand (const string& name) +{ + string retval; + + if (! error_state) + { + char *tmp = tilde_expand (name.c_str ()); + retval = tmp; + delete [] tmp; + } + + return retval; +} + +DEFUN ("tilde_expand", Ftilde_expand, Stilde_expand, 10, + "tilde_expand (STRING): perform tilde expansion on STRING") +{ + Octave_object retval; + + int nargin = args.length (); + + if (nargin == 1) + retval = oct_tilde_expand (args(0).string_value ()); + else + print_usage ("tilde_expand"); + + return retval; +} + /* ;;; Local Variables: *** ;;; mode: C++ ***