}
static void invokeCallbacksPRE(poptContext con, const struct poptOption * opt)
+ /*@modifies internalState@*/
{
if (opt != NULL)
for (; opt->longName || opt->shortName || opt->arg; opt++) {
}
static void invokeCallbacksPOST(poptContext con, const struct poptOption * opt)
+ /*@modifies internalState@*/
{
if (opt != NULL)
for (; opt->longName || opt->shortName || opt->arg; opt++) {
const struct poptOption * opt,
const struct poptOption * myOpt,
/*@null@*/ const void * myData, int shorty)
+ /*@modifies internalState@*/
{
const struct poptOption * cbopt = NULL;
if (name) {
char * t = malloc(strlen(name) + 1);
if (t) con->appName = strcpy(t, name);
- }
+ }
invokeCallbacksPRE(con, con->options);
return con;
}
-static void cleanOSE(struct optionStackEntry *os)
+static void cleanOSE(/*@special@*/ struct optionStackEntry *os)
+ /*@uses os @*/
+ /*@releases os->nextArg, os->argv, os->argb @*/
{
os->nextArg = _free(os->nextArg);
os->argv = _free(os->argv);
/*@=nullstate@*/
}
-/* Only one of longName, shortName may be set at a time */
-static int handleExec(poptContext con, /*@null@*/ const char * longName,
- char shortName)
+/* Only one of longName, shortName should be set, not both. */
+static int handleExec(/*@special@*/ poptContext con,
+ /*@null@*/ const char * longName, char shortName)
+ /*@uses con->execs, con->numExecs, con->flags, con->doExec,
+ con->finalArgv, con->finalArgvAlloced, con->finalArgvCount @*/
{
int i;
}
/* Only one of longName, shortName may be set at a time */
-static int handleAlias(poptContext con,
+static int handleAlias(/*@special@*/ poptContext con,
/*@null@*/ const char * longName, char shortName,
/*@keep@*/ /*@null@*/ const char * nextCharArg)
+ /*@uses con->aliases, con->numAliases, con->optionStack,
+ con->os, con->os->currAlias, con->os->currAlias->longName @*/
{
int rc;
int i;
}
if (con->leftovers != NULL && con->numLeftovers > 0) {
+#if 0
argv[argc++] = "--";
+#endif
memcpy(argv + argc, con->leftovers, sizeof(*argv) * con->numLeftovers);
argc += con->numLeftovers;
}
if (opt2 == NULL) continue;
/* Sub-table data will be inheirited if no data yet. */
if (!(callback && *callback)) return opt2;
- if (!(callbackData && *callback == NULL)) return opt2;
+ if (!(callbackData && *callbackData == NULL)) return opt2;
/*@-observertrans -dependenttrans @*/
*callbackData = opt->descrip;
/*@=observertrans =dependenttrans @*/
return opt;
}
-static const char * findNextArg(poptContext con, unsigned argx, int delete)
- /*@modifies con @*/
+static const char * findNextArg(/*@special@*/ poptContext con,
+ unsigned argx, int delete)
+ /*@uses con->optionStack, con->os,
+ con->os->next, con->os->argb, con->os->argc, con->os->argv @*/
{
struct optionStackEntry * os = con->os;
const char * arg;
}
if (os > con->optionStack) os--;
} while (arg == NULL);
- /*@-compdef@*/ /* FIX: con->os->argv undefined */
return arg;
- /*@=compdef@*/
}
static /*@only@*/ /*@null@*/ const char *
-expandNextArg(poptContext con, const char * s)
+expandNextArg(/*@special@*/ poptContext con, const char * s)
+ /*@uses con->optionStack, con->os,
+ con->os->next, con->os->argb, con->os->argc, con->os->argv @*/
/*@modifies con @*/
{
- const char *a;
+ const char * a = NULL;
size_t alen;
char *t, *te;
size_t tn = strlen(s) + 1;
case '!':
if (!(s[0] == '#' && s[1] == ':' && s[2] == '+'))
break;
- if ((a = findNextArg(con, 1, 1)) == NULL)
- break;
+ /* XXX Make sure that findNextArg deletes only next arg. */
+ if (a == NULL) {
+ if ((a = findNextArg(con, 1, 1)) == NULL) break;
+ }
s += 3;
alen = strlen(a);
}
static void poptStripArg(poptContext con, int which)
+ /*@modifies con @*/
{
if (con->arg_strip == NULL)
con->arg_strip = PBM_ALLOC(con->optionStack[0].argc);
}
static int poptSaveLong(const struct poptOption * opt, long aLong)
+ /*@modifies opt->arg @*/
{
if (opt->arg == NULL)
return POPT_ERROR_NULLARG;
}
static int poptSaveInt(const struct poptOption * opt, long aLong)
+ /*@modifies opt->arg @*/
{
if (opt->arg == NULL)
return POPT_ERROR_NULLARG;
/* XXX aliases with arg substitution need "--alias=arg" */
if (handleAlias(con, optString, '\0', NULL))
continue;
+
if (handleExec(con, optString, '\0'))
continue;
/* Process next short option */
if (con->os->nextCharArg) {
- /*@-branchstate@*/ /* FIX: W2DO? */
origOptString = con->os->nextCharArg;
con->os->nextCharArg = NULL;
- if (handleAlias(con, NULL, *origOptString,
- origOptString + 1)) {
+ if (handleAlias(con, NULL, *origOptString, origOptString + 1))
continue;
- }
+
if (handleExec(con, NULL, *origOptString)) {
/* Restore rest of short options for further processing */
origOptString++;
shorty = 1;
origOptString++;
+ /*@-branchstate@*/ /* FIX: W2DO? */
if (*origOptString != '\0')
con->os->nextCharArg = origOptString;
/*@=branchstate@*/
return POPT_ERROR_NOARG;
} else {
- /* make sure this isn't part of a short arg or the
- result of an alias expansion */
+ /*
+ * Make sure this isn't part of a short arg or the
+ * result of an alias expansion.
+ */
if (con->os == con->optionStack &&
(opt->argInfo & POPT_ARGFLAG_STRIP) &&
canstrip) {
}
if (con->os->argv != NULL) { /* XXX can't happen */
- longArg =
- expandNextArg(con, con->os->argv[con->os->next]);
+ /* XXX watchout: subtle side-effects live here. */
+ longArg = con->os->argv[con->os->next++];
+ longArg = expandNextArg(con, longArg);
con->os->nextArg = longArg;
- con->os->next++;
}
}
}