mirror of
https://github.com/zint/zint
synced 2024-11-16 20:57:25 +13:00
Allow FNC1 to be implied by mode character in Code 16k and pass reduced string of correct signedness
This commit is contained in:
parent
9b569c8717
commit
c6728f4c17
@ -290,6 +290,12 @@ int code16k(struct zint_symbol *symbol, unsigned char source[])
|
||||
glyph_count = glyph_count + 1.0;
|
||||
}
|
||||
}
|
||||
|
||||
if((gs1) && (set[0] != 'A')) {
|
||||
/* FNC1 can be integrated with mode character */
|
||||
glyph_count--;
|
||||
}
|
||||
|
||||
if(glyph_count > 77.0) {
|
||||
strcpy(symbol->errtxt, "Input too long [232]");
|
||||
return ERROR_TOO_LONG;
|
||||
@ -306,14 +312,24 @@ int code16k(struct zint_symbol *symbol, unsigned char source[])
|
||||
}
|
||||
|
||||
/* start with the mode character - Table 2 */
|
||||
read = 0;
|
||||
m = 0;
|
||||
switch(set[0]) {
|
||||
case 'A': m = 0; break;
|
||||
case 'B': m = 1; break;
|
||||
case 'C': m = 2; break;
|
||||
}
|
||||
|
||||
if(gs1) {
|
||||
/* Integrate FNC1 */
|
||||
switch(set[0]) {
|
||||
case 'B': m = 3; read = 1; break;
|
||||
case 'C': m = 4; read = 1; break;
|
||||
}
|
||||
} else {
|
||||
if((set[0] == 'B') && (set[1] == 'C')) { m = 5; }
|
||||
if(((set[0] == 'B') && (set[1] == 'B')) && (set[2] == 'C')) { m = 6; }
|
||||
}
|
||||
values[bar_characters] = (7 * (rows_needed - 2)) + m; /* see 4.3.4.2 */
|
||||
bar_characters++;
|
||||
|
||||
@ -332,7 +348,6 @@ int code16k(struct zint_symbol *symbol, unsigned char source[])
|
||||
}
|
||||
|
||||
/* Encode the data */
|
||||
read = 0;
|
||||
do {
|
||||
|
||||
if((read != 0) && (set[read] != set[read - 1]))
|
||||
@ -463,9 +478,11 @@ int code16k(struct zint_symbol *symbol, unsigned char source[])
|
||||
concat(width_pattern, "1");
|
||||
for(i = 0; i < 5; i++) {
|
||||
concat(width_pattern, C16KTable[values[(current_row * 5) + i]]);
|
||||
/* printf("[%d] ", values[(current_row * 5) + i]); */
|
||||
|
||||
}
|
||||
concat(width_pattern, C16KStartStop[C16KStopValues[current_row]]);
|
||||
/* printf("\n"); */
|
||||
|
||||
/* Write the information into the symbol */
|
||||
writer = 0;
|
||||
|
@ -247,3 +247,19 @@ int gs1_verify(struct zint_symbol *symbol, unsigned char source[], char reduced[
|
||||
/* the character '[' in the reduced string refers to the FNC1 character */
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ugs1_verify(struct zint_symbol *symbol, unsigned char source[], unsigned char reduced[])
|
||||
{
|
||||
/* Only to keep the compiler happy */
|
||||
char temp[ustrlen(source) + 5];
|
||||
int error_number, i;
|
||||
|
||||
error_number = gs1_verify(symbol, source, temp);
|
||||
if(error_number != 0) { return error_number; }
|
||||
|
||||
for(i = 0; i <= strlen(temp); i++) {
|
||||
reduced[i] = (unsigned char)temp[i];
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -20,3 +20,4 @@
|
||||
*/
|
||||
|
||||
int gs1_verify(struct zint_symbol *symbol, unsigned char source[], char reduced[]);
|
||||
int ugs1_verify(struct zint_symbol *symbol, unsigned char source[], unsigned char reduced[]);
|
@ -283,7 +283,8 @@ int ZBarcode_Encode(struct zint_symbol *symbol, unsigned char *source)
|
||||
break;
|
||||
case GS1_MODE:
|
||||
if(gs1_compliant(symbol->symbology) == 1) {
|
||||
ustrcpy(preprocessed, source);
|
||||
error_number = ugs1_verify(symbol, source, preprocessed);
|
||||
if(error_number != 0) { return error_number; }
|
||||
} else {
|
||||
strcpy(symbol->errtxt, "Selected symbology does not support GS1 mode");
|
||||
return ERROR_INVALID_OPTION;
|
||||
|
Loading…
Reference in New Issue
Block a user