]> Kevux Git Server - fll/commitdiff
Bugfix: The Byte Dump program prints extra new lines.
authorKevin Day <kevin@kevux.org>
Tue, 1 Aug 2023 01:57:54 +0000 (20:57 -0500)
committerKevin Day <kevin@kevux.org>
Tue, 1 Aug 2023 02:01:14 +0000 (21:01 -0500)
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
level_3/byte_dump/c/main/print/data.c
level_3/byte_dump/c/main/print/error.c
level_3/byte_dump/c/main/process.c

index a47adbf7a1d7a4292db91731b17a759fdb167fba..2909d666d47ef9162c82b4d67cf5f8732c6862c4 100644 (file)
@@ -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 {
index 070910cc8f922280d6b4ad21f10f0b9b26ec971c..8234d953490b469cf8139e9671aa227bb9caeb64 100644 (file)
@@ -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) {
index fb0ebba43a3e6f9a7389420dcf8d99ec64a0c479..af0c5e5430f92af4d3c686bec7a29c85583453d7 100644 (file)
@@ -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);
 
index 8e73eadf8ae336910a78efb1225c89991640d2f7..5b456492d2a3d832ffac5cb558d11b340a48663d 100644 (file)
@@ -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);