Index: toplev.cc =================================================================== RCS file: /cvs/octave/src/toplev.cc,v retrieving revision 1.198 diff -c -p -r1.198 toplev.cc *** toplev.cc 14 May 2007 17:35:46 -0000 1.198 --- toplev.cc 29 May 2007 10:15:11 -0000 *************** variable @code{status} to the integer @s *** 558,564 **** ZeroMemory (&si, sizeof (si)); ZeroMemory (&pi, sizeof (pi)); OCTAVE_LOCAL_BUFFER (char, xcmd_str, cmd_str.length()+1); ! strcpy (xcmd_str, cmd_str.c_str ()) if (! CreateProcess (0, xcmd_str, 0, 0, FALSE, 0, 0, 0, &si, &pi)) error ("system: CreateProcess failed -- can't create child process"); --- 558,564 ---- ZeroMemory (&si, sizeof (si)); ZeroMemory (&pi, sizeof (pi)); OCTAVE_LOCAL_BUFFER (char, xcmd_str, cmd_str.length()+1); ! strcpy (xcmd_str, cmd_str.c_str ()); if (! CreateProcess (0, xcmd_str, 0, 0, FALSE, 0, 0, 0, &si, &pi)) error ("system: CreateProcess failed -- can't create child process"); *************** will print the message \"Bye bye\" when *** 695,700 **** --- 695,765 ---- return retval; } + DEFUN (remove_atexit, args, nargout, + "-*- texinfo -*-\n\ + @deftypefn {Built-in Function} {} remove_atexit (@var{fcn})\n\ + Seacrch for a function in the stack of functions to be called when\n\ + Octave exits, and remove it. For example,\n\ + \n\ + @example\n\ + @group\n\ + function bye_bye ()\n\ + disp (\"Bye Bye\");\n\ + endfunction\n\ + atexit(\"bye_bye\");\n\ + @dots{}\n\ + remove_atexit(\"bye_bye\");\n\ + @end group\n\ + @end example\n\ + \n\ + @noindent\n\ + will then not print a message when Octave exits. Note that only the first\n\ + occurence of a function will be removed from the stack. Therefore, if a\n\ + function was placed in the stack multiple times with @code{atexit}, it\n\ + must equally be removed from the stack multiple times with\n\ + @code{remove_atexit}.\n\ + @seealso{atexit}\n\ + @end deftypefn") + { + octave_value retval; + int nargin = args.length(); + + if (nargin != 1) + print_usage(); + else + { + std::string cmd = args(0).string_value (); + if (! error_state) + { + bool found = false; + std::stack tmp_stack; + + while (! octave_atexit_functions.empty()) + { + if (octave_atexit_functions.top() == cmd) + { + octave_atexit_functions.pop(); + found = true; + break; + } + tmp_stack.push (octave_atexit_functions.top()); + octave_atexit_functions.pop(); + } + + while (! tmp_stack.empty()) + { + octave_atexit_functions.push (tmp_stack.top()); + tmp_stack.pop(); + } + + if (nargout > 0) + retval = found; + } + } + + return retval; + } + DEFUN (octave_config_info, args, , "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} octave_config_info (@var{option})\n\