diff options
Diffstat (limited to 'support/popthelp.c')
-rw-r--r-- | support/popthelp.c | 50 |
1 files changed, 20 insertions, 30 deletions
diff --git a/support/popthelp.c b/support/popthelp.c index fc2764a5..c36ecead 100644 --- a/support/popthelp.c +++ b/support/popthelp.c @@ -4,25 +4,13 @@ file accompanying popt source distributions, available from ftp://ftp.redhat.com/pub/code/popt */ -#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 "system.h" #include "poptint.h" -static void displayArgs(poptContext con, enum poptCallbackReason foo, - struct poptOption * key, - const char * arg, void * data) { +static void displayArgs(poptContext con, + /*@unused@*/ enum poptCallbackReason foo, + struct poptOption * key, + /*@unused@*/ const char * arg, /*@unused@*/ void * data) { if (key->shortName== '?') poptPrintHelp(con, stdout, 0); else @@ -31,14 +19,14 @@ static void displayArgs(poptContext con, enum poptCallbackReason foo, } struct poptOption poptHelpOptions[] = { - { 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 } + { 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 } } ; -static const char * +/*@observer@*/ /*@null@*/ static const char *const getTableTranslationDomain(const struct poptOption *table) { const struct poptOption *opt; @@ -53,8 +41,9 @@ getTableTranslationDomain(const struct poptOption *table) return NULL; } -static const char * getArgDescrip(const struct poptOption * opt, - const char *translation_domain) { +/*@observer@*/ /*@null@*/ static const char *const +getArgDescrip(const struct poptOption * opt, const char *translation_domain) +{ if (!(opt->argInfo & POPT_ARG_MASK)) return NULL; if (opt == (poptHelpOptions + 1) || opt == (poptHelpOptions + 2)) @@ -193,7 +182,7 @@ static int showHelpIntro(poptContext con, FILE * f) { return len; } -void poptPrintHelp(poptContext con, FILE * f, int flags) { +void poptPrintHelp(poptContext con, FILE * f, /*@unused@*/ int flags) { int leftColWidth; showHelpIntro(con, f); @@ -210,7 +199,7 @@ static int singleOptionUsage(FILE * f, int cursor, const struct poptOption * opt, const char *translation_domain) { int len = 3; - char shortStr[2]; + char shortStr[2] = { '\0', '\0' }; const char * item = shortStr; const char * argDescrip = getArgDescrip(opt, translation_domain); @@ -268,9 +257,10 @@ 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 */ - if (!str) { + s[0] = '\0'; + if (str == NULL) { + memset(s, 0, sizeof(s)); str = s; - memset(str, 0, sizeof(s)); } while (opt->longName || opt->shortName || opt->arg) { @@ -289,7 +279,7 @@ static int showShortOptions(const struct poptOption * opt, FILE * f, return strlen(s) + 4; } -void poptPrintUsage(poptContext con, FILE * f, int flags) { +void poptPrintUsage(poptContext con, FILE * f, /*@unused@*/ int flags) { int cursor; cursor = showHelpIntro(con, f); @@ -307,5 +297,5 @@ void poptPrintUsage(poptContext con, FILE * f, int flags) { void poptSetOtherOptionHelp(poptContext con, const char * text) { if (con->otherHelp) xfree(con->otherHelp); - con->otherHelp = strdup(text); + con->otherHelp = xstrdup(text); } |