From 6af035ba986ffed32ce0ca704aa6d2531b60b2d0 Mon Sep 17 00:00:00 2001 From: Robin Stuart Date: Sat, 26 Nov 2016 11:18:37 +0000 Subject: [PATCH] Unlatch X12 encodation when there are 2 codewords left in the buffer bug report by brunt, ticket #45 --- backend/dmatrix.c | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/backend/dmatrix.c b/backend/dmatrix.c index 7f8c6ffb..ca8f3fb3 100644 --- a/backend/dmatrix.c +++ b/backend/dmatrix.c @@ -1026,27 +1026,14 @@ static int dm200encode_remainder(unsigned char target[], int target_length, cons break; case DM_X12: - if (symbols_left == process_p) // Unlatch not required! - { - if (process_p == 1) // 1 data character left to encode. - { - target[target_length] = source[inputlen - 1] + 1; - target_length++; - } - - if (process_p == 2) { - // Encode last 2 bytes as ascii. - target[target_length] = source[inputlen - 2] + 1; - target_length++; - target[target_length] = source[inputlen - 1] + 1; - target_length++; - } - } - - if (symbols_left > process_p) // Unlatch and encode remaining data in ascii. - { + if ((symbols_left == process_p) && (process_p == 1)) { + // Unlatch not required! + target[target_length] = source[inputlen - 1] + 1; + target_length++; + } else { target[target_length] = (254); target_length++; // Unlatch. + if (process_p == 1) { target[target_length] = source[inputlen - 1] + 1; target_length++;