diff --git a/sed/execute.c b/sed/execute.c index 3fe15cb..c5a675b 100644 --- a/sed/execute.c +++ b/sed/execute.c @@ -955,13 +955,15 @@ do_list(int line_len) } olen = o - obuf; if (width+olen >= line_len && line_len > 0) { - ck_fwrite("\\\n", 1, 2, fp); + ck_fwrite("\\", 1, 1, fp); + ck_fwrite(&buffer_delimiter, 1, 1, fp); width = 0; } ck_fwrite(obuf, 1, olen, fp); width += olen; } - ck_fwrite("$\n", 1, 2, fp); + ck_fwrite("$", 1, 1, fp); + ck_fwrite(&buffer_delimiter, 1, 1, fp); flush_output (fp); } @@ -1567,15 +1569,17 @@ execute_program(struct vector *vec, struct input *input) case '=': output_missing_newline(&output_file); - fprintf(output_file.fp, "%lu\n", - (unsigned long)input->line_number); + fprintf(output_file.fp, "%lu%c", + (unsigned long)input->line_number, + buffer_delimiter); flush_output(output_file.fp); break; case 'F': output_missing_newline(&output_file); - fprintf(output_file.fp, "%s\n", - input->in_file_name); + fprintf(output_file.fp, "%s%c", + input->in_file_name, + buffer_delimiter); flush_output(output_file.fp); break; diff --git a/testsuite/nulldata.sh b/testsuite/nulldata.sh index 230f3f3..91befc6 100755 --- a/testsuite/nulldata.sh +++ b/testsuite/nulldata.sh @@ -30,8 +30,7 @@ printf "xB\000xD\nEF\n\000" > exp-s-z || framework_failure_ printf "1\nAB\000CD\n2\nEF\n3\n\000" > exp-=-nl || framework_failure_ # '=' cmd processed with EOF=\0 -# NOTE: currenly the line numbers are printed with \n, regardless of -z -printf "1\nAB\0002\nCD\nEF\n\000" > exp-=-z || framework_failure_ +printf "1\000AB\0002\000CD\nEF\n\000" > exp-=-z || framework_failure_ # 'l' cmd processed with EOF=\n @@ -42,11 +41,13 @@ EF$ EOF # 'l' cmd processed with EOF=\0 -# NOTE: currently the line-endings of 'l' are always \n, regardless of -z -cat <<\EOF >exp-l-z || framework_failure_ -AB$ -CD\nEF\n$ -EOF +printf 'AB$\000CD\\nEF\\n$\000' >exp-l-z || framework_failure_ + +# 'F' cmd with EOL=\n +printf "in1\n" > exp-F-nl || framework_failure_ + +# 'F' cmd with EOL=\0 +printf "in1\000" > exp-F-z || framework_failure_ # Test substitution @@ -75,5 +76,12 @@ sed -zn l in1 > out-l-z || fail=1 compare_ exp-l-z out-l-z || fail=1 +# Test 'F' command +sed -n 1F in1 > out-F-nl || fail=1 +compare_ exp-F-nl out-F-nl || fail=1 + +sed -zn 1F in1 > out-F-z || fail=1 +compare_ exp-F-z out-F-z || fail=1 + Exit $fail