Mercurial > octave-nkf
comparison libinterp/corefcn/variables.cc @ 20588:4bed806ee3d4
eliminate more simple uses of error_state
* daspk.cc, dassl.cc, dot.cc, luinc.cc, sylvester.cc, variables.cc,
__eigs__.cc: Eliminate simple uses of error_state.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 05 Oct 2015 20:21:55 -0400 |
parents | b70cc4bd8109 |
children | fd0efcdb3718 |
comparison
equal
deleted
inserted
replaced
20587:f90c8372b7ba | 20588:4bed806ee3d4 |
---|---|
265 { | 265 { |
266 int parse_status; | 266 int parse_status; |
267 | 267 |
268 unwind_protect frame; | 268 unwind_protect frame; |
269 | 269 |
270 frame.protect_var (error_state); | |
271 | |
272 frame.protect_var (discard_error_messages); | 270 frame.protect_var (discard_error_messages); |
273 frame.protect_var (discard_warning_messages); | 271 frame.protect_var (discard_warning_messages); |
274 | 272 |
275 discard_error_messages = true; | 273 discard_error_messages = true; |
276 discard_warning_messages = true; | 274 discard_warning_messages = true; |
307 int parse_status; | 305 int parse_status; |
308 | 306 |
309 unwind_protect frame; | 307 unwind_protect frame; |
310 | 308 |
311 frame.protect_var (discard_error_messages); | 309 frame.protect_var (discard_error_messages); |
312 frame.protect_var (error_state); | |
313 | 310 |
314 discard_error_messages = true; | 311 discard_error_messages = true; |
315 | 312 |
316 octave_value tmp = eval_string (text, true, parse_status); | 313 octave_value tmp = eval_string (text, true, parse_status); |
317 | 314 |
1694 | 1691 |
1695 frame.add_fcn (symbol_table::clear_variables); | 1692 frame.add_fcn (symbol_table::clear_variables); |
1696 | 1693 |
1697 feval ("load", octave_value (nm), 0); | 1694 feval ("load", octave_value (nm), 0); |
1698 | 1695 |
1699 if (! error_state) | 1696 std::string newmsg = std::string ("Variables in the file ") |
1700 { | 1697 + nm + ":\n\n"; |
1701 std::string newmsg = std::string ("Variables in the file ") + | 1698 |
1702 nm + ":\n\n"; | 1699 retval = do_who (i, argv, return_list, verbose, newmsg); |
1703 | |
1704 retval = do_who (i, argv, return_list, verbose, newmsg); | |
1705 } | |
1706 } | 1700 } |
1707 | 1701 |
1708 return retval; | 1702 return retval; |
1709 } | 1703 } |
1710 else if (argv[i] == "-regexp") | 1704 else if (argv[i] == "-regexp") |
1784 int parse_status; | 1778 int parse_status; |
1785 | 1779 |
1786 octave_value expr_val | 1780 octave_value expr_val |
1787 = eval_string (pat, true, parse_status); | 1781 = eval_string (pat, true, parse_status); |
1788 | 1782 |
1789 if (! error_state) | 1783 symbol_stats.append (sr, pat, expr_val); |
1790 symbol_stats.append (sr, pat, expr_val); | |
1791 else | |
1792 return retval; | |
1793 } | 1784 } |
1794 } | 1785 } |
1795 } | 1786 } |
1796 } | 1787 } |
1797 else | 1788 else |
1895 { | 1886 { |
1896 int argc = args.length () + 1; | 1887 int argc = args.length () + 1; |
1897 | 1888 |
1898 string_vector argv = args.make_argv ("who"); | 1889 string_vector argv = args.make_argv ("who"); |
1899 | 1890 |
1900 if (! error_state) | 1891 retval = do_who (argc, argv, nargout == 1); |
1901 retval = do_who (argc, argv, nargout == 1); | |
1902 } | 1892 } |
1903 else | 1893 else |
1904 print_usage (); | 1894 print_usage (); |
1905 | 1895 |
1906 return retval; | 1896 return retval; |
1976 { | 1966 { |
1977 int argc = args.length () + 1; | 1967 int argc = args.length () + 1; |
1978 | 1968 |
1979 string_vector argv = args.make_argv ("whos"); | 1969 string_vector argv = args.make_argv ("whos"); |
1980 | 1970 |
1981 if (! error_state) | 1971 retval = do_who (argc, argv, nargout == 1, true); |
1982 retval = do_who (argc, argv, nargout == 1, true); | |
1983 } | 1972 } |
1984 else | 1973 else |
1985 print_usage (); | 1974 print_usage (); |
1986 | 1975 |
1987 return retval; | 1976 return retval; |
2466 | 2455 |
2467 int argc = args.length () + 1; | 2456 int argc = args.length () + 1; |
2468 | 2457 |
2469 string_vector argv = args.make_argv ("clear"); | 2458 string_vector argv = args.make_argv ("clear"); |
2470 | 2459 |
2471 if (! error_state) | 2460 if (argc == 1) |
2472 { | 2461 { |
2473 if (argc == 1) | 2462 do_clear_globals (argv, argc, true); |
2474 { | 2463 do_clear_variables (argv, argc, true); |
2475 do_clear_globals (argv, argc, true); | 2464 |
2476 do_clear_variables (argv, argc, true); | 2465 octave_link::clear_workspace (); |
2477 | 2466 } |
2478 octave_link::clear_workspace (); | 2467 else |
2479 } | 2468 { |
2480 else | 2469 int idx = 0; |
2481 { | 2470 |
2482 int idx = 0; | 2471 bool clear_all = false; |
2483 | 2472 bool clear_functions = false; |
2484 bool clear_all = false; | 2473 bool clear_globals = false; |
2485 bool clear_functions = false; | 2474 bool clear_variables = false; |
2486 bool clear_globals = false; | 2475 bool clear_objects = false; |
2487 bool clear_variables = false; | 2476 bool exclusive = false; |
2488 bool clear_objects = false; | 2477 bool have_regexp = false; |
2489 bool exclusive = false; | 2478 bool have_dash_option = false; |
2490 bool have_regexp = false; | 2479 |
2491 bool have_dash_option = false; | 2480 while (++idx < argc) |
2492 | 2481 { |
2493 while (++idx < argc) | 2482 if (argv[idx] == "-all" || argv[idx] == "-a") |
2494 { | 2483 { |
2495 if (argv[idx] == "-all" || argv[idx] == "-a") | 2484 CLEAR_OPTION_ERROR (have_dash_option && ! exclusive); |
2485 | |
2486 have_dash_option = true; | |
2487 clear_all = true; | |
2488 } | |
2489 else if (argv[idx] == "-exclusive" || argv[idx] == "-x") | |
2490 { | |
2491 have_dash_option = true; | |
2492 exclusive = true; | |
2493 } | |
2494 else if (argv[idx] == "-functions" || argv[idx] == "-f") | |
2495 { | |
2496 CLEAR_OPTION_ERROR (have_dash_option && ! exclusive); | |
2497 | |
2498 have_dash_option = true; | |
2499 clear_functions = true; | |
2500 } | |
2501 else if (argv[idx] == "-global" || argv[idx] == "-g") | |
2502 { | |
2503 CLEAR_OPTION_ERROR (have_dash_option && ! exclusive); | |
2504 | |
2505 have_dash_option = true; | |
2506 clear_globals = true; | |
2507 } | |
2508 else if (argv[idx] == "-variables" || argv[idx] == "-v") | |
2509 { | |
2510 CLEAR_OPTION_ERROR (have_dash_option && ! exclusive); | |
2511 | |
2512 have_dash_option = true; | |
2513 clear_variables = true; | |
2514 } | |
2515 else if (argv[idx] == "-classes" || argv[idx] == "-c") | |
2516 { | |
2517 CLEAR_OPTION_ERROR (have_dash_option && ! exclusive); | |
2518 | |
2519 have_dash_option = true; | |
2520 clear_objects = true; | |
2521 } | |
2522 else if (argv[idx] == "-regexp" || argv[idx] == "-r") | |
2523 { | |
2524 CLEAR_OPTION_ERROR (have_dash_option && ! exclusive); | |
2525 | |
2526 have_dash_option = true; | |
2527 have_regexp = true; | |
2528 } | |
2529 else | |
2530 break; | |
2531 } | |
2532 | |
2533 if (idx <= argc) | |
2534 { | |
2535 if (! have_dash_option) | |
2536 { | |
2537 do_matlab_compatible_clear (argv, argc, idx); | |
2538 } | |
2539 else | |
2540 { | |
2541 if (clear_all) | |
2496 { | 2542 { |
2497 CLEAR_OPTION_ERROR (have_dash_option && ! exclusive); | 2543 maybe_warn_exclusive (exclusive); |
2498 | 2544 |
2499 have_dash_option = true; | 2545 if (++idx < argc) |
2500 clear_all = true; | 2546 warning |
2547 ("clear: ignoring extra arguments after -all"); | |
2548 | |
2549 symbol_table::clear_all (); | |
2501 } | 2550 } |
2502 else if (argv[idx] == "-exclusive" || argv[idx] == "-x") | 2551 else if (have_regexp) |
2503 { | 2552 { |
2504 have_dash_option = true; | 2553 do_clear_variables (argv, argc, idx, exclusive, true); |
2505 exclusive = true; | |
2506 } | 2554 } |
2507 else if (argv[idx] == "-functions" || argv[idx] == "-f") | 2555 else if (clear_functions) |
2508 { | 2556 { |
2509 CLEAR_OPTION_ERROR (have_dash_option && ! exclusive); | 2557 do_clear_functions (argv, argc, idx, exclusive); |
2510 | |
2511 have_dash_option = true; | |
2512 clear_functions = true; | |
2513 } | 2558 } |
2514 else if (argv[idx] == "-global" || argv[idx] == "-g") | 2559 else if (clear_globals) |
2515 { | 2560 { |
2516 CLEAR_OPTION_ERROR (have_dash_option && ! exclusive); | 2561 do_clear_globals (argv, argc, idx, exclusive); |
2517 | |
2518 have_dash_option = true; | |
2519 clear_globals = true; | |
2520 } | 2562 } |
2521 else if (argv[idx] == "-variables" || argv[idx] == "-v") | 2563 else if (clear_variables) |
2522 { | 2564 { |
2523 CLEAR_OPTION_ERROR (have_dash_option && ! exclusive); | 2565 do_clear_variables (argv, argc, idx, exclusive); |
2524 | |
2525 have_dash_option = true; | |
2526 clear_variables = true; | |
2527 } | 2566 } |
2528 else if (argv[idx] == "-classes" || argv[idx] == "-c") | 2567 else if (clear_objects) |
2529 { | 2568 { |
2530 CLEAR_OPTION_ERROR (have_dash_option && ! exclusive); | 2569 symbol_table::clear_objects (); |
2531 | 2570 octave_class::clear_exemplar_map (); |
2532 have_dash_option = true; | 2571 symbol_table::clear_all (); |
2533 clear_objects = true; | |
2534 } | |
2535 else if (argv[idx] == "-regexp" || argv[idx] == "-r") | |
2536 { | |
2537 CLEAR_OPTION_ERROR (have_dash_option && ! exclusive); | |
2538 | |
2539 have_dash_option = true; | |
2540 have_regexp = true; | |
2541 } | |
2542 else | |
2543 break; | |
2544 } | |
2545 | |
2546 if (idx <= argc) | |
2547 { | |
2548 if (! have_dash_option) | |
2549 { | |
2550 do_matlab_compatible_clear (argv, argc, idx); | |
2551 } | 2572 } |
2552 else | 2573 else |
2553 { | 2574 { |
2554 if (clear_all) | 2575 do_clear_symbols (argv, argc, idx, exclusive); |
2555 { | |
2556 maybe_warn_exclusive (exclusive); | |
2557 | |
2558 if (++idx < argc) | |
2559 warning | |
2560 ("clear: ignoring extra arguments after -all"); | |
2561 | |
2562 symbol_table::clear_all (); | |
2563 } | |
2564 else if (have_regexp) | |
2565 { | |
2566 do_clear_variables (argv, argc, idx, exclusive, true); | |
2567 } | |
2568 else if (clear_functions) | |
2569 { | |
2570 do_clear_functions (argv, argc, idx, exclusive); | |
2571 } | |
2572 else if (clear_globals) | |
2573 { | |
2574 do_clear_globals (argv, argc, idx, exclusive); | |
2575 } | |
2576 else if (clear_variables) | |
2577 { | |
2578 do_clear_variables (argv, argc, idx, exclusive); | |
2579 } | |
2580 else if (clear_objects) | |
2581 { | |
2582 symbol_table::clear_objects (); | |
2583 octave_class::clear_exemplar_map (); | |
2584 symbol_table::clear_all (); | |
2585 } | |
2586 else | |
2587 { | |
2588 do_clear_symbols (argv, argc, idx, exclusive); | |
2589 } | |
2590 } | 2576 } |
2591 | 2577 } |
2592 octave_link::set_workspace (); | 2578 |
2593 } | 2579 octave_link::set_workspace (); |
2594 } | 2580 } |
2595 } | 2581 } |
2596 | 2582 |
2597 return retval; | 2583 return retval; |
2598 } | 2584 } |