Page MenuHomeFreeBSD

D25640.id74379.diff
No OneTemporary

D25640.id74379.diff

Index: usr.bin/sed/compile.c
===================================================================
--- usr.bin/sed/compile.c
+++ usr.bin/sed/compile.c
@@ -437,15 +437,26 @@
linenum, fname);
while (*p) {
if (*p == '[' && *p != c) {
- if ((d = compile_ccl(&p, d)) == NULL)
- errx(1, "%lu: %s: unbalanced brackets ([])", linenum, fname);
- continue;
+ if (!is_tr) {
+ if ((d = compile_ccl(&p, d)) == NULL) {
+ errx(1,
+ "%lu: %s: unbalanced brackets ([])",
+ linenum, fname);
+ }
+ continue;
+ }
} else if (*p == '\\' && p[1] == '[') {
- *d++ = *p++;
+ if (is_tr)
+ p++;
+ else
+ *d++ = *p++;
} else if (*p == '\\' && p[1] == c) {
p++;
} else if (*p == '\\' &&
(p[1] == 'n' || p[1] == 'r' || p[1] == 't')) {
+#if 0
+ p[1] == 'n') {
+#endif
switch (p[1]) {
case 'n':
*d++ = '\n';
Index: usr.bin/sed/tests/sed2_test.sh
===================================================================
--- usr.bin/sed/tests/sed2_test.sh
+++ usr.bin/sed/tests/sed2_test.sh
@@ -134,6 +134,22 @@
atf_check -o 'empty' sed -f - < insert_x
}
+atf_test_case bracket_y
+bracket_y_head()
+{
+ atf_set "descr" "Verify '[' is ordinary character for 'y' command"
+}
+bracket_y_body()
+{
+ atf_check -e empty -o ignore echo | sed 'y/[/x/'
+ atf_check -e empty -o ignore echo | sed 'y/[]/xy/'
+ atf_check -e empty -o ignore echo | sed 'y/[a]/xyz/'
+ atf_check -e empty -o "inline:zyx" echo '][a' | sed 'y/[a]/xyz/'
+ atf_check -e empty -o "inline:bracket\n" echo 'bra[ke]' | sed 'y/[]/ct/'
+ atf_check -e empty -o "inline:bracket\n" \
+ echo 'bra[ke]' | sed 'y[\[][ct['
+}
+
atf_init_test_cases()
{
atf_add_test_case inplace_command_q
@@ -142,4 +158,5 @@
atf_add_test_case escape_subst
atf_add_test_case commands_on_stdin
atf_add_test_case hex_subst
+ atf_add_test_case bracket_y
}

File Metadata

Mime Type
text/plain
Expires
Thu, Mar 5, 3:21 PM (30 m, 30 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29258262
Default Alt Text
D25640.id74379.diff (1 KB)

Event Timeline