From 46fb351f9a3a642879d8d0b1c45298e83b3c64c2 Mon Sep 17 00:00:00 2001 From: Laurent Mazet Date: Mon, 19 Dec 2022 15:54:18 +0100 Subject: [PATCH] clean compress --- atoi.c | 2 +- atoi.h | 2 +- code.c | 2 +- compress.c | 8 ++++---- fprintf.c => fdprintf.c | 6 +++--- fdprintf.h | 14 ++++++++++++++ fprintf.h | 14 -------------- makefile | 2 +- 8 files changed, 25 insertions(+), 25 deletions(-) rename fprintf.c => fdprintf.c (97%) create mode 100644 fdprintf.h delete mode 100644 fprintf.h diff --git a/atoi.c b/atoi.c index fd3fedd..5547020 100644 --- a/atoi.c +++ b/atoi.c @@ -1,6 +1,6 @@ #include "atoi.h" -int myatoi (char *str) +int atoi (char *str) { int i = 0; int s = 1; diff --git a/atoi.h b/atoi.h index 74d58c3..11b8a46 100644 --- a/atoi.h +++ b/atoi.h @@ -1,7 +1,7 @@ #ifndef __ATOI_H__ #define __ATOI_H__ -int myatoi (char *str); +int atoi (char *str); #endif /* __ATOI_H__ */ diff --git a/code.c b/code.c index 934bfe9..5872443 100644 --- a/code.c +++ b/code.c @@ -1,5 +1,5 @@ #include "debug.h" -#include "fprintf.h" +#include "fdprintf.h" #include "code.h" diff --git a/compress.c b/compress.c index d27f8e5..4b91bbf 100644 --- a/compress.c +++ b/compress.c @@ -1,6 +1,6 @@ /* depend: */ /* cflags: */ -/* linker: atoi.o code.o debug.o fprintf.o */ +/* linker: atoi.o code.o debug.o fdprintf.o */ #include #include @@ -8,7 +8,7 @@ #include "atoi.h" #include "code.h" #include "debug.h" -#include "fprintf.h" +#include "fdprintf.h" /* constants */ @@ -31,7 +31,7 @@ char *progname = NULL; int usage (int ret) { - int fd = ret ? _fderr : _fdout; + int fd = ret ? stdfderr : stdfdout; fdprintf (fd, "usage: %s\n", progname); fdprintf (fd, " -h : help message\n"); fdprintf (fd, " -i : input file\n"); @@ -713,7 +713,7 @@ int main (int argc, char *argv[]) PRINTERR ("%s: missing verbose level\n", progname); return usage (1); } - verbose = myatoi (arg); + verbose = atoi (arg); VERBOSE (INFO, PRINTOUT ("verbose: %d\n", verbose)); break; case 'h': diff --git a/fprintf.c b/fdprintf.c similarity index 97% rename from fprintf.c rename to fdprintf.c index ff4f035..238878d 100644 --- a/fprintf.c +++ b/fdprintf.c @@ -15,10 +15,10 @@ #include #include -#include "fprintf.h" +#include "fdprintf.h" -int _fdout = STDOUT_FILENO; -int _fderr = STDERR_FILENO; +int stdfdout = STDOUT_FILENO; +int stdfderr = STDERR_FILENO; unsigned int nextpow (unsigned int x, int base) { unsigned int n = 0; diff --git a/fdprintf.h b/fdprintf.h new file mode 100644 index 0000000..3094ef7 --- /dev/null +++ b/fdprintf.h @@ -0,0 +1,14 @@ +#ifndef __FDPRINTF_H__ +#define __FDPRINTF_H__ + +int fdprintf (int fd, const char *fmt, ...); + +extern int stdfdout; +extern int stdfderr; + +#define PRINTOUT(fmt...) fdprintf (stdfdout, fmt) +#define PRINTERR(fmt...) fdprintf (stdfderr, fmt) + +#endif /* __FDPRINTF_H__ */ + +/* vim: set ts=4 sw=4 et: */ diff --git a/fprintf.h b/fprintf.h deleted file mode 100644 index 8c2bb0b..0000000 --- a/fprintf.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef __FPRINTF_H__ -#define __FPRINTF_H__ - -int fdprintf (int fd, const char *fmt, ...); - -extern int _fdout; -extern int _fderr; - -#define PRINTOUT(fmt...) fdprintf (_fdout, fmt) -#define PRINTERR(fmt...) fdprintf (_fderr, fmt) - -#endif /* __FPRINTF_H__ */ - -/* vim: set ts=4 sw=4 et */ diff --git a/makefile b/makefile index 918645f..997c6d7 100644 --- a/makefile +++ b/makefile @@ -98,7 +98,7 @@ valgrind_%: % %.ld: %.c $(call TITLE, "Building $@") - echo ${<:.c=.exe}: $(shell ./getcomments.pl -p='linker:\s' -f='%' $< | awk '{for (i=1;i<=NF;i++) if ($$(i) ~ /.o$$/) printf " %s", $$(i)}') >> $@ + echo ${<:.c=.exe}: $(shell ./getcomments.pl -p='linker:\s' -f='%' $< | awk '{for (i=1;i<=NF;i++) if ($$(i) ~ /.o$$/) printf " %s", $$(i)}') > $@ $(call PASS, SUCCESS) %.o: %.c -- 2.30.2