The following commit has been merged in the master branch:
commit e18a89b3b19a75df7dce782c3a26c9f0172656e0
Author: Guillem Jover <[email protected]>
Date: Sun Sep 27 16:46:25 2009 +0200
Remove helponly and versiononly functions
Directly use printversion and usage functions, make them exit and change
their prototypes to fit cmdinfos.
This solves the ugly situation of expecting helponly and versiononly
callers to respectively define printversion and usage themselves.
diff --git a/dpkg-deb/main.c b/dpkg-deb/main.c
index c203930..b478ba9 100644
--- a/dpkg-deb/main.c
+++ b/dpkg-deb/main.c
@@ -50,8 +50,8 @@
const char* showformat = "${Package}\t${Version}\n";
-void
-printversion(void)
+static void
+printversion(const struct cmdinfo *cip, const char *value)
{
printf(_("Debian `%s' package archive backend version %s.\n"),
BACKEND, DPKG_VERSION_ARCH);
@@ -61,10 +61,12 @@ printversion(void)
"See %s --license for copyright and license details.\n"), BACKEND);
m_output(stdout, _("<standard output>"));
+
+ exit(0);
}
-void
-usage(void)
+static void
+usage(const struct cmdinfo *cip, const char *value)
{
printf(_(
"Usage: %s [<option> ...] <command>\n"
@@ -123,6 +125,8 @@ usage(void)
"unpacked using `dpkg-deb --extract' will be incorrectly installed !\n"));
m_output(stdout, _("<standard output>"));
+
+ exit(0);
}
const char thisname[]= BACKEND;
@@ -171,8 +175,8 @@ static const struct cmdinfo cmdinfos[]= {
{ "compression", 'z', 1, NULL, &compression, NULL, 1 },
{ "compress_type", 'Z', 1, NULL, NULL, setcompresstype },
{ "showformat", 0, 1, NULL, &showformat, NULL },
- { "help", 'h', 0, NULL, NULL, helponly },
- { "version", 0, 0, NULL, NULL, versiononly },
+ { "help", 'h', 0, NULL, NULL, usage },
+ { "version", 0, 0, NULL, NULL, printversion },
/* UK spelling. */
{ "licence", 0, 0, NULL, NULL, showcopyright },
/* US spelling. */
diff --git a/dpkg-split/main.c b/dpkg-split/main.c
index 0bfbf64..db77466 100644
--- a/dpkg-split/main.c
+++ b/dpkg-split/main.c
@@ -42,8 +42,8 @@
#include "dpkg-split.h"
-void
-printversion(void)
+static void
+printversion(const struct cmdinfo *cip, const char *value)
{
printf(_("Debian `%s' package split/join tool; version %s.\n"),
SPLITTER, DPKG_VERSION_ARCH);
@@ -54,10 +54,12 @@ printversion(void)
"See %s --license for copyright and license details.\n"), SPLITTER);
m_output(stdout, _("<standard output>"));
+
+ exit(0);
}
-void
-usage(void)
+static void
+usage(const struct cmdinfo *cip, const char *value)
{
printf(_(
"Usage: %s [<option> ...] <command>\n"
@@ -91,6 +93,8 @@ usage(void)
ADMINDIR, PARTSDIR);
m_output(stdout, _("<standard output>"));
+
+ exit(0);
}
const char thisname[]= SPLITTER;
@@ -149,8 +153,8 @@ static const struct cmdinfo cmdinfos[]= {
{ "auto", 'a', 0, NULL, NULL, setaction },
{ "listq", 'l', 0, NULL, NULL, setaction },
{ "discard", 'd', 0, NULL, NULL, setaction },
- { "help", 'h', 0, NULL, NULL, helponly },
- { "version", 0, 0, NULL, NULL, versiononly },
+ { "help", 'h', 0, NULL, NULL, usage },
+ { "version", 0, 0, NULL, NULL, printversion },
{ "licence", 0, 0, NULL, NULL, showcopyright },
/* UK spelling */
{ "license", 0, 0, NULL, NULL, showcopyright },
/* US spelling */
{ "depotdir", 0, 1, NULL, &depotdir, NULL },
diff --git a/dselect/main.cc b/dselect/main.cc
index 832b1bd..4421b11 100644
--- a/dselect/main.cc
+++ b/dselect/main.cc
@@ -166,18 +166,20 @@ static const char licensestring[]= N_(
"later for copying conditions. There is NO warranty.\n"
"See %s --license for copyright and license details.\n");
-void
-printversion(void)
+static void
+printversion(const struct cmdinfo *ci, const char *value)
{
printf(gettext(programdesc), DSELECT, DPKG_VERSION_ARCH);
printf(gettext(copyrightstring));
printf(gettext(licensestring), DSELECT);
m_output(stdout, _("<standard output>"));
+
+ exit(0);
}
-void
-usage(void)
+static void
+usage(const struct cmdinfo *ci, const char *value)
{
int i;
@@ -221,6 +223,8 @@ usage(void)
fputs("\n\n", stdout);
m_output(stdout, _("<standard output>"));
+
+ exit(0);
}
/* These are called by C code, so need to have C calling convention */
@@ -304,8 +308,8 @@ static const struct cmdinfo cmdinfos[]= {
{ "admindir", 0, 1, 0, &admindir, 0 },
{ "debug", 'D', 1, 0, 0, setdebug },
{ "expert", 'E', 0, 0, 0, setexpert },
- { "help", 'h', 0, 0, 0, helponly },
- { "version", 0, 0, 0, 0, versiononly },
+ { "help", 'h', 0, 0, 0, usage },
+ { "version", 0, 0, 0, 0, printversion },
{ "licence", 0, 0, 0, 0, showcopyright }, /* UK spelling
*/
{ "license", 0, 0, 0, 0, showcopyright }, /* US spelling
*/
{ "color", 0, 1, 0, 0, setcolor }, /* US spelling
*/
diff --git a/lib/dpkg/myopt-util.c b/lib/dpkg/myopt-util.c
index 318d4f5..e976616 100644
--- a/lib/dpkg/myopt-util.c
+++ b/lib/dpkg/myopt-util.c
@@ -32,20 +32,6 @@
#include <dpkg/myopt.h>
void
-helponly(const struct cmdinfo *cip, const char *value)
-{
- usage();
- exit(0);
-}
-
-void
-versiononly(const struct cmdinfo *cip, const char *value)
-{
- printversion();
- exit(0);
-}
-
-void
showcopyright(const struct cmdinfo *cip, const char *value)
{
int fd;
diff --git a/lib/dpkg/myopt.h b/lib/dpkg/myopt.h
index 41629a4..9b72ab5 100644
--- a/lib/dpkg/myopt.h
+++ b/lib/dpkg/myopt.h
@@ -52,12 +52,6 @@ void loadcfgfile(const char *prog, const struct cmdinfo
*cmdinfos);
/* Utility functions. */
void showcopyright(const struct cmdinfo *cip, const char *value)
DPKG_ATTR_NORET;
-void helponly(const struct cmdinfo *cip, const char *value) DPKG_ATTR_NORET;
-void versiononly(const struct cmdinfo *cip, const char *value) DPKG_ATTR_NORET;
-
-/* To be defined by callers. */
-void usage(void);
-void printversion(void);
DPKG_END_DECLS
diff --git a/src/main.c b/src/main.c
index e55e63a..3a084ba 100644
--- a/src/main.c
+++ b/src/main.c
@@ -50,8 +50,8 @@
#include "main.h"
#include "filesdb.h"
-void
-printversion(void)
+static void
+printversion(const struct cmdinfo *ci, const char *value)
{
printf(_("Debian `%s' package management program version %s.\n"),
DPKG, DPKG_VERSION_ARCH);
@@ -61,13 +61,15 @@ printversion(void)
"See %s --license for copyright and license details.\n"), DPKG);
m_output(stdout, _("<standard output>"));
+
+ exit(0);
}
/*
options that need fixing:
dpkg --yet-to-unpack \n\
*/
-void
-usage(void)
+static void
+usage(const struct cmdinfo *ci, const char *value)
{
printf(_(
"Usage: %s [<option> ...] <command>\n"
@@ -152,6 +154,8 @@ usage(void)
"Use `dselect' or `aptitude' for user-friendly package management.\n"));
m_output(stdout, _("<standard output>"));
+
+ exit(0);
}
const char thisname[]= "dpkg";
@@ -516,8 +520,8 @@ static const struct cmdinfo cmdinfos[]= {
{ "refuse", 0, 2, NULL, NULL, setforce, 0 },
{ "no-force", 0, 2, NULL, NULL, setforce, 0 },
{ "debug", 'D', 1, NULL, NULL, setdebug, 0 },
- { "help", 'h', 0, NULL, NULL, helponly, 0 },
- { "version", 0, 0, NULL, NULL, versiononly, 0 },
+ { "help", 'h', 0, NULL, NULL, usage, 0 },
+ { "version", 0, 0, NULL, NULL, printversion, 0 },
/* UK spelling. */
{ "licence", 0, 0, NULL, NULL, showcopyright, 0 },
/* US spelling. */
diff --git a/src/query.c b/src/query.c
index a5278a1..3f1cfd5 100644
--- a/src/query.c
+++ b/src/query.c
@@ -553,8 +553,8 @@ control_path(const char *const *argv)
modstatdb_shutdown();
}
-void
-printversion(void)
+static void
+printversion(const struct cmdinfo *ci, const char *value)
{
printf(_("Debian `%s' package management program query tool\n"), DPKGQUERY);
printf(_(
@@ -563,10 +563,12 @@ printversion(void)
"See %s --license for copyright and license details.\n"), DPKGQUERY);
m_output(stdout, _("<standard output>"));
+
+ exit(0);
}
-void
-usage(void)
+static void
+usage(const struct cmdinfo *ci, const char *value)
{
printf(_(
"Usage: %s [<option> ...] <command>\n"
@@ -606,6 +608,8 @@ usage(void)
" case left alignment will be used.\n"));
m_output(stdout, _("<standard output>"));
+
+ exit(0);
}
const char thisname[]= "dpkg-query";
@@ -644,8 +648,8 @@ static const struct cmdinfo cmdinfos[]= {
{ "admindir", 0, 1, NULL, &admindir, NULL },
{ "showformat", 'f', 1, NULL, &showformat, NULL },
- { "help", 'h', 0, NULL, NULL, helponly },
- { "version", 0, 0, NULL, NULL, versiononly },
+ { "help", 'h', 0, NULL, NULL, usage },
+ { "version", 0, 0, NULL, NULL, printversion },
/* UK spelling. */
{ "licence", 0, 0, NULL, NULL, showcopyright },
/* US spelling */
diff --git a/src/trigcmd.c b/src/trigcmd.c
index d76df58..5225d94 100644
--- a/src/trigcmd.c
+++ b/src/trigcmd.c
@@ -48,8 +48,8 @@ const char thisname[] = "dpkg-trigger";
const char printforhelp[] = N_(
"Type dpkg-trigger --help for help about this utility.");
-void
-printversion(void)
+static void
+printversion(const struct cmdinfo *ci, const char *value)
{
printf(_("Debian %s package trigger utility.\n"), thisname);
@@ -59,10 +59,12 @@ printversion(void)
"See %s --license for copyright and license details.\n"), thisname);
m_output(stdout, _("<standard output>"));
+
+ exit(0);
}
-void
-usage(void)
+static void
+usage(const struct cmdinfo *ci, const char *value)
{
printf(_(
"Usage: %s [<options> ...] <trigger-name>\n"
@@ -90,6 +92,8 @@ usage(void)
"\n"), ADMINDIR);
m_output(stdout, _("<standard output>"));
+
+ exit(0);
}
static const char *admindir = ADMINDIR;
@@ -170,8 +174,8 @@ static const struct cmdinfo cmdinfos[] = {
{ "no-await", 0, 0, NULL, &bypackage, noawait },
{ "no-act", 0, 0, &f_noact, NULL, NULL, 1 },
{ "check-supported", 0, 0, &f_check, NULL, NULL, 1 },
- { "help", 'h', 0, NULL, NULL, helponly },
- { "version", 0, 0, NULL, NULL, versiononly },
+ { "help", 'h', 0, NULL, NULL, usage },
+ { "version", 0, 0, NULL, NULL, printversion },
/* UK spelling */
{ "licence", 0, 0, NULL, NULL, showcopyright },
/* US spelling */
--
dpkg's main repository
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]