Create defaults for the boolean negator argument

This commit is contained in:
Nick Chambers 2022-07-02 19:18:13 -05:00
parent 6ed142ebbe
commit a9b18e4e6f
2 changed files with 7 additions and 2 deletions

View File

@ -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);

View File

@ -4,6 +4,11 @@
#include <stdlib.h>
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);