pm

barely a pack manager
git clone git://z3bra.org/pm
Log | Files | Refs | README | LICENSE

commit cdc4dc147c7d6aece720af47f6fd85e34619635d
parent 1e3c9cc7bfb79be2052b44e6c9c70c95ad0c185b
Author: z3bra <willyatmailoodotorg>
Date:   Thu Jun 16 11:32:44 +0200

Revert "Add ARGLOOP() macro to arg.h"

This reverts commit e6be1867ce5efe508536369f17164ff2f4448e9c.

stdin should not be used to read metadata (filenames). Keep arg.h untouched.

Diffstat:
arg.h | 16----------------
pm.c | 12+++++++-----
2 files changed, 7 insertions(+), 21 deletions(-)
diff --git a/arg.h b/arg.h @@ -29,20 +29,6 @@ extern char *argv0; argc_ = argv[0][0];\ switch (argc_) -#define ARGLOOP() while((argc>0 && *argv)||(!argc && !feof(stdin))){\ - char *lf_;\ - char argi_[LINE_MAX];\ - memset(argi_, 0, LINE_MAX);\ - if (argc>0) {\ - strncpy(argi_, *(argv++), LINE_MAX);\ - } else {\ - fgets(argi_, LINE_MAX, stdin);\ - }\ - if (strnlen(argi_, LINE_MAX) > 0) {\ - lf_ = strrchr(argi_, '\n');\ - if (lf_){ *lf_ = 0; } - - /* Handles obsolete -NUM syntax */ #define ARGNUM case '0':\ case '1':\ @@ -74,8 +60,6 @@ extern char *argv0; (&argv[0][1]) :\ (argc--, argv++, argv[0]))) -#define ARGI() argi_ - #define LNGARG() &argv[0][0] #endif diff --git a/pm.c b/pm.c @@ -771,14 +771,16 @@ main (int argc, char **argv) case ACTION_INSTALL: case ACTION_UPDATE: case ACTION_DELETE: - ARGLOOP(){ + while ((n = ARGV_OR_STDIN(argc, argv)) != NULL) { if (action == ACTION_INSTALL) - r += install(rootfs, datadir, ARGI()); + r += install(rootfs, datadir, n); if (action == ACTION_UPDATE) - r += update(rootfs, datadir, ARGI()); + r += update(rootfs, datadir, n); if (action == ACTION_DELETE) - r += delete(rootfs, datadir, ARGI()); - }ARGEND; + r += delete(rootfs, datadir, n); + + free(n); + } break; case ACTION_INSPECT: if (inspect(datadir, n) != 0)