# HG changeset patch # User John W. Eaton # Date 1392915178 18000 # Node ID 3cac3d7f003fd243fa4ceaf3e52e442e0ced461d # Parent 3cb0e58a071d62e880da28d938e00bea3149c63c# Parent e4c319ed2414252c4cc6dc35639b6fc2cdf78007 maint: Periodic merge of stable to gui-release. diff -r 3cb0e58a071d -r 3cac3d7f003f doc/interpreter/func.txi --- 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. diff -r 3cb0e58a071d -r 3cac3d7f003f libinterp/corefcn/lu.cc --- 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 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]; diff -r 3cb0e58a071d -r 3cac3d7f003f libinterp/parse-tree/lex.ll --- 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 ('@'); + } } } diff -r 3cb0e58a071d -r 3cac3d7f003f test/parser.tst --- 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)