diff --git a/src/gargoyle.c b/src/gargoyle.c index 78d8de2..8a92c38 100644 --- a/src/gargoyle.c +++ b/src/gargoyle.c @@ -3,7 +3,6 @@ #include #include #include -#include #include uint8_t gargoyle_digest_argv(uint16_t optc, struct gargoyle_opt *optv, int *argc, char ***argv, struct gargoyle_err *err, gargoyle_flag_type flags) { @@ -137,6 +136,8 @@ uint8_t gargoyle_digest_envh(uint16_t optc, struct gargoyle_opt *optv, const cha flags |= GARGOYLE_FLG_ICASE; } + GARGOYLE_NEW_ERR(err); + for(; **envh; *envh += 1) { const char *var = **envh; @@ -149,10 +150,9 @@ uint8_t gargoyle_digest_envh(uint16_t optc, struct gargoyle_opt *optv, const cha if(!opt) { if(flags & GARGOYLE_FLG_STRCT) { - err->code = GARGOYLE_ERR_UNKNOWN_OPT; char *eql = index(brand, '='); - snprintf(err->msg, GARGOYLE_MAX_ERR_SZ, "unknown option %.*s", (int) (eql - brand), brand); - return GARGOYLE_ERR_UNKNOWN_OPT; + GARGOYLE_MK_ERR(err, GARGOYLE_ERR_UNKNOWN_OPT, "unknown variable '%.*s'", (int) (eql - brand), brand); + return err->code; } else { continue; } @@ -167,7 +167,8 @@ uint8_t gargoyle_digest_envh(uint16_t optc, struct gargoyle_opt *optv, const cha } if(res) { - return res; + GARGOYLE_MK_ERR(err, res, "invalid value '%s' for variable '%.*s'", brand + opt->brand_sz + 1, opt->brand_sz, opt->brand); + return err->code; } }