From: Kevin Day Date: Wed, 10 Nov 2021 03:58:44 +0000 (-0600) Subject: Regression: NULL is being printed and fix inline function. X-Git-Tag: 0.5.7~87 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=9b4d09c6733e088410f1e7b0c1372fd2b8fe182e;p=fll Regression: NULL is being printed and fix inline function. The NULL character should not be printed for "safely" print functions. The private inline functions should be made static. --- diff --git a/level_0/f_print/c/print_to.c b/level_0/f_print/c/print_to.c index 59e6e8c..fab6fa8 100644 --- a/level_0/f_print/c/print_to.c +++ b/level_0/f_print/c/print_to.c @@ -14,7 +14,7 @@ extern "C" { * @return * The appropriate status. */ -inline f_status_t private_inline_f_print_to_error() { +static inline f_status_t private_inline_f_print_to_error() { if (errno == EAGAIN || errno == EWOULDBLOCK) return F_status_set_error(F_block); if (errno == EBADF) return F_status_set_error(F_file_descriptor); if (errno == EDESTADDRREQ) return F_status_set_error(F_socket_not); diff --git a/level_0/f_print/c/private-print.c b/level_0/f_print/c/private-print.c index 980c2cb..393124b 100644 --- a/level_0/f_print/c/private-print.c +++ b/level_0/f_print/c/private-print.c @@ -305,7 +305,16 @@ extern "C" { safe = private_f_print_character_safely_get(string[i]); } else { - safe = 0; + if (total) { + if (fwrite_unlocked(string + start, 1, total, output) == -1) { + return F_status_set_error(F_output); + } + + total = 0; + } + + start = ++i; + continue; } width = macro_f_utf_character_t_width(string[i]); @@ -463,7 +472,16 @@ extern "C" { safe = private_f_print_character_safely_get(string[i]); } else { - safe = 0; + if (total) { + if (fwrite_unlocked(string + start, 1, total, output) == -1) { + return F_status_set_error(F_output); + } + + total = 0; + } + + start = ++i; + continue; } width = macro_f_utf_character_t_width(string[i]); @@ -592,7 +610,16 @@ extern "C" { safe = private_f_print_character_safely_get(string[i]); } else { - safe = 0; + if (total) { + if (fwrite_unlocked(string + start, 1, total, output) == -1) { + return F_status_set_error(F_output); + } + + total = 0; + } + + start = ++i; + continue; } width = macro_f_utf_character_t_width(string[i]); diff --git a/level_0/f_print/c/private-print_to.c b/level_0/f_print/c/private-print_to.c index 30d2dce..00c81ce 100644 --- a/level_0/f_print/c/private-print_to.c +++ b/level_0/f_print/c/private-print_to.c @@ -14,7 +14,7 @@ extern "C" { * @return * The appropriate status. */ -inline f_status_t private_inline_f_print_to_error() { +static inline f_status_t private_inline_f_print_to_error() { if (errno == EAGAIN || errno == EWOULDBLOCK) return F_status_set_error(F_block); if (errno == EBADF) return F_status_set_error(F_file_descriptor); if (errno == EDESTADDRREQ) return F_status_set_error(F_socket_not); @@ -218,7 +218,16 @@ inline f_status_t private_inline_f_print_to_error() { safe = private_f_print_character_safely_get(string[i]); } else { - safe = 0; + if (total) { + if (write(id, string + start, total) == -1) { + return private_inline_f_print_to_error(); + } + + total = 0; + } + + start = ++i; + continue; } if (safe) { @@ -489,7 +498,16 @@ inline f_status_t private_inline_f_print_to_error() { safe = private_f_print_character_safely_get(string[i]); } else { - safe = 0; + if (total) { + if (write(id, string + start, total) == -1) { + return private_inline_f_print_to_error(); + } + + total = 0; + } + + start = ++i; + continue; } if (safe) { @@ -623,7 +641,16 @@ inline f_status_t private_inline_f_print_to_error() { safe = private_f_print_character_safely_get(string[i]); } else { - safe = 0; + if (total) { + if (write(id, string + start, total) == -1) { + return private_inline_f_print_to_error(); + } + + total = 0; + } + + start = ++i; + continue; } if (safe) {