summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Johnson <johnsonm@src.gnome.org>1998-12-01 19:05:36 +0000
committerMichael Johnson <johnsonm@src.gnome.org>1998-12-01 19:05:36 +0000
commite3e53b0d517fdff2e8780733f0ea74b6d9aa19f1 (patch)
treeeb0f42cd2ff64954b49a1bab8b637787f667cdd0
parent9d053a3da02bd90ecf1e23df7be1e93bd4818ca8 (diff)
downloadgnome-common-e3e53b0d517fdff2e8780733f0ea74b6d9aa19f1.tar.gz
POPT_ARG_VAL appears to work, now that I have a finished test case...
svn path=/trunk/; revision=493
-rw-r--r--support/popt.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/support/popt.c b/support/popt.c
index f9e6153..7dd453d 100644
--- a/support/popt.c
+++ b/support/popt.c
@@ -368,9 +368,11 @@ int poptGetNextOpt(poptContext con) {
con->os->nextCharArg = origOptString;
}
- if (opt->arg && (opt->argInfo & POPT_ARG_MASK) == POPT_ARG_NONE)
+ if (opt->arg && (opt->argInfo & POPT_ARG_MASK) == POPT_ARG_NONE) {
*((int *)opt->arg) = 1;
- else if ((opt->argInfo & POPT_ARG_MASK) != POPT_ARG_NONE) {
+ } else if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_VAL) {
+ if (opt->arg) *((int *) opt->arg) = opt->val;
+ } else if ((opt->argInfo & POPT_ARG_MASK) != POPT_ARG_NONE) {
if (longArg) {
con->os->nextArg = longArg;
} else if (con->os->nextCharArg) {
@@ -392,10 +394,6 @@ int poptGetNextOpt(poptContext con) {
*((char **) opt->arg) = con->os->nextArg;
break;
- case POPT_ARG_VAL:
- *((int *) opt->arg) = opt->val;
- break;
-
case POPT_ARG_INT:
case POPT_ARG_LONG:
aLong = strtol(con->os->nextArg, &end, 0);
@@ -440,7 +438,8 @@ int poptGetNextOpt(poptContext con) {
else
sprintf(con->finalArgv[i], "-%c", opt->shortName);
- if (opt->arg && (opt->argInfo & POPT_ARG_MASK) != POPT_ARG_NONE)
+ if (opt->arg && (opt->argInfo & POPT_ARG_MASK) != POPT_ARG_NONE
+ && (opt->argInfo & POPT_ARG_MASK) != POPT_ARG_VAL)
con->finalArgv[con->finalArgvCount++] = strdup(con->os->nextArg);
}