Branch: refs/heads/master Author: Colomban Wendling ban@herbesfolles.org Committer: Colomban Wendling ban@herbesfolles.org Date: Mon, 24 Sep 2012 17:46:48 Commit: 297bca3799a99f68d177e1105d79a69a7d9ef103 https://github.com/geany/geany/commit/297bca3799a99f68d177e1105d79a69a7d9ef1...
Log Message: ----------- JavaScript parser: Don't drop the token after an unbraced if
If an `if` haven't had braces, the code used to check itself for an `else` after it, eating the next token if it wasn't actually an `else`.
So, drop the check for the else altogether since parseLine() handles `else`s by calling parseIf() anyway.
This fixes constructs like:
if (foo) bar(); function baz() { // ... }
Closes #3568542.
Modified Paths: -------------- tagmanager/ctags/js.c
Modified: tagmanager/ctags/js.c 33 files changed, 3 insertions(+), 30 deletions(-) =================================================================== @@ -805,36 +805,9 @@ static boolean parseIf (tokenInfo *const token) { findCmdTerm (token);
- /* - * The IF could be followed by an ELSE statement. - * This too could have two formats, a curly braced - * multiline section, or another single line. - */ - - if (isType (token, TOKEN_CLOSE_CURLY)) - { - /* - * This statement did not have a line terminator. - */ - read_next_token = FALSE; - } - else - { - readToken (token); - - if (isType (token, TOKEN_CLOSE_CURLY)) - { - /* - * This statement did not have a line terminator. - */ - read_next_token = FALSE; - } - else - { - if (isKeyword (token, KEYWORD_else)) - read_next_token = parseIf (token); - } - } + /* The next token should only be read if this statement had its own + * terminator */ + read_next_token = isType (token, TOKEN_SEMICOLON); } return read_next_token; }
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: TBD).