logo

utils-std

Collection of commonly available Unix tools git clone https://anongit.hacktivis.me/git/utils-std.git
commit: 1b0ada13e1d439b12ad0d8653d698f0a155e9063
parent 721b0a5cfe2760a012c2adf1eb222dc3cfdab1ed
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Sat,  7 Dec 2024 04:42:51 +0100

cmd/paste: switch from <err.h> to ./lib/err.h

Diffstat:

MMakefile4++++
Mcmd/paste.c11++++++-----
2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/Makefile b/Makefile @@ -214,3 +214,7 @@ test-cmd/getpriority: test-cmd/getpriority.c Makefile cmd/printf: cmd/printf.c lib/err.c lib/err.h Makefile config.mk $(RM) -f ${<:=.gcov} ${@:=.gcda} ${@:=.gcno} $(CC) -std=c99 $(CFLAGS) -o cmd/printf cmd/printf.c lib/err.c $(LDFLAGS) $(LDSTATIC) + +cmd/paste: cmd/paste.c lib/err.c lib/err.h Makefile config.mk + $(RM) -f ${<:=.gcov} ${@:=.gcda} ${@:=.gcno} + $(CC) -std=c99 $(CFLAGS) -o cmd/paste cmd/paste.c lib/err.c $(LDFLAGS) $(LDSTATIC) diff --git a/cmd/paste.c b/cmd/paste.c @@ -32,7 +32,8 @@ * SUCH DAMAGE. */ -#include <err.h> +#include "../lib/err.h" + #include <errno.h> #include <limits.h> #include <locale.h> @@ -76,7 +77,7 @@ parallel(char **argv) if(p[0] == '-' && !p[1]) lp->fp = stdin; else if(!(lp->fp = fopen(p, "r"))) - err(1, "error: %s", p); + err(1, "%s", p); lp->next = NULL; lp->cnt = cnt; lp->name = p; @@ -194,7 +195,7 @@ tr(wchar_t *arg) else *arg = ch; - if(!cnt) errx(1, "error: no delimiters specified"); + if(!cnt) errx(1, "no delimiters specified"); return (cnt); } @@ -225,13 +226,13 @@ main(int argc, char *argv[]) { const char *arg = optarg; size_t len = mbsrtowcs(NULL, &arg, 0, NULL); - if(len == (size_t)-1) err(1, "error: delimiters"); + if(len == (size_t)-1) err(1, "delimiters"); if(len == SIZE_MAX) err(1, NULL); wchar_t *warg = calloc((len + 1), sizeof(*warg)); if(warg == NULL) err(1, NULL); arg = optarg; len = mbsrtowcs(warg, &arg, len + 1, NULL); - if(len == (size_t)-1) err(1, "error: delimiters"); + if(len == (size_t)-1) err(1, "delimiters"); delimcnt = tr(delim = warg); break; }