changeset 15079:dda73cb60ac5

demo.m: Allow functions in demo blocks (bug #33981). * demo.m: Remove regexp code that checks for embedded functions in demo blocks and issues an error.
author Rik <rik@octave.org>
date Wed, 01 Aug 2012 16:44:16 -0700
parents fe4752f772e2
children 902a8e27b2a2
files scripts/testfun/demo.m
diffstat 1 files changed, 5 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/testfun/demo.m	Wed Aug 01 17:00:12 2012 -0500
+++ b/scripts/testfun/demo.m	Wed Aug 01 16:44:16 2012 -0700
@@ -123,19 +123,11 @@
     ## Process each demo without failing
     try
       block = code(idx(doidx(i)):idx(doidx(i)+1)-1);
-      ## FIXME: need to check for embedded test functions, which cause
-      ## segfaults, until issues with subfunctions in functions are resolved.
-      embed_func = regexp (block, '^\s*function ', 'once', 'lineanchors');
-      if (isempty (embed_func))
-        ## Use an environment without variables
-        eval (cstrcat ("function __demo__ ()\n", block, "\nendfunction"));
-        ## Display the code that will be executed before executing it
-        printf ("%s example %d:%s\n\n", name, doidx(i), block);
-        __demo__;
-      else
-        error (["Functions embedded in %!demo blocks are not allowed.\n", ...
-                "Use the %!function/%!endfunction syntax instead to define shared functions for testing.\n"]);
-      endif
+      ## Use an environment without variables
+      eval (cstrcat ("function __demo__ ()\n", block, "\nendfunction"));
+      ## Display the code that will be executed before executing it
+      printf ("%s example %d:%s\n\n", name, doidx(i), block);
+      __demo__;
     catch
       ## Let the programmer know which demo failed.
       printf ("%s example %d: failed\n%s\n", name, doidx(i), lasterr ());