about summary refs log tree commit diff stats
path: root/src/tools
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@iodoru.org>2020-02-12 14:50:58 +0100
committerMichael Vetter <jubalh@iodoru.org>2020-02-14 10:17:07 +0100
commit8f37afcd37ad8663ca36c13ca7fbc4a431119f73 (patch)
tree31875c3361ed79658ff3bfc2c10ea4ec05a49a16 /src/tools
parent1072cdab0add1389d0ab6667aceecf64e583fcc4 (diff)
downloadprofani-tty-8f37afcd37ad8663ca36c13ca7fbc4a431119f73.tar.gz
xep-0308: Make /correct work without quotation marks
Now we can specify an unlimited amount of arguments for commands.
Maybe this is also helpful for other commands that use quotation marks
so far.
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/parser.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/tools/parser.c b/src/tools/parser.c
index aa739330..fb21571c 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
+ * max - The maximum allowed number of arguments, -1 for infinite
  *
  * 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) || (num > max)) {
+    if ((num < min) || ((max != -1) && (num > max))) {
         g_slist_free_full(tokens, free);
         g_free(copy);
         *result = FALSE;