aboutsummaryrefslogtreecommitdiffstats
path: root/src/blind-skip-pattern.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2017-05-10 21:29:46 +0200
committerMattias Andrée <maandree@kth.se>2017-05-10 21:29:46 +0200
commit19ad368f68164b99a2cfedb11747d7ca2d040ee0 (patch)
tree5afb9c2f3c3c91d8bef7264a84180d60aedc9a7e /src/blind-skip-pattern.c
parentCleaner code (diff)
downloadblind-19ad368f68164b99a2cfedb11747d7ca2d040ee0.tar.gz
blind-19ad368f68164b99a2cfedb11747d7ca2d040ee0.tar.bz2
blind-19ad368f68164b99a2cfedb11747d7ca2d040ee0.tar.xz
Cleaner code
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'src/blind-skip-pattern.c')
-rw-r--r--src/blind-skip-pattern.c34
1 files changed, 4 insertions, 30 deletions
diff --git a/src/blind-skip-pattern.c b/src/blind-skip-pattern.c
index e8eee0b..1d3e25d 100644
--- a/src/blind-skip-pattern.c
+++ b/src/blind-skip-pattern.c
@@ -6,35 +6,11 @@
USAGE("(skipped-frames | +included-frames) ...")
-static int
-process_frame(struct stream *stream, int include)
-{
- size_t h, n, m;
- int anything = 0;
-
- for (h = stream->height; h; h--) {
- for (n = stream->row_size; n; n -= m, anything = 1) {
- if (!stream->ptr && !eread_stream(stream, n))
- goto done;
- m = MIN(stream->ptr, n);
- if (include)
- ewriteall(STDOUT_FILENO, stream->buf, m, "<stdout>");
- memmove(stream->buf, stream->buf + m, stream->ptr -= m);
- }
- }
-done:
-
- if (anything && h)
- eprintf("%s: is shorter than expected\n", stream->file);
-
- return anything;
-}
-
int
main(int argc, char *argv[])
{
struct stream stream;
- int i, include;
+ int i, include, outfd;
size_t f, n, total = 0;
char *includes;
size_t *ns;
@@ -68,13 +44,11 @@ main(int argc, char *argv[])
efflush(stdout, "<stdout>");
for (i = 0;; i = (i + 1) % argc) {
- include = (int)includes[i];
- for (n = ns[i]; n--;)
- if (!process_frame(&stream, include))
- goto done;
+ outfd = includes[i] ? STDOUT_FILENO : -1;
+ if (!esend_frames(&stream, outfd, ns[i], "<stdout>"))
+ break;
}
-done:
free(includes);
free(ns);
return 0;