From 7dd414a543ed29246aa23a9cc4d6ba56043cebcb Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Tue, 20 Jul 2021 07:53:59 -0700 Subject: [PATCH] DEFINE: Equals sign is optional for both positional and keyword parameters. Thanks to Frans Houweling for reporting this bug. --- src/language/control/define.c | 4 +--- tests/language/control/define.at | 13 +++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/language/control/define.c b/src/language/control/define.c index cda4c71fa6..48dda4c7af 100644 --- a/src/language/control/define.c +++ b/src/language/control/define.c @@ -160,10 +160,8 @@ cmd_define (struct lexer *lexer, struct dataset *ds UNUSED) p->positional = false; p->name = xasprintf ("!%s", lex_tokcstr (lexer)); lex_get (lexer); - - if (!lex_force_match (lexer, T_EQUALS)) - goto error; } + lex_match (lexer, T_EQUALS); bool saw_default = false; bool saw_arg_type = false; diff --git a/tests/language/control/define.at b/tests/language/control/define.at index 26df856673..9e1483ad82 100644 --- a/tests/language/control/define.at +++ b/tests/language/control/define.at @@ -44,7 +44,7 @@ AT_CLEANUP AT_SETUP([macro expansion - one !TOKENS(1) positional argument]) AT_KEYWORDS([TOKENS]) AT_DATA([define.sps], [dnl -DEFINE !t1(!positional !tokens(1)) t1 (!1) !ENDDEFINE. +DEFINE !t1(!positional=!tokens(1)) t1 (!1) !ENDDEFINE. DEBUG EXPAND. !t1 a. !t1 b. @@ -68,8 +68,8 @@ DEFINE !title(!positional !tokens(1)) !1 !ENDDEFINE. DEFINE !t1(!positional !tokens(1)) t1 (!1) !ENDDEFINE. DEFINE !t2(!positional !tokens(2)) t2 (!1) !ENDDEFINE. -DEFINE !ce(!positional !charend('/')) ce (!1) !ENDDEFINE. -DEFINE !ce2(!positional !charend('(') +DEFINE !ce(!positional=!charend('/')) ce (!1) !ENDDEFINE. +DEFINE !ce2(!positional=!charend('(') /!positional !charend(')')) ce2 (!1, !2) !ENDDEFINE. @@ -275,7 +275,7 @@ AT_CLEANUP AT_SETUP([keyword macro argument name with ! prefix]) AT_DATA([define.sps], [dnl -DEFINE !macro(!x=!TOKENS(1). +DEFINE !macro(!x !TOKENS(1). ]) AT_CHECK([pspp -O format=csv define.sps], [1], [dnl "define.sps:1.15-1.16: error: DEFINE: Syntax error at `!x': Keyword macro parameter must be named in definition without ""!"" prefix." @@ -315,7 +315,7 @@ AT_CLEANUP AT_SETUP([macro expansion - one !TOKENS(1) keyword argument - negative]) AT_KEYWORDS([TOKENS]) AT_DATA([define.sps], [dnl -DEFINE !k(arg1 = !TOKENS(1)) k(!arg1) !ENDDEFINE. +DEFINE !k(arg1 !TOKENS(1)) k(!arg1) !ENDDEFINE. DEBUG EXPAND. !k arg1. !k arg1=. @@ -1964,7 +1964,8 @@ define.sps:6.10: error: DEFINE: Syntax error at `y': expecting `@{:@'. define.sps:7.15: error: DEFINE: Syntax error at `1': expecting identifier. -define.sps:8.17: error: DEFINE: Syntax error at `2': expecting `='. +define.sps:8.17: error: DEFINE: Syntax error at `2': expecting !TOKENS, ! +CHAREND, !ENCLOSE, or !CMDEND. define.sps:9.26: error: DEFINE: Syntax error at `3': expecting `@{:@'. -- 2.30.2