File tree 2 files changed +18
-6
lines changed
2 files changed +18
-6
lines changed Original file line number Diff line number Diff line change @@ -439,14 +439,12 @@ substitute(struct s_command *cp)
439
439
* and at the end of the line, terminate.
440
440
*/
441
441
if (match [0 ].rm_so == match [0 ].rm_eo ) {
442
- if (* s == '\0' || * s == '\n' )
443
- slen = -1 ;
444
- else
445
- slen -- ;
446
- if (* s != '\0' ) {
442
+ if (slen > 0 ) {
447
443
cspace (& SS , s ++ , 1 , APPEND );
444
+ slen -- ;
448
445
le ++ ;
449
- }
446
+ } else
447
+ slen = -1 ;
450
448
lastempty = 1 ;
451
449
} else
452
450
lastempty = 0 ;
Original file line number Diff line number Diff line change @@ -159,6 +159,19 @@ minus_e_body()
159
159
atf_check -o ' inline:--\nab\n' sed $' 1 i\\\n --' a
160
160
}
161
161
162
+ atf_test_case command_D
163
+ command_D_head ()
164
+ {
165
+ atf_set " descr" " Test handling of an empty pattern space"
166
+ }
167
+ command_D_body ()
168
+ {
169
+ printf " hello\n\nworld\n" > a
170
+
171
+ atf_check -o file:a sed -e ' s/^//;P;D' a
172
+ atf_check -o file:a sed -e ' s/^//;$!N;P;D' a
173
+ }
174
+
162
175
atf_init_test_cases ()
163
176
{
164
177
atf_add_test_case inplace_command_q
@@ -169,4 +182,5 @@ atf_init_test_cases()
169
182
atf_add_test_case hex_subst
170
183
atf_add_test_case bracket_y
171
184
atf_add_test_case minus_e
185
+ atf_add_test_case command_D
172
186
}
You can’t perform that action at this time.
0 commit comments