From 1d503c54fe2c09029dc8b8c10a48e9460d7ca966 Mon Sep 17 00:00:00 2001 From: Robin Stuart Date: Sat, 26 Nov 2016 11:28:43 +0000 Subject: [PATCH] Unlatch EDIFACT encodation when buffer is empty bug report and patch by brunt, ticket #46 --- backend/dmatrix.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/backend/dmatrix.c b/backend/dmatrix.c index ca8f3fb3..da456b28 100644 --- a/backend/dmatrix.c +++ b/backend/dmatrix.c @@ -1063,7 +1063,16 @@ static int dm200encode_remainder(unsigned char target[], int target_length, cons target_length++; } } else { - // Append edifact unlatch value (31) and encode as triple. + // Append edifact unlatch value (31) and encode as triple + + if (process_p == 0) { + target[target_length] = (unsigned char) (31 << 2); + target_length++; + target[target_length] = 0; + target_length++; + target[target_length] = 0; + target_length++; + } if (process_p == 1) { target[target_length] = (unsigned char) ((process_buffer[0] << 2) + ((31 & 0x30) >> 4));