summaryrefslogtreecommitdiff
path: root/popt.c
diff options
context:
space:
mode:
authorjbj <jbj>2009-01-24 18:12:38 +0000
committerjbj <jbj>2009-01-24 18:12:38 +0000
commitb7ef45ebb16a0371bbb8c77b9022d39948220fdc (patch)
treedb5e9b964a5aaec5d6ed5479cdae2f3514453ec8 /popt.c
parente403ddced3e7dbdb1cefd872f22628619cf757c7 (diff)
downloadlibpopt-b7ef45ebb16a0371bbb8c77b9022d39948220fdc.tar.gz
- jbj: splint fiddles.
Diffstat (limited to 'popt.c')
-rw-r--r--popt.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/popt.c b/popt.c
index acd21b9..6c02a22 100644
--- a/popt.c
+++ b/popt.c
@@ -325,6 +325,9 @@ longOptionStrcmp(const struct poptOption * opt,
const char * optLongName = opt->longName;
int rc;
+ if (optLongName == NULL || longName == NULL) /* XXX can't heppen */
+ return 0;
+
if (F_ISSET(opt, TOGGLE)) {
if (optLongName[0] == 'n' && optLongName[1] == 'o') {
optLongName += sizeof("no") - 1;
@@ -340,9 +343,9 @@ longOptionStrcmp(const struct poptOption * opt,
}
}
}
- rc = (strlen(optLongName) == longNameLen);
+ rc = (int)(strlen(optLongName) == longNameLen);
if (rc)
- rc = !strncmp(optLongName, longName, longNameLen);
+ rc = (int)(strncmp(optLongName, longName, longNameLen) == 0);
return rc;
}
@@ -903,15 +906,15 @@ static unsigned int poptArgInfo(poptContext con, const struct poptOption * opt)
/*@*/
{
unsigned int argInfo = opt->argInfo;
+
+ if (con->os->argv != NULL && con->os->next > 0 && opt->longName != NULL)
if (LF_ISSET(TOGGLE)) {
const char * longName = con->os->argv[con->os->next-1];
while (*longName == '-') longName++;
/* XXX almost good enough but consider --[no]nofoo corner cases. */
if (longName[0] != opt->longName[0] || longName[1] != opt->longName[1])
{
- if (LF_ISSET(XOR)) /* XXX dont toggle with XOR */
- ;
- else {
+ if (!LF_ISSET(XOR)) { /* XXX dont toggle with XOR */
/* Toggle POPT_BIT_SET <=> POPT_BIT_CLR. */
if (LF_ISSET(LOGICALOPS))
argInfo ^= (POPT_ARGFLAG_OR|POPT_ARGFLAG_AND);