Mercurial > octave-nkf
comparison libinterp/corefcn/debug.cc @ 18393:6a2cc29f55fc
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.
author | Rik <rik@octave.org> |
---|---|
date | Sat, 25 Jan 2014 16:41:01 -0800 |
parents | ed1e63425f79 |
children | 7cefc77f0be2 |
comparison
equal
deleted
inserted
replaced
18392:ed1e63425f79 | 18393:6a2cc29f55fc |
---|---|
976 { | 976 { |
977 case 0: // dbtype | 977 case 0: // dbtype |
978 dbg_fcn = get_user_code (); | 978 dbg_fcn = get_user_code (); |
979 | 979 |
980 if (dbg_fcn) | 980 if (dbg_fcn) |
981 do_dbtype (octave_stdout, dbg_fcn->fcn_file_name (), 0, | 981 do_dbtype (octave_stdout, dbg_fcn->fcn_file_name (), |
982 std::numeric_limits<int>::max ()); | 982 0, std::numeric_limits<int>::max ()); |
983 else | 983 else |
984 error ("dbtype: must be inside a user function to give no arguments to dbtype\n"); | 984 error ("dbtype: must be inside a user function to give no arguments to dbtype\n"); |
985 | |
985 break; | 986 break; |
986 | 987 |
987 case 1: // (dbtype func) || (dbtype start:end) | 988 case 1: // (dbtype start:end) || (dbtype func) || (dbtype lineno) |
988 { | 989 { |
989 std::string arg = argv[1]; | 990 std::string arg = argv[1]; |
990 | 991 |
991 size_t ind = arg.find (':'); | 992 size_t ind = arg.find (':'); |
992 | 993 |
1012 break; | 1013 break; |
1013 } | 1014 } |
1014 | 1015 |
1015 if (start <= end) | 1016 if (start <= end) |
1016 do_dbtype (octave_stdout, dbg_fcn->fcn_file_name (), | 1017 do_dbtype (octave_stdout, dbg_fcn->fcn_file_name (), |
1017 start, end); | 1018 start, end); |
1018 else | 1019 else |
1019 error ("dbtype: start line must be less than end line\n"); | 1020 error ("dbtype: start line must be less than end line\n"); |
1020 } | 1021 } |
1021 } | 1022 } |
1022 else // (dbtype func) | 1023 else // (dbtype func) || (dbtype lineno) |
1023 { | 1024 { |
1024 dbg_fcn = get_user_code (arg); | 1025 int line = atoi (arg.c_str ()); |
1025 | 1026 |
1026 if (dbg_fcn) | 1027 if (line == 0) // (dbtype func) |
1027 do_dbtype (octave_stdout, dbg_fcn->fcn_file_name (), 0, | 1028 { |
1028 std::numeric_limits<int>::max ()); | 1029 dbg_fcn = get_user_code (arg); |
1029 else | 1030 |
1030 error ("dbtype: function <%s> not found\n", arg.c_str ()); | 1031 if (dbg_fcn) |
1032 do_dbtype (octave_stdout, dbg_fcn->fcn_file_name (), | |
1033 0, std::numeric_limits<int>::max ()); | |
1034 else | |
1035 error ("dbtype: function <%s> not found\n", arg.c_str ()); | |
1036 } | |
1037 else // (dbtype lineno) | |
1038 { | |
1039 if (line <= 0) | |
1040 { | |
1041 error ("dbtype: start and end lines must be >= 1\n"); | |
1042 break; | |
1043 } | |
1044 | |
1045 dbg_fcn = get_user_code (); | |
1046 | |
1047 if (dbg_fcn) | |
1048 do_dbtype (octave_stdout, dbg_fcn->fcn_file_name (), | |
1049 line, line); | |
1050 } | |
1031 } | 1051 } |
1032 } | 1052 } |
1033 break; | 1053 break; |
1034 | 1054 |
1035 case 2: // (dbtype func start:end) , (dbtype func start) | 1055 case 2: // (dbtype func start:end) || (dbtype func start) |
1036 dbg_fcn = get_user_code (argv[1]); | 1056 dbg_fcn = get_user_code (argv[1]); |
1037 | 1057 |
1038 if (dbg_fcn) | 1058 if (dbg_fcn) |
1039 { | 1059 { |
1040 std::string arg = argv[2]; | 1060 std::string arg = argv[2]; |
1057 start = atoi (arg.c_str ()); | 1077 start = atoi (arg.c_str ()); |
1058 end = start; | 1078 end = start; |
1059 } | 1079 } |
1060 | 1080 |
1061 if (std::min (start, end) <= 0) | 1081 if (std::min (start, end) <= 0) |
1062 error ("dbtype: start and end lines must be >= 1\n"); | 1082 { |
1083 error ("dbtype: start and end lines must be >= 1\n"); | |
1084 break; | |
1085 } | |
1063 | 1086 |
1064 if (start <= end) | 1087 if (start <= end) |
1065 do_dbtype (octave_stdout, dbg_fcn->fcn_file_name (), start, end); | 1088 do_dbtype (octave_stdout, dbg_fcn->fcn_file_name (), |
1089 start, end); | |
1066 else | 1090 else |
1067 error ("dbtype: start line must be less than end line\n"); | 1091 error ("dbtype: start line must be less than end line\n"); |
1068 } | 1092 } |
1069 else | 1093 else |
1070 error ("dbtype: function <%s> not found\n", argv[1].c_str ()); | 1094 error ("dbtype: function <%s> not found\n", argv[1].c_str ()); |