--- popt.c 2002/01/30 14:00:22 1.1
+++ popt.c 2002/03/15 08:49:48 1.2
@@ -25,7 +25,7 @@
*
* NOTICE:
* This is an automatically generated, stripped down version of the
- * POPT 1.6.3 library from Red Hat, Inc. This version is still
+ * POPT 1.6.4 library from Red Hat, Inc. This version is still
* distributed under above Open Source license, but Red Hat is no longer
* responsible for this version. Contact The OSSP Project instead.
*/
@@ -60,6 +60,7 @@
#elif defined(__GNUC__) && defined(__STRICT_ANSI__)
#define alloca __builtin_alloca
#endif
+
#include "popt.h"
#ifndef H_POPTINT
@@ -75,7 +76,7 @@
typedef unsigned int __pbm_bits;
#define __PBM_NBITS (8 * sizeof (__pbm_bits))
#define __PBM_IX(d) ((d) / __PBM_NBITS)
-#define __PBM_MASK(d) ((__pbm_bits) 1 << ((d) % __PBM_NBITS))
+#define __PBM_MASK(d) ((__pbm_bits) 1 << (((unsigned)(d)) % __PBM_NBITS))
typedef struct {
__pbm_bits bits[1];
} pbm_set;
@@ -166,6 +167,7 @@
strcpy(pathbuf, path);
chptr = NULL;
+
do {
if ((chptr = strchr(start, ':')))
*chptr = '\0';
@@ -195,6 +197,8 @@
con->execPath = _free(con->execPath);
con->execPath = strdup(path);
con->execAbsolute = allowAbsolute;
+ return;
+
}
static void invokeCallbacksPRE(popt_context con,
@@ -296,7 +300,7 @@
if (!(flags & POPT_CONTEXT_KEEP_FIRST))
con->os->next = 1;
- con->leftovers = calloc((argc + 1), sizeof (char *));
+ con->leftovers = calloc((argc + 1), sizeof (*con->leftovers));
con->options = options;
con->aliases = NULL;
@@ -624,6 +628,7 @@
break;
if (os->argv != NULL)
for (i = os->next; i < os->argc; i++) {
+
if (os->argb && PBM_ISSET(i, os->argb))
continue;
if (*os->argv[i] == '-')
@@ -638,6 +643,7 @@
PBM_SET(i, os->argb);
}
break;
+
}
if (os > con->optionStack)
os--;
@@ -689,10 +695,14 @@
static void poptStripArg(popt_context con, int which)
{
+
if (con->arg_strip == NULL)
con->arg_strip = PBM_ALLOC(con->optionStack[0].argc);
if (con->arg_strip != NULL)
PBM_SET(which, con->arg_strip);
+
+ return;
+
}
static int poptSaveLong(const struct popt_option *opt, long aLong)
@@ -769,7 +779,9 @@
cleanOSE(con->os--);
}
if (!con->os->nextCharArg && con->os->next == con->os->argc) {
+
invokeCallbacksPOST(con, con->options);
+
if (con->doExec)
return execCommand(con);
return -1;
@@ -783,6 +795,7 @@
con->os->next++;
continue;
}
+
thisopt = con->os->next;
if (con->os->argv != NULL)
origOptString = con->os->argv[con->os->next++];
@@ -878,7 +891,6 @@
origOptString++;
if (*origOptString != '\0')
con->os->nextCharArg = origOptString;
-
}
if (opt == NULL)
@@ -974,12 +986,14 @@
char *end;
if (con->os->nextArg) {
+
int saveerrno = errno;
errno = 0;
aDouble = strtod(con->os->nextArg, &end);
if (errno == ERANGE)
return POPT_ERROR_OVERFLOW;
errno = saveerrno;
+
if (*end != '\0')
return POPT_ERROR_BADNUMBER;
}
@@ -1003,12 +1017,16 @@
("option type (%d) not implemented in popt\n"),
(opt->argInfo & POPT_ARG_MASK));
exit(EXIT_FAILURE);
+ break;
}
}
}
- if (cb)
+ if (cb) {
+
invokeCallbacksOPTION(con, con->options, opt, cbData, shorty);
+
+ }
else if (opt->val && ((opt->argInfo & POPT_ARG_MASK) != POPT_ARG_VAL))
done = 1;
@@ -1051,10 +1069,12 @@
const char *popt_getoptarg(popt_context con)
{
const char *ret = NULL;
+
if (con) {
ret = con->os->nextArg;
con->os->nextArg = NULL;
}
+
return ret;
}
@@ -1133,19 +1153,19 @@
return con;
}
-int popt_addalias(popt_context con, struct popt_alias newAlias, int flags)
+int popt_addalias(popt_context con, struct popt_alias alias, int flags)
{
popt_item item = alloca(sizeof (*item));
memset(item, 0, sizeof (*item));
- item->option.longName = newAlias.longName;
- item->option.shortName = newAlias.shortName;
+ item->option.longName = alias.longName;
+ item->option.shortName = alias.shortName;
item->option.argInfo = POPT_ARGFLAG_DOC_HIDDEN;
item->option.arg = 0;
item->option.val = 0;
item->option.descrip = NULL;
item->option.argDescrip = NULL;
- item->argc = newAlias.argc;
- item->argv = newAlias.argv;
+ item->argc = alias.argc;
+ item->argv = alias.argv;
return popt_additem(con, item, 0);
}
@@ -1310,6 +1330,7 @@
argv2[i] = dst;
dst += strlen(strcpy(dst, argv[i])) + 1;
}
+
argv2[argc] = NULL;
if (argvPtr) {
@@ -1400,7 +1421,9 @@
static void configLine(popt_context con, char *line)
{
+
int nameLength = strlen(con->appName);
+
const char *entryType;
const char *opt;
popt_item item = alloca(sizeof (*item));
@@ -1410,6 +1433,7 @@
if (strncmp(line, con->appName, nameLength))
return;
+
line += nameLength;
if (*line == '\0' || !isspace(*line))
return;
@@ -1477,6 +1501,7 @@
(void)popt_additem(con, item, 0);
else if (!strcmp(entryType, "exec"))
(void)popt_additem(con, item, 1);
+
}
int popt_readconfigfile(popt_context con, const char *fn)
@@ -1495,7 +1520,9 @@
if (fileLength == -1 || lseek(fd, 0, 0) == -1) {
rc = errno;
(void)close(fd);
+
errno = rc;
+
return POPT_ERROR_ERRNO;
}
@@ -1503,7 +1530,9 @@
if (read(fd, (char *)file, fileLength) != fileLength) {
rc = errno;
(void)close(fd);
+
errno = rc;
+
return POPT_ERROR_ERRNO;
}
if (close(fd) == -1)
@@ -1645,7 +1674,7 @@
char *le = malloc(4 * lineLength + 1);
char *l = le;
- if (l == NULL)
+ if (le == NULL)
return NULL;
*le = '\0';
*le++ = '(';
@@ -1873,7 +1902,9 @@
fprintf(fp, "%s\n", help);
out:
+
defs = _free(defs);
+
left = _free(left);
}
|