# HG changeset patch # User Mike Miller # Date 1392906299 18000 # Node ID e4c319ed2414252c4cc6dc35639b6fc2cdf78007 # Parent 477b5916cafe6ac63ba7ef85750b7b5f514074a1 Fix regression, allow space-separated cell array of function handles (bug #41569) * lex.ll ("@"): Unput comma before function handle when after whitespace in an array context. * parser.tst: New test case. diff -r 477b5916cafe -r e4c319ed2414 libinterp/parse-tree/lex.ll --- a/libinterp/parse-tree/lex.ll Thu Feb 20 00:44:14 2014 -0500 +++ b/libinterp/parse-tree/lex.ll Thu Feb 20 09:24:59 2014 -0500 @@ -1099,6 +1099,8 @@ } "@" { + curr_lexer->lexer_debug ("@"); + if (curr_lexer->previous_token_may_be_command () && curr_lexer->space_follows_previous_token ()) { @@ -1107,15 +1109,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 477b5916cafe -r e4c319ed2414 test/parser.tst --- a/test/parser.tst Thu Feb 20 00:44:14 2014 -0500 +++ b/test/parser.tst Thu Feb 20 09:24:59 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)