From 9c87aaef1f8abeff6f864bf3ca8be9b0d8e4f4b2 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Wed, 5 May 2021 00:04:00 -0500 Subject: [PATCH] Bugfix: Status codes F_complete_not_utf_stop and F_complete_not_utf_eos are not handled properly. The previous commit: "Bugfix: UTF-8 characters are not being fully printed" exposed that these error codes are being improperly handled. --- level_2/fll_error/c/private-error.c | 14 +++++++++++--- level_3/fake/c/private-make.c | 2 +- level_3/fake/c/private-print.c | 26 ++++++++++++++++++++++++-- 3 files changed, 36 insertions(+), 6 deletions(-) diff --git a/level_2/fll_error/c/private-error.c b/level_2/fll_error/c/private-error.c index 4ca4dd4..c5f45b9 100644 --- a/level_2/fll_error/c/private-error.c +++ b/level_2/fll_error/c/private-error.c @@ -99,14 +99,22 @@ extern "C" { return F_false; } - if (status == F_complete_not_utf) { + if (status == F_complete_not_utf || status == F_complete_not_utf_eos || status == F_complete_not_utf_stop) { if (print.verbosity != f_console_verbosity_quiet) { fprintf(print.to.stream, "%c", f_string_eol_s[0]); - fprintf(print.to.stream, "%s%sInvalid (incomplete) UTF-8 character", print.context.before->string, print.prefix); + fprintf(print.to.stream, "%s%sInvalid (incomplete) UTF-8 character found ", print.context.before->string, print.prefix); private_fll_error_print_function(print, function); - fprintf(print.to.stream, ".%s%c", print.context.after->string, f_string_eol_s[0]); + if (status == F_complete_not_utf_eos) { + fprintf(print.to.stream, " at end of string.%s%c", print.context.after->string, f_string_eol_s[0]); + } + else if (status == F_complete_not_utf_stop) { + fprintf(print.to.stream, " at stop point of string.%s%c", print.context.after->string, f_string_eol_s[0]); + } + else { + fprintf(print.to.stream, ".%s%c", print.context.after->string, f_string_eol_s[0]); + } } return F_false; diff --git a/level_3/fake/c/private-make.c b/level_3/fake/c/private-make.c index b8a3f00..b648dde 100644 --- a/level_3/fake/c/private-make.c +++ b/level_3/fake/c/private-make.c @@ -210,7 +210,7 @@ extern "C" { *status = fll_fss_basic_list_read(data_make->buffer, &range, &list_objects, &list_contents, &delimits, 0, &comments); if (F_status_is_error(*status)) { - fake_print_error_fss(main, *status, "fll_fss_basic_list_read", main.file_data_build_fakefile.string, range, F_true); + fake_print_error_fss(main, F_status_set_fine(*status), "fll_fss_basic_list_read", main.file_data_build_fakefile.string, range, F_true); } else { *status = fl_fss_apply_delimit(delimits, &data_make->buffer); diff --git a/level_3/fake/c/private-print.c b/level_3/fake/c/private-print.c index 8b976df..8e77e91 100644 --- a/level_3/fake/c/private-print.c +++ b/level_3/fake/c/private-print.c @@ -247,10 +247,32 @@ extern "C" { return F_false; } - if (status == F_status_set_error(F_complete_not_utf_stop)) { + if (status == F_complete_not_utf || status == F_complete_not_utf_eos || status == F_complete_not_utf_stop) { if (main.error.verbosity != f_console_verbosity_quiet) { fprintf(main.error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main.error.to.stream, main.context.set.error, "%serror occurred on invalid UTF-8 character at end of string (at ", fll_error_print_error); + f_color_print(main.error.to.stream, main.context.set.error, "%serror occurred on invalid UTF-8 character", fll_error_print_error); + + if (status == F_complete_not_utf_eos) { + f_color_print(main.error.to.stream, main.context.set.error, " at end of string"); + } + else if (status == F_complete_not_utf_stop) { + f_color_print(main.error.to.stream, main.context.set.error, " at stop point of string"); + } + + f_color_print(main.error.to.stream, main.context.set.error, " (at "); + f_color_print(main.error.to.stream, main.context.set.notable, "%d", range.start); + f_color_print(main.error.to.stream, main.context.set.error, " of setting file '"); + f_color_print(main.error.to.stream, main.context.set.notable, "%s", path_file); + f_color_print(main.error.to.stream, main.context.set.error, "').%c", f_string_eol_s[0]); + } + + return F_false; + } + + if (status == F_complete_not_utf_stop) { + if (main.error.verbosity != f_console_verbosity_quiet) { + fprintf(main.error.to.stream, "%c", f_string_eol_s[0]); + f_color_print(main.error.to.stream, main.context.set.error, "%serror occurred on invalid UTF-8 character at stop point of string (at ", fll_error_print_error); f_color_print(main.error.to.stream, main.context.set.notable, "%d", range.start); f_color_print(main.error.to.stream, main.context.set.error, " of setting file '"); f_color_print(main.error.to.stream, main.context.set.notable, "%s", path_file); -- 1.8.3.1