From c216ac3049102422a41ba2c9476b0dbf4f3e4034 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sun, 16 Jul 2017 00:59:42 +0200 Subject: Use #include instead of #define MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/blind-coordinate-field.c | 43 ++++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 19 deletions(-) (limited to 'src/blind-coordinate-field.c') diff --git a/src/blind-coordinate-field.c b/src/blind-coordinate-field.c index 2d73399..884b513 100644 --- a/src/blind-coordinate-field.c +++ b/src/blind-coordinate-field.c @@ -1,4 +1,5 @@ /* See LICENSE file for copyright and license details. */ +#ifndef TYPE #include "common.h" USAGE("[-f frames | -f 'inf'] [-F pixel-format] -w width -h height") @@ -6,25 +7,8 @@ USAGE("[-f frames | -f 'inf'] [-F pixel-format] -w width -h height") static struct stream stream = { .width = 0, .height = 0, .frames = 1 }; static int inf = 0; -#define PROCESS(TYPE)\ - do {\ - TYPE buf[4] = {0, 0, 0, 0};\ - size_t x, y;\ - \ - while (inf || stream.frames--) {\ - for (y = 0; y < stream.height; y++) {\ - buf[1] = (TYPE)y;\ - for (x = 0; x < stream.width; x++) {\ - buf[0] = (TYPE)x;\ - if (write(STDOUT_FILENO, buf, sizeof(buf)) < 0)\ - eprintf("write :");\ - }\ - }\ - }\ - } while (0) - -static void process_lf(void) {PROCESS(double);} -static void process_f(void) {PROCESS(float);} +#define FILE "blind-coordinate-field.c" +#include "define-functions.h" int main(int argc, char *argv[]) @@ -75,3 +59,24 @@ main(int argc, char *argv[]) process(); return 0; } + +#else + +static void +PROCESS(void) +{ + TYPE buf[4] = {0, 0, 0, 0}; + size_t x, y; + while (inf || stream.frames--) { + for (y = 0; y < stream.height; y++) { + buf[1] = (TYPE)y; + for (x = 0; x < stream.width; x++) { + buf[0] = (TYPE)x; + if (write(STDOUT_FILENO, buf, sizeof(buf)) < 0) + eprintf("write :"); + } + } + } +} + +#endif -- cgit v1.2.3-70-g09d2