# HG changeset patch # User jwe # Date 1018466319 0 # Node ID d38c7538b954b2ce7305e3364408c8570b0b3bcb # Parent d71f92546e45cc24c999fb30f64eb6b246ea2b72 [project @ 2002-04-10 19:18:39 by jwe] diff --git a/doc/interpreter/preface.txi b/doc/interpreter/preface.txi --- a/doc/interpreter/preface.txi +++ b/doc/interpreter/preface.txi @@ -127,7 +127,7 @@ incompatibilities and bugs. @item -Mark Odegard @email{meo@@sugarland.unocal.com} provided the initial +Mark Odegard @email{meo@@getech.com} provided the initial implementation of @code{fread}, @code{fwrite}, @code{feof}, and @code{ferror}. diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,18 @@ +2002-04-10 Ben Sapp + + * pt-stmt.cc (delete_breakpoint): List breakpoints if line < 0. + * debug.cc (get_user_function): Check symbol by name first. + (Fdbstop): Rename from Fdbg_set. + (Fdbclear): Rename from Fdbg_delete. + (Fdbstatus): Rename from Fdbg_list. + (Fdbg_where): Rename from Fdbwhere. + (do_dbtype, Fdbtype): New functions. + +2002-04-10 Peter Van Wieren + + * load-save.cc (save_mat5_binary_element): Save elements of 2d + character matrices in proper order. + 2002-04-09 Paul Kienzle * utils.cc (do_string_escapes): Handle \0 too. diff --git a/src/debug.cc b/src/debug.cc --- a/src/debug.cc +++ b/src/debug.cc @@ -24,6 +24,12 @@ #include #endif +#include +#include +#include +#include +#include + #include "defun.h" #include "error.h" #include "input.h" @@ -49,11 +55,7 @@ { octave_user_function *dbg_fcn = NULL; - if (curr_function) - { - dbg_fcn = curr_function; - } - else if (str.compare ("")) + if (str.compare ("")) { symbol_record *ptr = curr_sym_tab->lookup (str); @@ -73,13 +75,18 @@ } } } + else if (curr_function) + { + dbg_fcn = curr_function; + } return dbg_fcn; } -DEFUN_TEXT (dbg_set, args, , + +DEFUN_TEXT (dbstop, args, , "-*- texinfo -*-\n\ -@deftypefn {Loadable Function} {rline =} dbg_set (func, line)\n\ +@deftypefn {Loadable Function} {rline =} dbstop (func, line)\n\ Set a breakpoint in a function\n\ @table @code\n\ @item func\n\ @@ -92,14 +99,14 @@ The rline returned is the real line that the breakpoint was set at.\n\ \n\ @end deftypefn\n\ -@seealso{dbg_delete, dbg_list, dbg_where}") +@seealso{dbclear, dbtatus, dbnext}") { octave_value retval; int result = -1; int nargin = args.length (); - string_vector argv = args.make_argv ("dbg_set"); + string_vector argv = args.make_argv ("dbstop"); if (error_state) return retval; @@ -146,9 +153,9 @@ return retval; } -DEFUN_TEXT (dbg_delete, args, , +DEFUN_TEXT (dbclear, args, , "-*- texinfo -*-\n\ -@deftypefn {Loadable Function} {} dbg_delete (func, line)\n\ +@deftypefn {Loadable Function} {} dbclear (func, line)\n\ Delete a breakpoint in a function\n\ @table @code\n\ @item func\n\ @@ -160,12 +167,12 @@ No checking is done to make sure that the line you requested is really\n\ a breakpoint. If you get the wrong line nothing will happen.\n\ @end deftypefn\n\ -@seealso{dbg_set, dbg_list, dbg_where}") +@seealso{dbstop, dbstatus, dbwhere}") { octave_value retval; std::string symbol_name = ""; - + std::string line_number; int line = -1; int nargin = args.length (); @@ -175,7 +182,7 @@ return retval; } - string_vector argv = args.make_argv ("dbg_delete"); + string_vector argv = args.make_argv ("dbclear"); if (error_state) return retval; @@ -186,16 +193,13 @@ symbol_name = argv[1]; octave_stdout << argv[1] << std::endl; - std::string line_number = argv[2]; + line_number = argv[2]; - line = atoi (line_number.c_str ()); } else if (nargin == 1) { octave_stdout << "1 input argument\n"; - std::string line_number = argv[1]; - - line = atoi (line_number.c_str ()); + line_number = argv[1]; } else { @@ -203,6 +207,12 @@ return retval; } + + if (line_number.compare("all") && line_number.compare("ALL")) + line = atoi (line_number.c_str ()); + else + line = -1; + octave_stdout << "symbol_name = " << symbol_name << std::endl; octave_user_function *dbg_fcn = get_user_function (symbol_name); @@ -217,9 +227,9 @@ return retval; } -DEFUN_TEXT (dbg_list, args, , +DEFUN_TEXT (dbstatus, args, , "-*- texinfo -*-\n\ -@deftypefn {Loadable Function} {lst =} dbg_list ([func])\n\ +@deftypefn {Loadable Function} {lst =} dbstatus ([func])\n\ Return a vector containing the lines on which a function has \n\ breakpoints set.\n\ @table @code\n\ @@ -228,7 +238,7 @@ mode this should be left out.\n\ @end table\n\ @end deftypefn\n\ -@seealso{dbg_delete, dbg_set, dbg_where}") +@seealso{dbclear, dbwhere}") { octave_value retval; @@ -247,7 +257,7 @@ if (args(0).is_string ()) symbol_name = args(0).string_value (); else - gripe_wrong_type_arg ("dbg_list", args(0)); + gripe_wrong_type_arg ("dbstatus", args(0)); } octave_user_function *dbg_fcn = get_user_function (symbol_name); @@ -276,13 +286,12 @@ return retval; } - -DEFUN_TEXT (dbg_where, , , +DEFUN_TEXT (dbwhere, , , "-*- texinfo -*-\n\ -@deftypefn {Loadable Function} {} dbg_where ()\n\ +@deftypefn {Loadable Function} {} dbwhere ()\n\ Show where we are in the code\n\ @end deftypefn\n\ -@seealso{dbg_delete, dbg_list, dbg_set}") +@seealso{dbclear, dbstatus, dbstop}") { octave_value retval; @@ -305,7 +314,169 @@ octave_stdout << "-1\n"; } else - error ("must be inside of a user function to use dbg_where\n"); + error ("must be inside of a user function to use dbwhere\n"); + + return retval; +} + +// Copied and modified from the do_type command in help.cc +// Maybe we could share some code? +void +do_dbtype(std::ostream& os, const std::string& name, int start, int end) +{ + std::string ff = fcn_file_in_path (name); + + if (! ff.empty ()) + { + std::ifstream fs (ff.c_str (), std::ios::in); + + if (fs) + { + char ch; + int line = 1; + + if (line >= start && line <= end) + os << line << "\t"; + + while (fs.get (ch)) + { + if (line >= start && line <= end) + { + os << ch; + } + + if (ch == '\n') + { + line++; + if (line >= start && line <= end) + os << line << "\t"; + } + } + } + else + os << "unable to open `" << ff << "' for reading!\n"; + } + else + os << "unkown function"; + +} + +DEFUN_TEXT (dbtype, args, , + "-*- texinfo -*-\n\ +@deftypefn {Loadable Function} {} dbtype ()\n\ +List script file with line numbers.\n\ +@end deftypefn\n\ +@seealso{dbclear, dbstatus, dbstop}") +{ + octave_value retval; + octave_user_function *dbg_fcn; + + int nargin = args.length (); + string_vector argv = args.make_argv ("dbtype"); + + if (! error_state) + { + switch (nargin) + { + case 0: // dbtype + dbg_fcn = get_user_function (); + + if (dbg_fcn) + do_dbtype(octave_stdout,dbg_fcn->function_name (), 0, INT_MAX); + else + error("must be in a user function to give no arguments to dbtype\n"); + + break; + case 1: // (dbtype func) || (dbtype start:end) + dbg_fcn = get_user_function (argv[1].c_str ()); + + if (dbg_fcn) + do_dbtype(octave_stdout,dbg_fcn->function_name (), 0, INT_MAX); + else + { + dbg_fcn = get_user_function (""); + + if (dbg_fcn) + { + char *str = (char *)malloc(strlen(argv[1].c_str ()) + 1); + + if (str) + memcpy(str, argv[1].c_str (), strlen(argv[1].c_str ()) + 1); + else + error("croaked\n"); + + char *ind = index(str,':'); + + if (ind) + *ind = '\0'; + else + { + free(str); + error("if you specify lines it must be like `start:end`"); + } + ind++; + + int start = atoi(str); + int end = atoi(ind); + + free(str); + str = NULL; + ind = NULL; + + octave_stdout << "got start and end\n"; + + if (start > end) + error("the start line must be less than the end line\n"); + + octave_stdout << "doing dbtype\n"; + do_dbtype(octave_stdout, dbg_fcn->function_name (), start, end); + octave_stdout << "did dbtype\n"; + } + } + break; + case 2: // (dbtype func start:end) + dbg_fcn = get_user_function (argv[1].c_str ()); + + if (dbg_fcn) + { + + char *str = (char *)malloc(strlen(argv[2].c_str ()) + 1); + + if (str) + memcpy(str, argv[2].c_str (), strlen(argv[2].c_str ()) + 1); + else + error("not enough memory\n"); + + + char *ind = index(str,':'); + + if (ind) + *ind = '\0'; + else + { + free(str); + error("if you specify lines it must be like `start:end`"); + } + ind++; + + int start = atoi(str); + int end = atoi(ind); + + free(str); + ind = NULL; + str = NULL; + + if (start > end) + error("the start line must be less than the end line\n"); + + do_dbtype(octave_stdout, dbg_fcn->function_name (), start, end); + } + + break; + default: + error("unacceptable number of arguments\n"); + } + } return retval; } diff --git a/src/load-save.cc b/src/load-save.cc --- a/src/load-save.cc +++ b/src/load-save.cc @@ -4157,7 +4157,7 @@ int len = nr*nc*2; int paddedlength = PAD (nr*nc*2); - TWO_BYTE_INT *buf = new TWO_BYTE_INT[nc+3]; + TWO_BYTE_INT *buf = new TWO_BYTE_INT[nc*nr+3]; write_mat5_tag (os, miUINT16, len); for (int i = 0; i < nr; i++) @@ -4166,10 +4166,9 @@ const char *s = tstr.data (); for (int j = 0; j < nc; j++) - buf[j] = *s++; - - os.write ((char *)buf, nc*2); + buf[j*nr+i] = *s++; } + os.write ((char *)buf, nr*nc*2); if (paddedlength > len) os.write ((char *)buf, paddedlength - len); diff --git a/src/pt-stmt.cc b/src/pt-stmt.cc --- a/src/pt-stmt.cc +++ b/src/pt-stmt.cc @@ -197,8 +197,23 @@ void tree_statement_list::delete_breakpoint (int line) { - tree_breakpoint tbp (line, tree_breakpoint::clear); - accept(tbp); + if (line < 0) + { + octave_value_list lst = list_breakpoints (); + + int len = lst.length (); + + for (int line = 0; line < len; line++) + { + tree_breakpoint tbp (line, tree_breakpoint::clear); + accept (tbp); + } + } + else + { + tree_breakpoint tbp (line, tree_breakpoint::clear); + accept (tbp); + } } octave_value_list