Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F109386872
D47377.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
D47377.diff
View Options
diff --git a/usr.bin/sed/main.c b/usr.bin/sed/main.c
--- a/usr.bin/sed/main.c
+++ b/usr.bin/sed/main.c
@@ -137,10 +137,8 @@
break;
case 'e':
eflag = 1;
- if ((temp_arg = malloc(strlen(optarg) + 2)) == NULL)
- err(1, "malloc");
- strcpy(temp_arg, optarg);
- strcat(temp_arg, "\n");
+ if (asprintf(&temp_arg, "%s\n", optarg) == -1)
+ err(1, "asprintf");
add_compunit(CU_STRING, temp_arg);
break;
case 'f':
@@ -173,7 +171,9 @@
/* First usage case; script is the first arg */
if (!eflag && !fflag && *argv) {
- add_compunit(CU_STRING, *argv);
+ if (asprintf(&temp_arg, "%s\n", *argv) == -1)
+ err(1, "asprintf");
+ add_compunit(CU_STRING, temp_arg);
argv++;
}
diff --git a/usr.bin/sed/tests/sed2_test.sh b/usr.bin/sed/tests/sed2_test.sh
--- a/usr.bin/sed/tests/sed2_test.sh
+++ b/usr.bin/sed/tests/sed2_test.sh
@@ -147,6 +147,18 @@
echo 'bra[ke]' | sed 'y[\[][ct['
}
+atf_test_case minus_e
+minus_e_head()
+{
+ atf_set "descr" "Verify that -e and implicit arg do the same thing"
+}
+minus_e_body()
+{
+ printf "ab\n" > a
+ atf_check -o 'inline:--\nab\n' sed -e $'1 i\\\n--' a
+ atf_check -o 'inline:--\nab\n' sed $'1 i\\\n--' a
+}
+
atf_init_test_cases()
{
atf_add_test_case inplace_command_q
@@ -156,4 +168,5 @@
atf_add_test_case commands_on_stdin
atf_add_test_case hex_subst
atf_add_test_case bracket_y
+ atf_add_test_case minus_e
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Feb 5, 9:49 AM (20 h, 57 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
16471971
Default Alt Text
D47377.diff (1 KB)
Attached To
Mode
D47377: sed: fix commandline-given expression when -e is not used
Attached
Detach File
Event Timeline
Log In to Comment