From: Kevin Day Date: Sat, 2 Apr 2022 13:39:08 +0000 (-0500) Subject: Bugfix: The byte_dump program should respect the +q/++quiet. X-Git-Tag: 0.5.9~7 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=ff8a46d22c24d847fd6cf70f464d546a99d5e0de;p=fll Bugfix: The byte_dump program should respect the +q/++quiet. When printing the "Invalid UTF-8 code.." or "read() failed.." error message, the code needs to check and respect the verbosity state. --- diff --git a/level_3/byte_dump/c/private-byte_dump.c b/level_3/byte_dump/c/private-byte_dump.c index 3ee16c4..817ab30 100644 --- a/level_3/byte_dump/c/private-byte_dump.c +++ b/level_3/byte_dump/c/private-byte_dump.c @@ -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); }