[geany/geany] e01ae9: javascript: Cleanup `findCmdTerm()` callers a bit

Colomban Wendling git-noreply at xxxxx
Mon Nov 24 01:43:44 UTC 2014


Branch:      refs/heads/master
Author:      Colomban Wendling <ban at herbesfolles.org>
Committer:   Colomban Wendling <ban at herbesfolles.org>
Date:        Mon, 24 Nov 2014 01:43:44 UTC
Commit:      e01ae923a15a01245dbe52d5023f9a8db5d17758
             https://github.com/geany/geany/commit/e01ae923a15a01245dbe52d5023f9a8db5d17758

Log Message:
-----------
javascript: Cleanup `findCmdTerm()` callers a bit

Move the check for unterminated inside `findCmdTerm()` itself and
return it rather than having each caller do it itself.


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

Modified: tagmanager/ctags/js.c
16 lines changed, 6 insertions(+), 10 deletions(-)
===================================================================
@@ -644,7 +644,7 @@ static void addToScope (tokenInfo* const token, vString* const extra)
  *	 Scanning functions
  */
 
-static void findCmdTerm (tokenInfo *const token)
+static boolean findCmdTerm (tokenInfo *const token)
 {
 	/*
 	 * Read until we find either a semicolon or closing brace.
@@ -672,6 +672,8 @@ static void findCmdTerm (tokenInfo *const token)
 			readToken (token);
 		}
 	}
+
+	return isType (token, TOKEN_SEMICOLON);
 }
 
 static void parseSwitch (tokenInfo *const token)
@@ -874,11 +876,9 @@ static boolean parseIf (tokenInfo *const token)
 	}
 	else
 	{
-		findCmdTerm (token);
-
 		/* The next token should only be read if this statement had its own
 		 * terminator */
-		read_next_token = isType (token, TOKEN_SEMICOLON);
+		read_next_token = findCmdTerm (token);
 	}
 	return read_next_token;
 }
@@ -1607,8 +1607,6 @@ static boolean parseStatement (tokenInfo *const token, boolean is_inside_class)
 	if (! isType (token, TOKEN_CLOSE_CURLY) &&
 	    ! isType (token, TOKEN_SEMICOLON))
 	{
-		findCmdTerm (token);
-
 		/*
 		 * Statements can be optionally terminated in the case of
 		 * statement prior to a close curly brace as in the
@@ -1621,8 +1619,7 @@ static boolean parseStatement (tokenInfo *const token, boolean is_inside_class)
 		 *	   return 1;
 		 * }
 		 */
-		if (isType (token, TOKEN_CLOSE_CURLY))
-			is_terminated = FALSE;
+		is_terminated = findCmdTerm (token);
 	}
 
 cleanUp:
@@ -1717,8 +1714,7 @@ static boolean parseLine (tokenInfo *const token, boolean is_inside_class)
 				parseSwitch (token);
 				break;
 			case KEYWORD_return:
-				findCmdTerm (token);
-				is_terminated = isType (token, TOKEN_SEMICOLON);
+				is_terminated = findCmdTerm (token);
 				break;
 			default:
 				is_terminated = parseStatement (token, is_inside_class);



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