From: Nathan Wagner Date: Mon, 17 Sep 2018 12:18:16 +0000 (+0000) Subject: remove dupstr and readopts X-Git-Tag: v0.1.6~19 X-Git-Url: https://pd.if.org/git/?p=zpackage;a=commitdiff_plain;h=3d74ddc7c1810f6eb26b1ee60fe4a1fd2a889df3 remove dupstr and readopts --- diff --git a/lib/zpm.c b/lib/zpm.c index 9eb69c2..ebe8909 100644 --- a/lib/zpm.c +++ b/lib/zpm.c @@ -114,18 +114,6 @@ void uncompresslzma(void *buf, size_t bufsize, FILE *out); #define SQLERROR(x) fprintf(stderr, "%s %d: %s\n", __func__, __LINE__, (x)) #endif -static char *dupstr(char *s) { - size_t n; - char *d; - - n = strlen(s); - d = malloc(n+1); - if (d) { - d = strcpy(d, s); - } - return d; -} - #if 0 int zpm_newpkg(struct zpm *z, char *base, char *version, int release) { char *sql = "insert or ignore into packages (package,version,release) values (?,?,?)"; @@ -430,37 +418,6 @@ int zpm_addvercmp(struct zpm *pkg) { ); } -/* set package struct variables, database, environment, then command line */ -int zpm_readopts(struct zpm *zpm, int ac, char **av) { - char *ev; - struct zpm_package *pkg; - - if (!zpm) { - return -1; - } - - pkg = zpm->current_package; - - if (pkg) { - ev = getenv("ZPMPACKAGE"); - if (ev) { - pkg->name = dupstr(ev); - } - ev = getenv("ZPMPKGREL"); - if (ev) { - pkg->release = strtol(ev, 0, 0); - } - ev = getenv("ZPMPKGVER"); - if (ev) { - pkg->version = dupstr(ev); - } - } - - /* now, parse the options, return optind so the caller can adjust if needed */ - - return av ? ac : 1; -} - int zpm_extract(struct zpm *pkg, char *hash, char *path, int mode) { int rc; diff --git a/zpm-addfile.c b/zpm-addfile.c index fd8d67b..99f914c 100644 --- a/zpm-addfile.c +++ b/zpm-addfile.c @@ -12,9 +12,6 @@ int main(int ac, char **av){ return 1; } - /* this is really just read env */ - zpm_readopts(&pkg, ac, av); - if (zpm_open(&pkg, av[1])) { zpm_begin(&pkg); for (i=2; i