From e01ae923a15a01245dbe52d5023f9a8db5d17758 Mon Sep 17 00:00:00 2001 From: Colomban Wendling Date: Thu, 20 Nov 2014 15:30:28 +0100 Subject: [PATCH] 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. --- tagmanager/ctags/js.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/tagmanager/ctags/js.c b/tagmanager/ctags/js.c index 99ffcc7b3..9716e43cd 100644 --- a/tagmanager/ctags/js.c +++ b/tagmanager/ctags/js.c @@ -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); -- 2.11.4.GIT