From 86281072f9b943c23119f1c90cd33934caf1d737 Mon Sep 17 00:00:00 2001 From: Michael Vetter Date: Mon, 20 Jul 2020 15:33:19 +0200 Subject: Use parse_args_with_freetext() for `/correct` This commit partly reverts 8f37afcd37ad8663ca36c13ca7fbc4a431119f73 Which was using a wrong approach to achieve this. It changed parse_args() to have a -1 for infinite parameters. But actually parse_args_with_freetext() should have been used exactly for this behaviour. Discovered when checking for https://github.com/profanity-im/profanity/issues/1404 --- src/command/cmd_defs.c | 2 +- src/tools/parser.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/command/cmd_defs.c b/src/command/cmd_defs.c index c2a6ad18..558b02bd 100644 --- a/src/command/cmd_defs.c +++ b/src/command/cmd_defs.c @@ -2443,7 +2443,7 @@ static struct cmd_t command_defs[] = { }, { "/correct", - parse_args, 1, -1, NULL, + parse_args_with_freetext, 1, 1, NULL, CMD_NOSUBFUNCS CMD_MAINFUNC(cmd_correct) CMD_TAGS( diff --git a/src/tools/parser.c b/src/tools/parser.c index 240d5358..2e1d5c98 100644 --- a/src/tools/parser.c +++ b/src/tools/parser.c @@ -48,7 +48,7 @@ * * inp - The line of input * min - The minimum allowed number of arguments - * max - The maximum allowed number of arguments, -1 for infinite + * max - The maximum allowed number of arguments * * Returns - An NULL terminated array of strings representing the arguments * of the command, or NULL if the validation fails. @@ -135,7 +135,7 @@ parse_args(const char* const inp, int min, int max, gboolean* result) int num = g_slist_length(tokens) - 1; // if num args not valid return NULL - if ((num < min) || ((max != -1) && (num > max))) { + if ((num < min) || (num > max)) { g_slist_free_full(tokens, free); g_free(copy); *result = FALSE; -- cgit 1.4.1-2-gfad0 put type='hidden' name='id' value='a328367eb400012a04b9aac9204c9fab2e2fc583'/>
path: root/apidocs/c/gen.sh
blob: e251843b1f368cc62e6f54de00544a48305c80a2 (plain) (blame)
1