logo

utils-std

Collection of commonly available Unix tools git clone https://anongit.hacktivis.me/git/utils-std.git
commit: 80ce8e179c38661c772c92d5567e51bb9ea2be21
parent b6cba2230bc94a954de6e61f11141fe2c56c5836
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Fri, 30 Aug 2024 10:18:52 +0200

cmd/cut: use err as return in cut_b/cut_c/cut_f

Diffstat:

Mcmd/cut.c9++++++---
1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/cmd/cut.c b/cmd/cut.c @@ -6,6 +6,7 @@ #include "../lib/reallocarray.h" +#include <assert.h> #include <ctype.h> #include <errno.h> #include <locale.h> @@ -179,7 +180,7 @@ cut_b(FILE *in, const char *filename) if(line_len != 0) free(line); - return 0; + return err; } static int @@ -225,6 +226,8 @@ cut_c(FILE *in, const char *filename) line_wsz = nread; } + assert(line_wsz > 0); + size_t wcread = mbstowcs(line_w, line, line_wsz); if(wcread == (size_t)-1) { @@ -253,7 +256,7 @@ cut_c(FILE *in, const char *filename) if(line_len != 0) free(line); - return 0; + return err; } static int @@ -329,7 +332,7 @@ cut_f(FILE *in, const char *filename) if(line_len != 0) free(line); - return 0; + return err; } static int