Compare commits

...

2 Commits

Author SHA1 Message Date
Nick Chambers 941af4e4cd Fix name of variable 2022-07-10 17:20:13 -05:00
Nick Chambers cb257baec0 Remove defaults from utility functions 2022-07-10 17:19:44 -05:00
4 changed files with 4 additions and 14 deletions

View File

@ -32,7 +32,7 @@ uint8_t gargoyle_digest_argv(uint16_t optc, struct gargoyle_optn *optv, int *arg
if(*(arg + 1) == '-') {
const char *brand = arg + 2;
optn = gargoyle_find_brand(optc, optv, brand, NULL, 0, flags);
optn = gargoyle_find_brand(optc, optv, brand, "no-", 3, flags);
if(!optn) {
if(flags & GARGOYLE_FLG_STRCT) {
@ -50,7 +50,7 @@ uint8_t gargoyle_digest_argv(uint16_t optc, struct gargoyle_optn *optv, int *arg
const char *val = NULL;
if(optn->type & GARGOYLE_TYPE_BOOL) {
res = gargoyle_from_bool(optn, brand, NULL, 0, flags);
res = gargoyle_from_bool(optn, brand, "no-", 3, flags);
} else if(*(brand + optn->brand_sz) == '=') {
val = brand + optn->brand_sz + 1;
res = gargoyle_from_rope(optn, val, flags);
@ -95,7 +95,7 @@ uint8_t gargoyle_digest_argv(uint16_t optc, struct gargoyle_optn *optv, int *arg
const char *val = NULL;
if(optn->type & GARGOYLE_TYPE_BOOL) {
res = gargoyle_from_bool(optn, "", NULL, 0, flags);
res = gargoyle_from_bool(optn, "", "*", 1, flags);
} else if(*(idx + 1)) {
val = idx + 1;
res = gargoyle_from_rope(optn, val, flags);

View File

@ -4,11 +4,6 @@
#include <stdlib.h>
uint8_t gargoyle_from_bool(struct gargoyle_optn *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);

View File

@ -5,11 +5,6 @@
#include <stddef.h>
struct gargoyle_optn *gargoyle_find_brand(uint16_t optc, struct gargoyle_optn *optv, const char *brand, const char *neg, uint16_t neg_sz, gargoyle_flag_type flags) {
if(!neg) {
neg = "no-";
neg_sz = 3;
}
for(; optc; optc -= 1, optv += 1) {
const char *idx = brand;

View File

@ -36,7 +36,7 @@ void gargoyle_test_digest_argv(void) {
NULL
};
int argc = sizeof(args) / sizeof(char *);
int argc = sizeof(normal_args) / sizeof(char *);
char **argv = normal_args;
uint8_t res = gargoyle_digest_argv(optc, optv, &argc, &argv, &err, 0);
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);