mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-20 22:46:22 +00:00
Handle commands with min 0 args
This commit is contained in:
12
src/parser.c
12
src/parser.c
@@ -75,6 +75,12 @@ parse_args(const char * const inp, int min, int max, int *num)
|
||||
*num = 0;
|
||||
return NULL;
|
||||
|
||||
// if min allowed is 0 and 0 found, return empty char* array
|
||||
} else if (min == 0 && *num == 0) {
|
||||
gchar **args = malloc((*num + 1) * sizeof(*args));
|
||||
args[0] = NULL;
|
||||
return args;
|
||||
|
||||
// otherwise return args array
|
||||
} else {
|
||||
gchar **args = malloc((*num + 1) * sizeof(*args));
|
||||
@@ -151,6 +157,12 @@ parse_args_with_freetext(const char * const inp, int min, int max, int *num)
|
||||
*num = 0;
|
||||
return NULL;
|
||||
|
||||
// if min allowed is 0 and 0 found, return empty char* array
|
||||
} else if (min == 0 && *num == 0) {
|
||||
gchar **args = malloc((*num + 1) * sizeof(*args));
|
||||
args[0] = NULL;
|
||||
return args;
|
||||
|
||||
// otherwise return args array
|
||||
} else {
|
||||
gchar **args = malloc((*num + 1) * sizeof(*args));
|
||||
|
||||
@@ -26,5 +26,6 @@
|
||||
#include <glib.h>
|
||||
|
||||
gchar** parse_args(const char * const inp, int min, int max, int *num);
|
||||
gchar** parse_args_with_freetext(const char * const inp, int min, int max, int *num);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user