X-Git-Url: https://git.distorted.org.uk/~mdw/sod/blobdiff_plain/fd040f066b906ce63396b9703bc16d32bcc5204e..016f25e4b5f5edb3b478cd87947b176f871f201c:/lib/keyword.h diff --git a/lib/keyword.h b/lib/keyword.h index 432fbd1..525b31f 100644 --- a/lib/keyword.h +++ b/lib/keyword.h @@ -158,7 +158,7 @@ extern kw_unkhookfn *kw_unkhook; /* Slight hack. The @KWCALL@ macro sets GCC and similar compilers up to * check for a sentinal null pointer at the end of the variable-length * argument tail. Alas, if there are no keywords at all, then the null - * terminator ends up in the @kwfirst_@ argument, and the tail is propetly + * terminator ends up in the @kwfirst_@ argument, and the tail is properly * empty, with the result that the compiler gives an annoying warning. * Supplying an extra argument here is obviously harmless, and makes the * otherwise useful warning go away in this case where it's not wanted. @@ -174,7 +174,7 @@ extern kw_unkhookfn *kw_unkhook; #define K(kw, val) #kw, (val), -/* --- @KW_VALIST@ --- * +/* --- @K_VALIST@ --- * * * Arguments: @va_list ap@ = argument-list extraction state * @@ -184,7 +184,7 @@ extern kw_unkhookfn *kw_unkhook; #define K_VALIST(ap) "kw.valist", &(ap), -/* --- @KW_TAB@ --- * +/* --- @K_TAB@ --- * * * Arguments: @const struct kwval *v@ = base address of argument vector * @size_t n@ = length of argument vector @@ -322,7 +322,8 @@ extern kw_unkhookfn *kw_unkhook; size_t nn; \ \ for (k = kwfirst; k; k = va_arg(*ap, const char *)) { \ - if (!strcmp(k, "kw.valist")) { \ + set##_KWSET(KWSET__ARGVA) \ + /*else*/ if (!strcmp(k, "kw.valist")) { \ aap = va_arg(*ap, va_list *); \ kk = va_arg(*aap, const char *); \ set##_kwparse(kw, kk, aap, 0, 0); \ @@ -330,35 +331,33 @@ extern kw_unkhookfn *kw_unkhook; vv = va_arg(*ap, const struct kwval *); \ nn = va_arg(*ap, size_t); \ set##_kwparse(kw, 0, 0, vv, nn); \ - } \ - set##_KWSET(KWSET__ARGVA) \ - else kw_unknown(#set, k); \ + } else kw_unknown(#set, k); \ } \ \ while (n) { \ - if (!strcmp(v->kw, "kw.valist")) { \ + set##_KWSET(KWSET__ARGTAB) \ + /*else*/ if (!strcmp(v->kw, "kw.valist")) { \ aap = *(va_list *const *)v->val; \ kk = va_arg(*aap, const char *); \ set##_kwparse(kw, kk, aap, 0, 0); \ } else if (!strcmp(v->kw, "kw.tab")) { \ t = (const struct kwtab *)v->val; \ set##_kwparse(kw, 0, 0, t->v, t->n); \ - } \ - set##_KWSET(KWSET__ARGTAB) \ - else kw_unknown(#set, v->kw); \ + } else kw_unknown(#set, v->kw); \ v++; n--; \ } \ } + #define KWSET__ARGVA(type, name, dflt) \ - else if (!strcmp(k, #name)) { \ + if (!strcmp(k, #name)) { \ kw->name##_suppliedp = 1; \ kw->name = va_arg(*ap, type); \ - } + } else #define KWSET__ARGTAB(type, name, dflt) \ - else if (!strcmp(v->kw, #name)) { \ + if (!strcmp(v->kw, #name)) { \ kw->name##_suppliedp = 1; \ kw->name = *(type const *)v->val; \ - } + } else /*----- Defining keyword-accepting functions ------------------------------*/ @@ -471,8 +470,8 @@ extern kw_unkhookfn *kw_unkhook; * Use: Copies arguments from the source structure @kw@ into the * vector @v@. The structure @kw@ must have type @struct * fromset_kwargs *@. The argument @v@ must have type @struct - * kwval *@ (after array-to- pointer decay), and there must be a - * variable @v_n@ of sufficiently large integral type suitably + * kwval *@ (after array-to-pointer decay), and there must be a + * variable @n@ of sufficiently large integral type suitably * initialized. Elements of the vector, starting with element * @n@, will be filled in with those keyword arguments defined * in @toset@ -- which must be a subset of @srcsrc@ from @kw@