From d53dbc8350cefa089cc4d16ada7f50bc1dec02da Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Mon, 31 Jul 2023 20:57:54 -0500 Subject: [PATCH] Bugfix: The Byte Dump program prints extra new lines. Migrating from the old way to the new way results in extra new lines because of the first and last new line being printed. Remove the extra new line being printed but still print in all other cases. --- level_3/byte_dump/c/main/byte_dump.c | 8 ++++++++ level_3/byte_dump/c/main/print/data.c | 4 ++-- level_3/byte_dump/c/main/print/error.c | 4 ++-- level_3/byte_dump/c/main/process.c | 2 -- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/level_3/byte_dump/c/main/byte_dump.c b/level_3/byte_dump/c/main/byte_dump.c index a47adbf..2909d66 100644 --- a/level_3/byte_dump/c/main/byte_dump.c +++ b/level_3/byte_dump/c/main/byte_dump.c @@ -51,6 +51,10 @@ extern "C" { byte_dump_print_file_header(&main->program.output, f_string_empty_s); byte_dump_process_file(main, f_string_empty_s, file); + + if (main->setting.files.used && F_status_is_error_not(main->setting.state.status)) { + f_print_dynamic_raw(f_string_eol_s, main->program.output.to); + } } if (main->setting.files.used && F_status_is_error_not(main->setting.state.status)) { @@ -78,6 +82,10 @@ extern "C" { f_file_stream_close(&file); if (F_status_is_error(main->setting.state.status)) break; + + if (i + 1 < main->setting.files.used) { + f_print_dynamic_raw(f_string_eol_s, main->program.output.to); + } } // for } else { diff --git a/level_3/byte_dump/c/main/print/data.c b/level_3/byte_dump/c/main/print/data.c index 070910c..8234d95 100644 --- a/level_3/byte_dump/c/main/print/data.c +++ b/level_3/byte_dump/c/main/print/data.c @@ -655,11 +655,11 @@ extern "C" { f_file_stream_lock(print->to); if (name.used) { - fl_print_format("%r%[%r of: %]%[", print->to, f_string_eol_s, print->set->title, byte_dump_program_name_long_s, print->set->title, print->set->notable); + fl_print_format("%[%r of: %]%[", print->to, print->set->title, byte_dump_program_name_long_s, print->set->title, print->set->notable); fl_print_format("%Q%] %[(in ", print->to, name, print->set->notable, print->set->title); } else { - fl_print_format("%r%[Piped %q: (in ", print->to, f_string_eol_s, print->set->title, byte_dump_program_name_long_s); + fl_print_format("%[Piped %q: (in ", print->to, print->set->title, byte_dump_program_name_long_s); } if (main->setting.mode == byte_dump_mode_hexidecimal_e) { diff --git a/level_3/byte_dump/c/main/print/error.c b/level_3/byte_dump/c/main/print/error.c index fb0ebba..af0c5e5 100644 --- a/level_3/byte_dump/c/main/print/error.c +++ b/level_3/byte_dump/c/main/print/error.c @@ -38,9 +38,9 @@ extern "C" { f_file_stream_lock(print->to); - fl_print_format("%[Invalid UTF-8 codes were detected for file '%]", print->to, print->set->error, print->set->error); + fl_print_format("%r%[Invalid UTF-8 codes were detected for file '%]", print->to, f_string_eol_s, print->set->error, print->set->error); fl_print_format("%[%Q%]", print->to, print->set->notable, name.used ? name : f_string_ascii_minus_s, print->set->notable); - fl_print_format("%['.%]%r%r", print->to, print->set->error, print->set->error, f_string_eol_s, f_string_eol_s); + fl_print_format("%['.%]%r", print->to, print->set->error, print->set->error, f_string_eol_s); f_file_stream_unlock(print->to); diff --git a/level_3/byte_dump/c/main/process.c b/level_3/byte_dump/c/main/process.c index 8e73ead..5b45649 100644 --- a/level_3/byte_dump/c/main/process.c +++ b/level_3/byte_dump/c/main/process.c @@ -272,8 +272,6 @@ extern "C" { } } - f_print_dynamic_raw(f_string_eol_s, main->program.output.to); - f_file_stream_unlock(main->program.output.to); f_file_stream_flush(main->program.output.to); -- 1.8.3.1