public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Mike Frysinger (vapier)" <vapier@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] gentoo commit in src/patchsets/coreutils/uname-test: uname-test.c
Date: Wed,  5 Aug 2015 07:00:11 +0000 (UTC)	[thread overview]
Message-ID: <20150805070011.36845127@oystercatcher.gentoo.org> (raw)

vapier      15/08/05 07:00:11

  Modified:             uname-test.c
  Log:
  use getopt to parse the command line

Revision  Changes    Path
1.5                  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.5&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo/src/patchsets/coreutils/uname-test/uname-test.c?rev=1.5&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo/src/patchsets/coreutils/uname-test/uname-test.c?r1=1.4&r2=1.5

Index: uname-test.c
===================================================================
RCS file: /var/cvsroot/gentoo/src/patchsets/coreutils/uname-test/uname-test.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- uname-test.c	5 Aug 2015 04:37:36 -0000	1.4
+++ uname-test.c	5 Aug 2015 07:00:11 -0000	1.5
@@ -3,12 +3,14 @@
  * Distributed under the terms of the GNU General Public License v2
  */
 
+#include <ctype.h>
+#include <err.h>
 #include <stdbool.h>
 #include <stddef.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <ctype.h>
+#include <unistd.h>
 
 #ifndef ARRAY_SIZE
 # define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
@@ -140,14 +142,21 @@
 	static char hardware_platform[257];
 	int i;
 
-	for (i = 1; i < argc; ++i) {
-		if (!strcmp(argv[i], "-v"))
+	while ((i = getopt(argc, argv, "v")) != -1) {
+		switch (i) {
+		case 'v':
 			verbose = true;
-		else {
-			filename = argv[1];
-			printf(">>> Parsing data out of %s\n", filename);
+			break;
+		default:
+ usage:
+			errx(1, "Usage: uname-test [-v] <file>");
 		}
 	}
+	if (optind + 1 != argc)
+		goto usage;
+
+	filename = argv[optind];
+	printf(">>> Parsing data out of %s\n", filename);
 	i = 0;
 
 	if (0 > __linux_procinfo (PROCINFO_PROCESSOR, processor, sizeof processor)) {





             reply	other threads:[~2015-08-05  7:00 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-05  7:00 Mike Frysinger (vapier) [this message]
  -- strict thread matches above, loose matches on Subject: below --
2015-08-05  7:35 [gentoo-commits] gentoo commit in src/patchsets/coreutils/uname-test: uname-test.c Mike Frysinger (vapier)
2015-08-05  7:31 Mike Frysinger (vapier)
2015-08-05  7:26 Mike Frysinger (vapier)
2015-08-05  7:18 Mike Frysinger (vapier)
2015-08-05  7:15 Mike Frysinger (vapier)
2015-08-05  7:14 Mike Frysinger (vapier)
2015-08-05  7:06 Mike Frysinger (vapier)
2015-08-05  7:05 Mike Frysinger (vapier)
2015-08-05  4:37 Mike Frysinger (vapier)
2015-08-04 11:30 Mike Frysinger (vapier)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150805070011.36845127@oystercatcher.gentoo.org \
    --to=vapier@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox