diff options
author | Erik Troan <ewt@src.gnome.org> | 1998-10-21 20:31:24 +0000 |
---|---|---|
committer | Erik Troan <ewt@src.gnome.org> | 1998-10-21 20:31:24 +0000 |
commit | f868a66144258f0c113c8a64b37270f6ef9c8c5a (patch) | |
tree | e3026dd4cf6effdaec8fc8d6506c2b0e27897c2a /support | |
parent | ff539f09e315b9bb4e070e88b748f1802acb5a1e (diff) | |
download | shared-mime-info-f868a66144258f0c113c8a64b37270f6ef9c8c5a.tar.gz |
added POPT_ARGFLAG_ONEDASH
svn path=/trunk/; revision=449
Diffstat (limited to 'support')
-rw-r--r-- | support/popt-gnome.h | 2 | ||||
-rw-r--r-- | support/popt.c | 27 | ||||
-rw-r--r-- | support/popt.h | 2 |
3 files changed, 21 insertions, 10 deletions
diff --git a/support/popt-gnome.h b/support/popt-gnome.h index aee7ccbd..64c7b806 100644 --- a/support/popt-gnome.h +++ b/support/popt-gnome.h @@ -19,7 +19,7 @@ to callback, descrip points to callback data to pass */ #define POPT_ARG_MASK 0x0000FFFF -#define POPT_ARGFLAG_MULTIPLE 0x80000000 +#define POPT_ARGFLAG_ONEDASH 0x80000000 /* allow -longoption */ #define POPT_ERROR_NOARG -10 #define POPT_ERROR_BADOPT -11 diff --git a/support/popt.c b/support/popt.c index a8367105..be9a1810 100644 --- a/support/popt.c +++ b/support/popt.c @@ -211,7 +211,8 @@ static const struct poptOption * findOption(const struct poptOption * table, const char * longName, const char shortName, poptCallbackType * callback, - void ** callbackData) { + void ** callbackData, + int singleDash) { const struct poptOption * opt = table; const struct poptOption * opt2; const struct poptOption * cb = NULL; @@ -219,11 +220,12 @@ static const struct poptOption * findOption(const struct poptOption * table, while (opt->longName || opt->shortName || opt->arg) { if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_INCLUDE_TABLE) { opt2 = findOption(opt->arg, longName, shortName, callback, - callbackData); + callbackData, singleDash); if (opt2) return opt2; } else if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_CALLBACK) { cb = opt; } else if (longName && opt->longName && + (!singleDash || (opt->argInfo & POPT_ARGFLAG_ONEDASH)) && !strcmp(longName, opt->longName)) { break; } else if (shortName && shortName == opt->shortName) { @@ -255,6 +257,7 @@ int poptGetNextOpt(poptContext con) { int i; poptCallbackType cb; void * cbData; + int singleDash; while (!done) { while (!con->os->nextCharArg && con->os->next == con->os->argc @@ -287,8 +290,12 @@ int poptGetNextOpt(poptContext con) { if (optString[1] == '-' && !optString[2]) { con->restLeftover = 1; continue; - } else if (optString[1] == '-') { - optString += 2; + } else { + optString++; + if (*optString == '-') + singleDash = 0, optString++; + else + singleDash = 1; if (handleAlias(con, optString, '\0', NULL)) continue; @@ -302,9 +309,12 @@ int poptGetNextOpt(poptContext con) { *chptr = '\0'; } - opt = findOption(con->options, optString, '\0', &cb, &cbData); - if (!opt) return POPT_ERROR_BADOPT; - } else + opt = findOption(con->options, optString, '\0', &cb, &cbData, + singleDash); + if (!opt && !singleDash) return POPT_ERROR_BADOPT; + } + + if (!opt) con->os->nextCharArg = origOptString + 1; } @@ -321,7 +331,8 @@ int poptGetNextOpt(poptContext con) { if (handleExec(con, NULL, *origOptString)) continue; - opt = findOption(con->options, NULL, *origOptString, &cb, &cbData); + opt = findOption(con->options, NULL, *origOptString, &cb, + &cbData, 0); if (!opt) return POPT_ERROR_BADOPT; origOptString++; diff --git a/support/popt.h b/support/popt.h index aee7ccbd..64c7b806 100644 --- a/support/popt.h +++ b/support/popt.h @@ -19,7 +19,7 @@ to callback, descrip points to callback data to pass */ #define POPT_ARG_MASK 0x0000FFFF -#define POPT_ARGFLAG_MULTIPLE 0x80000000 +#define POPT_ARGFLAG_ONEDASH 0x80000000 /* allow -longoption */ #define POPT_ERROR_NOARG -10 #define POPT_ERROR_BADOPT -11 |