changeset 12400:5252f12537f8

don't warn about coercing nested functions to subfunctions if yyparse failed
author John W. Eaton <jwe@octave.org>
date Tue, 08 Feb 2011 03:22:12 -0500
parents 824b3e0ab12a
children 88a8248f5b97
files ChangeLog NEWS src/ChangeLog src/oct-parse.yy
diffstat 4 files changed, 26 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2011-02-08  John W. Eaton  <jwe@octave.org>
+
+	* NEWS: Add note about subfunctions.
+
 2011-02-06  John W. Eaton  <jwe@octave.org>
 
 	* PROJECTS, README.devel: Use maintainers@octave.org instead of
--- a/NEWS
+++ b/NEWS
@@ -575,6 +575,18 @@
 
     the lines "s *= y;" and "t = y + x" will not be executed.
 
+ ** If any subfunction in a file ends with "end" or "endfunction", then
+    they all must end that way.  Previously, Octave accepted
+
+      function main ()
+        ...
+      # no endfunction here.
+      function sub ()
+        ...
+      endfunction
+
+    but this is no longer allowed.
+
  ** Special treatment in the parser of expressions like "a' * b".
 
     In these cases the transpose is no longer explicitly formed and
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
+2011-02-08  John W. Eaton  <jwe@octave.org>
+
+	* oct-parse.yy (parse_fcn_file): Don't warn about coercing
+	nested functions to subfunctions if yyparse failed.
+
 2011-02-06  Konstantinos Poulios  <logari81@googlemail.com>
 
 	* graphics.h.in (class axes::properties): Tag positionmode,
--- a/src/oct-parse.yy
+++ b/src/oct-parse.yy
@@ -3589,14 +3589,14 @@
 
           fcn_ptr = primary_fcn_ptr;
 
-          if (reading_fcn_file && endfunction_found && max_function_depth > 1)
+          if (status != 0)
+            error ("parse error while reading %s file %s",
+                   file_type.c_str(), ff.c_str ());
+          else if (reading_fcn_file && endfunction_found
+                   && max_function_depth > 1)
             warning_with_id ("Octave:nested-functions-coerced",
                              "nested functions are coerced into subfunctions "
                              "in file %s", ff.c_str ());
-
-          if (status != 0)
-            error ("parse error while reading %s file %s",
-                   file_type.c_str(), ff.c_str ());
         }
       else
         {