mirror of
https://github.com/zint/zint
synced 2024-11-16 20:57:25 +13:00
Force unlatch from EDIFACT on illegal character
Bug report and patch by brunt, ticket #44
This commit is contained in:
parent
1155683be1
commit
dc36261030
@ -867,7 +867,7 @@ static int dm200encode(struct zint_symbol *symbol, const unsigned char source[],
|
|||||||
|
|
||||||
/* step (f) EDIFACT encodation */
|
/* step (f) EDIFACT encodation */
|
||||||
if (current_mode == DM_EDIFACT) {
|
if (current_mode == DM_EDIFACT) {
|
||||||
int value = 0;
|
int value = -1;
|
||||||
|
|
||||||
next_mode = DM_EDIFACT;
|
next_mode = DM_EDIFACT;
|
||||||
if (*process_p == 3) {
|
if (*process_p == 3) {
|
||||||
@ -885,11 +885,21 @@ static int dm200encode(struct zint_symbol *symbol, const unsigned char source[],
|
|||||||
if ((source[sp] >= ' ') && (source[sp] <= '?')) {
|
if ((source[sp] >= ' ') && (source[sp] <= '?')) {
|
||||||
value = source[sp];
|
value = source[sp];
|
||||||
}
|
}
|
||||||
/* possibility put an assertion here for invalid character (none of the ifs trigger) */
|
if (value != -1) {
|
||||||
|
process_buffer[*process_p] = value;
|
||||||
|
(*process_p)++;
|
||||||
|
sp++;
|
||||||
|
} else {
|
||||||
|
// Invalid character, latch to ASCII
|
||||||
|
process_buffer[*process_p] = 31;
|
||||||
|
(*process_p)++;
|
||||||
|
|
||||||
process_buffer[*process_p] = value;
|
while (*process_p < 4) {
|
||||||
(*process_p)++;
|
process_buffer[*process_p] = 0;
|
||||||
sp++;
|
(*process_p)++;
|
||||||
|
}
|
||||||
|
next_mode = DM_ASCII;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*process_p >= 4) {
|
if (*process_p >= 4) {
|
||||||
|
Loading…
Reference in New Issue
Block a user