[geany/geany] 6063e0: PHP: Recognize vertical tab (\v) and form-feed (\f) as whitespaces

Colomban Wendling git-noreply at xxxxx
Thu Aug 15 12:51:28 UTC 2013


Branch:      refs/heads/master
Author:      Colomban Wendling <ban at herbesfolles.org>
Committer:   Colomban Wendling <ban at herbesfolles.org>
Date:        Thu, 15 Aug 2013 12:51:28 UTC
Commit:      6063e077c37230d03ca4d7fd1844e9a3dea25a77
             https://github.com/geany/geany/commit/6063e077c37230d03ca4d7fd1844e9a3dea25a77

Log Message:
-----------
PHP: Recognize vertical tab (\v) and form-feed (\f) as whitespaces

Even though PHP doesn't handle those very well (it emits warnings about
"unexpected character"), it still counts them as whitespaces, so
properly handle them as such.


Modified Paths:
--------------
    tagmanager/ctags/php.c
    tests/ctags/Makefile.am
    tests/ctags/whitespaces.php
    tests/ctags/whitespaces.php.tags

Modified: tagmanager/ctags/php.c
18 files changed, 9 insertions(+), 9 deletions(-)
===================================================================
@@ -672,9 +672,15 @@ static keywordId analyzeToken (vString *const name, langType language)
 	return result;
 }
 
+static boolean isSpace (int c)
+{
+	return (c == '\t' || c == ' ' || c == '\v' ||
+			c == '\n' || c == '\r' || c == '\f');
+}
+
 static int skipWhitespaces (int c)
 {
-	while (c == '\t' || c == ' ' || c == '\n' || c == '\r')
+	while (isSpace (c))
 		c = fileGetc ();
 	return c;
 }
@@ -695,10 +701,7 @@ static boolean isOpenScriptLanguagePhp (int c)
 		tolower ((c = fileGetc ()))         != 'i' ||
 		tolower ((c = fileGetc ()))         != 'p' ||
 		tolower ((c = fileGetc ()))         != 't' ||
-		((c = fileGetc ()) != '\t' &&
-		  c                != ' '  &&
-		  c                != '\n' &&
-		  c                != '\r')                ||
+		! isSpace ((c = fileGetc ()))              ||
 		tolower ((c = skipWhitespaces (c))) != 'l' ||
 		tolower ((c = fileGetc ()))         != 'a' ||
 		tolower ((c = fileGetc ()))         != 'n' ||
@@ -806,10 +809,7 @@ static void readToken (tokenInfo *const token)
 	else
 		c = fileGetc ();
 
-	while (c == '\t' || c == ' ' || c == '\n' || c == '\r')
-	{
-		c = fileGetc ();
-	}
+	c = skipWhitespaces (c);
 
 	token->lineNumber   = getSourceLineNumber ();
 	token->filePosition = getInputFilePosition ();


Modified: tests/ctags/Makefile.am
1 files changed, 1 insertions(+), 0 deletions(-)
===================================================================
@@ -231,6 +231,7 @@ test_sources = \
 	traits.php						\
 	union.f							\
 	value.f							\
+	whitespaces.php					\
 	$(NULL)
 test_results = $(test_sources:=.tags)
 


Modified: tests/ctags/whitespaces.php
34 files changed, 34 insertions(+), 0 deletions(-)
===================================================================
@@ -0,0 +1,34 @@
+<?php
+
+function	a	()	{}
+
+function
+b
+()
+{}
+
+functionc(){}
+
+functiond(){}
+
+function
e
()
{}
+
+function f () {}
+
+function	
+
 g	
+  ()	
+  {}
+
+function h(){}
+
+
+/* for live PHP tests */
+var_dump(a());
+var_dump(b());
+var_dump(c());
+var_dump(d());
+var_dump(e());
+var_dump(f());
+var_dump(g());
+var_dump(h());


Modified: tests/ctags/whitespaces.php.tags
9 files changed, 9 insertions(+), 0 deletions(-)
===================================================================
@@ -0,0 +1,9 @@
+# format=tagmanager
+a�16�()�0
+b�16�()�0
+c�16�()�0
+d�16�()�0
+e�16�()�0
+f�16�()�0
+g�16�()�0
+h�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