]> Kevux Git Server - fll/commitdiff
Regression: NULL is being printed and fix inline function.
authorKevin Day <thekevinday@gmail.com>
Wed, 10 Nov 2021 03:58:44 +0000 (21:58 -0600)
committerKevin Day <thekevinday@gmail.com>
Wed, 10 Nov 2021 03:58:44 +0000 (21:58 -0600)
The NULL character should not be printed for "safely" print functions.

The private inline functions should be made static.

level_0/f_print/c/print_to.c
level_0/f_print/c/private-print.c
level_0/f_print/c/private-print_to.c

index 59e6e8c69ed8ffa7927af43b5a2b2c860fe00b2b..fab6fa833561071cd8e4bc4abc13a451a24e48ad 100644 (file)
@@ -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);
index 980c2cbaca1f940cb9c2d3f1107207671f523b78..393124bb30b66a28510de0e5e66f45fd50b2bfb9 100644 (file)
@@ -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]);
index 30d2dce9f5695d003b0365936b68c3bff4de168b..00c81ce58e8ef1a3a9f970d895b1611420d291ee 100644 (file)
@@ -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) {