[geany/geany] f1e88c: Ruby parser: don't create an extra scope after "for .. in .. do"

Colomban Wendling git-noreply at xxxxx
Thu Sep 13 14:34:18 UTC 2012


Branch:      refs/heads/master
Author:      Colomban Wendling <ban at herbesfolles.org>
Committer:   Colomban Wendling <ban at herbesfolles.org>
Date:        Thu, 13 Sep 2012 14:34:18
Commit:      f1e88ca311af3c3ced49f4b348d88140a74302b0
             https://github.com/geany/geany/commit/f1e88ca311af3c3ced49f4b348d88140a74302b0

Log Message:
-----------
Ruby parser: don't create an extra scope after "for .. in .. do"

When "do" appears as the separator after a "for", "while" or "until"
construct, don't improperly make it start its own scope too.


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

Modified: tagmanager/ctags/ruby.c
26 files changed, 23 insertions(+), 3 deletions(-)
===================================================================
@@ -287,6 +287,9 @@ static void findRubyTags (void)
 	while ((line = fileReadLine ()) != NULL)
 	{
 		const unsigned char *cp = line;
+		/* if we expect a separator after a while, for, or until statement
+		 * separators are "do", ";" or newline */
+		boolean expect_separator = FALSE;
 
 		if (canMatch (&cp, "=begin"))
 		{
@@ -318,10 +321,15 @@ static void findRubyTags (void)
 		*   puts("hello") \
 		*       unless <exp>
 		*/
-		if (canMatch (&cp, "case") || canMatch (&cp, "for") ||
-			canMatch (&cp, "if") || canMatch (&cp, "unless") ||
+		if (canMatch (&cp, "for") || canMatch (&cp, "until") ||
 			canMatch (&cp, "while"))
 		{
+			expect_separator = TRUE;
+			enterUnnamedScope ();
+		}
+		else if (canMatch (&cp, "case") || canMatch (&cp, "if") ||
+				 canMatch (&cp, "unless"))
+		{
 			enterUnnamedScope ();
 		}
 
@@ -362,10 +370,17 @@ static void findRubyTags (void)
 				*/
 				break;
 			}
-			else if (canMatch (&cp, "begin") || canMatch (&cp, "do"))
+			else if (canMatch (&cp, "begin"))
 			{
 				enterUnnamedScope ();
 			}
+			else if (canMatch (&cp, "do"))
+			{
+				if (! expect_separator)
+					enterUnnamedScope ();
+				else
+					expect_separator = FALSE;
+			}
 			else if (canMatch (&cp, "end") && stringListCount (nesting) > 0)
 			{
 				/* Leave the most recent scope. */
@@ -383,6 +398,11 @@ static void findRubyTags (void)
 				if (*cp == '"')
 				    cp++; /* skip the last found '"' */
 			}
+			else if (*cp == ';')
+			{
+				++cp;
+				expect_separator = FALSE;
+			}
 			else if (*cp != '\0')
 			{
 				do


@@ Diff output truncated at 100000 characters. @@


--------------
This E-Mail was brought to you by github_commit_mail.py (Source: TBD).



More information about the Commits mailing list