Mercurial > hg > octave-nkf
changeset 5800:e8be7fe586f9
[project @ 2006-05-10 06:50:45 by jwe]
author | jwe |
---|---|
date | Wed, 10 May 2006 06:50:45 +0000 |
parents | 9ad09b44beba |
children | 70013c9f3ccc |
files | README.Windows src/ChangeLog src/defun.cc src/help.cc src/help.h src/oct-hist.cc src/variables.cc |
diffstat | 7 files changed, 113 insertions(+), 25 deletions(-) [+] |
line wrap: on
line diff
--- a/README.Windows +++ b/README.Windows @@ -57,12 +57,12 @@ at this prompt and a new window with the sombrero plot should appear. -13. To build .oct files (dynamically loaded functions) for Octave, you - will also need the octave-headers package. Currently, due to some - bugs in the most recent version of the C++ compiler and libraries - for Cygwin, you will also need gcc and g++ 3.3 rather than 3.4. - You can use the setup.exe installer to select and install the - older version. +13. IMPORTANT: to build .oct files (dynamically loaded functions) for + Octave, you will also need the octave-headers package. Currently, + due to some bugs in the most recent version of the C++ compiler + and libraries for Cygwin, you will also need gcc and g++ 3.3 + rather than 3.4. You can use the setup.exe installer to select + and install the older version. John W. Eaton
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,11 @@ +2006-05-10 John W. Eaton <jwe@octave.org> + + * oct-hist.cc (initialize_history, Fhistory_size): + Also call command_history::set_size here. + + * defun.cc (Fprint_usage): New function. + * help.cc (display_usage_text): New function. + 2006-05-09 Keith Goodman <kwgoodman@gmail.com> * DLD-FUNCTIONS/rand.cc: Doc string fix.
--- a/src/defun.cc +++ b/src/defun.cc @@ -63,7 +63,7 @@ h = extract_help_from_dispatch (nm) + h; - display_help_text (buf, h); + display_usage_text (buf, h); buf << extra_msg << "\n"; @@ -77,6 +77,32 @@ warning ("no usage message found for `%s'", nm.c_str ()); } +DEFUN (print_usage, args, , + "-*- texinfo -*-\n\ +@deftypefn {Loadable Function} {} print_usage (@var{fname})\n\ +Print the usage message for the function named @var{fname}. The\n\ +@code{print_usage} function is only intended to work inside the\n\ +named function.\n\ +@seealso{help}\n\ +@end deftypefn") +{ + octave_value retval; + + if (args.length () == 1) + { + std::string fname = args(0).string_value (); + + if (! error_state) + print_usage (fname); + else + error ("print_usage: expecting character string"); + } + else + print_usage ("print_usage"); + + return retval; +} + void check_version (const std::string& version, const std::string& fcn) {
--- a/src/help.cc +++ b/src/help.cc @@ -695,6 +695,49 @@ os << msg; } +void +display_usage_text (std::ostream& os, const std::string& msg) +{ + std::string filtered_msg = msg; + + size_t pos; + + if (looks_like_texinfo (msg, pos)) + { + std::ostringstream buf; + + buf << "-*- texinfo -*-\n"; + + bool found_def = false; + + size_t msg_len = msg.length (); + + while (pos < msg_len) + { + size_t new_pos = msg.find_first_of ('\n', pos); + + if (new_pos == NPOS) + new_pos = msg_len-1; + + std::string line = msg.substr (pos, new_pos-pos+1); + + if (line.substr (0, 4) == "@def" + || line.substr (0, 8) == "@end def") + { + found_def = true; + buf << line; + } + + pos = new_pos + 1; + } + + if (found_def) + filtered_msg = buf.str (); + } + + display_help_text (os, filtered_msg); +} + static bool help_from_list (std::ostream& os, const help_list *list, const std::string& nm, int usage, bool& symbol_found)
--- a/src/help.h +++ b/src/help.h @@ -35,6 +35,8 @@ extern void display_help_text (std::ostream&, const std::string&); +extern void display_usage_text (std::ostream&, const std::string&); + extern void additional_help_message (std::ostream&); // Name of the info file specified on command line.
--- a/src/oct-hist.cc +++ b/src/oct-hist.cc @@ -552,7 +552,8 @@ initialize_history (void) { command_history::set_file (file_ops::tilde_expand (Vhistory_file)); - + command_history::set_size (Vhistory_size); + command_history::read (false); } @@ -691,7 +692,15 @@ @seealso{history_file, history_timestamp_format, saving_history}\n\ @end deftypefn") { - return SET_INTERNAL_VARIABLE_WITH_LIMITS (history_size, -1, INT_MAX); + int saved_history_size = Vhistory_size; + + octave_value retval + = SET_INTERNAL_VARIABLE_WITH_LIMITS (history_size, -1, INT_MAX); + + if (Vhistory_size != saved_history_size) + command_history::set_size (Vhistory_size); + + return retval; } DEFUN (history_file, args, nargout, @@ -712,7 +721,7 @@ if (Vhistory_file != saved_history_file) command_history::set_file (file_ops::tilde_expand (Vhistory_file)); - return retval;; + return retval; } DEFUN (history_timestamp_format_string, args, nargout,
--- a/src/variables.cc +++ b/src/variables.cc @@ -1248,11 +1248,11 @@ { octave_value retval; - if (nargout > 0) + int nargin = args.length (); + + if (nargout > 0 || nargin == 0) retval = var; - int nargin = args.length (); - if (nargin == 1) { bool bval = args(0).bool_value (); @@ -1274,11 +1274,11 @@ { octave_value retval; - if (nargout > 0) + int nargin = args.length (); + + if (nargout > 0 || nargin == 0) retval = var; - int nargin = args.length (); - if (nargin == 1) { std::string sval = args(0).string_value (); @@ -1316,11 +1316,11 @@ { octave_value retval; - if (nargout > 0) + int nargin = args.length (); + + if (nargout > 0 || nargin == 0) retval = var; - int nargin = args.length (); - if (nargin == 1) { int ival = args(0).int_value (); @@ -1350,11 +1350,11 @@ { octave_value retval; - if (nargout > 0) + int nargin = args.length (); + + if (nargout > 0 || nargin == 0) retval = var; - int nargin = args.length (); - if (nargin == 1) { double dval = args(0).scalar_value (); @@ -1383,11 +1383,11 @@ { octave_value retval; - if (nargout > 0) + int nargin = args.length (); + + if (nargout > 0 || nargin == 0) retval = var; - int nargin = args.length (); - if (nargin == 1) { std::string sval = args(0).string_value ();