- (popt): add POPT_ARGFLAG_OPTIONAL for long options with optional arg.

- (popt): diddle auto-help to include type of arg expected.

CVS patchset: 4394
CVS date: 2000/12/31 20:30:37
This commit is contained in:
jbj 2000-12-31 20:30:37 +00:00
parent b9145eabe0
commit 37a87e6f14
39 changed files with 161 additions and 65 deletions

View File

@ -86,6 +86,8 @@
- (python): bind initdb (#20988).
- (popt): fix float/double handling (#19701).
- (popt): non-linux needs <float.h> (#22732).
- (popt): add POPT_ARGFLAG_OPTIONAL for long options with optional arg.
- (popt): diddle auto-help to include type of arg expected.
3.0.6 -> 4.0
- use DIRNAMES/BASENAMES/DIRINDICES not FILENAMES in packages and db.

View File

@ -50,37 +50,37 @@ rpm_LDFLAGS = @LDFLAGS_STATIC@ $(myLDFLAGS)
rpm_LDADD = $(myLDADD) @LIBMISC@
rpmb_SOURCES = build.c
rpmb_LDFLAGS = @LDFLAGS_STATIC@ $(myLDFLAGS)
rpmb_LDFLAGS = $(myLDFLAGS)
rpmb_LDADD = rpmb.o $(myLDADD)
rpmb.o: rpmqv.c
$(COMPILE) -DIAM_RPMBT -o $@ -c $<
rpmdb_SOURCES =
rpmdb_LDFLAGS = @LDFLAGS_STATIC@ $(myLDFLAGS)
rpmdb_LDFLAGS = $(myLDFLAGS)
rpmdb_LDADD = rpmdb.o $(myLDADD)
rpmdb.o: rpmqv.c
$(COMPILE) -DIAM_RPMDB -o $@ -c $<
rpmi_SOURCES =
rpmi_LDFLAGS = @LDFLAGS_STATIC@ $(myLDFLAGS)
rpmi_LDFLAGS = $(myLDFLAGS)
rpmi_LDADD = rpmi.o $(myLDADD)
rpmi.o: rpmqv.c
$(COMPILE) -DIAM_RPMEIU -o $@ -c $<
rpmk_SOURCES =
rpmk_LDFLAGS = @LDFLAGS_STATIC@ $(myLDFLAGS)
rpmk_LDFLAGS = $(myLDFLAGS)
rpmk_LDADD = rpmk.o $(myLDADD)
rpmk.o: rpmqv.c
$(COMPILE) -DIAM_RPMK -o $@ -c $<
rpmq_SOURCES =
rpmq_LDFLAGS = @LDFLAGS_STATIC@ $(myLDFLAGS)
rpmq_LDFLAGS = $(myLDFLAGS)
rpmq_LDADD = rpmq.o $(myLDADD)
rpmq.o: rpmqv.c
$(COMPILE) -DIAM_RPMQV -o $@ -c $<
rpm2cpio_SOURCES = rpm2cpio.c
rpm2cpio_LDFLAGS = @LDFLAGS_STATIC@ $(myLDFLAGS)
rpm2cpio_LDFLAGS = $(myLDFLAGS)
rpm2cpio_LDADD = $(myLDADD) @LIBMISC@
$(PROGRAMS): $(myLDADD) @WITH_APIDOCS_TARGET@

View File

@ -1,7 +1,7 @@
msgid ""
msgstr ""
"Project-Id-Version: popt 1.6.1\n"
"POT-Creation-Date: 2000-12-30 14:24-0500\n"
"POT-Creation-Date: 2000-12-31 15:18-0500\n"
"PO-Revision-Date: 2000-08-23 22:24+0100\n"
"Last-Translator: Milan Kerslager <milan.kerslager@spsselib.hiedu.cz>\n"
"Language-Team: Czech <cs@li.org>\n"

View File

@ -1,7 +1,7 @@
msgid ""
msgstr ""
"Project-Id-Version: popt 1.6.1\n"
"POT-Creation-Date: 2000-12-30 14:24-0500\n"
"POT-Creation-Date: 2000-12-31 15:18-0500\n"
"PO-Revision-Date: 2000-03-07 05:17+01:00\n"
"Last-Translator: K. Christiansen <kenneth@gnu.org>\n"
"Language-Team: Danish/Dansk <dansk@klid.dk>\n"

View File

@ -6,7 +6,7 @@
msgid ""
msgstr ""
"Project-Id-Version: popt 1.6.1\n"
"POT-Creation-Date: 2000-12-30 14:24-0500\n"
"POT-Creation-Date: 2000-12-31 15:18-0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"

View File

@ -6,7 +6,7 @@
msgid ""
msgstr ""
"Project-Id-Version: popt 1.6.1\n"
"POT-Creation-Date: 2000-12-30 14:24-0500\n"
"POT-Creation-Date: 2000-12-31 15:18-0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"

View File

@ -6,7 +6,7 @@
msgid ""
msgstr ""
"Project-Id-Version: popt 1.6.1\n"
"POT-Creation-Date: 2000-12-30 14:24-0500\n"
"POT-Creation-Date: 2000-12-31 15:18-0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"

View File

@ -6,7 +6,7 @@
msgid ""
msgstr ""
"Project-Id-Version: popt 1.6.1\n"
"POT-Creation-Date: 2000-12-30 14:24-0500\n"
"POT-Creation-Date: 2000-12-31 15:18-0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"

View File

@ -10,7 +10,7 @@
msgid ""
msgstr ""
"Project-Id-Version: popt 1.6.1\n"
"POT-Creation-Date: 2000-12-30 14:24-0500\n"
"POT-Creation-Date: 2000-12-31 15:18-0500\n"
"PO-Revision-Date: 2000-01-06 20:31+0100\n"
"Last-Translator: Jesús Bravo Álvarez <jba@pobox.com>\n"
"Language-Team: Galician <gpul-traduccion@ceu.fi.udc.es>\n"

View File

@ -1,7 +1,7 @@
msgid ""
msgstr ""
"Project-Id-Version: popt 1.6.1\n"
"POT-Creation-Date: 2000-12-30 14:24-0500\n"
"POT-Creation-Date: 2000-12-31 15:18-0500\n"
"PO-Revision-Date: 2000-08-03 23:26+0200\n"
"Last-Translator: László Németh <nemeth@qwertynet.hu>\n"
"Language-Team: Hungarian\n"

View File

@ -6,7 +6,7 @@
msgid ""
msgstr ""
"Project-Id-Version: popt 1.6.1\n"
"POT-Creation-Date: 2000-12-30 14:24-0500\n"
"POT-Creation-Date: 2000-12-31 15:18-0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"

View File

@ -1,7 +1,7 @@
msgid ""
msgstr ""
"Project-Id-Version: popt 1.6.1\n"
"POT-Creation-Date: 2000-12-30 14:24-0500\n"
"POT-Creation-Date: 2000-12-31 15:18-0500\n"
"PO-Revision-Date: 2000-06-16 02:12+0000\n"
"Last-Translator: Richard Allen <ra@hp.is>\n"
"Language-Team: is <kde-isl@mmedia.is>\n"

View File

@ -6,7 +6,7 @@
msgid ""
msgstr ""
"Project-Id-Version: popt 1.6.1\n"
"POT-Creation-Date: 2000-12-30 14:24-0500\n"
"POT-Creation-Date: 2000-12-31 15:18-0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"

View File

@ -6,7 +6,7 @@
msgid ""
msgstr ""
"Project-Id-Version: popt 1.6.1\n"
"POT-Creation-Date: 2000-12-30 14:24-0500\n"
"POT-Creation-Date: 2000-12-31 15:18-0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"

View File

@ -6,7 +6,7 @@
msgid ""
msgstr ""
"Project-Id-Version: popt 1.6.1\n"
"POT-Creation-Date: 2000-12-30 14:24-0500\n"
"POT-Creation-Date: 2000-12-31 15:18-0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"

View File

@ -1,7 +1,7 @@
msgid ""
msgstr ""
"Project-Id-Version: popt 1.6.1\n"
"POT-Creation-Date: 2000-12-30 14:24-0500\n"
"POT-Creation-Date: 2000-12-31 15:18-0500\n"
"PO-Revision-Date: 2000-06-21 16:11+02:00\n"
"Last-Translator: Kjartan Maraas <kmaraas@online.no>\n"
"Language-Team: Norwegian <no@li.org>\n"

View File

@ -6,7 +6,7 @@
msgid ""
msgstr ""
"Project-Id-Version: popt 1.6.1\n"
"POT-Creation-Date: 2000-12-30 14:24-0500\n"
"POT-Creation-Date: 2000-12-31 15:18-0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"

View File

@ -6,7 +6,7 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2000-12-30 14:24-0500\n"
"POT-Creation-Date: 2000-12-31 15:18-0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"

View File

@ -1,7 +1,7 @@
msgid ""
msgstr ""
"Project-Id-Version: popt 1.6.1\n"
"POT-Creation-Date: 2000-12-30 14:24-0500\n"
"POT-Creation-Date: 2000-12-31 15:18-0500\n"
"PO-Revision-Date: 2000-06-22 01:02+01:00\n"
"Last-Translator: Pedro Morais <morais@kde.org>\n"
"Language-Team: pt <morais@kde.org>\n"

View File

@ -6,7 +6,7 @@
msgid ""
msgstr ""
"Project-Id-Version: popt 1.6.1\n"
"POT-Creation-Date: 2000-12-30 14:24-0500\n"
"POT-Creation-Date: 2000-12-31 15:18-0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"

View File

@ -1,7 +1,7 @@
msgid ""
msgstr ""
"Project-Id-Version: popt 1.6.1\n"
"POT-Creation-Date: 2000-12-30 14:24-0500\n"
"POT-Creation-Date: 2000-12-31 15:18-0500\n"
"PO-Revision-Date: 2000-06-14 23:23+EST\n"
"Last-Translator: Cristian Gafton <gafton@redhat.com>\n"
"Language-Team: Romanian <ro@li.org>\n"

View File

@ -1,7 +1,7 @@
msgid ""
msgstr ""
"Project-Id-Version: popt 1.6.1\n"
"POT-Creation-Date: 2000-12-30 14:24-0500\n"
"POT-Creation-Date: 2000-12-31 15:18-0500\n"
"PO-Revision-Date: 2000-08-13 21:00+0300\n"
"Last-Translator: Leon Kanter <leon@blackcatlinux.com>\n"
"Language-Team: Black Cat Linux Team <blackcat-support@blackcatlinux.com>\n"

View File

@ -5,7 +5,7 @@
msgid ""
msgstr ""
"Project-Id-Version: popt 1.6.1\n"
"POT-Creation-Date: 2000-12-30 14:24-0500\n"
"POT-Creation-Date: 2000-12-31 15:18-0500\n"
"PO-Revision-Date: 1999-08-04 21:40+0200\n"
"Last-Translator: Stanislav Meduna <stano@eunet.sk>\n"
"Language-Team: Slovak <sk-i18n@rak.isternet.sk>\n"

View File

@ -1,7 +1,7 @@
msgid ""
msgstr ""
"Project-Id-Version: popt 1.6.1\n"
"POT-Creation-Date: 2000-12-30 14:24-0500\n"
"POT-Creation-Date: 2000-12-31 15:18-0500\n"
"PO-Revision-Date: 2000-09-05 12:30+0200\n"
"Last-Translator: Roman Maurer <roman.maurer@hermes.si>\n"
"Language-Team: Slovenian <sl@li.org>\n"

View File

@ -6,7 +6,7 @@
msgid ""
msgstr ""
"Project-Id-Version: popt 1.6.1\n"
"POT-Creation-Date: 2000-12-30 14:24-0500\n"
"POT-Creation-Date: 2000-12-31 15:18-0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"

View File

@ -1,7 +1,7 @@
msgid ""
msgstr ""
"Project-Id-Version: popt 1.6.1\n"
"POT-Creation-Date: 2000-12-30 14:24-0500\n"
"POT-Creation-Date: 2000-12-31 15:18-0500\n"
"PO-Revision-Date: 2000-06-20 00:07+0200\n"
"Last-Translator: Christian Rose <menthos@menthos.com>\n"
"Language-Team: Swedish <sv@li.org>\n"

View File

@ -1,7 +1,7 @@
msgid ""
msgstr ""
"Project-Id-Version: popt 1.6.1\n"
"POT-Creation-Date: 2000-12-30 14:24-0500\n"
"POT-Creation-Date: 2000-12-31 15:18-0500\n"
"PO-Revision-Date: 2000-01-06 13:01+0100\n"
"Last-Translator: Görkem Çetin <kabalak@gmx.net>\n"
"Language-Team: Gelecek A.Þ <gorkem@gelecek.com.tr>\n"

View File

@ -5,7 +5,7 @@
msgid ""
msgstr ""
"Project-Id-Version: popt 1.6.1\n"
"POT-Creation-Date: 2000-12-30 14:24-0500\n"
"POT-Creation-Date: 2000-12-31 15:18-0500\n"
"PO-Revision-Date: 1999-09-30 16:54+0200\n"
"Last-Translator: Yuri Syrota <rasta@renome.rovno.ua>\n"
"Language-Team: Ukrainian <uk@li.org>\n"

View File

@ -9,7 +9,7 @@
msgid ""
msgstr ""
"Project-Id-Version: popt 1.6.1\n"
"POT-Creation-Date: 2000-12-30 14:24-0500\n"
"POT-Creation-Date: 2000-12-31 15:18-0500\n"
"PO-Revision-Date: 1999-03-18 23:11+0100\n"
"Last-Translator: Nobody yet\n"
"Language-Team: walon <linux-wa@chanae.alphanet.ch>\n"

View File

@ -6,7 +6,7 @@
msgid ""
msgstr ""
"Project-Id-Version: popt 1.6.1\n"
"POT-Creation-Date: 2000-12-30 14:24-0500\n"
"POT-Creation-Date: 2000-12-31 15:18-0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"

View File

@ -1,7 +1,7 @@
msgid ""
msgstr ""
"Project-Id-Version: popt 1.6.1\n"
"POT-Creation-Date: 2000-12-30 14:24-0500\n"
"POT-Creation-Date: 2000-12-31 15:18-0500\n"
"PO-Revision-Date: 1999-11-11 05:04+0800\n"
"Last-Translator: Dillion Chen <dillon.chen@turbolinux.com.cn>\n"
"Language-Team: TLDN\n"

View File

@ -169,6 +169,12 @@ specified to win; for example, "rm -i -f". \fBPOPT_ARG_VAL\fP causes
the parsing function not to return a value, since the value of \fIval\fP
has already been used.
.sp
If the \fIargInfo\fR value is bitwise or'd with \fBPOPT_ARGFLAG_OPTIONAL\fR,
the argument to the long option may be omitted. If the long option
is used without an argument, a default value of zero or NULL will be saved
(if the arg pointer is present), otherwise behavior will be identical to
a long option with argument.
.sp
.RI "The next option, " val ", is the value popt's parsing function
should return when the option is encountered. If it is 0, the parsing
function does not return a value, instead parsing the next

View File

@ -674,35 +674,43 @@ int poptGetNextOpt(poptContext con)
con->os > con->optionStack) {
cleanOSE(con->os--);
}
if (con->os->next == con->os->argc)
return POPT_ERROR_NOARG;
if (con->os->next == con->os->argc) {
if (opt->argInfo & POPT_ARGFLAG_OPTIONAL)
con->os->nextArg = NULL;
else
return POPT_ERROR_NOARG;
} else {
/* 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) {
poptStripArg(con, con->os->next);
}
/* 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) {
poptStripArg(con, con->os->next);
}
con->os->nextArg = expandNextArg(con, con->os->argv[con->os->next++]);
con->os->nextArg = expandNextArg(con, con->os->argv[con->os->next++]);
}
}
if (opt->arg) {
switch (opt->argInfo & POPT_ARG_MASK) {
case POPT_ARG_STRING:
/* XXX memory leak, hard to plug */
*((const char **) opt->arg) = xstrdup(con->os->nextArg);
*((const char **) opt->arg) = (con->os->nextArg)
? xstrdup(con->os->nextArg) : NULL;
break;
case POPT_ARG_INT:
case POPT_ARG_LONG:
{ long aLong;
{ long aLong = 0;
char *end;
aLong = strtol(con->os->nextArg, &end, 0);
if (!(end && *end == '\0'))
return POPT_ERROR_BADNUMBER;
if (con->os->nextArg) {
aLong = strtol(con->os->nextArg, &end, 0);
if (!(end && *end == '\0'))
return POPT_ERROR_BADNUMBER;
}
if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_LONG) {
if (aLong == LONG_MIN || aLong == LONG_MAX)
@ -719,12 +727,14 @@ int poptGetNextOpt(poptContext con)
case POPT_ARG_FLOAT:
case POPT_ARG_DOUBLE:
{ double aDouble;
{ double aDouble = 0.0;
char *end;
aDouble = strtod(con->os->nextArg, &end);
if (*end)
return POPT_ERROR_BADNUMBER;
if (con->os->nextArg) {
aDouble = strtod(con->os->nextArg, &end);
if (*end)
return POPT_ERROR_BADNUMBER;
}
if (aDouble == +HUGE_VAL || aDouble == -HUGE_VAL)
return POPT_ERROR_OVERFLOW;
@ -778,7 +788,9 @@ int poptGetNextOpt(poptContext con)
else if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_VAL)
/*@-ifempty@*/ ;
else if ((opt->argInfo & POPT_ARG_MASK) != POPT_ARG_NONE) {
con->finalArgv[con->finalArgvCount++] = xstrdup(con->os->nextArg);
if (con->os->nextArg)
con->finalArgv[con->finalArgvCount++] =
xstrdup(con->os->nextArg);
}
}

View File

@ -37,7 +37,8 @@ extern "C" {
#define POPT_ARG_MASK 0x0000FFFF
#define POPT_ARGFLAG_ONEDASH 0x80000000 /* allow -longoption */
#define POPT_ARGFLAG_DOC_HIDDEN 0x40000000 /* don't show in help/usage */
#define POPT_ARGFLAG_STRIP 0x20000000 /* strip this arg from argv (only applies to long args) */
#define POPT_ARGFLAG_STRIP 0x20000000 /* strip this arg from argv(only applies to long args) */
#define POPT_ARGFLAG_OPTIONAL 0x10000000 /* arg may be missing */
#define POPT_ARGFLAG_OR 0x08000000 /* arg will be or'ed */
#define POPT_ARGFLAG_NOR 0x09000000 /* arg will be nor'ed */

View File

@ -54,7 +54,17 @@ getArgDescrip(const struct poptOption * opt, const char *translation_domain)
if (opt->argDescrip) return POPT_(opt->argDescrip);
if (opt->argDescrip) return D_(translation_domain, opt->argDescrip);
return POPT_("ARG");
switch (opt->argInfo & POPT_ARG_MASK) {
case POPT_ARG_NONE: return POPT_("NONE");
case POPT_ARG_VAL: return POPT_("VAL");
case POPT_ARG_INT: return POPT_("INT");
case POPT_ARG_LONG: return POPT_("LONG");
case POPT_ARG_STRING: return POPT_("STRING");
case POPT_ARG_FLOAT: return POPT_("FLOAT");
case POPT_ARG_DOUBLE: return POPT_("DOUBLE");
default: return POPT_("ARG");
}
}
static void singleOptionHelp(FILE * f, int maxLeftCol,
@ -70,18 +80,60 @@ static void singleOptionHelp(FILE * f, int maxLeftCol,
const char * argDescrip = getArgDescrip(opt, translation_domain);
left = malloc(maxLeftCol + 1);
*left = '\0';
left[0] = left[maxLeftCol] = '\0';
if (opt->longName && opt->shortName)
sprintf(left, "-%c, --%s", opt->shortName, opt->longName);
snprintf(left, maxLeftCol, "-%c, --%s", opt->shortName, opt->longName);
else if (opt->shortName)
sprintf(left, "-%c", opt->shortName);
snprintf(left, maxLeftCol, "-%c", opt->shortName);
else if (opt->longName)
sprintf(left, "--%s", opt->longName);
snprintf(left, maxLeftCol, "--%s", opt->longName);
if (!*left) return ;
if (argDescrip) {
strcat(left, "=");
strcat(left, argDescrip);
char * le = left + strlen(left);
int nl = maxLeftCol - (le - left);
if (opt->argInfo & POPT_ARGFLAG_OPTIONAL) {
*le++ = '['; nl--;
}
if (opt->argDescrip == NULL) {
switch (opt->argInfo & POPT_ARG_MASK) {
case POPT_ARG_NONE:
snprintf(le, nl-1, "[true]");
break;
case POPT_ARG_VAL:
{ long aLong = opt->val;
if (opt->argInfo & POPT_ARGFLAG_NOT) aLong = ~aLong;
switch (opt->argInfo & POPT_ARGFLAG_LOGICALOPS) {
case POPT_ARGFLAG_OR:
snprintf(le, nl-1, "[|=0x%lx]", aLong); break;
case POPT_ARGFLAG_AND:
snprintf(le, nl-1, "[&=0x%lx]", aLong); break;
case POPT_ARGFLAG_XOR:
snprintf(le, nl-1, "[^=0x%lx]", aLong); break;
default:
if (!(aLong == 0L || aLong == 1L || aLong == -1L))
snprintf(le, nl-1, "[=%ld]", aLong);
break;
}
} break;
case POPT_ARG_INT:
case POPT_ARG_LONG:
case POPT_ARG_STRING:
case POPT_ARG_FLOAT:
case POPT_ARG_DOUBLE:
snprintf(le, nl-1, "=%s", argDescrip);
break;
}
} else {
snprintf(le, nl-1, "=%s", argDescrip);
}
nl -= strlen(le);
le += strlen(le);
if (opt->argInfo & POPT_ARGFLAG_OPTIONAL) {
*le++ = ']'; nl--;
}
*le = '\0';
}
if (help)

View File

@ -19,6 +19,7 @@ int inc = 0;
int shortopt = 0;
float aFloat = 0.0;
double aDouble = 0.0;
char * oStr = (char *)-1;
int singleDash = 0;
static struct poptOption moreCallbackArgs[] = {
@ -54,6 +55,9 @@ static struct poptOption options[] = {
"A float argument", "FLOAT" },
{ "double", 'd', POPT_ARG_DOUBLE, &aDouble, 0,
"A double argument", "DOUBLE" },
{ "ostr", '\0', POPT_ARG_STRING|POPT_ARGFLAG_OPTIONAL, &oStr, 0,
"An optional str", "ARG" },
{ NULL, '-', POPT_ARG_NONE | POPT_ARGFLAG_DOC_HIDDEN, &singleDash, 0 },
{ NULL, '\0', POPT_ARG_INCLUDE_TABLE, &moreArgs, 0, NULL },
{ NULL, '\0', POPT_ARG_INCLUDE_TABLE, &callbackArgs, 0, "Callback arguments" },
@ -128,6 +132,8 @@ int main(int argc, const char ** argv) {
fprintf(stdout, " aFloat: %g", aFloat);
if (aDouble != 0.0)
fprintf(stdout, " aDouble: %g", aDouble);
if (oStr != (char *)-1)
fprintf(stdout, " oStr: %s", (oStr ? oStr : "(none)"));
if (singleDash)
fprintf(stdout, " -");

View File

@ -62,6 +62,11 @@ run test1 "test1 - 32" "arg1: 0 arg2: (none) aFloat: 10.1" -f 10.1
run test1 "test1 - 33" "arg1: 0 arg2: (none) aFloat: 10.1" --float 10.1
run test1 "test1 - 34" "arg1: 0 arg2: (none) aDouble: 10.1" -d 10.1
run test1 "test1 - 35" "arg1: 0 arg2: (none) aDouble: 10.1" --double 10.1
run test1 "test1 - 36" "arg1: 0 arg2: (none) oStr: (none)" --ostr
run test1 "test1 - 37" "arg1: 0 arg2: (none) oStr: yadda" --ostr=yadda
run test1 "test1 - 38" "arg1: 0 arg2: (none) oStr: yadda" --ostr yadda
run test1 "test1 - 39" "arg1: 0 arg2: (none) oStr: ping rest: pong" --ostr=ping pong
run test1 "test1 - 40" "arg1: 0 arg2: (none) oStr: ping rest: pong" --ostr ping pong
echo ""
echo "Passed."

View File

@ -13,7 +13,7 @@ Summary: The Red Hat package management system.
Name: rpm
%define version 4.0.2
Version: %{version}
Release: 0.12
Release: 0.13
Group: System Environment/Base
Source: ftp://ftp.rpm.org/pub/rpm/dist/rpm-4.0.x/rpm-%{version}.tar.gz
Copyright: GPL
@ -309,6 +309,12 @@ fi
%{__prefix}/include/popt.h
%changelog
* Sun Dec 31 2000 Jeff Johnson <jbj@redhat.com>
- (popt): fix float/double handling (#19701).
- (popt): non-linux needs <float.h> (#22732).
- (popt): add POPT_ARGFLAG_OPTIONAL for long options with optional arg.
- (popt): diddle auto-help to include type of arg expected.
* Sat Dec 30 2000 Jeff Johnson <jbj@redhat.com>
- (non-linux): move stubs.c to rpmio (#21132).
- (python): bind initdb (#20988).

View File

@ -13,7 +13,7 @@ Summary: The Red Hat package management system.
Name: rpm
%define version @VERSION@
Version: %{version}
Release: 0.12
Release: 0.13
Group: System Environment/Base
Source: ftp://ftp.rpm.org/pub/rpm/dist/rpm-4.0.x/rpm-%{version}.tar.gz
Copyright: GPL
@ -309,6 +309,12 @@ fi
%{__prefix}/include/popt.h
%changelog
* Sun Dec 31 2000 Jeff Johnson <jbj@redhat.com>
- (popt): fix float/double handling (#19701).
- (popt): non-linux needs <float.h> (#22732).
- (popt): add POPT_ARGFLAG_OPTIONAL for long options with optional arg.
- (popt): diddle auto-help to include type of arg expected.
* Sat Dec 30 2000 Jeff Johnson <jbj@redhat.com>
- (non-linux): move stubs.c to rpmio (#21132).
- (python): bind initdb (#20988).