From a9b18e4e6fe21d0aaf2645bdae0d3fb8933d3c75 Mon Sep 17 00:00:00 2001 From: Nick Chambers Date: Sat, 2 Jul 2022 19:18:13 -0500 Subject: [PATCH] Create defaults for the boolean negator argument --- src/gargoyle.c | 4 ++-- src/scribe.c | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/gargoyle.c b/src/gargoyle.c index 1c8f36d..49c8fe7 100644 --- a/src/gargoyle.c +++ b/src/gargoyle.c @@ -50,7 +50,7 @@ uint8_t gargoyle_digest_argv(uint16_t optc, struct gargoyle_opt *optv, int *argc const char *val = NULL; if(opt->type & GARGOYLE_TYPE_BOOL) { - res = gargoyle_from_bool(opt, brand, "no-", 3, flags); + res = gargoyle_from_bool(opt, brand, NULL, 0, flags); } else if(*(brand + opt->brand_sz) == '=') { val = brand + opt->brand_sz + 1; res = gargoyle_from_rope(opt, val, flags); @@ -95,7 +95,7 @@ uint8_t gargoyle_digest_argv(uint16_t optc, struct gargoyle_opt *optv, int *argc const char *val = NULL; if(opt->type & GARGOYLE_TYPE_BOOL) { - res = gargoyle_from_bool(opt, "", "*", 1, flags); + res = gargoyle_from_bool(opt, "", NULL, 0, flags); } else if(*(idx + 1)) { val = idx + 1; res = gargoyle_from_rope(opt, val, flags); diff --git a/src/scribe.c b/src/scribe.c index 1c55aa4..3f2697f 100644 --- a/src/scribe.c +++ b/src/scribe.c @@ -4,6 +4,11 @@ #include uint8_t gargoyle_from_bool(struct gargoyle_opt *opt, const char *brand, const char *neg, uint16_t neg_sz, gargoyle_flag_type flags) { + if(!neg) { + neg = "no-"; + neg_sz = 3; + } + if(opt->val) { uint8_t *val = opt->val; *val = !gargoyle_cmp(brand, neg, neg_sz, flags);