author | Olivier Brunel
<jjk@jjacky.com> 2023-01-28 08:49:47 UTC |
committer | Olivier Brunel
<jjk@jjacky.com> 2023-01-30 22:07:04 UTC |
parent | c1c3b652c25468452af88cabbf64f3780a5a55c5 |
src/put.c | +11 | -19 |
diff --git a/src/put.c b/src/put.c index 018d69f..a0402c9 100644 --- a/src/put.c +++ b/src/put.c @@ -1,7 +1,6 @@ #include <errno.h> #include <unistd.h> /* _exit() */ #include <skalibs/buffer.h> -#include <skalibs/strerr.h> #include "limb/output.h" void @@ -10,25 +9,18 @@ put(int r, unsigned int opts, const char * const *as, unsigned int n) int e = errno; buffer *b = (opts & PUT_ERR) ? buffer_2 : buffer_1; - for(;;) { - unsigned int i; - for (i = 0; i < n; ++i) - if (as[i] && as[i][0] && !buffer_puts(b, as[i])) - break; - if (i < n) - break; + unsigned int i; + for (i = 0; i < n; ++i) + if (as[i] && as[i][0]) buffer_puts(b, as[i]); - if ((opts & PUT_SYS) - && (!buffer_put(b, ": ", 2) || !buffer_puts(b, strerror(e))) - ) - break; + if (opts & PUT_SYS) { + buffer_put(b, ": ", 2); + buffer_puts(b, strerror(e)); + } - if (!buffer_putflush(b, "\n", 1)) - break; + buffer_putflush(b, "\n", 1); - errno = e; - if (opts & PUT_DIE) _exit(r); - return; - } - strerr_die6sys(55, PROG, ": fatal: ", "unable to ", "print to ", (opts & PUT_ERR) ? "stderr" : "stdout", ": "); + errno = e; + if (opts & PUT_DIE) + _exit(r); }