Remove MSVC compile bugs

This commit is contained in:
hooper114 2009-06-11 20:37:47 +00:00
parent 805e80e0bb
commit 6c631bf282
3 changed files with 30 additions and 27 deletions

View File

@ -259,7 +259,7 @@ int pharmazentral(struct zint_symbol *symbol, unsigned char source[])
int i, error_number; int i, error_number;
unsigned int h, count, check_digit; unsigned int h, count, check_digit;
char localstr[8], checkstr[3]; char localstr[10], checkstr[3];
int zeroes; int zeroes;
error_number = 0; error_number = 0;
@ -371,19 +371,20 @@ int c93(struct zint_symbol *symbol, unsigned char source[])
strcpy(buffer, ""); strcpy(buffer, "");
int ascii_value; int ascii_value;
char dest[1000]; char dest[1000];
unsigned char local_source[47];
error_number = 0; error_number = 0;
strcpy(dest, ""); strcpy(dest, "");
if(ustrlen(source) > 45) { if(ustrlen(local_source) > 45) {
/* This stops rediculously long input - the actual length of the barcode /* This stops rediculously long input - the actual length of the barcode
depends on the type of data */ depends on the type of data */
strcpy(symbol->errtxt, "Input too long"); strcpy(symbol->errtxt, "Input too long");
return ERROR_TOO_LONG; return ERROR_TOO_LONG;
} }
for(i = 0; i < ustrlen(source); i++) { for(i = 0; i < ustrlen(local_source); i++) {
if(source[i] > 127) { if(local_source[i] > 127) {
/* Cannot encode extended ASCII */ /* Cannot encode extended ASCII */
strcpy(symbol->errtxt, "Invalid characters in input data"); strcpy(symbol->errtxt, "Invalid characters in input data");
return ERROR_INVALID_DATA; return ERROR_INVALID_DATA;
@ -394,8 +395,8 @@ int c93(struct zint_symbol *symbol, unsigned char source[])
concat(dest, "111141"); concat(dest, "111141");
/* Message Content */ /* Message Content */
for(i = 0; i < ustrlen(source); i++) { for(i = 0; i < ustrlen(local_source); i++) {
ascii_value = source[i]; ascii_value = local_source[i];
if(ascii_value == symbol->nullchar) { if(ascii_value == symbol->nullchar) {
concat(buffer, C93Ctrl[0]); concat(buffer, C93Ctrl[0]);
} else { } else {
@ -463,12 +464,12 @@ int c93(struct zint_symbol *symbol, unsigned char source[])
/* Stop character */ /* Stop character */
concat(dest, "1111411"); concat(dest, "1111411");
h = ustrlen(source); h = ustrlen(local_source);
source[h] = set_copy[c]; local_source[h] = set_copy[c];
source[h + 1] = set_copy[k]; local_source[h + 1] = set_copy[k];
source[h + 2] = '\0'; local_source[h + 2] = '\0';
expand(symbol, dest); expand(symbol, dest);
ustrcpy(symbol->text, source); ustrcpy(symbol->text, local_source);
for(i = 0; i < ustrlen(symbol->text); i++) { for(i = 0; i < ustrlen(symbol->text); i++) {
if(symbol->text[i] == symbol->nullchar) { if(symbol->text[i] == symbol->nullchar) {
symbol->text[i] = ' '; symbol->text[i] = ' ';

View File

@ -43,11 +43,11 @@ void crc_machine(char data_prefix_bitstream[], int scheme, unsigned char source[
input_length = ustrlen(source); input_length = ustrlen(source);
char xor_register[17]; char xor_register[17];
#ifndef _MSC_VER #ifndef _MSC_VER
char precrc_bitstream[(input_length * 8) + 16]; char precrc_bitstream[(input_length * 8) + 18];
char precrc_bitstream_reversed[(input_length * 8) + 16]; char precrc_bitstream_reversed[(input_length * 8) + 18];
#else #else
char* precrc_bitstream = (char*)_alloca((input_length * 8) + 16); char* precrc_bitstream = (char*)_alloca((input_length * 8) + 18);
char* precrc_bitstream_reversed = (char*)_alloca((input_length * 8) + 16); char* precrc_bitstream_reversed = (char*)_alloca((input_length * 8) + 18);
#endif #endif
int machine_cycles; int machine_cycles;
char input_bit, out1, out2, out3; char input_bit, out1, out2, out3;

View File

@ -206,7 +206,7 @@ int korea_post(struct zint_symbol *symbol, unsigned char source[])
{ /* Korean Postal Authority */ { /* Korean Postal Authority */
int total, h, loop, check, zeroes, error_number; int total, h, loop, check, zeroes, error_number;
char localstr[7], checkstr[3], dest[80]; char localstr[8], checkstr[3], dest[80];
error_number = 0; error_number = 0;
h = ustrlen(source); h = ustrlen(source);
@ -499,19 +499,16 @@ int flattermarken(struct zint_symbol *symbol, unsigned char source[])
int japan_post(struct zint_symbol *symbol, unsigned char source[]) int japan_post(struct zint_symbol *symbol, unsigned char source[])
{ /* Japanese Postal Code (Kasutama Barcode) */ { /* Japanese Postal Code (Kasutama Barcode) */
int input_length, error_number; int input_length, error_number;
char pattern[65]; char pattern[69];
int writer, loopey, inter_posn, i, inter_length, sum, check; int writer, loopey, inter_posn, i, sum, check;
char check_char; char check_char;
char inter[23];
input_length = ustrlen(source); input_length = ustrlen(source);
inter_length = input_length * 2;
if(inter_length < 20) { inter_length = 20; }
#ifndef _MSC_VER #ifndef _MSC_VER
char inter[inter_length]; char local_source[input_length + 1];
char local_source[input_length];
#else #else
char* inter = (char*)_alloca(inter_length); char* local_source = (char*)_alloca(input_length + 1);
char* local_source = (char*)_alloca(inter_length);
#endif #endif
inter_posn = 0; inter_posn = 0;
@ -526,11 +523,14 @@ int japan_post(struct zint_symbol *symbol, unsigned char source[])
return error_number; return error_number;
} }
for(i = 0; i < inter_length; i++) { for(i = 0; i < 20; i++) {
inter[i] = 'd'; /* Pad character CC4 */ inter[i] = 'd'; /* Pad character CC4 */
} }
inter[20] = '\0';
for(i = 0; i < input_length; i++) { i = 0;
inter_posn = 0;
do {
if(((local_source[i] >= '0') && (local_source[i] <= '9')) || (local_source[i] == '-')) { if(((local_source[i] >= '0') && (local_source[i] <= '9')) || (local_source[i] == '-')) {
inter[inter_posn] = local_source[i]; inter[inter_posn] = local_source[i];
inter_posn++; inter_posn++;
@ -551,7 +551,9 @@ int japan_post(struct zint_symbol *symbol, unsigned char source[])
inter_posn += 2; inter_posn += 2;
} }
} }
} i++;
}while((i < input_length) && (inter_posn < 20));
inter[20] = '\0';
strcpy(pattern, "13"); /* Start */ strcpy(pattern, "13"); /* Start */