summaryrefslogtreecommitdiff
path: root/popt
diff options
context:
space:
mode:
authorewt <devnull@localhost>1998-10-27 05:38:37 +0000
committerewt <devnull@localhost>1998-10-27 05:38:37 +0000
commit2796491ba3a7b3047fbb24f469d31ded77e274fd (patch)
tree5f4f13857db285ec202d5a82b98c8871548129e5 /popt
parentf65c9a1541f742f2cfd901e693d3f9ef8bc02b0f (diff)
downloadlibrpm-tizen-2796491ba3a7b3047fbb24f469d31ded77e274fd.tar.gz
librpm-tizen-2796491ba3a7b3047fbb24f469d31ded77e274fd.tar.bz2
librpm-tizen-2796491ba3a7b3047fbb24f469d31ded77e274fd.zip
implemented POPT_ARGINFO_INC_DATA
CVS patchset: 2501 CVS date: 1998/10/27 05:38:37
Diffstat (limited to 'popt')
-rw-r--r--popt/po/Makefile.in2
-rw-r--r--popt/po/popt.pot2
-rw-r--r--popt/popt.c13
-rw-r--r--popt/popt.h3
-rw-r--r--popt/test1.c7
-rwxr-xr-xpopt/testit.sh1
6 files changed, 21 insertions, 7 deletions
diff --git a/popt/po/Makefile.in b/popt/po/Makefile.in
index 2f041d343..604c18417 100644
--- a/popt/po/Makefile.in
+++ b/popt/po/Makefile.in
@@ -2,7 +2,7 @@
srcdir = .
top_srcdir = ..
-INSTALL= /usr/bin/install -c
+INSTALL= /usr/bin/ginstall -c
INSTALL_PROGRAM= ${INSTALL}
INSTALL_DATA= ${INSTALL} -m 644
CC = gcc
diff --git a/popt/po/popt.pot b/popt/po/popt.pot
index dedc6f7f2..2131d9237 100644
--- a/popt/po/popt.pot
+++ b/popt/po/popt.pot
@@ -6,7 +6,7 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
-"POT-Creation-Date: 1998-10-22 16:16-0400\n"
+"POT-Creation-Date: 1998-10-26 23:55-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"
diff --git a/popt/popt.c b/popt/popt.c
index 47f0d008a..9ebc81bbc 100644
--- a/popt/popt.c
+++ b/popt/popt.c
@@ -242,7 +242,11 @@ static const struct poptOption * findOption(const struct poptOption * table,
if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_INCLUDE_TABLE) {
opt2 = findOption(opt->arg, longName, shortName, callback,
callbackData, singleDash);
- if (opt2) return opt2;
+ if (opt2) {
+ if (*callback && !*callbackData)
+ *callbackData = opt->descrip;
+ return opt2;
+ }
} else if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_CALLBACK) {
cb = opt;
} else if (longName && opt->longName &&
@@ -256,11 +260,12 @@ static const struct poptOption * findOption(const struct poptOption * table,
}
if (!opt->longName && !opt->shortName) return NULL;
+ *callbackData = NULL;
+ *callback = NULL;
if (cb) {
*callback = cb->arg;
- *callbackData = cb->descrip;
- } else {
- *callback = NULL;
+ if (!(cb->argInfo & POPT_CBFLAG_INC_DATA))
+ *callbackData = cb->descrip;
}
return opt;
diff --git a/popt/popt.h b/popt/popt.h
index ba3a815d8..9bac79722 100644
--- a/popt/popt.h
+++ b/popt/popt.h
@@ -23,6 +23,8 @@
#define POPT_ARGFLAG_DOC_HIDDEN 0x40000000 /* don't show in help/usage */
#define POPT_CBFLAG_PRE 0x80000000 /* call the callback before parse */
#define POPT_CBFLAG_POST 0x40000000 /* call the callback after parse */
+#define POPT_CBFLAG_INC_DATA 0x20000000 /* use data from the include line,
+ not the subtable */
#define POPT_ERROR_NOARG -10
#define POPT_ERROR_BADOPT -11
@@ -66,7 +68,6 @@ typedef struct poptContext_s * poptContext;
typedef struct poptOption * poptOption;
#endif
-#define POPT_CB_USE_INCLUDE_DATA ((void *) -1)
enum poptCallbackReason { POPT_CALLBACK_REASON_PRE,
POPT_CALLBACK_REASON_POST,
POPT_CALLBACK_REASON_OPTION };
diff --git a/popt/test1.c b/popt/test1.c
index cdda82ba6..28ee26925 100644
--- a/popt/test1.c
+++ b/popt/test1.c
@@ -24,6 +24,12 @@ int main(int argc, char ** argv) {
int help = 0;
int usage = 0;
int shortopt = 0;
+ struct poptOption moreCallbackArgs[] = {
+ { NULL, '\0', POPT_ARG_CALLBACK | POPT_CBFLAG_INC_DATA,
+ option_callback, 0, NULL },
+ { "cb2", 'c', POPT_ARG_STRING, NULL, 'c', "Test argument callbacks" },
+ { NULL, '\0', 0, NULL, 0 }
+ };
struct poptOption callbackArgs[] = {
{ NULL, '\0', POPT_ARG_CALLBACK, option_callback, 0, "sampledata" },
{ "cb", 'c', POPT_ARG_STRING, NULL, 'c', "Test argument callbacks" },
@@ -35,6 +41,7 @@ int main(int argc, char ** argv) {
{ NULL, '\0', 0, NULL, 0 }
};
struct poptOption options[] = {
+ { NULL, '\0', POPT_ARG_INCLUDE_TABLE, &moreCallbackArgs, 0, "arg for cb2" },
{ "arg1", '\0', 0, &arg1, 0, "First argument with a really long"
" description. After all, we have to test argument help"
" wrapping somehow, right?", NULL },
diff --git a/popt/testit.sh b/popt/testit.sh
index a231df860..bdb78ab1d 100755
--- a/popt/testit.sh
+++ b/popt/testit.sh
@@ -41,6 +41,7 @@ run test1 "test1 - 22" "./test1 ; --arg2 something -- more args" -T something -a
run test1 "test1 - 23" "./test1 ; --echo-args -a" --echo-args -e -a
run test1 "test1 - 24" "arg1: 0 arg2: (none) short: 1" -shortoption
run test1 "test1 - 25" "arg1: 0 arg2: (none) short: 1" --shortoption
+run test1 "test1 - 26" "callback: c arg for cb2 foo arg1: 0 arg2: (none)" --cb2 foo
echo ""
echo "Passed."