Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F144455637
D43402.id132681.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D43402.id132681.diff
View Options
diff --git a/usr.bin/uniq/tests/uniq_test.sh b/usr.bin/uniq/tests/uniq_test.sh
--- a/usr.bin/uniq/tests/uniq_test.sh
+++ b/usr.bin/uniq/tests/uniq_test.sh
@@ -74,6 +74,7 @@
skip_fields_body() {
printf "1 a\n2 a\n3 b\n4 b\n5 a\n6 a\n" >input
printf "1 a\n3 b\n5 a\n" >expected
+ atf_check_uniq -1
atf_check_uniq -f 1
atf_check_uniq --skip-fields 1
}
@@ -85,6 +86,7 @@
skip_fields_tab_body() {
printf "1\ta\n2\ta\n3\tb\n4\tb\n5\ta\n6\ta\n" >input
printf "1\ta\n3\tb\n5\ta\n" >expected
+ atf_check_uniq -1
atf_check_uniq -f 1
atf_check_uniq --skip-fields 1
}
@@ -107,6 +109,7 @@
skip_chars_body() {
printf "1 a\n2 a\n3 b\n4 b\n5 a\n6 a\n" >input
printf "1 a\n3 b\n5 a\n" >expected
+ atf_check_uniq +2
atf_check_uniq -s 2
atf_check_uniq --skip-chars 2
}
diff --git a/usr.bin/uniq/uniq.c b/usr.bin/uniq/uniq.c
--- a/usr.bin/uniq/uniq.c
+++ b/usr.bin/uniq/uniq.c
@@ -338,29 +338,25 @@
static void
obsolete(char *argv[])
{
- int len;
- char *ap, *p, *start;
+ char *ap, *p;
while ((ap = *++argv)) {
/* Return if "--" or not an option of any form. */
if (ap[0] != '-') {
if (ap[0] != '+')
return;
- } else if (ap[1] == '-')
+ } else if (ap[1] == '-') {
return;
+ }
if (!isdigit((unsigned char)ap[1]))
continue;
/*
* Digit signifies an old-style option. Malloc space for dash,
* new option and argument.
*/
- len = strlen(ap);
- if ((start = p = malloc(len + 3)) == NULL)
+ if (asprintf(&p, "-%c%s", ap[0] == '+' ? 's' : 'f', ap + 1) < 0)
err(1, "malloc");
- *p++ = '-';
- *p++ = ap[0] == '+' ? 's' : 'f';
- (void)strcpy(p, ap + 1);
- *argv = start;
+ *argv = p;
}
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Feb 9, 1:07 PM (7 h, 51 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28581846
Default Alt Text
D43402.id132681.diff (1 KB)
Attached To
Mode
D43402: uniq: Clean up and test obsolete options.
Attached
Detach File
Event Timeline
Log In to Comment