[geany/geany] fb7bd3: PHP: Fix parsing of anonymous functions returning a reference
Colomban Wendling
git-noreply at xxxxx
Thu Aug 8 15:27:25 UTC 2013
Branch: refs/heads/master
Author: Colomban Wendling <ban at herbesfolles.org>
Committer: Colomban Wendling <ban at herbesfolles.org>
Date: Thu, 08 Aug 2013 15:27:25 UTC
Commit: fb7bd34592e2905b83aee43c1a396354dfd6867a
https://github.com/geany/geany/commit/fb7bd34592e2905b83aee43c1a396354dfd6867a
Log Message:
-----------
PHP: Fix parsing of anonymous functions returning a reference
Modified Paths:
--------------
tagmanager/ctags/php.c
tests/ctags/Makefile.am
tests/ctags/anonymous_functions.php
tests/ctags/anonymous_functions.php.tags
Modified: tagmanager/ctags/php.c
14 files changed, 8 insertions(+), 6 deletions(-)
===================================================================
@@ -1084,7 +1084,8 @@ static boolean parseTrait (tokenInfo *const token)
* function &myfunc($foo, $bar) {}
*
* if @name is not NULL, parses an anonymous function with name @name
- * $foo = function($foo, $bar) {} */
+ * $foo = function($foo, $bar) {}
+ * $foo = function&($foo, $bar) {} */
static boolean parseFunction (tokenInfo *const token, const tokenInfo *name)
{
boolean readNext = TRUE;
@@ -1092,20 +1093,21 @@ static boolean parseFunction (tokenInfo *const token, const tokenInfo *name)
implType impl = CurrentStatement.impl;
tokenInfo *nameFree = NULL;
+ readToken (token);
+ /* skip a possible leading ampersand (return by reference) */
+ if (token->type == TOKEN_AMPERSAND)
+ readToken (token);
+
if (! name)
{
- readToken (token);
- /* skip a possible leading ampersand (return by reference) */
- if (token->type == TOKEN_AMPERSAND)
- readToken (token);
if (token->type != TOKEN_IDENTIFIER)
return FALSE;
name = nameFree = newToken ();
copyToken (nameFree, token, TRUE);
+ readToken (token);
}
- readToken (token);
if (token->type == TOKEN_OPEN_PAREN)
{
vString *arglist = vStringNew ();
Modified: tests/ctags/Makefile.am
1 files changed, 1 insertions(+), 0 deletions(-)
===================================================================
@@ -13,6 +13,7 @@ test_sources = \
3526726.tex \
68hc11.asm \
angle_bracket.cpp \
+ anonymous_functions.php \
array_ref_and_out.cs \
array_spec.f90 \
array-spec.f90 \
Modified: tests/ctags/anonymous_functions.php
24 files changed, 24 insertions(+), 0 deletions(-)
===================================================================
@@ -0,0 +1,24 @@
+<?php
+
+$a = function() {};
+
+$b = function($x, $y) {};
+
+/* return a value */
+$c = function() {
+ return 42;
+};
+
+/* return a function */
+$d = function() {
+ return function() {
+ return "hello";
+ };
+};
+
+/* return by reference */
+$_g = 42;
+$e = function&() {
+ global $_g;
+ return $_g;
+};
Modified: tests/ctags/anonymous_functions.php.tags
7 files changed, 7 insertions(+), 0 deletions(-)
===================================================================
@@ -0,0 +1,7 @@
+# format=tagmanager
+_g�16384�0
+a�16�()�0
+b�16�($x, $y)�0
+c�16�()�0
+d�16�()�0
+e�16�()�0
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
More information about the Commits
mailing list