Commit cc248aae authored by Wayne Davison's avatar Wayne Davison

Updated to version 1.6.4.

parent ca23c51a
1.3 -> 1.5 -> 1.6
- add ability to perform callbacks for every, not just first, match.
1.3 -> 1.5
- heavy dose of const's - heavy dose of const's
- poptParseArgvString() now NULL terminates the list - poptParseArgvString() now NULL terminates the list
......
...@@ -5,7 +5,7 @@ to getopt(3), it contains a number of enhancements, including: ...@@ -5,7 +5,7 @@ to getopt(3), it contains a number of enhancements, including:
2) popt can parse arbitrary argv[] style arrays while 2) popt can parse arbitrary argv[] style arrays while
getopt(2) makes this quite difficult getopt(2) makes this quite difficult
3) popt allows users to alias command line arguments 3) popt allows users to alias command line arguments
4) popt provides convience functions for parsting strings 4) popt provides convience functions for parsing strings
into argv[] style arrays into argv[] style arrays
popt is used by rpm, the Red Hat install program, and many other Red Hat popt is used by rpm, the Red Hat install program, and many other Red Hat
......
Unlike zlib, this is a perfectly ordinary copy of libpopt. It's only This is a perfectly ordinary copy of libpopt. It is only used on platforms
used on platforms that don't have a sufficiently up-to-date copy of that do not have a sufficiently up-to-date copy of their own. If you build
their own. If you build rsync on a platform which has popt, this rsync on a platform which has popt, this directory should not be used. (You
directory should not be used. (You can control that using can control that using the --with-included-popt configure flag.)
--with-included-popt.)
/* (C) 1998 Red Hat Software, Inc. -- Licensing details are in the COPYING /** \ingroup popt
* \file popt/findme.c
*/
/* (C) 1998-2000 Red Hat, Inc. -- Licensing details are in the COPYING
file accompanying popt source distributions, available from file accompanying popt source distributions, available from
ftp://ftp.redhat.com/pub/code/popt */ ftp://ftp.rpm.org/pub/rpm/dist. */
#include "system.h" #include "system.h"
#include "findme.h" #include "findme.h"
...@@ -9,38 +13,38 @@ const char * findProgramPath(const char * argv0) { ...@@ -9,38 +13,38 @@ const char * findProgramPath(const char * argv0) {
char * path = getenv("PATH"); char * path = getenv("PATH");
char * pathbuf; char * pathbuf;
char * start, * chptr; char * start, * chptr;
char * buf, *local = NULL; char * buf;
/* If there is a / in the argv[0], it has to be an absolute if (argv0 == NULL) return NULL; /* XXX can't happen */
path */ /* If there is a / in the argv[0], it has to be an absolute path */
if (strchr(argv0, '/')) if (strchr(argv0, '/'))
return xstrdup(argv0); return xstrdup(argv0);
if (!path) return NULL; if (path == NULL) return NULL;
local = start = pathbuf = malloc(strlen(path) + 1); start = pathbuf = alloca(strlen(path) + 1);
buf = malloc(strlen(path) + strlen(argv0) + 2); buf = malloc(strlen(path) + strlen(argv0) + sizeof("/"));
if (buf == NULL) return NULL; /* XXX can't happen */
strcpy(pathbuf, path); strcpy(pathbuf, path);
chptr = NULL; chptr = NULL;
/*@-branchstate@*/
do { do {
if ((chptr = strchr(start, ':'))) if ((chptr = strchr(start, ':')))
*chptr = '\0'; *chptr = '\0';
sprintf(buf, "%s/%s", start, argv0); sprintf(buf, "%s/%s", start, argv0);
if (!access(buf, X_OK)) { if (!access(buf, X_OK))
if (local) free(local); return buf;
return buf;
}
if (chptr) if (chptr)
start = chptr + 1; start = chptr + 1;
else else
start = NULL; start = NULL;
} while (start && *start); } while (start && *start);
/*@=branchstate@*/
free(buf); free(buf);
if (local) free(local);
return NULL; return NULL;
} }
/* (C) 1998 Red Hat Software, Inc. -- Licensing details are in the COPYING /** \ingroup popt
* \file popt/findme.h
*/
/* (C) 1998-2000 Red Hat, Inc. -- Licensing details are in the COPYING
file accompanying popt source distributions, available from file accompanying popt source distributions, available from
ftp://ftp.redhat.com/pub/code/popt */ ftp://ftp.rpm.org/pub/rpm/dist. */
#ifndef H_FINDME #ifndef H_FINDME
#define H_FINDME #define H_FINDME
const char * findProgramPath(const char * argv0); /**
* Return absolute path to executable by searching PATH.
* @param argv0 name of executable
* @return (malloc'd) absolute path to executable (or NULL)
*/
/*@null@*/ const char * findProgramPath(/*@null@*/ const char * argv0)
/*@*/;
#endif #endif
This diff is collapsed.
This diff is collapsed.
/* (C) 1998 Red Hat Software, Inc. -- Licensing details are in the COPYING /** \ingroup popt
* \file popt/poptconfig.c
*/
/* (C) 1998-2000 Red Hat, Inc. -- Licensing details are in the COPYING
file accompanying popt source distributions, available from file accompanying popt source distributions, available from
ftp://ftp.redhat.com/pub/code/popt */ ftp://ftp.rpm.org/pub/rpm/dist. */
#include "system.h" #include "system.h"
#include "poptint.h" #include "poptint.h"
static void configLine(poptContext con, char * line) { /*@-compmempass@*/ /* FIX: item->option.longName kept, not dependent. */
static void configLine(poptContext con, char * line)
/*@modifies con @*/
{
/*@-type@*/
int nameLength = strlen(con->appName); int nameLength = strlen(con->appName);
char * opt; /*@=type@*/
struct poptAlias alias; const char * entryType;
char * entryType; const char * opt;
char * longName = NULL; poptItem item = alloca(sizeof(*item));
char shortName = '\0'; int i, j;
memset(item, 0, sizeof(*item));
/*@-type@*/
if (strncmp(line, con->appName, nameLength)) return; if (strncmp(line, con->appName, nameLength)) return;
/*@=type@*/
line += nameLength; line += nameLength;
if (!*line || !isspace(*line)) return; if (*line == '\0' || !isspace(*line)) return;
while (*line && isspace(*line)) line++;
entryType = line;
while (!*line || !isspace(*line)) line++; while (*line != '\0' && isspace(*line)) line++;
entryType = line;
while (*line == '\0' || !isspace(*line)) line++;
*line++ = '\0'; *line++ = '\0';
while (*line && isspace(*line)) line++;
if (!*line) return;
opt = line;
while (!*line || !isspace(*line)) line++; while (*line != '\0' && isspace(*line)) line++;
if (*line == '\0') return;
opt = line;
while (*line == '\0' || !isspace(*line)) line++;
*line++ = '\0'; *line++ = '\0';
while (*line && isspace(*line)) line++;
if (!*line) return;
while (*line != '\0' && isspace(*line)) line++;
if (*line == '\0') return;
/*@-temptrans@*/ /* FIX: line alias is saved */
if (opt[0] == '-' && opt[1] == '-') if (opt[0] == '-' && opt[1] == '-')
longName = opt + 2; item->option.longName = opt + 2;
else if (opt[0] == '-' && !opt[2]) else if (opt[0] == '-' && opt[2] == '\0')
shortName = opt[1]; item->option.shortName = opt[1];
/*@=temptrans@*/
if (!strcmp(entryType, "alias")) {
if (poptParseArgvString(line, &alias.argc, &alias.argv)) return; if (poptParseArgvString(line, &item->argc, &item->argv)) return;
alias.longName = longName, alias.shortName = shortName;
poptAddAlias(con, alias, 0); /*@-modobserver@*/
} else if (!strcmp(entryType, "exec")) { item->option.argInfo = POPT_ARGFLAG_DOC_HIDDEN;
con->execs = realloc(con->execs, for (i = 0, j = 0; i < item->argc; i++, j++) {
sizeof(*con->execs) * (con->numExecs + 1)); const char * f;
if (longName) if (!strncmp(item->argv[i], "--POPTdesc=", sizeof("--POPTdesc=")-1)) {
con->execs[con->numExecs].longName = xstrdup(longName); f = item->argv[i] + sizeof("--POPTdesc=");
else if (f[0] == '$' && f[1] == '"') f++;
con->execs[con->numExecs].longName = NULL; item->option.descrip = f;
item->option.argInfo &= ~POPT_ARGFLAG_DOC_HIDDEN;
con->execs[con->numExecs].shortName = shortName; j--;
con->execs[con->numExecs].script = xstrdup(line); } else
if (!strncmp(item->argv[i], "--POPTargs=", sizeof("--POPTargs=")-1)) {
con->numExecs++; f = item->argv[i] + sizeof("--POPTargs=");
if (f[0] == '$' && f[1] == '"') f++;
item->option.argDescrip = f;
item->option.argInfo &= ~POPT_ARGFLAG_DOC_HIDDEN;
item->option.argInfo |= POPT_ARG_STRING;
j--;
} else
if (j != i)
item->argv[j] = item->argv[i];
}
if (j != i) {
item->argv[j] = NULL;
item->argc = j;
} }
/*@=modobserver@*/
/*@-nullstate@*/ /* FIX: item->argv[] may be NULL */
if (!strcmp(entryType, "alias"))
(void) poptAddItem(con, item, 0);
else if (!strcmp(entryType, "exec"))
(void) poptAddItem(con, item, 1);
/*@=nullstate@*/
} }
/*@=compmempass@*/
int poptReadConfigFile(poptContext con, const char * fn) { int poptReadConfigFile(poptContext con, const char * fn)
char * file=NULL, * chptr, * end; {
char * buf=NULL, * dst; const char * file, * chptr, * end;
char * buf;
/*@dependent@*/ char * dst;
int fd, rc; int fd, rc;
int fileLength; off_t fileLength;
fd = open(fn, O_RDONLY); fd = open(fn, O_RDONLY);
if (fd < 0) { if (fd < 0)
if (errno == ENOENT) return (errno == ENOENT ? 0 : POPT_ERROR_ERRNO);
return 0;
else
return POPT_ERROR_ERRNO;
}
fileLength = lseek(fd, 0, SEEK_END); fileLength = lseek(fd, 0, SEEK_END);
(void) lseek(fd, 0, 0); if (fileLength == -1 || lseek(fd, 0, 0) == -1) {
rc = errno;
(void) close(fd);
/*@-mods@*/
errno = rc;
/*@=mods@*/
return POPT_ERROR_ERRNO;
}
file = malloc(fileLength + 1); file = alloca(fileLength + 1);
if (read(fd, file, fileLength) != fileLength) { if (read(fd, (char *)file, fileLength) != fileLength) {
rc = errno; rc = errno;
close(fd); (void) close(fd);
/*@-mods@*/
errno = rc; errno = rc;
if (file) free(file); /*@=mods@*/
return POPT_ERROR_ERRNO; return POPT_ERROR_ERRNO;
} }
close(fd); if (close(fd) == -1)
return POPT_ERROR_ERRNO;
dst = buf = malloc(fileLength + 1); dst = buf = alloca(fileLength + 1);
chptr = file; chptr = file;
end = (file + fileLength); end = (file + fileLength);
/*@-infloops@*/ /* LCL: can't detect chptr++ */
while (chptr < end) { while (chptr < end) {
switch (*chptr) { switch (*chptr) {
case '\n': case '\n':
*dst = '\0'; *dst = '\0';
dst = buf; dst = buf;
while (*dst && isspace(*dst)) dst++; while (*dst && isspace(*dst)) dst++;
if (*dst && *dst != '#') { if (*dst && *dst != '#')
configLine(con, dst); configLine(con, dst);
}
chptr++; chptr++;
break; /*@switchbreak@*/ break;
case '\\': case '\\':
*dst++ = *chptr++; *dst++ = *chptr++;
if (chptr < end) { if (chptr < end) {
...@@ -105,15 +148,13 @@ int poptReadConfigFile(poptContext con, const char * fn) { ...@@ -105,15 +148,13 @@ int poptReadConfigFile(poptContext con, const char * fn) {
else else
*dst++ = *chptr++; *dst++ = *chptr++;
} }
break; /*@switchbreak@*/ break;
default: default:
*dst++ = *chptr++; *dst++ = *chptr++;
break; /*@switchbreak@*/ break;
} }
} }
/*@=infloops@*/
free(file);
free(buf);
return 0; return 0;
} }
...@@ -122,21 +163,21 @@ int poptReadDefaultConfig(poptContext con, /*@unused@*/ int useEnv) { ...@@ -122,21 +163,21 @@ int poptReadDefaultConfig(poptContext con, /*@unused@*/ int useEnv) {
char * fn, * home; char * fn, * home;
int rc; int rc;
/*@-type@*/
if (!con->appName) return 0; if (!con->appName) return 0;
/*@=type@*/
rc = poptReadConfigFile(con, "/etc/popt"); rc = poptReadConfigFile(con, "/etc/popt");
if (rc) return rc; if (rc) return rc;
if (getuid() != geteuid()) return 0; if (getuid() != geteuid()) return 0;
if ((home = getenv("HOME"))) { if ((home = getenv("HOME"))) {
fn = malloc(strlen(home) + 20); fn = alloca(strlen(home) + 20);
strcpy(fn, home); strcpy(fn, home);
strcat(fn, "/.popt"); strcat(fn, "/.popt");
rc = poptReadConfigFile(con, fn); rc = poptReadConfigFile(con, fn);
free(fn);
if (rc) return rc; if (rc) return rc;
} }
return 0; return 0;
} }
This diff is collapsed.
/* (C) 1998 Red Hat Software, Inc. -- Licensing details are in the COPYING /** \ingroup popt
* \file popt/poptint.h
*/
/* (C) 1998-2000 Red Hat, Inc. -- Licensing details are in the COPYING
file accompanying popt source distributions, available from file accompanying popt source distributions, available from
ftp://ftp.redhat.com/pub/code/popt */ ftp://ftp.rpm.org/pub/rpm/dist. */
#ifndef H_POPTINT #ifndef H_POPTINT
#define H_POPTINT #define H_POPTINT
/**
* Wrapper to free(3), hides const compilation noise, permit NULL, return NULL.
* @param p memory to free
* @retval NULL always
*/
/*@unused@*/ static inline /*@null@*/ void *
_free(/*@only@*/ /*@null@*/ const void * p)
/*@modifies p @*/
{
if (p != NULL) free((void *)p);
return NULL;
}
/* Bit mask macros. */ /* Bit mask macros. */
typedef unsigned int __pbm_bits; typedef unsigned int __pbm_bits;
#define __PBM_NBITS (8 * sizeof (__pbm_bits)) #define __PBM_NBITS (8 * sizeof (__pbm_bits))
#define __PBM_IX(d) ((d) / __PBM_NBITS) #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 { typedef struct {
__pbm_bits bits[1]; __pbm_bits bits[1];
} pbm_set; } pbm_set;
#define __PBM_BITS(set) ((set)->bits) #define __PBM_BITS(set) ((set)->bits)
#define PBM_ALLOC(d) calloc(__PBM_IX (d) + 1, sizeof(__pbm_bits)) #define PBM_ALLOC(d) calloc(__PBM_IX (d) + 1, sizeof(__pbm_bits))
#define PBM_FREE(s) free(s); #define PBM_FREE(s) _free(s);
#define PBM_SET(d, s) (__PBM_BITS (s)[__PBM_IX (d)] |= __PBM_MASK (d)) #define PBM_SET(d, s) (__PBM_BITS (s)[__PBM_IX (d)] |= __PBM_MASK (d))
#define PBM_CLR(d, s) (__PBM_BITS (s)[__PBM_IX (d)] &= ~__PBM_MASK (d)) #define PBM_CLR(d, s) (__PBM_BITS (s)[__PBM_IX (d)] &= ~__PBM_MASK (d))
#define PBM_ISSET(d, s) ((__PBM_BITS (s)[__PBM_IX (d)] & __PBM_MASK (d)) != 0) #define PBM_ISSET(d, s) ((__PBM_BITS (s)[__PBM_IX (d)] & __PBM_MASK (d)) != 0)
struct optionStackEntry { struct optionStackEntry {
int argc; int argc;
/*@only@*/ const char ** argv; /*@only@*/ /*@null@*/ const char ** argv;
/*@only@*/ pbm_set * argb; /*@only@*/ /*@null@*/ pbm_set * argb;
int next; int next;
/*@only@*/ const char * nextArg; /*@only@*/ /*@null@*/ const char * nextArg;
/*@keep@*/ const char * nextCharArg; /*@keep@*/ /*@null@*/ const char * nextCharArg;
/*@dependent@*/ struct poptAlias * currAlias; /*@dependent@*/ /*@null@*/ poptItem currAlias;
int stuffed; int stuffed;
}; };
struct execEntry {
const char * longName;
char shortName;
const char * script;
};
struct poptContext_s { struct poptContext_s {
struct optionStackEntry optionStack[POPT_OPTION_DEPTH]; struct optionStackEntry optionStack[POPT_OPTION_DEPTH];
/*@dependent@*/ struct optionStackEntry * os; /*@dependent@*/ struct optionStackEntry * os;
/*@owned@*/ const char ** leftovers; /*@owned@*/ /*@null@*/ const char ** leftovers;
int numLeftovers; int numLeftovers;
int nextLeftover; int nextLeftover;
/*@keep@*/ const struct poptOption * options; /*@keep@*/ const struct poptOption * options;
int restLeftover; int restLeftover;
/*@only@*/ const char * appName; /*@only@*/ /*@null@*/ const char * appName;
/*@only@*/ struct poptAlias * aliases; /*@only@*/ /*@null@*/ poptItem aliases;
int numAliases; int numAliases;
int flags; int flags;
struct execEntry * execs; /*@owned@*/ /*@null@*/ poptItem execs;
int numExecs; int numExecs;
/*@only@*/ const char ** finalArgv; /*@only@*/ /*@null@*/ const char ** finalArgv;
int finalArgvCount; int finalArgvCount;
int finalArgvAlloced; int finalArgvAlloced;
/*@dependent@*/ struct execEntry * doExec; /*@dependent@*/ /*@null@*/ poptItem doExec;
/*@only@*/ const char * execPath; /*@only@*/ const char * execPath;
int execAbsolute; int execAbsolute;
/*@only@*/ const char * otherHelp; /*@only@*/ const char * otherHelp;
pbm_set * arg_strip; /*@null@*/ pbm_set * arg_strip;
}; };
#define xfree(_a) free((void *)_a)
#ifdef HAVE_LIBINTL_H #ifdef HAVE_LIBINTL_H
#include <libintl.h> #include <libintl.h>
#endif #endif
...@@ -71,17 +80,17 @@ struct poptContext_s { ...@@ -71,17 +80,17 @@ struct poptContext_s {
#if defined(HAVE_GETTEXT) && !defined(__LCLINT__) #if defined(HAVE_GETTEXT) && !defined(__LCLINT__)
#define _(foo) gettext(foo) #define _(foo) gettext(foo)
#else #else
#define _(foo) (foo) #define _(foo) foo
#endif #endif
#if defined(HAVE_DGETTEXT) && !defined(__LCLINT__) #if defined(HAVE_DGETTEXT) && !defined(__LCLINT__)
#define D_(dom, str) dgettext(dom, str) #define D_(dom, str) dgettext(dom, str)
#define POPT_(foo) D_("popt", foo) #define POPT_(foo) D_("popt", foo)
#else #else
#define POPT_(foo) (foo) #define D_(dom, str) str
#define D_(dom, str) (str) #define POPT_(foo) foo
#endif #endif
#define N_(foo) (foo) #define N_(foo) foo
#endif #endif
/* (C) 1998 Red Hat Software, Inc. -- Licensing details are in the COPYING /** \ingroup popt
* \file popt/poptparse.c
*/
/* (C) 1998-2000 Red Hat, Inc. -- Licensing details are in the COPYING
file accompanying popt source distributions, available from file accompanying popt source distributions, available from
ftp://ftp.redhat.com/pub/code/popt */ ftp://ftp.rpm.org/pub/rpm/dist. */
#include "system.h" #include "system.h"
...@@ -14,6 +18,8 @@ int poptDupArgv(int argc, const char **argv, ...@@ -14,6 +18,8 @@ int poptDupArgv(int argc, const char **argv,
char * dst; char * dst;
int i; int i;
if (argc <= 0 || argv == NULL) /* XXX can't happen */
return POPT_ERROR_NOARG;
for (i = 0; i < argc; i++) { for (i = 0; i < argc; i++) {
if (argv[i] == NULL) if (argv[i] == NULL)
return POPT_ERROR_NOARG; return POPT_ERROR_NOARG;
...@@ -21,17 +27,27 @@ int poptDupArgv(int argc, const char **argv, ...@@ -21,17 +27,27 @@ int poptDupArgv(int argc, const char **argv,
} }
dst = malloc(nb); dst = malloc(nb);
if (dst == NULL) /* XXX can't happen */
return POPT_ERROR_MALLOC;
argv2 = (void *) dst; argv2 = (void *) dst;
dst += (argc + 1) * sizeof(*argv); dst += (argc + 1) * sizeof(*argv);
/*@-branchstate@*/
for (i = 0; i < argc; i++) { for (i = 0; i < argc; i++) {
argv2[i] = dst; argv2[i] = dst;
dst += strlen(strcpy(dst, argv[i])) + 1; dst += strlen(strcpy(dst, argv[i])) + 1;
} }
/*@=branchstate@*/
argv2[argc] = NULL; argv2[argc] = NULL;
*argvPtr = argv2; if (argvPtr) {
*argcPtr = argc; *argvPtr = argv2;
} else {
free(argv2);
argv2 = NULL;
}
if (argcPtr)
*argcPtr = argc;
return 0; return 0;
} }
...@@ -43,31 +59,32 @@ int poptParseArgvString(const char * s, int * argcPtr, const char *** argvPtr) ...@@ -43,31 +59,32 @@ int poptParseArgvString(const char * s, int * argcPtr, const char *** argvPtr)
const char ** argv = malloc(sizeof(*argv) * argvAlloced); const char ** argv = malloc(sizeof(*argv) * argvAlloced);
int argc = 0; int argc = 0;
int buflen = strlen(s) + 1; int buflen = strlen(s) + 1;
char *buf0 = calloc(buflen, 1); char * buf = memset(alloca(buflen), 0, buflen);
char *buf = buf0; int rc = POPT_ERROR_MALLOC;
if (argv == NULL) return rc;
argv[argc] = buf; argv[argc] = buf;
for (src = s; *src; src++) { for (src = s; *src != '\0'; src++) {
if (quote == *src) { if (quote == *src) {
quote = '\0'; quote = '\0';
} else if (quote) { } else if (quote != '\0') {
if (*src == '\\') { if (*src == '\\') {
src++; src++;
if (!*src) { if (!*src) {
free(argv); rc = POPT_ERROR_BADQUOTE;
free(buf0); goto exit;
return POPT_ERROR_BADQUOTE;
} }
if (*src != quote) *buf++ = '\\'; if (*src != quote) *buf++ = '\\';
} }
*buf++ = *src; *buf++ = *src;
} else if (isspace(*src)) { } else if (isspace(*src)) {
if (*argv[argc]) { if (*argv[argc] != '\0') {
buf++, argc++; buf++, argc++;
if (argc == argvAlloced) { if (argc == argvAlloced) {
argvAlloced += POPT_ARGV_ARRAY_GROW_DELTA; argvAlloced += POPT_ARGV_ARRAY_GROW_DELTA;
argv = realloc(argv, sizeof(*argv) * argvAlloced); argv = realloc(argv, sizeof(*argv) * argvAlloced);
if (argv == NULL) goto exit;
} }
argv[argc] = buf; argv[argc] = buf;
} }
...@@ -75,18 +92,17 @@ int poptParseArgvString(const char * s, int * argcPtr, const char *** argvPtr) ...@@ -75,18 +92,17 @@ int poptParseArgvString(const char * s, int * argcPtr, const char *** argvPtr)
case '"': case '"':
case '\'': case '\'':
quote = *src; quote = *src;
break; /*@switchbreak@*/ break;
case '\\': case '\\':
src++; src++;
if (!*src) { if (!*src) {
free(argv); rc = POPT_ERROR_BADQUOTE;
free(buf0); goto exit;
return POPT_ERROR_BADQUOTE;
} }
/*@fallthrough@*/ /*@fallthrough@*/
default: default:
*buf++ = *src; *buf++ = *src;
break; /*@switchbreak@*/ break;
} }
} }
...@@ -94,9 +110,9 @@ int poptParseArgvString(const char * s, int * argcPtr, const char *** argvPtr) ...@@ -94,9 +110,9 @@ int poptParseArgvString(const char * s, int * argcPtr, const char *** argvPtr)
argc++, buf++; argc++, buf++;
} }
(void) poptDupArgv(argc, argv, argcPtr, argvPtr); rc = poptDupArgv(argc, argv, argcPtr, argvPtr);
free(argv); exit:
free(buf0); if (argv) free(argv);
return 0; return rc;
} }
...@@ -25,6 +25,14 @@ ...@@ -25,6 +25,14 @@
#include <libc.h> #include <libc.h>
#endif #endif
#if defined(__LCLINT__)
/*@-declundef -incondefs -redecl@*/ /* LCL: missing annotation */
/*@only@*/ void * alloca (size_t __size)
/*@ensures MaxSet(result) == (__size - 1) @*/
/*@*/;
/*@=declundef =incondefs =redecl@*/
#endif
/* AIX requires this to be the first thing in the file. */ /* AIX requires this to be the first thing in the file. */
#ifndef __GNUC__ #ifndef __GNUC__
# if HAVE_ALLOCA_H # if HAVE_ALLOCA_H
...@@ -42,7 +50,10 @@ char *alloca (); ...@@ -42,7 +50,10 @@ char *alloca ();
#define alloca __builtin_alloca #define alloca __builtin_alloca
#endif #endif
/*@only@*/ char * xstrdup (const char *str); /*@-redecl -redef@*/
/*@mayexit@*/ /*@only@*/ char * xstrdup (const char *str)
/*@*/;
/*@=redecl =redef@*/
#if HAVE_MCHECK_H && defined(__GNUC__) #if HAVE_MCHECK_H && defined(__GNUC__)
#define vmefail() (fprintf(stderr, "virtual memory exhausted.\n"), exit(EXIT_FAILURE), NULL) #define vmefail() (fprintf(stderr, "virtual memory exhausted.\n"), exit(EXIT_FAILURE), NULL)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment