comparison libinterp/corefcn/help.cc @ 20616:fd0efcdb3718

use new string_value method to handle value extraction errors * dirfns.cc, file-io.cc, gammainc.cc, help.cc, load-path.cc, octave-link.cc, qz.cc, regexp.cc, strfns.cc, syscalls.cc, time.cc, variables.cc: Use new string_value method.
author John W. Eaton <jwe@octave.org>
date Thu, 08 Oct 2015 19:00:51 -0400
parents a9574e3c6e9e
children
comparison
equal deleted inserted replaced
20615:729a85dafba8 20616:fd0efcdb3718
1090 { 1090 {
1091 octave_value_list retval; 1091 octave_value_list retval;
1092 1092
1093 if (args.length () == 1) 1093 if (args.length () == 1)
1094 { 1094 {
1095 const std::string name = args(0).string_value (); 1095 const std::string name = args(0).string_value ("get_help_text: NAME must be a string");
1096 1096
1097 if (! error_state) 1097 std::string text;
1098 { 1098 std::string format;
1099 std::string text; 1099
1100 std::string format; 1100 do_get_help_text (name, text, format);
1101 1101
1102 do_get_help_text (name, text, format); 1102 retval(1) = format;
1103 1103 retval(0) = text;
1104 retval(1) = format;
1105 retval(0) = text;
1106 }
1107 else
1108 error ("get_help_text: invalid input");
1109 } 1104 }
1110 else 1105 else
1111 print_usage (); 1106 print_usage ();
1112 1107
1113 return retval; 1108 return retval;
1160 { 1155 {
1161 octave_value_list retval; 1156 octave_value_list retval;
1162 1157
1163 if (args.length () == 1) 1158 if (args.length () == 1)
1164 { 1159 {
1165 const std::string fname = args(0).string_value (); 1160 const std::string fname = args(0).string_value ("get_help_text_from_file: NAME must be a string");
1166 1161
1167 if (! error_state) 1162 std::string text;
1168 { 1163 std::string format;
1169 std::string text; 1164
1170 std::string format; 1165 do_get_help_text_from_file (fname, text, format);
1171 1166
1172 do_get_help_text_from_file (fname, text, format); 1167 retval(1) = format;
1173 1168 retval(0) = text;
1174 retval(1) = format;
1175 retval(0) = text;
1176 }
1177 else
1178 error ("get_help_text_from_file: invalid input");
1179 } 1169 }
1180 else 1170 else
1181 print_usage (); 1171 print_usage ();
1182 1172
1183 return retval; 1173 return retval;
1378 string_vector ffl = load_path::fcn_names (); 1368 string_vector ffl = load_path::fcn_names ();
1379 string_vector afl = autoloaded_functions (); 1369 string_vector afl = autoloaded_functions ();
1380 1370
1381 if (args.length () == 0) 1371 if (args.length () == 0)
1382 retval = Cell (ffl.append (afl)); 1372 retval = Cell (ffl.append (afl));
1383 else if (args(0).is_string ()) 1373 else
1384 { 1374 {
1385 std::string dir = args(0).string_value (); 1375 std::string dir = args(0).string_value ("__list_functions__: DIRECTORY argument must be a string");
1386 1376
1387 string_vector fl = load_path::files (dir, true); 1377 string_vector fl = load_path::files (dir, true);
1388 1378
1389 if (! error_state) 1379 // Return a sorted list with unique entries (in case of
1390 { 1380 // .m and .oct versions of the same function in a given
1391 // Return a sorted list with unique entries (in case of 1381 // directory, for example).
1392 // .m and .oct versions of the same function in a given 1382 fl.sort (true);
1393 // directory, for example). 1383
1394 fl.sort (true); 1384 retval = Cell (fl);
1395
1396 retval = Cell (fl);
1397 }
1398 } 1385 }
1399 else
1400 error ("__list_functions__: DIRECTORY argument must be a string");
1401 1386
1402 return retval; 1387 return retval;
1403 } 1388 }
1404 1389
1405 DEFUN (doc_cache_file, args, nargout, 1390 DEFUN (doc_cache_file, args, nargout,