diff options
-rw-r--r-- | CHANGES | 1 | ||||
-rw-r--r-- | popt.c | 12 | ||||
-rw-r--r-- | poptint.h | 10 |
3 files changed, 15 insertions, 8 deletions
@@ -1,4 +1,5 @@ 1.13 -> 1.14: + - jbj: poptint.h: add poptSubstituteHelpI18N() to bury the ABI hack. - jbj: start using poptArg and poptArgType() where useful. - jbj: poptint.h: add a poptArgType define for bitfield type abstraction. - jbj: poptint.h: add a poptArg union for opt->arg access without casts. @@ -70,8 +70,7 @@ static void invokeCallbacksPRE(poptContext con, const struct poptOption * opt) poptArg arg = { .ptr = opt->arg }; if (arg.ptr == NULL) continue; /* XXX program error. */ if (poptArgType(opt) == POPT_ARG_INCLUDE_TABLE) { - /* XXX sick hack to preserve pretense of ABI. */ - if (arg.opt == poptHelpOptions) arg.opt = poptHelpOptionsI18N; + poptSubstituteHelpI18N(arg.opt); /* XXX side effects */ /* Recurse on included sub-tables. */ invokeCallbacksPRE(con, arg.opt); } else if (poptArgType(opt) == POPT_ARG_CALLBACK && @@ -94,8 +93,7 @@ static void invokeCallbacksPOST(poptContext con, const struct poptOption * opt) poptArg arg = { .ptr = opt->arg }; if (arg.ptr == NULL) continue; /* XXX program error. */ if (poptArgType(opt) == POPT_ARG_INCLUDE_TABLE) { - /* XXX sick hack to preserve pretense of ABI. */ - if (arg.opt == poptHelpOptions) arg.opt = poptHelpOptionsI18N; + poptSubstituteHelpI18N(arg.opt); /* XXX side effects */ /* Recurse on included sub-tables. */ invokeCallbacksPOST(con, arg.opt); } else if (poptArgType(opt) == POPT_ARG_CALLBACK && @@ -123,8 +121,7 @@ static void invokeCallbacksOPTION(poptContext con, for (; opt->longName || opt->shortName || opt->arg; opt++) { poptArg arg = { .ptr = opt->arg }; if (poptArgType(opt) == POPT_ARG_INCLUDE_TABLE) { - /* XXX sick hack to preserve pretense of ABI. */ - if (arg.opt == poptHelpOptions) arg.opt = poptHelpOptionsI18N; + poptSubstituteHelpI18N(arg.opt); /* XXX side effects */ /* Recurse on included sub-tables. */ if (opt->arg != NULL) /* XXX program error */ invokeCallbacksOPTION(con, opt->arg, myOpt, myData, shorty); @@ -476,8 +473,7 @@ findOption(const struct poptOption * opt, /*@null@*/ const char * longName, int if (poptArgType(opt) == POPT_ARG_INCLUDE_TABLE) { const struct poptOption * opt2; - /* XXX sick hack to preserve pretense of ABI. */ - if (arg.opt == poptHelpOptions) arg.opt = poptHelpOptionsI18N; + poptSubstituteHelpI18N(arg.opt); /* XXX side effects */ /* Recurse on included sub-tables. */ if (arg.ptr == NULL) continue; /* XXX program error */ opt2 = findOption(arg.opt, longName, longNameLen, shortName, callback, @@ -45,17 +45,27 @@ typedef struct { /** \ingroup popt * A union to simplify opt->arg access without casting. */ +/*@-exporttype -fielduse@*/ typedef union poptArg_u { +/*@shared@*/ void * ptr; int * intp; long * longp; const char ** argv; poptCallbackType cb; +/*@shared@*/ poptOption opt; } poptArg; +/*@=exporttype =fielduse@*/ #define poptArgType(opt) ((opt)->argInfo & POPT_ARG_MASK) +/* XXX sick hack to preserve pretense of a popt-1.x ABI. */ +#define poptSubstituteHelpI18N(opt) \ + { /*@-observertrans@*/ \ + if ((opt) == poptHelpOptions) (opt) = poptHelpOptionsI18N; \ + /*@=observertrans@*/ } + struct optionStackEntry { int argc; /*@only@*/ /*@null@*/ |