Create defaults for the boolean negator argument
This commit is contained in:
parent
6ed142ebbe
commit
a9b18e4e6f
2 changed files with 7 additions and 2 deletions
|
@ -50,7 +50,7 @@ uint8_t gargoyle_digest_argv(uint16_t optc, struct gargoyle_opt *optv, int *argc
|
||||||
const char *val = NULL;
|
const char *val = NULL;
|
||||||
|
|
||||||
if(opt->type & GARGOYLE_TYPE_BOOL) {
|
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) == '=') {
|
} else if(*(brand + opt->brand_sz) == '=') {
|
||||||
val = brand + opt->brand_sz + 1;
|
val = brand + opt->brand_sz + 1;
|
||||||
res = gargoyle_from_rope(opt, val, flags);
|
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;
|
const char *val = NULL;
|
||||||
|
|
||||||
if(opt->type & GARGOYLE_TYPE_BOOL) {
|
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)) {
|
} else if(*(idx + 1)) {
|
||||||
val = idx + 1;
|
val = idx + 1;
|
||||||
res = gargoyle_from_rope(opt, val, flags);
|
res = gargoyle_from_rope(opt, val, flags);
|
||||||
|
|
|
@ -4,6 +4,11 @@
|
||||||
#include <stdlib.h>
|
#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) {
|
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) {
|
if(opt->val) {
|
||||||
uint8_t *val = opt->val;
|
uint8_t *val = opt->val;
|
||||||
*val = !gargoyle_cmp(brand, neg, neg_sz, flags);
|
*val = !gargoyle_cmp(brand, neg, neg_sz, flags);
|
||||||
|
|
Loading…
Reference in a new issue