[PATCH 1/2] vbscript: Allow keywords to be used as function name.

Jacek Caban jacek at codeweavers.com
Thu Nov 5 12:30:54 CST 2020



On 10/26/20 11:17 PM, Robert Wilhelm wrote:
> 
> Signed-off-by: Robert Wilhelm <robert.wilhelm at gmx.net>
> ---
>   dlls/vbscript/lex.c          | 10 +++++++++-
>   dlls/vbscript/tests/lang.vbs | 22 ++++++++++++++++++++++
>   2 files changed, 31 insertions(+), 1 deletion(-)
> 
> diff --git a/dlls/vbscript/lex.c b/dlls/vbscript/lex.c
> index 251374d90e6..78fca8271cc 100644
> --- a/dlls/vbscript/lex.c
> +++ b/dlls/vbscript/lex.c
> @@ -99,6 +99,14 @@ static inline BOOL is_identifier_char(WCHAR c)
>       return iswalnum(c) || c == '_';
>   }
> 
> +static BOOL is_identifier( int token)
> +{
> +    if (token == tIdentifier || token == tDEFAULT  || token == tERROR ||
> +        token == tEXPLICIT   || token == tPROPERTY || token == tSTEP)
> +        return TRUE;
> +    return FALSE;
> +}
> +
>   static int check_keyword(parser_ctx_t *ctx, const WCHAR *word, const WCHAR **lval)
>   {
>       const WCHAR *p1 = ctx->ptr;
> @@ -425,7 +433,7 @@ static int parse_next_token(void *lval, unsigned *loc, parser_ctx_t *ctx)
>            * Parser can't predict if bracket is part of argument expression or an argument
>            * in call expression. We predict it here instead.
>            */
> -        if(ctx->last_token == tIdentifier || ctx->last_token == ')')
> +        if(is_identifier(ctx->last_token) || ctx->last_token == ')')

This should work, but I think we'd ideally distinguish if last token was 
actually used as an identifier and have that logic in one place. What do 
you think about something like the attached patch?

Thanks,
Jacek
-------------- next part --------------
A non-text attachment was scrubbed...
Name: vbscript.diff
Type: text/x-diff
Size: 889 bytes
Desc: not available
URL: <http://www.winehq.org/pipermail/wine-devel/attachments/20201105/3d6c6748/attachment.diff>


More information about the wine-devel mailing list