From 94733dd5f5917827c993a6034180f217b8eae0e4 Mon Sep 17 00:00:00 2001 From: Robin Stuart Date: Mon, 22 Aug 2016 18:07:27 +0100 Subject: [PATCH] Bugfix: increase ECC if there is capacity Bug found by Michael --- backend/hanxin.c | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/backend/hanxin.c b/backend/hanxin.c index 8570fd1e..9c563479 100644 --- a/backend/hanxin.c +++ b/backend/hanxin.c @@ -1448,22 +1448,20 @@ int han_xin(struct zint_symbol *symbol, const unsigned char source[], int length } /* If there is spare capacity, increase the level of ECC */ - switch (ecc_level) { - case 1: - if (est_codewords < hx_data_codewords_L2[version - 1]) { - ecc_level = 2; - data_codewords = hx_data_codewords_L2[version - 1]; - } - case 2: - if (est_codewords < hx_data_codewords_L3[version - 1]) { - ecc_level = 3; - data_codewords = hx_data_codewords_L3[version - 1]; - } - case 3: - if (est_codewords < hx_data_codewords_L4[version - 1]) { - ecc_level = 4; - data_codewords = hx_data_codewords_L4[version - 1]; - } + + if ((ecc_level == 1) && (est_codewords < hx_data_codewords_L2[version - 1])) { + ecc_level = 2; + data_codewords = hx_data_codewords_L2[version - 1]; + } + + if ((ecc_level == 2) && (est_codewords < hx_data_codewords_L3[version - 1])) { + ecc_level = 3; + data_codewords = hx_data_codewords_L3[version - 1]; + } + + if ((ecc_level == 3) && (est_codewords < hx_data_codewords_L4[version - 1])) { + ecc_level = 4; + data_codewords = hx_data_codewords_L4[version - 1]; } //printf("Version %d, ECC %d\n", version, ecc_level);