mirror of
https://git.code.sf.net/p/zint/code
synced 2025-06-01 07:38:26 -04:00
Add corrections from tgotic
This commit is contained in:
parent
de9984a346
commit
1ff9c0d472
46 changed files with 11829 additions and 2646 deletions
|
@ -53,7 +53,7 @@ void itostr(char ai_string[], int ai_value)
|
|||
concat(ai_string, ")");
|
||||
}
|
||||
|
||||
int gs1_verify(struct zint_symbol *symbol, unsigned char source[], char reduced[])
|
||||
int gs1_verify(struct zint_symbol *symbol, unsigned char source[], const unsigned int src_len, char reduced[])
|
||||
{
|
||||
int i, j, last_ai, ai_latch;
|
||||
char ai_string[6];
|
||||
|
@ -62,7 +62,7 @@ int gs1_verify(struct zint_symbol *symbol, unsigned char source[], char reduced[
|
|||
int error_latch;
|
||||
|
||||
/* Detect extended ASCII characters */
|
||||
for(i = 0; i < ustrlen(source); i++) {
|
||||
for(i = 0; i < src_len; i++) {
|
||||
if(source[i] >=128) {
|
||||
strcpy(symbol->errtxt, "Extended ASCII characters are not supported by GS1");
|
||||
return ERROR_INVALID_DATA;
|
||||
|
@ -86,7 +86,7 @@ int gs1_verify(struct zint_symbol *symbol, unsigned char source[], char reduced[
|
|||
min_ai_length = 5;
|
||||
j = 0;
|
||||
ai_latch = 0;
|
||||
for(i = 0; i < ustrlen(source); i++) {
|
||||
for(i = 0; i < src_len; i++) {
|
||||
ai_length += j;
|
||||
if(((j == 1) && (source[i] != ']')) && ((source[i] < '0') || (source[i] > '9'))) { ai_latch = 1; }
|
||||
if(source[i] == '[') { bracket_level++; j = 1; }
|
||||
|
@ -94,7 +94,8 @@ int gs1_verify(struct zint_symbol *symbol, unsigned char source[], char reduced[
|
|||
bracket_level--;
|
||||
if(ai_length < min_ai_length) { min_ai_length = ai_length; }
|
||||
j = 0;
|
||||
ai_length = 0; }
|
||||
ai_length = 0;
|
||||
}
|
||||
if(bracket_level > max_bracket_level) { max_bracket_level = bracket_level; }
|
||||
if(ai_length > max_ai_length) { max_ai_length = ai_length; }
|
||||
}
|
||||
|
@ -131,7 +132,7 @@ int gs1_verify(struct zint_symbol *symbol, unsigned char source[], char reduced[
|
|||
}
|
||||
|
||||
ai_count = 0;
|
||||
for(i = 1; i < ustrlen(source); i++) {
|
||||
for(i = 1; i < src_len; i++) {
|
||||
if(source[i - 1] == '[') {
|
||||
ai_location[ai_count] = i;
|
||||
j = 0;
|
||||
|
@ -226,16 +227,14 @@ int gs1_verify(struct zint_symbol *symbol, unsigned char source[], char reduced[
|
|||
j = 0;
|
||||
last_ai = 0;
|
||||
ai_latch = 1;
|
||||
for(i = 0; i < ustrlen(source); i++) {
|
||||
for(i = 0; i < src_len; i++) {
|
||||
if((source[i] != '[') && (source[i] != ']')) {
|
||||
reduced[j] = source[i];
|
||||
j++;
|
||||
reduced[j++] = source[i];
|
||||
}
|
||||
if(source[i] == '[') {
|
||||
/* Start of an AI string */
|
||||
if(ai_latch == 0) {
|
||||
reduced[j] = '[';
|
||||
j++;
|
||||
reduced[j++] = '[';
|
||||
}
|
||||
ai_string[0] = source[i + 1];
|
||||
ai_string[1] = source[i + 2];
|
||||
|
@ -258,22 +257,23 @@ int gs1_verify(struct zint_symbol *symbol, unsigned char source[], char reduced[
|
|||
return 0;
|
||||
}
|
||||
|
||||
int ugs1_verify(struct zint_symbol *symbol, unsigned char source[], unsigned char reduced[])
|
||||
int ugs1_verify(struct zint_symbol *symbol, unsigned char source[], const unsigned int src_len, unsigned char reduced[])
|
||||
{
|
||||
/* Only to keep the compiler happy */
|
||||
#ifndef _MSC_VER
|
||||
char temp[ustrlen(source) + 5];
|
||||
char temp[src_len + 5];
|
||||
#else
|
||||
char* temp = (char*)_alloca(ustrlen(source) + 5);
|
||||
char* temp = (char*)_alloca(src_len + 5);
|
||||
#endif
|
||||
int error_number, i;
|
||||
int error_number;
|
||||
|
||||
error_number = gs1_verify(symbol, source, temp);
|
||||
error_number = gs1_verify(symbol, source, src_len, temp);
|
||||
if(error_number != 0) { return error_number; }
|
||||
|
||||
for(i = 0; i <= strlen(temp); i++) {
|
||||
reduced[i] = (unsigned char)temp[i];
|
||||
if (strlen(temp) < src_len + 5) {
|
||||
ustrcpy(reduced, (unsigned char*)temp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
strcpy(symbol->errtxt, "ugs1_verify overflow");
|
||||
return ERROR_INVALID_DATA;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue