summaryrefslogtreecommitdiff
path: root/support/popthelp.c
diff options
context:
space:
mode:
Diffstat (limited to 'support/popthelp.c')
-rw-r--r--support/popthelp.c50
1 files changed, 30 insertions, 20 deletions
diff --git a/support/popthelp.c b/support/popthelp.c
index c36ecead..fc2764a5 100644
--- a/support/popthelp.c
+++ b/support/popthelp.c
@@ -4,13 +4,25 @@
file accompanying popt source distributions, available from
ftp://ftp.redhat.com/pub/code/popt */
-#include "system.h"
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <ctype.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#ifdef HAVE_ALLOCA_H
+#include <alloca.h>
+#endif
+
+#include "popt-gnome.h"
#include "poptint.h"
-static void displayArgs(poptContext con,
- /*@unused@*/ enum poptCallbackReason foo,
- struct poptOption * key,
- /*@unused@*/ const char * arg, /*@unused@*/ void * data) {
+static void displayArgs(poptContext con, enum poptCallbackReason foo,
+ struct poptOption * key,
+ const char * arg, void * data) {
if (key->shortName== '?')
poptPrintHelp(con, stdout, 0);
else
@@ -19,14 +31,14 @@ static void displayArgs(poptContext con,
}
struct poptOption poptHelpOptions[] = {
- { NULL, '\0', POPT_ARG_CALLBACK, (void *)&displayArgs, '\0', NULL, NULL },
- { "help", '?', 0, NULL, '?', N_("Show this help message"), NULL },
- { "usage", '\0', 0, NULL, 'u', N_("Display brief usage message"), NULL },
- { NULL, '\0', 0, NULL, 0, NULL, NULL }
+ { NULL, '\0', POPT_ARG_CALLBACK, (void *)&displayArgs, '\0', NULL },
+ { "help", '?', 0, NULL, '?', N_("Show this help message") },
+ { "usage", '\0', 0, NULL, 'u', N_("Display brief usage message") },
+ { NULL, '\0', 0, NULL, 0 }
} ;
-/*@observer@*/ /*@null@*/ static const char *const
+static const char *
getTableTranslationDomain(const struct poptOption *table)
{
const struct poptOption *opt;
@@ -41,9 +53,8 @@ getTableTranslationDomain(const struct poptOption *table)
return NULL;
}
-/*@observer@*/ /*@null@*/ static const char *const
-getArgDescrip(const struct poptOption * opt, const char *translation_domain)
-{
+static const char * getArgDescrip(const struct poptOption * opt,
+ const char *translation_domain) {
if (!(opt->argInfo & POPT_ARG_MASK)) return NULL;
if (opt == (poptHelpOptions + 1) || opt == (poptHelpOptions + 2))
@@ -182,7 +193,7 @@ static int showHelpIntro(poptContext con, FILE * f) {
return len;
}
-void poptPrintHelp(poptContext con, FILE * f, /*@unused@*/ int flags) {
+void poptPrintHelp(poptContext con, FILE * f, int flags) {
int leftColWidth;
showHelpIntro(con, f);
@@ -199,7 +210,7 @@ static int singleOptionUsage(FILE * f, int cursor,
const struct poptOption * opt,
const char *translation_domain) {
int len = 3;
- char shortStr[2] = { '\0', '\0' };
+ char shortStr[2];
const char * item = shortStr;
const char * argDescrip = getArgDescrip(opt, translation_domain);
@@ -257,10 +268,9 @@ static int showShortOptions(const struct poptOption * opt, FILE * f,
char s[300]; /* this is larger then the ascii set, so
it should do just fine */
- s[0] = '\0';
- if (str == NULL) {
- memset(s, 0, sizeof(s));
+ if (!str) {
str = s;
+ memset(str, 0, sizeof(s));
}
while (opt->longName || opt->shortName || opt->arg) {
@@ -279,7 +289,7 @@ static int showShortOptions(const struct poptOption * opt, FILE * f,
return strlen(s) + 4;
}
-void poptPrintUsage(poptContext con, FILE * f, /*@unused@*/ int flags) {
+void poptPrintUsage(poptContext con, FILE * f, int flags) {
int cursor;
cursor = showHelpIntro(con, f);
@@ -297,5 +307,5 @@ void poptPrintUsage(poptContext con, FILE * f, /*@unused@*/ int flags) {
void poptSetOtherOptionHelp(poptContext con, const char * text) {
if (con->otherHelp) xfree(con->otherHelp);
- con->otherHelp = xstrdup(text);
+ con->otherHelp = strdup(text);
}