comparison src/toplev.cc @ 7409:73036cdd855d

[project @ 2008-01-22 20:31:59 by jwe]
author jwe
date Tue, 22 Jan 2008 20:32:00 +0000
parents a2870fd8ac58
children 78f3811155f7
comparison
equal deleted inserted replaced
7408:246f905cb984 7409:73036cdd855d
661 flush_octave_stdout (); 661 flush_octave_stdout ();
662 } 662 }
663 } 663 }
664 } 664 }
665 665
666 void
667 octave_add_atexit_function (const std::string& fname)
668 {
669 octave_atexit_functions.push_front (fname);
670 }
671
672 bool
673 octave_remove_atexit_function (const std::string& fname)
674 {
675 bool found = false;
676
677 for (std::list<std::string>::iterator p = octave_atexit_functions.begin ();
678 p != octave_atexit_functions.end (); p++)
679 {
680 if (*p == fname)
681 {
682 octave_atexit_functions.erase (p);
683 found = true;
684 break;
685 }
686 }
687
688 return found;
689 }
690
691
666 DEFUN (atexit, args, nargout, 692 DEFUN (atexit, args, nargout,
667 "-*- texinfo -*-\n\ 693 "-*- texinfo -*-\n\
668 @deftypefn {Built-in Function} {} atexit (@var{fcn})\n\ 694 @deftypefn {Built-in Function} {} atexit (@var{fcn})\n\
669 Register a function to be called when Octave exits. For example,\n\ 695 Register a function to be called when Octave exits. For example,\n\
670 \n\ 696 \n\
721 } 747 }
722 748
723 if (! error_state) 749 if (! error_state)
724 { 750 {
725 if (add_mode) 751 if (add_mode)
726 octave_atexit_functions.push_front (arg); 752 octave_add_atexit_function (arg);
727 else 753 else
728 { 754 {
729 bool found = false; 755 bool found = octave_remove_atexit_function (arg);
730 std::list<std::string>::iterator it;
731
732 for (std::list<std::string>::iterator p = octave_atexit_functions.begin ();
733 p != octave_atexit_functions.end (); p++)
734 {
735 if (*p == arg)
736 {
737 octave_atexit_functions.erase (p);
738 found = true;
739 break;
740 }
741 }
742 756
743 if (nargout > 0) 757 if (nargout > 0)
744 retval(0) = found; 758 retval(0) = found;
745 } 759 }
746 } 760 }