From 076d0dc569608c276b25742605d35b0ac44dbf46 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sun, 15 Jan 2017 20:52:36 +0100 Subject: Fix errors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/blind-arithm.c | 51 +++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 41 insertions(+), 10 deletions(-) (limited to 'src/blind-arithm.c') diff --git a/src/blind-arithm.c b/src/blind-arithm.c index 015df42..d74fbf8 100644 --- a/src/blind-arithm.c +++ b/src/blind-arithm.c @@ -8,7 +8,12 @@ #include #include -USAGE("operation right-hand-stream") +USAGE("[-ayxz] operation right-hand-stream") + +static int skip_a = 0; +static int skip_x = 0; +static int skip_y = 0; +static int skip_z = 0; /* Because the syntax for a function returning a function pointer is disgusting. */ typedef void (*process_func)(struct stream *left, struct stream *right, size_t n); @@ -30,14 +35,22 @@ typedef void (*process_func)(struct stream *left, struct stream *right, size_t n size_t i;\ double *lh, rh;\ for (i = 0; i < n; i += 4 * sizeof(double)) {\ - lh = ((double *)(left->buf + i)) + 0, rh = ((double *)(right->buf + i))[0];\ - ALGO;\ - lh = ((double *)(left->buf + i)) + 1, rh = ((double *)(right->buf + i))[1];\ - ALGO;\ - lh = ((double *)(left->buf + i)) + 2, rh = ((double *)(right->buf + i))[2];\ - ALGO;\ - lh = ((double *)(left->buf + i)) + 3, rh = ((double *)(right->buf + i))[3];\ - ALGO;\ + if (!skip_x) {\ + lh = ((double *)(left->buf + i)) + 0, rh = ((double *)(right->buf + i))[0];\ + ALGO;\ + }\ + if (!skip_y) {\ + lh = ((double *)(left->buf + i)) + 1, rh = ((double *)(right->buf + i))[1];\ + ALGO;\ + }\ + if (!skip_z) {\ + lh = ((double *)(left->buf + i)) + 2, rh = ((double *)(right->buf + i))[2];\ + ALGO;\ + }\ + if (!skip_a) {\ + lh = ((double *)(left->buf + i)) + 3, rh = ((double *)(right->buf + i))[3];\ + ALGO;\ + }\ }\ } LIST_OPERATORS @@ -60,7 +73,25 @@ main(int argc, char *argv[]) struct stream left, right; process_func process = NULL; - ENOFLAGS(argc != 2); + ARGBEGIN { + case 'a': + skip_a = 1; + break; + case 'x': + skip_x = 1; + break; + case 'y': + skip_y = 1; + break; + case 'z': + skip_z = 1; + break; + default: + usage(); + } ARGEND; + + if (argc != 2) + usage(); left.file = ""; left.fd = STDIN_FILENO; -- cgit v1.2.3-70-g09d2