X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/18c71e96f8f9281f570046095433df38c6785fd6:/popt-1.2/poptconfig.c..b348deae3ddbb25802a5b533d91e06832212b48a:/popt/poptconfig.c diff --git a/popt-1.2/poptconfig.c b/popt/poptconfig.c similarity index 83% rename from popt-1.2/poptconfig.c rename to popt/poptconfig.c index 8f2656d7..7a1a4c2b 100644 --- a/popt-1.2/poptconfig.c +++ b/popt/poptconfig.c @@ -2,22 +2,7 @@ file accompanying popt source distributions, available from ftp://ftp.redhat.com/pub/code/popt */ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include -#include -#include -#include -#include - -#if HAVE_ALLOCA_H -# include -#endif - -#include "popt.h" +#include "system.h" #include "poptint.h" static void configLine(poptContext con, char * line) { @@ -55,21 +40,21 @@ static void configLine(poptContext con, char * line) { alias.longName = longName, alias.shortName = shortName; poptAddAlias(con, alias, 0); } else if (!strcmp(entryType, "exec")) { - con->execs = realloc(con->execs, + con->execs = realloc(con->execs, sizeof(*con->execs) * (con->numExecs + 1)); if (longName) - con->execs[con->numExecs].longName = strdup(longName); + con->execs[con->numExecs].longName = xstrdup(longName); else con->execs[con->numExecs].longName = NULL; con->execs[con->numExecs].shortName = shortName; - con->execs[con->numExecs].script = strdup(line); + con->execs[con->numExecs].script = xstrdup(line); con->numExecs++; } } -int poptReadConfigFile(poptContext con, char * fn) { +int poptReadConfigFile(poptContext con, const char * fn) { char * file, * chptr, * end; char * buf, * dst; int fd, rc; @@ -84,10 +69,10 @@ int poptReadConfigFile(poptContext con, char * fn) { } fileLength = lseek(fd, 0, SEEK_END); - lseek(fd, 0, 0); + (void) lseek(fd, 0, 0); file = alloca(fileLength + 1); - if ((fd = read(fd, file, fileLength)) != fileLength) { + if (read(fd, file, fileLength) != fileLength) { rc = errno; close(fd); errno = rc; @@ -122,13 +107,14 @@ int poptReadConfigFile(poptContext con, char * fn) { break; default: *dst++ = *chptr++; + break; } } return 0; } -int poptReadDefaultConfig(poptContext con, int useEnv) { +int poptReadDefaultConfig(poptContext con, /*@unused@*/ int useEnv) { char * fn, * home; int rc;