changeset 9255:1c2d2c9f4a8d

don't allow quit() in embedded mode by default, make configurable
author Jaroslav Hajek <highegg@gmail.com>
date Mon, 25 May 2009 15:00:10 +0200
parents fbb43bc17a4d
children 5c05996ee4ac
files src/ChangeLog src/octave.cc src/toplev.cc src/toplev.h
diffstat 4 files changed, 18 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Mon May 25 11:54:52 2009 +0200
+++ b/src/ChangeLog	Mon May 25 15:00:10 2009 +0200
@@ -1,3 +1,11 @@
+2009-05-25  Jaroslav Hajek  <highegg@gmail.com>
+
+	* toplev.h (quit_allowed): New global variable.
+	* toplev.cc (quit_allowed): Declare it.
+	(Fquit): Raise error if quitting is not allowed.
+	* octave.cc (octave_main): if running as embedded, disable quit by
+	default.
+
 2009-05-25  Jaroslav Hajek  <highegg@gmail.com>
 
 	* variables.cc (do_who): Only output symbols with a defined value.
--- a/src/octave.cc	Mon May 25 11:54:52 2009 +0200
+++ b/src/octave.cc	Mon May 25 15:00:10 2009 +0200
@@ -647,6 +647,8 @@
 
   if (! embedded)
     install_signal_handlers ();
+  else
+    quit_allowed = false;
 
   initialize_file_io ();
 
--- a/src/toplev.cc	Mon May 25 11:54:52 2009 +0200
+++ b/src/toplev.cc	Mon May 25 15:00:10 2009 +0200
@@ -81,6 +81,9 @@
 
 void (*octave_exit) (int) = ::exit;
 
+// TRUE means the quit() call is allowed.
+bool quit_allowed = true;
+
 // TRUE means we are exiting via the builtin exit or quit functions.
 static bool quitting_gracefully = false;
 
@@ -654,7 +657,9 @@
 {
   octave_value_list retval;
 
-  if (nargout == 0)
+  if (! quit_allowed)
+    error ("quit: not supported in embedded mode.");
+  else if (nargout == 0)
     {
       int exit_status = 0;
 
--- a/src/toplev.h	Mon May 25 11:54:52 2009 +0200
+++ b/src/toplev.h	Mon May 25 15:00:10 2009 +0200
@@ -46,6 +46,8 @@
 typedef void (*octave_exit_func) (int);
 extern OCTINTERP_API octave_exit_func octave_exit;
 
+extern OCTINTERP_API bool quit_allowed;
+
 // quit is a lot like an interrupt, so we subclass it to simplify possible
 // handling.
 class octave_quit_exception