Corrected detection of all zeros and all ones in a block.

This commit is contained in:
hooper114 2008-11-08 16:05:51 +00:00
parent f68751fbc9
commit 2fe1acc4d4

View File

@ -216,6 +216,10 @@ int aztec_text_process(unsigned char source[], char binary_string[])
} }
} }
for(i = 0; i < maplength; i++) {
printf("%d %d\n", charmap[i], typemap[i]);
}
for(i = 0; i < 20000; i++) { for(i = 0; i < 20000; i++) {
binary_string[i] = '\0'; binary_string[i] = '\0';
} }
@ -541,6 +545,8 @@ int aztec_text_process(unsigned char source[], char binary_string[])
} }
printf("%s\n", binary_string);
if(strlen(binary_string) > 14970) { if(strlen(binary_string) > 14970) {
return ERROR_TOO_LONG; return ERROR_TOO_LONG;
} }
@ -669,7 +675,6 @@ int aztec(struct zint_symbol *symbol, unsigned char source[])
count = 0; count = 0;
for(i = 0; i <= data_length; i++) { for(i = 0; i <= data_length; i++) {
remainder = i % codeword_size; remainder = i % codeword_size;
if(binary_string[i] == '1') count++;
if(remainder == codeword_size - 1) { if(remainder == codeword_size - 1) {
/* Last bit of codeword */ /* Last bit of codeword */
if(count == codeword_size - 1) { if(count == codeword_size - 1) {
@ -684,6 +689,7 @@ int aztec(struct zint_symbol *symbol, unsigned char source[])
} }
count = 0; count = 0;
} }
if(binary_string[i] == '1') count++;
adjusted_string[j] = binary_string[i]; adjusted_string[j] = binary_string[i];
j++; j++;
} }
@ -699,6 +705,8 @@ int aztec(struct zint_symbol *symbol, unsigned char source[])
concat(adjusted_string, "1"); concat(adjusted_string, "1");
} }
adjusted_length = strlen(adjusted_string); adjusted_length = strlen(adjusted_string);
printf("\nbitlen %d\n", codeword_size);
printf("%s\n", adjusted_string);
count = 0; count = 0;
for(i = (adjusted_length - codeword_size); i < adjusted_length; i++) { for(i = (adjusted_length - codeword_size); i < adjusted_length; i++) {
@ -736,7 +744,6 @@ int aztec(struct zint_symbol *symbol, unsigned char source[])
count = 0; count = 0;
for(i = 0; i <= data_length; i++) { for(i = 0; i <= data_length; i++) {
remainder = i % codeword_size; remainder = i % codeword_size;
if(binary_string[i] == '1') count++;
if(remainder == codeword_size - 1) { if(remainder == codeword_size - 1) {
/* Last bit of codeword */ /* Last bit of codeword */
if(count == codeword_size - 1) { if(count == codeword_size - 1) {
@ -751,6 +758,7 @@ int aztec(struct zint_symbol *symbol, unsigned char source[])
} }
count = 0; count = 0;
} }
if(binary_string[i] == '1') count++;
adjusted_string[j] = binary_string[i]; adjusted_string[j] = binary_string[i];
j++; j++;
} }