From 8fe438d0b48a28b953dd7c7db709a2669b22f7df Mon Sep 17 00:00:00 2001 From: Nigel Tao Date: Fri, 23 Jun 2017 15:46:08 +1000 Subject: [PATCH] Temporary code to continue this.lzw.decode calls. This is a hard-coded, short term fix so that GIF decoding works end-to-end. The long term fix is to have some principled way of responding to non-fatal status codes such as "short read". --- cmd/puffs-gen-c/main.go | 3 ++- gen/c/std/gif.c | 2 +- test/c/std/gif.c | 3 +-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cmd/puffs-gen-c/main.go b/cmd/puffs-gen-c/main.go index 0a8a9adb..1b2a28bc 100644 --- a/cmd/puffs-gen-c/main.go +++ b/cmd/puffs-gen-c/main.go @@ -1214,7 +1214,8 @@ func (g *gen) writeCallSuspendibles(n *a.Expr, depth uint32) error { } else if isDecode(g.tm, n) { g.printf("status = puffs_%s_lzw_decoder_decode(&self->private_impl.f_lzw, %sdst, %s%s);\n", g.pkgName, aPrefix, vPrefix, n.Args()[1].Arg().Value().String(g.tm)) - g.writes("if (status) { return status; }\n") + // TODO: be principled with "if (status&1)" vs "if (status)". + g.writes("if (status&1) { return status; }\n") return nil } else { diff --git a/gen/c/std/gif.c b/gen/c/std/gif.c index 54078634..592d56e4 100644 --- a/gen/c/std/gif.c +++ b/gen/c/std/gif.c @@ -787,7 +787,7 @@ puffs_gif_status puffs_gif_decoder_decode_id(puffs_gif_decoder* self, PUFFS_COROUTINE_STATE(4); status = puffs_gif_lzw_decoder_decode(&self->private_impl.f_lzw, a_dst, v_lzw_src); - if (status) { + if (status & 1) { return status; } } diff --git a/test/c/std/gif.c b/test/c/std/gif.c index 915bf671..ffd7137b 100644 --- a/test/c/std/gif.c +++ b/test/c/std/gif.c @@ -347,8 +347,7 @@ void test_gif_decode_input_is_a_gif() { test_gif_decode_input_is_a_xxx("../../testdata/bricks-dither.gif", "../../testdata/bricks-dither.palette", "../../testdata/bricks-dither.indexes", - // TODO: puffs_gif_status_ok); - puffs_gif_status_short_read); + puffs_gif_status_ok); } void test_gif_decode_input_is_a_png() {