]> Kevux Git Server - fll/commitdiff
Bugfix: The byte_dump program should respect the +q/++quiet.
authorKevin Day <thekevinday@gmail.com>
Sat, 2 Apr 2022 13:39:08 +0000 (08:39 -0500)
committerKevin Day <thekevinday@gmail.com>
Sat, 2 Apr 2022 13:39:08 +0000 (08:39 -0500)
When printing the "Invalid UTF-8 code.." or "read() failed.." error message, the code needs to check and respect the verbosity state.

level_3/byte_dump/c/private-byte_dump.c

index 3ee16c41f0c6978ab9460019ab9cb3b1a273be95..817ab30526eb2606c8776302bb7710d288ff4904 100644 (file)
@@ -277,24 +277,27 @@ extern "C" {
     fflush(data->main->output.to.stream);
 
     if (found_invalid_utf) {
-      flockfile(data->main->error.to.stream);
+      if (data->main->error.verbosity != f_console_verbosity_quiet_e) {
+        flockfile(data->main->error.to.stream);
 
-      fl_print_format("%[Invalid UTF-8 codes were detected for file '%]", data->main->error.to.stream, data->main->context.set.error, data->main->context.set.error);
-      fl_print_format("%[%Q%]", data->main->error.to.stream, data->main->context.set.notable, file_name.used ? file_name : f_string_ascii_minus_s, data->main->context.set.notable);
-      fl_print_format("%['.%]%r%r", data->main->error.to.stream, data->main->context.set.error, data->main->context.set.error, f_string_eol_s, f_string_eol_s);
+        fl_print_format("%[Invalid UTF-8 codes were detected for file '%]", data->main->error.to.stream, data->main->context.set.error, data->main->context.set.error);
+        fl_print_format("%[%Q%]", data->main->error.to.stream, data->main->context.set.notable, file_name.used ? file_name : f_string_ascii_minus_s, data->main->context.set.notable);
+        fl_print_format("%['.%]%r%r", data->main->error.to.stream, data->main->context.set.error, data->main->context.set.error, f_string_eol_s, f_string_eol_s);
 
-      funlockfile(data->main->error.to.stream);
+        funlockfile(data->main->error.to.stream);
+      }
     }
 
     if (ferror(file.stream)) {
-      // @todo determine what the error is and display it.
-      flockfile(data->main->error.to.stream);
+      if (data->main->error.verbosity != f_console_verbosity_quiet_e) {
+        flockfile(data->main->error.to.stream);
 
-      fl_print_format("%[%Qread() failed for '%]", data->main->error.to.stream, data->main->context.set.error, data->main->error.prefix, data->main->context.set.error);
-      fl_print_format("%[%Q%]", data->main->error.to.stream, data->main->context.set.notable, file_name.used ? file_name : f_string_ascii_minus_s, data->main->context.set.notable);
-      fl_print_format("%['.%]%r%r", data->main->error.to.stream, data->main->context.set.error, data->main->context.set.error, f_string_eol_s, f_string_eol_s);
+        fl_print_format("%[%Qread() failed for '%]", data->main->error.to.stream, data->main->context.set.error, data->main->error.prefix, data->main->context.set.error);
+        fl_print_format("%[%Q%]", data->main->error.to.stream, data->main->context.set.notable, file_name.used ? file_name : f_string_ascii_minus_s, data->main->context.set.notable);
+        fl_print_format("%['.%]%r%r", data->main->error.to.stream, data->main->context.set.error, data->main->context.set.error, f_string_eol_s, f_string_eol_s);
 
-      funlockfile(data->main->error.to.stream);
+        funlockfile(data->main->error.to.stream);
+      }
 
       status = F_status_set_error(F_failure);
     }