tRevert "Add ARGLOOP() macro to arg.h" - pm - barely a pack manager
(HTM) git clone git://z3bra.org/pm
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit cdc4dc147c7d6aece720af47f6fd85e34619635d
(DIR) parent 1e3c9cc7bfb79be2052b44e6c9c70c95ad0c185b
(HTM) Author: z3bra <willyatmailoodotorg>
Date: Thu, 16 Jun 2016 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:
M arg.h | 16 ----------------
M pm.c | 12 +++++++-----
2 files changed, 7 insertions(+), 21 deletions(-)
---
(DIR) diff --git a/arg.h b/arg.h
t@@ -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':\
t@@ -74,8 +60,6 @@ extern char *argv0;
(&argv[0][1]) :\
(argc--, argv++, argv[0])))
-#define ARGI() argi_
-
#define LNGARG() &argv[0][0]
#endif
(DIR) diff --git a/pm.c b/pm.c
t@@ -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)