summaryrefslogtreecommitdiff
path: root/popt
diff options
context:
space:
mode:
authorjbj <devnull@localhost>2001-06-17 15:19:26 +0000
committerjbj <devnull@localhost>2001-06-17 15:19:26 +0000
commitc32276cdf5c28d7d701d7211e55f28ebc6f097d7 (patch)
treee1efb328e183e3d1bcc70c913c2aef0714b0b3a5 /popt
parent6f3943da6c5a26d2bf52cd7c47352bf785e9c8e6 (diff)
downloadrpm-c32276cdf5c28d7d701d7211e55f28ebc6f097d7.tar.gz
rpm-c32276cdf5c28d7d701d7211e55f28ebc6f097d7.tar.bz2
rpm-c32276cdf5c28d7d701d7211e55f28ebc6f097d7.zip
- popt: add POPT_CONTEXT_ARG_OPTS for all opts to return 1 (#30912).
- fix: fsm reads/writes now return error on partial I/O. - fix: Ferror returned spurious error for gzdio/bzdio. CVS patchset: 4874 CVS date: 2001/06/17 15:19:26
Diffstat (limited to 'popt')
-rw-r--r--popt/popt.c15
-rw-r--r--popt/popt.h1
-rw-r--r--popt/popthelp.c24
3 files changed, 27 insertions, 13 deletions
diff --git a/popt/popt.c b/popt/popt.c
index 851f6ab9c..a5672c498 100644
--- a/popt/popt.c
+++ b/popt/popt.c
@@ -675,10 +675,14 @@ int poptGetNextOpt(poptContext con)
return POPT_ERROR_BADOPT;
if (con->restLeftover || *origOptString != '-') {
- if (con->leftovers != NULL) /* XXX can't happen */
- con->leftovers[con->numLeftovers++] = origOptString;
if (con->flags & POPT_CONTEXT_POSIXMEHARDER)
con->restLeftover = 1;
+ if (con->flags & POPT_CONTEXT_ARG_OPTS) {
+ con->os->nextArg = xstrdup(origOptString);
+ return 0;
+ }
+ if (con->leftovers != NULL) /* XXX can't happen */
+ con->leftovers[con->numLeftovers++] = origOptString;
continue;
}
@@ -793,10 +797,11 @@ int poptGetNextOpt(poptContext con)
cleanOSE(con->os--);
}
if (con->os->next == con->os->argc) {
- if (opt->argInfo & POPT_ARGFLAG_OPTIONAL)
- con->os->nextArg = NULL;
- else
+ if (!(opt->argInfo & POPT_ARGFLAG_OPTIONAL))
+ /*@-compdef@*/ /* FIX: con->os->argv not defined */
return POPT_ERROR_NOARG;
+ /*@=compdef@*/
+ con->os->nextArg = NULL;
} else {
/*
diff --git a/popt/popt.h b/popt/popt.h
index 844e67354..a4c60e998 100644
--- a/popt/popt.h
+++ b/popt/popt.h
@@ -110,6 +110,7 @@ extern "C" {
#define POPT_CONTEXT_NO_EXEC (1 << 0) /*!< ignore exec expansions */
#define POPT_CONTEXT_KEEP_FIRST (1 << 1) /*!< pay attention to argv[0] */
#define POPT_CONTEXT_POSIXMEHARDER (1 << 2) /*!< options can't follow args */
+#define POPT_CONTEXT_ARG_OPTS (1 << 4) /*!< return args as options with value 0 */
/*@}*/
/** \ingroup popt
diff --git a/popt/popthelp.c b/popt/popthelp.c
index 5ce98e8cf..b63a15ea9 100644
--- a/popt/popthelp.c
+++ b/popt/popthelp.c
@@ -81,18 +81,22 @@ getArgDescrip(const struct poptOption * opt,
static /*@only@*/ /*@null@*/ char * singleOptionDefaultValue(int lineLength,
const struct poptOption * opt,
- /*@null@*/ const char *translation_domain)
+ /*@-paramuse@*/ /* FIX: i18n macros disable with lclint */
+ /*@null@*/ const char * translation_domain)
+ /*@=paramuse@*/
/*@*/
{
const char * defstr = D_(translation_domain, "default");
- char * l = malloc(4*lineLength + 1);
- char * le = l;
+ char * le = malloc(4*lineLength + 1);
+ char * l = le;
- if (l == NULL) return l; /* XXX can't happen */
+ if (l == NULL) return NULL; /* XXX can't happen */
+ *le = '\0';
*le++ = '(';
le = stpcpy(le, defstr);
*le++ = ':';
*le++ = ' ';
+ if (opt->arg) /* XXX programmer error */
switch (opt->argInfo & POPT_ARG_MASK) {
case POPT_ARG_VAL:
case POPT_ARG_INT:
@@ -128,7 +132,7 @@ static /*@only@*/ /*@null@*/ char * singleOptionDefaultValue(int lineLength,
default:
l = _free(l);
return NULL;
- break;
+ /*@notreached@*/ break;
}
*le++ = ')';
*le = '\0';
@@ -138,7 +142,7 @@ static /*@only@*/ /*@null@*/ char * singleOptionDefaultValue(int lineLength,
static void singleOptionHelp(FILE * fp, int maxLeftCol,
const struct poptOption * opt,
- /*@null@*/ const char *translation_domain)
+ /*@null@*/ const char * translation_domain)
/*@modifies *fp, fileSystem @*/
{
int indentLength = maxLeftCol + 5;
@@ -180,9 +184,13 @@ static void singleOptionHelp(FILE * fp, int maxLeftCol,
if (opt->argInfo & POPT_ARGFLAG_SHOW_DEFAULT) {
defs = singleOptionDefaultValue(lineLength, opt, translation_domain);
if (defs) {
- char * t = malloc(strlen(help) + strlen(defs) + sizeof(" "));
+ char * t = malloc((help ? strlen(help) : 0) +
+ strlen(defs) + sizeof(" "));
if (t) {
- (void) stpcpy( stpcpy( stpcpy(t, help), " "), defs);
+ char * te = t;
+ *te = '\0';
+ if (help) te = stpcpy(te, help);
+ (void) stpcpy( stpcpy( te, " "), defs);
defs = _free(defs);
}
defs = t;