From ec4e7984963a32927b35790a3488a12d011fde2e Mon Sep 17 00:00:00 2001 From: Simon Lieb Date: Wed, 1 Apr 2015 22:50:39 +0200 Subject: [PATCH 1/5] Pass _XOPEN_SOURCE constant from macro config. --- config.mk | 2 +- slow.c | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/config.mk b/config.mk index 6a37cc8..0064496 100644 --- a/config.mk +++ b/config.mk @@ -11,7 +11,7 @@ INCS = LIBS = # flags -CPPFLAGS = -DVERSION=\"${VERSION}\" +CPPFLAGS = -DVERSION=\"${VERSION}\" -D_XOPEN_SOURCE=500 CFLAGS = -std=c99 -pedantic -Wall -Os ${INCS} ${CPPFLAGS} LDFLAGS = -s ${LIBS} diff --git a/slow.c b/slow.c index 71b1fef..da46795 100644 --- a/slow.c +++ b/slow.c @@ -1,4 +1,3 @@ -#define _XOPEN_SOURCE 500 #include #include #include From dc1d5b6f24cd49f99c9c8595c59a9c3585e1ac3a Mon Sep 17 00:00:00 2001 From: Simon Lieb Date: Wed, 1 Apr 2015 22:52:22 +0200 Subject: [PATCH 2/5] Default to static linking. --- config.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.mk b/config.mk index 0064496..bd994da 100644 --- a/config.mk +++ b/config.mk @@ -13,7 +13,7 @@ LIBS = # flags CPPFLAGS = -DVERSION=\"${VERSION}\" -D_XOPEN_SOURCE=500 CFLAGS = -std=c99 -pedantic -Wall -Os ${INCS} ${CPPFLAGS} -LDFLAGS = -s ${LIBS} +LDFLAGS = -static -s ${LIBS} # compiler and linker CC = cc From 036d9f8d82330f680358b9ad2d260d1e37ef894c Mon Sep 17 00:00:00 2001 From: Simon Lieb Date: Thu, 3 Nov 2016 13:28:19 +0100 Subject: [PATCH 3/5] Remove exit constants --- slow.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/slow.c b/slow.c index da46795..69f8be3 100644 --- a/slow.c +++ b/slow.c @@ -8,7 +8,7 @@ char *argv0; void usage() { fprintf(stderr, "usage: %s [-t usec] [-f]\n", argv0); - exit(EXIT_FAILURE); + exit(1); } int main(int argc, char *argv[]) { @@ -32,7 +32,7 @@ int main(int argc, char *argv[]) { usleep(useconds); if (fwrite(&buffer, 1, nread, stdout) != nread) { fprintf(stderr, "stdout: write error"); - exit(EXIT_FAILURE); + exit(1); } if (flush) { fflush(stdout); @@ -40,8 +40,8 @@ int main(int argc, char *argv[]) { } if (ferror(stdin)) { fprintf(stderr, "stdin: read error"); - exit(EXIT_FAILURE); + exit(1); } - return EXIT_SUCCESS; + return 0; } From 1b000205975a55eda2193ba130c8d96627afed30 Mon Sep 17 00:00:00 2001 From: Simon Lieb Date: Thu, 3 Nov 2016 13:38:18 +0100 Subject: [PATCH 4/5] Indentation & usage() declaration --- slow.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/slow.c b/slow.c index 69f8be3..d58f409 100644 --- a/slow.c +++ b/slow.c @@ -6,12 +6,18 @@ char *argv0; -void usage() { +static void usage(void); + +void +usage() +{ fprintf(stderr, "usage: %s [-t usec] [-f]\n", argv0); exit(1); } -int main(int argc, char *argv[]) { +int +main(int argc, char *argv[]) +{ char buffer; size_t nread; useconds_t useconds = 1000000; // default 1 second @@ -30,14 +36,16 @@ int main(int argc, char *argv[]) { while ((nread = fread(&buffer, 1, sizeof buffer, stdin)) > 0) { usleep(useconds); + if (fwrite(&buffer, 1, nread, stdout) != nread) { fprintf(stderr, "stdout: write error"); exit(1); } - if (flush) { + + if (flush) fflush(stdout); - } } + if (ferror(stdin)) { fprintf(stderr, "stdin: read error"); exit(1); From a2813998769c3145d23169e1f65dfb1cc3108fef Mon Sep 17 00:00:00 2001 From: pips Date: Mon, 2 Jul 2018 23:01:54 +0200 Subject: [PATCH 5/5] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4d863d7..ec6549d 100644 --- a/README.md +++ b/README.md @@ -6,12 +6,12 @@ Slow down input to output Install ------- - # make clean install + # make clean install Usage ----- - $ slow [-t usec] [-f] + $ slow [-t usec] [-f] -t usec : Define sleep between each bytes in micro-second. Default to 1 second.