The following commit has been merged in the master branch: commit 0fc0d6d598c045c77d056b40446208448b9ec6e2 Author: Guillem Jover <guil...@debian.org> Date: Fri Jul 1 04:22:51 2011 +0200
libdpkg: Do not require programs to define printforhelp Instead define it in myopt.c and initialize it through a new argument to myopt(). diff --git a/dpkg-deb/main.c b/dpkg-deb/main.c index 9543412..4512a98 100644 --- a/dpkg-deb/main.c +++ b/dpkg-deb/main.c @@ -126,7 +126,7 @@ usage(const struct cmdinfo *cip, const char *value) } const char thisname[]= BACKEND; -const char printforhelp[]= +static const char printforhelp[] = N_("Type dpkg-deb --help for help about manipulating *.deb files;\n" "Type dpkg --help for help about installing and deinstalling packages."); @@ -190,7 +190,7 @@ int main(int argc, const char *const *argv) { textdomain(PACKAGE); standard_startup(); - myopt(&argv, cmdinfos); + myopt(&argv, cmdinfos, printforhelp); if (!cipaction) badusage(_("need an action option")); diff --git a/dpkg-split/main.c b/dpkg-split/main.c index 860fca5..e92ba29 100644 --- a/dpkg-split/main.c +++ b/dpkg-split/main.c @@ -101,7 +101,7 @@ usage(const struct cmdinfo *cip, const char *value) } const char thisname[]= SPLITTER; -const char printforhelp[]= N_("Type dpkg-split --help for help."); +static const char printforhelp[] = N_("Type dpkg-split --help for help."); struct partqueue *queue= NULL; @@ -160,7 +160,7 @@ int main(int argc, const char *const *argv) { textdomain(PACKAGE); standard_startup(); - myopt(&argv, cmdinfos); + myopt(&argv, cmdinfos, printforhelp); if (!cipaction) badusage(_("need an action option")); diff --git a/dselect/main.cc b/dselect/main.cc index b00bb12..15c86a9 100644 --- a/dselect/main.cc +++ b/dselect/main.cc @@ -58,7 +58,7 @@ #include "pkglist.h" const char thisname[]= DSELECT; -const char printforhelp[]= N_("Type dselect --help for help."); +static const char printforhelp[] = N_("Type dselect --help for help."); modstatdb_rw readwrite; int expertmode= 0; @@ -517,7 +517,7 @@ main(int, const char *const *argv) push_error_context_func(dselect_catch_fatal_error, print_fatal_error, 0); loadcfgfile(DSELECT, cmdinfos); - myopt(&argv,cmdinfos); + myopt(&argv, cmdinfos, printforhelp); admindir = dpkg_db_set_dir(admindir); diff --git a/lib/dpkg/libdpkg.Versions b/lib/dpkg/libdpkg.Versions index c72ffec..c3311e6 100644 --- a/lib/dpkg/libdpkg.Versions +++ b/lib/dpkg/libdpkg.Versions @@ -134,7 +134,6 @@ LIBDPKG_PRIVATE { loadcfgfile; myopt; badusage; - # printforhelp; # XXX variable, do not require external # thisname; # XXX variable, do not require external cipaction; # XXX variable, do not export setaction; diff --git a/lib/dpkg/myopt.c b/lib/dpkg/myopt.c index ea8a310..4181a90 100644 --- a/lib/dpkg/myopt.c +++ b/lib/dpkg/myopt.c @@ -35,6 +35,8 @@ #include <dpkg/string.h> #include <dpkg/myopt.h> +static const char *printforhelp; + void badusage(const char *fmt, ...) { @@ -198,11 +200,16 @@ void loadcfgfile(const char *prog, const struct cmdinfo* cmdinfos) { } } -void myopt(const char *const **argvp, const struct cmdinfo *cmdinfos) { +void +myopt(const char *const **argvp, const struct cmdinfo *cmdinfos, + const char *help_str) +{ const struct cmdinfo *cip; const char *p, *value; int l; + printforhelp = help_str; + ++(*argvp); while ((p= **argvp) && *p == '-') { ++(*argvp); diff --git a/lib/dpkg/myopt.h b/lib/dpkg/myopt.h index d8e32fa..230fd89 100644 --- a/lib/dpkg/myopt.h +++ b/lib/dpkg/myopt.h @@ -48,14 +48,13 @@ struct cmdinfo { action_func *action; }; -extern const char printforhelp[]; - void badusage(const char *fmt, ...) DPKG_ATTR_NORET DPKG_ATTR_PRINTF(1); #define MAX_CONFIG_LINE 1024 void myfileopt(const char* fn, const struct cmdinfo* cmdinfos); -void myopt(const char *const **argvp, const struct cmdinfo *cmdinfos); +void myopt(const char *const **argvp, const struct cmdinfo *cmdinfos, + const char *help_str); void loadcfgfile(const char *prog, const struct cmdinfo *cmdinfos); /** diff --git a/src/divertcmd.c b/src/divertcmd.c index 5ea6c65..d88ecd0 100644 --- a/src/divertcmd.c +++ b/src/divertcmd.c @@ -47,7 +47,8 @@ const char thisname[] = "dpkg-divert"; -const char printforhelp[] = N_("Use --help for help about querying packages."); +static const char printforhelp[] = N_( +"Use --help for help about querying packages."); static const char *admindir; @@ -698,7 +699,7 @@ main(int argc, const char * const *argv) textdomain(PACKAGE); standard_startup(); - myopt(&argv, cmdinfos); + myopt(&argv, cmdinfos, printforhelp); admindir = dpkg_db_set_dir(admindir); diff --git a/src/main.c b/src/main.c index 000e589..fbda5f1 100644 --- a/src/main.c +++ b/src/main.c @@ -167,7 +167,7 @@ usage(const struct cmdinfo *ci, const char *value) const char thisname[]= "dpkg"; const char native_arch[] = ARCHITECTURE; -const char printforhelp[]= N_( +static const char printforhelp[] = N_( "Type dpkg --help for help about installing and deinstalling packages [*];\n" "Use `dselect' or `aptitude' for user-friendly package management;\n" "Type dpkg -Dhelp for a list of dpkg debug flag values;\n" @@ -716,7 +716,7 @@ commandfd(const char *const *argv) newargs[i] = m_strdup(newargs[i]); setaction(NULL, NULL); - myopt((const char *const**)&newargs,cmdinfos); + myopt((const char *const **)&newargs, cmdinfos, printforhelp); if (!cipaction) badusage(_("need an action option")); ret |= cipaction->action(newargs); @@ -736,7 +736,7 @@ int main(int argc, const char *const *argv) { standard_startup(); loadcfgfile(DPKG, cmdinfos); - myopt(&argv, cmdinfos); + myopt(&argv, cmdinfos, printforhelp); if (!cipaction) badusage(_("need an action option")); diff --git a/src/querycmd.c b/src/querycmd.c index 41a2e90..cb512ae 100644 --- a/src/querycmd.c +++ b/src/querycmd.c @@ -653,7 +653,8 @@ usage(const struct cmdinfo *ci, const char *value) } const char thisname[]= "dpkg-query"; -const char printforhelp[]= N_("Use --help for help about querying packages."); +static const char printforhelp[] = N_( +"Use --help for help about querying packages."); static const char *admindir; @@ -684,7 +685,7 @@ int main(int argc, const char *const *argv) { textdomain(PACKAGE); standard_startup(); - myopt(&argv, cmdinfos); + myopt(&argv, cmdinfos, printforhelp); admindir = dpkg_db_set_dir(admindir); diff --git a/src/statcmd.c b/src/statcmd.c index 9718201..55ac07a 100644 --- a/src/statcmd.c +++ b/src/statcmd.c @@ -49,7 +49,8 @@ #include "filesdb.h" const char thisname[] = "dpkg-statoverride"; -const char printforhelp[] = N_("Use --help for help about querying packages."); +static const char printforhelp[] = N_( +"Use --help for help about querying packages."); static void DPKG_ATTR_NORET printversion(const struct cmdinfo *cip, const char *value) @@ -369,7 +370,7 @@ main(int argc, const char *const *argv) textdomain(PACKAGE); standard_startup(); - myopt(&argv, cmdinfos); + myopt(&argv, cmdinfos, printforhelp); admindir = dpkg_db_set_dir(admindir); diff --git a/src/trigcmd.c b/src/trigcmd.c index a37f882..2f27188 100644 --- a/src/trigcmd.c +++ b/src/trigcmd.c @@ -44,7 +44,7 @@ const char thisname[] = "dpkg-trigger"; -const char printforhelp[] = N_( +static const char printforhelp[] = N_( "Type dpkg-trigger --help for help about this utility."); static void DPKG_ATTR_NORET @@ -189,7 +189,7 @@ main(int argc, const char *const *argv) textdomain(PACKAGE); standard_startup(); - myopt(&argv, cmdinfos); + myopt(&argv, cmdinfos, printforhelp); admindir = dpkg_db_set_dir(admindir); -- dpkg's main repository -- To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org