diff options
author | jbj <devnull@localhost> | 2000-07-31 15:04:20 +0000 |
---|---|---|
committer | jbj <devnull@localhost> | 2000-07-31 15:04:20 +0000 |
commit | 79f6c8be8708941355e6408ad8ce527bc8af4d92 (patch) | |
tree | fa501d05e3d031c0f6699422b6094e56ab57f60a /popt | |
parent | 6040ca6f5333229b24e9bc319e87ba797601dbc3 (diff) | |
download | librpm-tizen-79f6c8be8708941355e6408ad8ce527bc8af4d92.tar.gz librpm-tizen-79f6c8be8708941355e6408ad8ce527bc8af4d92.tar.bz2 librpm-tizen-79f6c8be8708941355e6408ad8ce527bc8af4d92.zip |
- fix: uniqify dependency problems when printing (#14034).
- popt: add ability to perform callbacks for every, not just first, match.
CVS patchset: 3993
CVS date: 2000/07/31 15:04:20
Diffstat (limited to 'popt')
-rw-r--r-- | popt/CHANGES | 5 | ||||
-rw-r--r-- | popt/po/cs.po | 2 | ||||
-rw-r--r-- | popt/po/da.po | 2 | ||||
-rw-r--r-- | popt/po/de.po | 2 | ||||
-rw-r--r-- | popt/po/es.po | 2 | ||||
-rw-r--r-- | popt/po/fi.po | 2 | ||||
-rw-r--r-- | popt/po/fr.po | 2 | ||||
-rw-r--r-- | popt/po/gl.po | 2 | ||||
-rw-r--r-- | popt/po/hu.po | 2 | ||||
-rw-r--r-- | popt/po/id.po | 2 | ||||
-rw-r--r-- | popt/po/is.po | 2 | ||||
-rw-r--r-- | popt/po/it.po | 2 | ||||
-rw-r--r-- | popt/po/ja.po | 2 | ||||
-rw-r--r-- | popt/po/ko.po | 2 | ||||
-rw-r--r-- | popt/po/no.po | 2 | ||||
-rw-r--r-- | popt/po/pl.po | 2 | ||||
-rw-r--r-- | popt/po/popt.pot | 2 | ||||
-rw-r--r-- | popt/po/pt.po | 2 | ||||
-rw-r--r-- | popt/po/pt_BR.po | 2 | ||||
-rw-r--r-- | popt/po/ro.po | 2 | ||||
-rw-r--r-- | popt/po/ru.po | 2 | ||||
-rw-r--r-- | popt/po/sk.po | 2 | ||||
-rw-r--r-- | popt/po/sl.po | 2 | ||||
-rw-r--r-- | popt/po/sr.po | 2 | ||||
-rw-r--r-- | popt/po/sv.po | 2 | ||||
-rw-r--r-- | popt/po/tr.po | 2 | ||||
-rw-r--r-- | popt/po/uk.po | 2 | ||||
-rw-r--r-- | popt/po/wa.po | 2 | ||||
-rw-r--r-- | popt/po/zh.po | 2 | ||||
-rw-r--r-- | popt/po/zh_CN.GB2312.po | 2 | ||||
-rw-r--r-- | popt/popt.c | 98 | ||||
-rw-r--r-- | popt/popt.h | 2 |
32 files changed, 109 insertions, 54 deletions
diff --git a/popt/CHANGES b/popt/CHANGES index b6ab2aa30..db16a5fdd 100644 --- a/popt/CHANGES +++ b/popt/CHANGES @@ -1,4 +1,7 @@ -1.3 -> +1.5 -> 1.6 + - add ability to perform callbacks for every, not just first, match. + +1.3 -> 1.5 - heavy dose of const's - poptParseArgvString() now NULL terminates the list diff --git a/popt/po/cs.po b/popt/po/cs.po index 92e772911..14f88e123 100644 --- a/popt/po/cs.po +++ b/popt/po/cs.po @@ -1,7 +1,7 @@ msgid "" msgstr "" "Project-Id-Version: popt 1.3\n" -"POT-Creation-Date: 2000-07-09 15:05-0400\n" +"POT-Creation-Date: 2000-07-30 09:36-0400\n" "PO-Revision-Date: 2000-07-26 23:09+0100\n" "Last-Translator: Milan Kerslager <milan.kerslager@spsselib.hiedu.cz>\n" "Language-Team: Czech <cs@li.org>\n" diff --git a/popt/po/da.po b/popt/po/da.po index 644f1faf5..af02b5ae2 100644 --- a/popt/po/da.po +++ b/popt/po/da.po @@ -1,7 +1,7 @@ msgid "" msgstr "" "Project-Id-Version: popt\n" -"POT-Creation-Date: 2000-07-09 15:05-0400\n" +"POT-Creation-Date: 2000-07-30 09:36-0400\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" diff --git a/popt/po/de.po b/popt/po/de.po index 79aa22d5f..2c1939766 100644 --- a/popt/po/de.po +++ b/popt/po/de.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"POT-Creation-Date: 2000-07-09 15:05-0400\n" +"POT-Creation-Date: 2000-07-30 09:36-0400\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/po/es.po b/popt/po/es.po index 79aa22d5f..2c1939766 100644 --- a/popt/po/es.po +++ b/popt/po/es.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"POT-Creation-Date: 2000-07-09 15:05-0400\n" +"POT-Creation-Date: 2000-07-30 09:36-0400\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/po/fi.po b/popt/po/fi.po index 79aa22d5f..2c1939766 100644 --- a/popt/po/fi.po +++ b/popt/po/fi.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"POT-Creation-Date: 2000-07-09 15:05-0400\n" +"POT-Creation-Date: 2000-07-30 09:36-0400\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/po/fr.po b/popt/po/fr.po index 79aa22d5f..2c1939766 100644 --- a/popt/po/fr.po +++ b/popt/po/fr.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"POT-Creation-Date: 2000-07-09 15:05-0400\n" +"POT-Creation-Date: 2000-07-30 09:36-0400\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/po/gl.po b/popt/po/gl.po index 4efd338af..cb7e52dc7 100644 --- a/popt/po/gl.po +++ b/popt/po/gl.po @@ -10,7 +10,7 @@ msgid "" msgstr "" "Project-Id-Version: popt 1.4\n" -"POT-Creation-Date: 2000-07-09 15:05-0400\n" +"POT-Creation-Date: 2000-07-30 09:36-0400\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" diff --git a/popt/po/hu.po b/popt/po/hu.po index 79aa22d5f..2c1939766 100644 --- a/popt/po/hu.po +++ b/popt/po/hu.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"POT-Creation-Date: 2000-07-09 15:05-0400\n" +"POT-Creation-Date: 2000-07-30 09:36-0400\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/po/id.po b/popt/po/id.po index 79aa22d5f..2c1939766 100644 --- a/popt/po/id.po +++ b/popt/po/id.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"POT-Creation-Date: 2000-07-09 15:05-0400\n" +"POT-Creation-Date: 2000-07-30 09:36-0400\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/po/is.po b/popt/po/is.po index a062e6899..8540f16eb 100644 --- a/popt/po/is.po +++ b/popt/po/is.po @@ -1,7 +1,7 @@ msgid "" msgstr "" "Project-Id-Version: popt 1.0\n" -"POT-Creation-Date: 2000-07-09 15:05-0400\n" +"POT-Creation-Date: 2000-07-30 09:36-0400\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" diff --git a/popt/po/it.po b/popt/po/it.po index 79aa22d5f..2c1939766 100644 --- a/popt/po/it.po +++ b/popt/po/it.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"POT-Creation-Date: 2000-07-09 15:05-0400\n" +"POT-Creation-Date: 2000-07-30 09:36-0400\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/po/ja.po b/popt/po/ja.po index 79aa22d5f..2c1939766 100644 --- a/popt/po/ja.po +++ b/popt/po/ja.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"POT-Creation-Date: 2000-07-09 15:05-0400\n" +"POT-Creation-Date: 2000-07-30 09:36-0400\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/po/ko.po b/popt/po/ko.po index 79aa22d5f..2c1939766 100644 --- a/popt/po/ko.po +++ b/popt/po/ko.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"POT-Creation-Date: 2000-07-09 15:05-0400\n" +"POT-Creation-Date: 2000-07-30 09:36-0400\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/po/no.po b/popt/po/no.po index c1746be49..99732b0e1 100644 --- a/popt/po/no.po +++ b/popt/po/no.po @@ -1,7 +1,7 @@ msgid "" msgstr "" "Project-Id-Version: popt 7.0\n" -"POT-Creation-Date: 2000-07-09 15:05-0400\n" +"POT-Creation-Date: 2000-07-30 09:36-0400\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" diff --git a/popt/po/pl.po b/popt/po/pl.po index 79aa22d5f..2c1939766 100644 --- a/popt/po/pl.po +++ b/popt/po/pl.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"POT-Creation-Date: 2000-07-09 15:05-0400\n" +"POT-Creation-Date: 2000-07-30 09:36-0400\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/po/popt.pot b/popt/po/popt.pot index 79aa22d5f..2c1939766 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: 2000-07-09 15:05-0400\n" +"POT-Creation-Date: 2000-07-30 09:36-0400\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/po/pt.po b/popt/po/pt.po index 5bba89c7b..c1321800e 100644 --- a/popt/po/pt.po +++ b/popt/po/pt.po @@ -1,7 +1,7 @@ msgid "" msgstr "" "Project-Id-Version: popt\n" -"POT-Creation-Date: 2000-07-09 15:05-0400\n" +"POT-Creation-Date: 2000-07-30 09:36-0400\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" diff --git a/popt/po/pt_BR.po b/popt/po/pt_BR.po index 79aa22d5f..2c1939766 100644 --- a/popt/po/pt_BR.po +++ b/popt/po/pt_BR.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"POT-Creation-Date: 2000-07-09 15:05-0400\n" +"POT-Creation-Date: 2000-07-30 09:36-0400\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/po/ro.po b/popt/po/ro.po index 841731eee..7d6fedaa2 100644 --- a/popt/po/ro.po +++ b/popt/po/ro.po @@ -1,7 +1,7 @@ msgid "" msgstr "" "Project-Id-Version: popt 1.6\n" -"POT-Creation-Date: 2000-07-09 15:05-0400\n" +"POT-Creation-Date: 2000-07-30 09:36-0400\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" diff --git a/popt/po/ru.po b/popt/po/ru.po index 79aa22d5f..2c1939766 100644 --- a/popt/po/ru.po +++ b/popt/po/ru.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"POT-Creation-Date: 2000-07-09 15:05-0400\n" +"POT-Creation-Date: 2000-07-30 09:36-0400\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/po/sk.po b/popt/po/sk.po index eb9a8b8bf..172c26324 100644 --- a/popt/po/sk.po +++ b/popt/po/sk.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: popt\n" -"POT-Creation-Date: 2000-07-09 15:05-0400\n" +"POT-Creation-Date: 2000-07-30 09:36-0400\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" diff --git a/popt/po/sl.po b/popt/po/sl.po index 79aa22d5f..2c1939766 100644 --- a/popt/po/sl.po +++ b/popt/po/sl.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"POT-Creation-Date: 2000-07-09 15:05-0400\n" +"POT-Creation-Date: 2000-07-30 09:36-0400\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/po/sr.po b/popt/po/sr.po index 79aa22d5f..2c1939766 100644 --- a/popt/po/sr.po +++ b/popt/po/sr.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"POT-Creation-Date: 2000-07-09 15:05-0400\n" +"POT-Creation-Date: 2000-07-30 09:36-0400\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/po/sv.po b/popt/po/sv.po index 2a6f26ae0..649a79cf7 100644 --- a/popt/po/sv.po +++ b/popt/po/sv.po @@ -1,7 +1,7 @@ msgid "" msgstr "" "Project-Id-Version: popt\n" -"POT-Creation-Date: 2000-07-09 15:05-0400\n" +"POT-Creation-Date: 2000-07-30 09:36-0400\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" diff --git a/popt/po/tr.po b/popt/po/tr.po index 041be0af3..a1333f593 100644 --- a/popt/po/tr.po +++ b/popt/po/tr.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: popt 1.2\n" -"POT-Creation-Date: 2000-07-09 15:05-0400\n" +"POT-Creation-Date: 2000-07-30 09:36-0400\n" "PO-Revision-Date: 2000-01-06 13:01+0100\n" "Last-Translator: Fatih Demir <kabalak@gmx.net>\n" "Language-Team: Turkish Gnome Tranlation Team <gnotrap@gmx.net>\n" diff --git a/popt/po/uk.po b/popt/po/uk.po index bd204775a..2e8dd21fc 100644 --- a/popt/po/uk.po +++ b/popt/po/uk.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: popt 1.4\n" -"POT-Creation-Date: 2000-07-09 15:05-0400\n" +"POT-Creation-Date: 2000-07-30 09:36-0400\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" diff --git a/popt/po/wa.po b/popt/po/wa.po index cbf357bd2..cb7af6628 100644 --- a/popt/po/wa.po +++ b/popt/po/wa.po @@ -9,7 +9,7 @@ msgid "" msgstr "" "Project-Id-Version: popt 1.3\n" -"POT-Creation-Date: 2000-07-09 15:05-0400\n" +"POT-Creation-Date: 2000-07-30 09:36-0400\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" diff --git a/popt/po/zh.po b/popt/po/zh.po index 79aa22d5f..2c1939766 100644 --- a/popt/po/zh.po +++ b/popt/po/zh.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"POT-Creation-Date: 2000-07-09 15:05-0400\n" +"POT-Creation-Date: 2000-07-30 09:36-0400\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/po/zh_CN.GB2312.po b/popt/po/zh_CN.GB2312.po index 44972aec1..5c158de97 100644 --- a/popt/po/zh_CN.GB2312.po +++ b/popt/po/zh_CN.GB2312.po @@ -1,7 +1,7 @@ msgid "" msgstr "" "Project-Id-Version: kcmkpanel\n" -"POT-Creation-Date: 2000-07-09 15:05-0400\n" +"POT-Creation-Date: 2000-07-30 09:36-0400\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" diff --git a/popt/popt.c b/popt/popt.c index 5b2c8d5ab..852729503 100644 --- a/popt/popt.c +++ b/popt/popt.c @@ -26,27 +26,72 @@ void poptSetExecPath(poptContext con, const char * path, int allowAbsolute) { con->execAbsolute = allowAbsolute; } -static void invokeCallbacks(poptContext con, const struct poptOption * table, - int post) { - const struct poptOption * opt = table; - poptCallbackType cb; +static void invokeCallbacksPRE(poptContext con, const struct poptOption * opt) +{ + for (; opt->longName || opt->shortName || opt->arg; opt++) { + if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_INCLUDE_TABLE) { + /* Recurse on included sub-tables. */ + invokeCallbacksPRE(con, opt->arg); + } else if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_CALLBACK && + (opt->argInfo & POPT_CBFLAG_PRE)) + { poptCallbackType cb = (poptCallbackType)opt->arg; + /* Perform callback. */ + cb(con, POPT_CALLBACK_REASON_PRE, NULL, NULL, opt->descrip); + } + } +} - while (opt->longName || opt->shortName || opt->arg) { +static void invokeCallbacksPOST(poptContext con, const struct poptOption * opt) +{ + for (; opt->longName || opt->shortName || opt->arg; opt++) { if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_INCLUDE_TABLE) { - invokeCallbacks(con, opt->arg, post); - } else if (((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_CALLBACK) && - ((!post && (opt->argInfo & POPT_CBFLAG_PRE)) || - ( post && (opt->argInfo & POPT_CBFLAG_POST)))) { - cb = (poptCallbackType)opt->arg; - cb(con, post ? POPT_CALLBACK_REASON_POST : POPT_CALLBACK_REASON_PRE, - NULL, NULL, opt->descrip); + /* Recurse on included sub-tables. */ + invokeCallbacksPRE(con, opt->arg); + } else if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_CALLBACK && + (opt->argInfo & POPT_CBFLAG_POST)) + { poptCallbackType cb = (poptCallbackType)opt->arg; + /* Perform callback. */ + cb(con, POPT_CALLBACK_REASON_POST, NULL, NULL, opt->descrip); + } + } +} + +static void invokeCallbacksOPTION(poptContext con, + const struct poptOption * opt, + const struct poptOption * myOpt, + const void * myData, int shorty) +{ + const struct poptOption * cbopt = NULL; + + for (; opt->longName || opt->shortName || opt->arg; opt++) { + if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_INCLUDE_TABLE) { + /* Recurse on included sub-tables. */ + invokeCallbacksOPTION(con, opt->arg, myOpt, myData, shorty); + } else if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_CALLBACK && + !(opt->argInfo & POPT_CBFLAG_SKIPOPTION)) { + /* Save callback info. */ + cbopt = opt; + } else if (cbopt != NULL && + ((myOpt->shortName && opt->shortName && shorty && + myOpt->shortName == opt->shortName) || + (myOpt->longName && opt->longName && + !strcmp(myOpt->longName, opt->longName))) + ) + { poptCallbackType cb = (poptCallbackType)cbopt->arg; + const void * cbData = (cbopt->descrip ? cbopt->descrip : myData); + /* Perform callback. */ + cb(con, POPT_CALLBACK_REASON_OPTION, myOpt, + con->os->nextArg, cbData); + /* Terminate (unless explcitly continuing). */ + if (!(cbopt->argInfo & POPT_CBFLAG_CONTINUE)) + return; } - opt++; } } poptContext poptGetContext(const char * name, int argc, const char ** argv, - const struct poptOption * options, int flags) { + const struct poptOption * options, int flags) +{ poptContext con = malloc(sizeof(*con)); memset(con, 0, sizeof(*con)); @@ -77,7 +122,7 @@ poptContext poptGetContext(const char * name, int argc, const char ** argv, if (name) con->appName = strcpy(malloc(strlen(name) + 1), name); - invokeCallbacks(con, con->options, 0); + invokeCallbacksPRE(con, con->options); return con; } @@ -290,25 +335,27 @@ static void execCommand(poptContext con) { } /*@observer@*/ static const struct poptOption * -findOption(const struct poptOption * table, const char * longName, +findOption(const struct poptOption * opt, const char * longName, char shortName, /*@out@*/ poptCallbackType * callback, /*@out@*/ const void ** callbackData, int singleDash) { - const struct poptOption * opt = table; - const struct poptOption * opt2; const struct poptOption * cb = NULL; /* This happens when a single - is given */ if (singleDash && !shortName && !*longName) shortName = '-'; - while (opt->longName || opt->shortName || opt->arg) { + for (; opt->longName || opt->shortName || opt->arg; opt++) { + if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_INCLUDE_TABLE) { + const struct poptOption * opt2; + /* Recurse on included sub-tables. */ opt2 = findOption(opt->arg, longName, shortName, callback, callbackData, singleDash); if (opt2) { - if (*callback && !*callbackData) + /* Sub-table data will be inheirited if no data yet. */ + if (*callback && *callbackData == NULL) *callbackData = opt->descrip; return opt2; } @@ -321,10 +368,10 @@ findOption(const struct poptOption * table, const char * longName, } else if (shortName && shortName == opt->shortName) { break; } - opt++; } - if (!opt->longName && !opt->shortName) return NULL; + if (!opt->longName && !opt->shortName) + return NULL; *callbackData = NULL; *callback = NULL; if (cb) { @@ -482,13 +529,14 @@ int poptGetNextOpt(poptContext con) const void * cbData = NULL; const char * longArg = NULL; int canstrip = 0; + int shorty = 0; while (!con->os->nextCharArg && con->os->next == con->os->argc && con->os > con->optionStack) { cleanOSE(con->os--); } if (!con->os->nextCharArg && con->os->next == con->os->argc) { - invokeCallbacks(con, con->options, 1); + invokeCallbacksPOST(con, con->options); if (con->doExec) execCommand(con); return -1; } @@ -562,6 +610,7 @@ int poptGetNextOpt(poptContext con) canstrip = 1; poptStripArg(con, thisopt); } + shorty = 0; } } @@ -586,6 +635,7 @@ int poptGetNextOpt(poptContext con) &cbData, 0); if (!opt) return POPT_ERROR_BADOPT; + shorty = 1; origOptString++; if (*origOptString) con->os->nextCharArg = origOptString; @@ -666,7 +716,7 @@ int poptGetNextOpt(poptContext con) } if (cb) - cb(con, POPT_CALLBACK_REASON_OPTION, opt, con->os->nextArg, cbData); + invokeCallbacksOPTION(con, con->options, opt, cbData, shorty); else if (opt->val && ((opt->argInfo & POPT_ARG_MASK) != POPT_ARG_VAL)) done = 1; diff --git a/popt/popt.h b/popt/popt.h index 841adcbae..2209f385c 100644 --- a/popt/popt.h +++ b/popt/popt.h @@ -46,6 +46,8 @@ extern "C" { #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_CBFLAG_SKIPOPTION 0x10000000 /* don't callback with option */ +#define POPT_CBFLAG_CONTINUE 0x08000000 /* continue callbacks with option */ #define POPT_ERROR_NOARG -10 #define POPT_ERROR_BADOPT -11 |