# HG changeset patch # User Rik # Date 1390696861 28800 # Node ID 6a2cc29f55fcd58ac59314dc7fb1dae4d403a1a0 # Parent ed1e63425f79b775a7284533abe4657ef05246c9 Correctly handle 'dbtype lineno' case. * debug.cc: Add extra if statement to distinguish between 'dbtype func' and 'dbtype lineno' by testing whether lineno is 0 from atoi call. diff -r ed1e63425f79 -r 6a2cc29f55fc libinterp/corefcn/debug.cc --- a/libinterp/corefcn/debug.cc Sat Jan 25 16:15:13 2014 -0800 +++ b/libinterp/corefcn/debug.cc Sat Jan 25 16:41:01 2014 -0800 @@ -978,13 +978,14 @@ dbg_fcn = get_user_code (); if (dbg_fcn) - do_dbtype (octave_stdout, dbg_fcn->fcn_file_name (), 0, - std::numeric_limits::max ()); + do_dbtype (octave_stdout, dbg_fcn->fcn_file_name (), + 0, std::numeric_limits::max ()); else error ("dbtype: must be inside a user function to give no arguments to dbtype\n"); + break; - case 1: // (dbtype func) || (dbtype start:end) + case 1: // (dbtype start:end) || (dbtype func) || (dbtype lineno) { std::string arg = argv[1]; @@ -1014,25 +1015,44 @@ if (start <= end) do_dbtype (octave_stdout, dbg_fcn->fcn_file_name (), - start, end); + start, end); else error ("dbtype: start line must be less than end line\n"); } } - else // (dbtype func) + else // (dbtype func) || (dbtype lineno) { - dbg_fcn = get_user_code (arg); + int line = atoi (arg.c_str ()); + + if (line == 0) // (dbtype func) + { + dbg_fcn = get_user_code (arg); - if (dbg_fcn) - do_dbtype (octave_stdout, dbg_fcn->fcn_file_name (), 0, - std::numeric_limits::max ()); - else - error ("dbtype: function <%s> not found\n", arg.c_str ()); + if (dbg_fcn) + do_dbtype (octave_stdout, dbg_fcn->fcn_file_name (), + 0, std::numeric_limits::max ()); + else + error ("dbtype: function <%s> not found\n", arg.c_str ()); + } + else // (dbtype lineno) + { + if (line <= 0) + { + error ("dbtype: start and end lines must be >= 1\n"); + break; + } + + dbg_fcn = get_user_code (); + + if (dbg_fcn) + do_dbtype (octave_stdout, dbg_fcn->fcn_file_name (), + line, line); + } } } break; - case 2: // (dbtype func start:end) , (dbtype func start) + case 2: // (dbtype func start:end) || (dbtype func start) dbg_fcn = get_user_code (argv[1]); if (dbg_fcn) @@ -1059,10 +1079,14 @@ } if (std::min (start, end) <= 0) - error ("dbtype: start and end lines must be >= 1\n"); + { + error ("dbtype: start and end lines must be >= 1\n"); + break; + } if (start <= end) - do_dbtype (octave_stdout, dbg_fcn->fcn_file_name (), start, end); + do_dbtype (octave_stdout, dbg_fcn->fcn_file_name (), + start, end); else error ("dbtype: start line must be less than end line\n"); }