[geany/geany] 38c561: PHP: leave PHP mode inside single line comments

Colomban Wendling git-noreply at xxxxx
Wed Jul 3 17:42:13 UTC 2013


Branch:      refs/heads/master
Author:      Colomban Wendling <ban at herbesfolles.org>
Committer:   Colomban Wendling <ban at herbesfolles.org>
Date:        Mon, 15 Apr 2013 17:17:57 UTC
Commit:      38c561620046592111b421fb6332f3c37eb1f0a9
             https://github.com/geany/geany/commit/38c561620046592111b421fb6332f3c37eb1f0a9

Log Message:
-----------
PHP: leave PHP mode inside single line comments

If "?>" appears in a single-line PHP comment it leaves PHP mode.
http://www.php.net/manual/en/language.basic-syntax.comments.php


Modified Paths:
--------------
    tagmanager/ctags/php.c

Modified: tagmanager/ctags/php.c
49 files changed, 29 insertions(+), 20 deletions(-)
===================================================================
@@ -505,24 +505,6 @@ static int skipToCharacter (const int c)
 	return d;
 }
 
-static int skipToEndOfLine (void)
-{
-	int c;
-	do
-	{
-		c = fileGetc ();
-		if (c == '\r')
-		{
-			int next = fileGetc ();
-			if (next != '\n')
-				fileUngetc (next);
-			else
-				c = next;
-		}
-	} while (c != EOF && c != '\n' && c != '\r');
-	return c;
-}
-
 static void parseString (vString *const string, const int delimiter)
 {
 	while (TRUE)
@@ -704,6 +686,33 @@ static int findPhpStart (void)
 	return c;
 }
 
+static int skipSingleComment (void)
+{
+	int c;
+	do
+	{
+		c = fileGetc ();
+		if (c == '\r')
+		{
+			int next = fileGetc ();
+			if (next != '\n')
+				fileUngetc (next);
+			else
+				c = next;
+		}
+		/* ?> in single-line comments leaves PHP mode */
+		else if (c == '?')
+		{
+			int next = fileGetc ();
+			if (next == '>')
+				InPhp = FALSE;
+			else
+				fileUngetc (next);
+		}
+	} while (InPhp && c != EOF && c != '\n' && c != '\r');
+	return c;
+}
+
 static void readToken (tokenInfo *const token)
 {
 	int c;
@@ -785,7 +794,7 @@ static void readToken (tokenInfo *const token)
 		}
 
 		case '#': /* comment */
-			skipToEndOfLine ();
+			skipSingleComment ();
 			goto getNextChar;
 			break;
 
@@ -806,7 +815,7 @@ static void readToken (tokenInfo *const token)
 			int d = fileGetc ();
 			if (d == '/') /* single-line comment */
 			{
-				skipToEndOfLine ();
+				skipSingleComment ();
 				goto getNextChar;
 			}
 			else if (d == '*')



--------------
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