From a1327cbd0d1198b5e5617a70ab62fe23c496030c Mon Sep 17 00:00:00 2001 From: Robin Stuart Date: Sun, 14 May 2017 18:46:43 +0100 Subject: [PATCH] Bugfix: Insertion of unlatch character in EDIFACT mode will unlatch immediately, not at the end of the 24-bit block Fixes #60, Ref: ISO para 5.2.8.2. Bug report thanks to ice4x800@sf --- backend/dmatrix.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/backend/dmatrix.c b/backend/dmatrix.c index 2cde5690..78f7ce60 100644 --- a/backend/dmatrix.c +++ b/backend/dmatrix.c @@ -1041,7 +1041,7 @@ static int dm200encode_remainder(unsigned char target[], int target_length, cons } break; - case DM_EDIFACT: + case DM_EDIFACT: if (symbols_left <= 2) // Unlatch not required! { if (process_p == 1) { @@ -1056,15 +1056,10 @@ 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 empty buffer 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) { @@ -1072,8 +1067,6 @@ static int dm200encode_remainder(unsigned char target[], int target_length, cons target_length++; target[target_length] = (unsigned char) ((31 & 0x0f) << 4); target_length++; - target[target_length] = (unsigned char) 0; - target_length++; } if (process_p == 2) { @@ -1093,7 +1086,6 @@ static int dm200encode_remainder(unsigned char target[], int target_length, cons target[target_length] = (unsigned char) (((process_buffer[2] & 0x03) << 6) + 31); target_length++; } - } break; } @@ -1219,7 +1211,7 @@ int data_matrix_200(struct zint_symbol *symbol, const unsigned char source[], co // Print Codewords #ifdef DEBUG { - int CWCount; + int CWCount; int posCur; if (skew) CWCount = 1558 + 620; @@ -1254,7 +1246,7 @@ int data_matrix_200(struct zint_symbol *symbol, const unsigned char source[], co #ifdef DEBUG // Print position matrix as in standard for (y = NR - 1; y >= 0; y--) { - for (x = 0; x < NC; x++) { + for (x = 0; x < NC; x++) { int v; if (x != 0) fprintf(stderr, "|");