FreeBSD Bugzilla – Attachment 216441 Details for
Bug 247931
sed "y" command bracket balancing check
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
patch for exp-run
sed.diff (text/plain), 2.14 KB, created by
Yuri Pankov
on 2020-07-14 16:32:38 UTC
(
hide
)
Description:
patch for exp-run
Filename:
MIME Type:
Creator:
Yuri Pankov
Created:
2020-07-14 16:32:38 UTC
Size:
2.14 KB
patch
obsolete
>commit de2f6e500bb2e162d3739102bead01d9259d6d57 >Author: Yuri Pankov <yuripv@yuripv.dev> >Date: Mon Jul 13 06:15:00 2020 +0300 > > sed y > >diff --git a/usr.bin/sed/compile.c b/usr.bin/sed/compile.c >index 99fa2b17a92f..462fe8a9b1ac 100644 >--- a/usr.bin/sed/compile.c >+++ b/usr.bin/sed/compile.c >@@ -437,11 +437,19 @@ compile_delimited(char *p, char *d, int is_tr) > 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 == '\\' && >@@ -465,7 +473,7 @@ compile_delimited(char *p, char *d, int is_tr) > p += hexlen + 2; > continue; > } >- } else if (*p == '\\' && p[1] == '\\') { >+ } else if (*p == '\\') { > if (is_tr) > p++; > else >diff --git a/usr.bin/sed/tests/sed2_test.sh b/usr.bin/sed/tests/sed2_test.sh >index efa04f212ad4..9f831e0ed673 100755 >--- a/usr.bin/sed/tests/sed2_test.sh >+++ b/usr.bin/sed/tests/sed2_test.sh >@@ -134,6 +134,22 @@ commands_on_stdin_body() > 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_init_test_cases() > 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 > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 247931
: 216441