Permalink
Browse files

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.
  • Loading branch information...
1 parent 66888d5 commit 297bca3799a99f68d177e1105d79a69a7d9ef103 @b4n b4n committed Sep 24, 2012
Showing with 3 additions and 30 deletions.
  1. +3 −30 tagmanager/ctags/js.c
View
@@ -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;
}

0 comments on commit 297bca3

Please sign in to comment.