summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authorru <ru@FreeBSD.org>2006-09-07 19:48:52 +0000
committerru <ru@FreeBSD.org>2006-09-07 19:48:52 +0000
commit5da4fcde162d43c30faa67700ea0d266e624685c (patch)
tree7df58dd978d532a527498d13a33dcaac621c8df6 /usr.bin
parent650ade562121b8efc44f725eafc92da813581862 (diff)
downloadFreeBSD-src-5da4fcde162d43c30faa67700ea0d266e624685c.zip
FreeBSD-src-5da4fcde162d43c30faa67700ea0d266e624685c.tar.gz
Fixed the -# option to work as documented in a manpage.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/tip/tip/cu.c28
1 files changed, 20 insertions, 8 deletions
diff --git a/usr.bin/tip/tip/cu.c b/usr.bin/tip/tip/cu.c
index f34bba2..d8d104d 100644
--- a/usr.bin/tip/tip/cu.c
+++ b/usr.bin/tip/tip/cu.c
@@ -60,7 +60,26 @@ cumain(int argc, char *argv[])
CU = DV = NOSTR;
BR = DEFBR;
parity = 0; /* none */
- while ((ch = getopt(argc, argv, "a:l:s:htoe0123456789")) != -1) {
+
+ /*
+ * We want to accept -# as a speed. It's easiest to look through
+ * the arguments, replace -# with -s#, and let getopt() handle it.
+ */
+ for (i = 1; i < argc; i++) {
+ if (argv[i][0] == '-' &&
+ argv[i][1] >= '0' && argv[i][1] <= '9') {
+ asprintf(&cp, "-s%s", argv[i] + 1);
+ if (cp == NULL) {
+ fprintf(stderr,
+ "%s: cannot convert -# to -s#\n",
+ __progname);
+ exit(3);
+ }
+ argv[i] = cp;
+ }
+ }
+
+ while ((ch = getopt(argc, argv, "a:l:s:htoe")) != -1) {
switch (ch) {
case 'a':
CU = optarg;
@@ -105,13 +124,6 @@ cumain(int argc, char *argv[])
else
parity = -1; /* even */
break;
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- if (CU)
- CU[strlen(CU)-1] = ch;
- if (DV)
- DV[strlen(DV)-1] = ch;
- break;
default:
cuusage();
break;
OpenPOWER on IntegriCloud