From: Panu Matilainen Date: Tue, 8 Jan 2013 10:51:36 +0000 (+0200) Subject: Alternatively accept files from command line arguments in elfdeps X-Git-Tag: tznext/4.11.0.1.tizen20130304~110 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=41702fa154ad1fdf8a54aa5642f0a572ecfe123b;p=tools%2Flibrpm-tizen.git Alternatively accept files from command line arguments in elfdeps - Nothing actually needs this, but for testing & debugging command line args are often nicer than having to pass stuff via stdin. (cherry picked from commit 6941d51e7e5139014418d1056acb6dafccefbab7) --- diff --git a/tools/elfdeps.c b/tools/elfdeps.c index fc9a905..a140014 100644 --- a/tools/elfdeps.c +++ b/tools/elfdeps.c @@ -282,7 +282,6 @@ exit: int main(int argc, char *argv[]) { - char fn[BUFSIZ]; int provides = 0; int requires = 0; poptContext optCon; @@ -303,9 +302,18 @@ int main(int argc, char *argv[]) exit(EXIT_FAILURE); } - while (fgets(fn, sizeof(fn), stdin) != NULL) { - fn[strlen(fn)-1] = '\0'; - (void) processFile(fn, requires); + /* Normally our data comes from stdin, but permit args too */ + if (poptPeekArg(optCon)) { + const char *fn; + while ((fn = poptGetArg(optCon)) != NULL) { + (void) processFile(fn, requires); + } + } else { + char fn[BUFSIZ]; + while (fgets(fn, sizeof(fn), stdin) != NULL) { + fn[strlen(fn)-1] = '\0'; + (void) processFile(fn, requires); + } } poptFreeContext(optCon);