vapier      15/08/05 07:11:22

  Modified:             Makefile uname-test.c
  Log:
  allow more than one file to be specified on the command line for easier mass 
processing

Revision  Changes    Path
1.2                  src/patchsets/coreutils/uname-test/Makefile

file : 
http://sources.gentoo.org/viewvc.cgi/gentoo/src/patchsets/coreutils/uname-test/Makefile?rev=1.2&view=markup
plain: 
http://sources.gentoo.org/viewvc.cgi/gentoo/src/patchsets/coreutils/uname-test/Makefile?rev=1.2&content-type=text/plain
diff : 
http://sources.gentoo.org/viewvc.cgi/gentoo/src/patchsets/coreutils/uname-test/Makefile?r1=1.1&r2=1.2

Index: Makefile
===================================================================
RCS file: /var/cvsroot/gentoo/src/patchsets/coreutils/uname-test/Makefile,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Makefile    24 Jun 2006 19:36:38 -0000      1.1
+++ Makefile    5 Aug 2015 07:11:22 -0000       1.2
@@ -5,9 +5,7 @@
 test: check
 
 check: uname-test
-       for f in $(wildcard *.data) ; do \
-               ./uname-test $$f || exit 1 ; \
-       done
+       ./uname-test *.data
 
 clean:
        rm -f uname-test



1.8                  src/patchsets/coreutils/uname-test/uname-test.c

file : 
http://sources.gentoo.org/viewvc.cgi/gentoo/src/patchsets/coreutils/uname-test/uname-test.c?rev=1.8&view=markup
plain: 
http://sources.gentoo.org/viewvc.cgi/gentoo/src/patchsets/coreutils/uname-test/uname-test.c?rev=1.8&content-type=text/plain
diff : 
http://sources.gentoo.org/viewvc.cgi/gentoo/src/patchsets/coreutils/uname-test/uname-test.c?r1=1.7&r2=1.8

Index: uname-test.c
===================================================================
RCS file: /var/cvsroot/gentoo/src/patchsets/coreutils/uname-test/uname-test.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- uname-test.c        5 Aug 2015 07:06:12 -0000       1.7
+++ uname-test.c        5 Aug 2015 07:11:22 -0000       1.8
@@ -153,41 +153,25 @@
        return false;
 }
 
-int main(int argc, char *argv[])
+static bool process_file(const char *file)
 {
        static char processor[257];
        static char hardware_platform[257];
-       int i;
-
-       while ((i = getopt(argc, argv, "v")) != -1) {
-               switch (i) {
-               case 'v':
-                       verbose = true;
-                       break;
-               default:
- usage:
-                       errx(1, "Usage: uname-test [-v] <file>");
-               }
-       }
-       if (optind + 1 != argc)
-               goto usage;
+       bool ret = true;
 
-       filename = argv[optind];
+       filename = file;
        printf(">>> Parsing data out of %s\n", filename);
-
        if (!procinfo_init())
-               return 1;
-
-       i = 0;
+               return false;
 
        if (0 > __linux_procinfo (PROCINFO_PROCESSOR, processor, sizeof 
processor)) {
                strcpy(processor, "failed");
-               ++i;
+               ret = false;
        }
 
        if (0 > __linux_procinfo (PROCINFO_HARDWARE_PLATFORM, 
hardware_platform, sizeof hardware_platform)) {
                strcpy(hardware_platform, "failed");
-               ++i;
+               ret = false;
        }
 
        printf(">>> Results from %s:\n", filename);
@@ -196,5 +180,30 @@
 
        printf("\n");
 
-       return i;
+       return ret;
+}
+
+int main(int argc, char *argv[])
+{
+       int i, ret;
+
+       while ((i = getopt(argc, argv, "v")) != -1) {
+               switch (i) {
+               case 'v':
+                       verbose = true;
+                       break;
+               default:
+ usage:
+                       errx(1, "Usage: uname-test [-v] <file> [files]");
+               }
+       }
+       if (optind == argc)
+               goto usage;
+
+       ret = 0;
+       for (i = optind; i < argc; ++i)
+               if (!process_file(argv[i]))
+                       ret = 1;
+
+       return ret;
 }




Reply via email to