1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Use parse_args_with_freetext() for /correct

This commit partly reverts
8f37afcd37
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
This commit is contained in:
Michael Vetter 2020-07-20 15:33:19 +02:00
parent c5c969a929
commit 86281072f9
2 changed files with 3 additions and 3 deletions

View File

@ -2443,7 +2443,7 @@ static struct cmd_t command_defs[] = {
}, },
{ "/correct", { "/correct",
parse_args, 1, -1, NULL, parse_args_with_freetext, 1, 1, NULL,
CMD_NOSUBFUNCS CMD_NOSUBFUNCS
CMD_MAINFUNC(cmd_correct) CMD_MAINFUNC(cmd_correct)
CMD_TAGS( CMD_TAGS(

View File

@ -48,7 +48,7 @@
* *
* inp - The line of input * inp - The line of input
* min - The minimum allowed number of arguments * 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 * Returns - An NULL terminated array of strings representing the arguments
* of the command, or NULL if the validation fails. * 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; int num = g_slist_length(tokens) - 1;
// if num args not valid return NULL // 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_slist_free_full(tokens, free);
g_free(copy); g_free(copy);
*result = FALSE; *result = FALSE;