From 79ee95ac529c6c88dae6f7cedb7a46ed9d48b64c Mon Sep 17 00:00:00 2001 From: Masatake YAMATO Date: Tue, 15 Nov 2022 05:54:19 +0900 Subject: [PATCH] PowerShell,refactor: don't use output parameter as input The cross-parser convention of readTags() takes TOKEN as an output parameter. 433c933ad3aa77a35579fc73b361cd026b721baa violates the convention; readTags() refers to a field of TOKEN. This can be a cause of trouble. Signed-off-by: Masatake YAMATO --- parsers/powershell.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/parsers/powershell.c b/parsers/powershell.c index b0e9b4841b..af9f8e2395 100644 --- a/parsers/powershell.c +++ b/parsers/powershell.c @@ -303,7 +303,7 @@ static int skipSingleComment (void) return c; } -static void readToken (tokenInfo *const token) +static void readTokenFull (tokenInfo *const token, bool includingScope) { int c; @@ -408,8 +408,7 @@ static void readToken (tokenInfo *const token) token->type = TOKEN_UNDEFINED; else { - if (token->keyword == KEYWORD_function || - token->keyword == KEYWORD_filter) + if (includingScope) parseScopeIdentifier (token->string, c); else parseIdentifier (token->string, c); @@ -424,6 +423,11 @@ static void readToken (tokenInfo *const token) } } +static void readToken (tokenInfo *const token) +{ + readTokenFull (token, false); +} + static void enterScope (tokenInfo *const parentToken, const vString *const extraScope, const int parentKind); @@ -470,7 +474,7 @@ static bool parseFunction (tokenInfo *const token, int kind) tokenInfo *nameFree = NULL; const char *access; - readToken (token); + readTokenFull (token, true); if (token->type != TOKEN_IDENTIFIER) return false;