changeset 18493:3cac3d7f003f gui-release

maint: Periodic merge of stable to gui-release.
author John W. Eaton <jwe@octave.org>
date Thu, 20 Feb 2014 11:52:58 -0500
parents 3cb0e58a071d (current diff) e4c319ed2414 (diff)
children 1ec884e5ff00
files doc/interpreter/func.txi libinterp/parse-tree/lex.ll
diffstat 4 files changed, 41 insertions(+), 33 deletions(-) [+]
line wrap: on
line diff
--- a/doc/interpreter/func.txi	Tue Feb 18 21:56:05 2014 +0100
+++ b/doc/interpreter/func.txi	Thu Feb 20 11:52:58 2014 -0500
@@ -1054,18 +1054,22 @@
 As an example,
 
 @example
-mlock ("my_function");
+@group
+function my_function ()
+  mlock ();
+  @dots{}
+@end group
 @end example
 
 @noindent
-prevents @code{my_function} from being removed from memory, even if
-@code{clear} is called.  It is possible to determine if a function is
-locked into memory with the @code{mislocked}, and to unlock a function
-with @code{munlock}, which the following illustrates.
+prevents @code{my_function} from being removed from memory after it is
+called, even if @code{clear} is called.  It is possible to determine if
+a function is locked into memory with the @code{mislocked}, and to unlock
+a function with @code{munlock}, which the following illustrates.
 
 @example
 @group
-mlock ("my_function");
+my_function ();
 mislocked ("my_function")
 @result{} ans = 1
 munlock ("my_function");
@@ -1080,11 +1084,11 @@
 @example
 @group
 function count_calls ()
+  mlock ();
   persistent calls = 0;
   printf ("'count_calls' has been called %d times\n",
           ++calls);
 endfunction
-mlock ("count_calls");
 
 count_calls ();
 @print{} 'count_calls' has been called 1 times
@@ -1095,22 +1099,6 @@
 @end group
 @end example
 
-@noindent
-It is, however, often inconvenient to lock a function from the prompt,
-so it is also possible to lock a function from within its body.  This
-is simply done by calling @code{mlock} from within the function.
-
-@example
-@group
-function count_calls ()
-  mlock ();
-  persistent calls = 0;
-  printf ("'count_calls' has been called %d times\n",
-          ++calls);
-endfunction
-@end group
-@end example
-
 @code{mlock} might equally be used to prevent changes to a function from having
 effect in Octave, though a similar effect can be had with the
 @code{ignore_function_time_stamp} function.
--- a/libinterp/corefcn/lu.cc	Tue Feb 18 21:56:05 2014 +0100
+++ b/libinterp/corefcn/lu.cc	Thu Feb 20 11:52:58 2014 -0500
@@ -574,7 +574,7 @@
 %!error lu ()
 %!error <can not define pivoting threshold> lu ([1, 2; 3, 4], 2)
 
-%!test
+%!testif HAVE_UMFPACK
 %! Bi = [1 2 3 4 5 2 3 6 7 8 4 5 7 8 9];
 %! Bj = [1 3 4 5 6 7 8 9 11 12 13 14 15 16 17];
 %! Bv = [1 1 1 1 1 1 -1 1 1 1 1 -1 1 -1 1];
--- a/libinterp/parse-tree/lex.ll	Tue Feb 18 21:56:05 2014 +0100
+++ b/libinterp/parse-tree/lex.ll	Thu Feb 20 11:52:58 2014 -0500
@@ -1201,6 +1201,8 @@
   }
 
 "@" {
+    curr_lexer->lexer_debug ("@");
+
     if (curr_lexer->previous_token_may_be_command ()
         &&  curr_lexer->space_follows_previous_token ())
       {
@@ -1209,15 +1211,26 @@
       }
     else
       {
-        curr_lexer->lexer_debug ("@");
-
-        curr_lexer->current_input_column++;
-
-        curr_lexer->looking_at_function_handle++;
-        curr_lexer->looking_for_object_index = false;
-        curr_lexer->at_beginning_of_statement = false;
-
-        return curr_lexer->count_token ('@');
+        int tok = curr_lexer->previous_token_value ();
+
+        if (curr_lexer->whitespace_is_significant ()
+            && curr_lexer->space_follows_previous_token ()
+            && ! (tok == '[' || tok == '{'
+                  || curr_lexer->previous_token_is_binop ()))
+          {
+            yyless (0);
+            unput (',');
+          }
+        else
+          {
+            curr_lexer->current_input_column++;
+
+            curr_lexer->looking_at_function_handle++;
+            curr_lexer->looking_for_object_index = false;
+            curr_lexer->at_beginning_of_statement = false;
+
+            return curr_lexer->count_token ('@');
+          }
       }
   }
 
--- a/test/parser.tst	Tue Feb 18 21:56:05 2014 +0100
+++ b/test/parser.tst	Thu Feb 20 11:52:58 2014 -0500
@@ -287,3 +287,10 @@
 %! a = [97 ... % comment
 %!      'b'];
 %! assert (a, 'ab');
+
+## Check that a cell array containing function handles is parsed
+## correctly with or without commas.
+%!test
+%! a = {1, @sin, 2, @cos};
+%! b = {1 @sin 2 @cos};
+%! assert (a, b)