[geany/geany] b9ca95: JavaScript parser: fix some unterminated statement corner case issues
Colomban Wendling
git-noreply at xxxxx
Mon Sep 24 23:31:11 UTC 2012
Branch: refs/heads/master
Author: Colomban Wendling <ban at herbesfolles.org>
Committer: Colomban Wendling <ban at herbesfolles.org>
Date: Mon, 24 Sep 2012 23:31:11
Commit: b9ca95c381624a288a7ea733624f36a9af10212a
https://github.com/geany/geany/commit/b9ca95c381624a288a7ea733624f36a9af10212a
Log Message:
-----------
JavaScript parser: fix some unterminated statement corner case issues
This fixes parsing of the following unterminated statements:
if () {
foo = 42
}
if () {
foo = new Object()
}
if () {
foo = ({a:1,b:2})
}
Modified Paths:
--------------
tagmanager/ctags/js.c
Modified: tagmanager/ctags/js.c
40 files changed, 25 insertions(+), 15 deletions(-)
===================================================================
@@ -1347,6 +1347,8 @@ static boolean parseStatement (tokenInfo *const token, boolean is_inside_class)
makeJsTag (name, JSTAG_METHOD);
parseBlock (token, name);
}
+ else if (isType (token, TOKEN_CLOSE_CURLY))
+ is_terminated = FALSE;
}
else if (isType (token, TOKEN_OPEN_CURLY))
{
@@ -1441,6 +1443,8 @@ static boolean parseStatement (tokenInfo *const token, boolean is_inside_class)
}
}
}
+ else if (isType (token, TOKEN_CLOSE_CURLY))
+ is_terminated = FALSE;
}
}
else if (isKeyword (token, KEYWORD_NONE))
@@ -1486,23 +1490,29 @@ static boolean parseStatement (tokenInfo *const token, boolean is_inside_class)
}
}
}
- findCmdTerm (token);
- /*
- * Statements can be optionally terminated in the case of
- * statement prior to a close curly brace as in the
- * document.write line below:
- *
- * function checkForUpdate() {
- * if( 1==1 ) {
- * document.write("hello from checkForUpdate<br>")
- * }
- * return 1;
- * }
- */
- if ( ! is_terminated && isType (token, TOKEN_CLOSE_CURLY))
- is_terminated = FALSE;
+ /* if we aren't already at the cmd end, advance to it and check whether
+ * the statement was terminated */
+ 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
+ * document.write line below:
+ *
+ * function checkForUpdate() {
+ * if( 1==1 ) {
+ * document.write("hello from checkForUpdate<br>")
+ * }
+ * return 1;
+ * }
+ */
+ if (isType (token, TOKEN_CLOSE_CURLY))
+ is_terminated = FALSE;
+ }
cleanUp:
vStringCopy(token->scope, saveScope);
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: TBD).
More information about the Commits
mailing list