summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOtto Moerbeek <otto@cvs.openbsd.org>2007-10-16 19:02:10 +0000
committerOtto Moerbeek <otto@cvs.openbsd.org>2007-10-16 19:02:10 +0000
commitbb923ef378e44d4e36b564a2c57df55bc5acd94d (patch)
tree6242eed4fed47c1dfc8e4cbd5ea74e9e13b4a74b
parentd002b6f00eb0f3e393fd3170d5c453f946ac9ccc (diff)
fix -b arch option parsing; ok todd@
-rw-r--r--usr.bin/pcc/cc/cc.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/usr.bin/pcc/cc/cc.c b/usr.bin/pcc/cc/cc.c
index 2ce4d56b21d..d492c27ac73 100644
--- a/usr.bin/pcc/cc/cc.c
+++ b/usr.bin/pcc/cc/cc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cc.c,v 1.4 2007/10/08 14:55:13 deraadt Exp $ */
+/* $OpenBSD: cc.c,v 1.5 2007/10/16 19:02:09 otto Exp $ */
/*
* Copyright(C) Caldera International Inc. 2001-2002. All rights reserved.
*
@@ -166,7 +166,12 @@ main(int argc, char *argv[])
break;
case 'b':
- if (strncmp(argv[i+1], "?", 1) == 0) {
+ t = &argv[i][2];
+ if (*t == '\0' && i + 1 < argc) {
+ t = argv[i+1];
+ i++;
+ }
+ if (strncmp(t, "?", 1) == 0) {
/* show machine targets */
printf("Available machine targets:");
for (j=0; cppmds[j].mach; j++)
@@ -175,8 +180,12 @@ main(int argc, char *argv[])
exit(0);
}
for (j=0; cppmds[j].mach; j++)
- if (strcmp(argv[i+1],cppmds[j].mach) == 0)
+ if (strcmp(t, cppmds[j].mach) == 0) {
mach = cppmds[j].mach;
+ break;
+ }
+ if (cppmds[j].mach == NULL)
+ errorx(1, "unknown target arch %s", t);
break;
case 'X':