Force flush of last two C40 or Text values in buffer

Relates to #38
This commit is contained in:
Robin Stuart 2016-11-22 20:24:33 +00:00
parent 4ea35b9082
commit a0493a0d0c

View File

@ -987,10 +987,12 @@ static int dm200encode_remainder(unsigned char target[], int target_length, cons
switch (last_mode) { switch (last_mode) {
case DM_C40: case DM_C40:
case DM_TEXT: case DM_TEXT:
if (symbols_left == process_p) // No unlatch required!
{
if (process_p == 1) // 1 data character left to encode. if (process_p == 1) // 1 data character left to encode.
{ {
if (symbols_left > 1) {
target[target_length] = 254;
target_length++; // Unlatch and encode remaining data in ascii.
}
target[target_length] = source[inputlen - 1] + 1; target[target_length] = source[inputlen - 1] + 1;
target_length++; target_length++;
} }
@ -1003,19 +1005,8 @@ static int dm200encode_remainder(unsigned char target[], int target_length, cons
target_length++; target_length++;
target[target_length] = (unsigned char) (intValue % 256); target[target_length] = (unsigned char) (intValue % 256);
target_length++; target_length++;
} if (symbols_left > 2) {
} target[target_length] = 254; // Unlatch
if (symbols_left > process_p) {
target[target_length] = (254);
target_length++; // Unlatch and encode remaining data in ascii.
if (process_p == 1) {
target[target_length] = source[inputlen - 1] + 1;
target_length++;
} else if (process_p == 2) {
target[target_length] = source[inputlen - 2] + 1;
target_length++;
target[target_length] = source[inputlen - 1] + 1;
target_length++; target_length++;
} }
} }