diff --git a/backend/2of5.c b/backend/2of5.c index 81e2c0a0..59411214 100644 --- a/backend/2of5.c +++ b/backend/2of5.c @@ -84,7 +84,7 @@ int matrix_two_of_five(struct zint_symbol *symbol, unsigned char source[], int l } /* Stop character */ - concat(dest, "41111"); + strcat(dest, "41111"); expand(symbol, dest); ustrcpy(symbol->text, source); @@ -117,7 +117,7 @@ int industrial_two_of_five(struct zint_symbol *symbol, unsigned char source[], i } /* Stop character */ - concat(dest, "31113"); + strcat(dest, "31113"); expand(symbol, dest); ustrcpy(symbol->text, source); @@ -149,7 +149,7 @@ int iata_two_of_five(struct zint_symbol *symbol, unsigned char source[], int len } /* stop */ - concat(dest, "311"); + strcat(dest, "311"); expand(symbol, dest); ustrcpy(symbol->text, source); @@ -182,7 +182,7 @@ int logic_two_of_five(struct zint_symbol *symbol, unsigned char source[], int le } /* Stop character */ - concat(dest, "311"); + strcat(dest, "311"); expand(symbol, dest); ustrcpy(symbol->text, source); @@ -219,7 +219,7 @@ int interleaved_two_of_five(struct zint_symbol *symbol, unsigned char source[], ustrcpy(temp, (unsigned char *) "0"); length++; } - uconcat(temp, source); + strcat((char*)temp, (char*)source); /* start character */ strcpy(dest, "1111"); @@ -240,11 +240,11 @@ int interleaved_two_of_five(struct zint_symbol *symbol, unsigned char source[], k++; } mixed[k] = '\0'; - concat(dest, mixed); + strcat(dest, mixed); } /* Stop character */ - concat(dest, "311"); + strcat(dest, "311"); expand(symbol, dest); ustrcpy(symbol->text, temp); diff --git a/backend/auspost.c b/backend/auspost.c index 83bbdf43..b6477099 100644 --- a/backend/auspost.c +++ b/backend/auspost.c @@ -88,7 +88,7 @@ void rs_error(char data_pattern[]) { rs_encode(triple_writer, (unsigned char*) inv_triple, result); for (reader = 4; reader > 0; reader--) { - concat(data_pattern, AusBarTable[(int) result[reader - 1]]); + strcat(data_pattern, AusBarTable[(int) result[reader - 1]]); } rs_free(); } @@ -164,7 +164,7 @@ int australia_post(struct zint_symbol *symbol, unsigned char source[], int lengt localstr[8] = '\0'; } - concat(localstr, (char*) source); + strcat(localstr, (char*) source); h = strlen(localstr); error_number = is_sane(GDSET, (unsigned char *) localstr, h); if (error_number == ZINT_ERROR_INVALID_DATA) { @@ -215,7 +215,7 @@ int australia_post(struct zint_symbol *symbol, unsigned char source[], int lengt case 22: case 37: case 52: - concat(data_pattern, "3"); + strcat(data_pattern, "3"); break; default: break; @@ -225,7 +225,7 @@ int australia_post(struct zint_symbol *symbol, unsigned char source[], int lengt rs_error(data_pattern); /* Stop character */ - concat(data_pattern, "13"); + strcat(data_pattern, "13"); /* Turn the symbol into a bar pattern ready for plotting */ writer = 0; diff --git a/backend/aztec.c b/backend/aztec.c index 3a4370df..6c20e8b7 100644 --- a/backend/aztec.c +++ b/backend/aztec.c @@ -311,21 +311,21 @@ int aztec_text_process(unsigned char source[], const unsigned int src_len, char case (64 + UPPER): /* To UPPER */ switch (curtable) { case LOWER: /* US */ - concat(binary_string, hexbit[28]); + strcat(binary_string, hexbit[28]); if (debug) printf("US "); break; case MIXED: /* UL */ - concat(binary_string, hexbit[29]); + strcat(binary_string, hexbit[29]); if (debug) printf("UL "); newtable = UPPER; break; case PUNC: /* UL */ - concat(binary_string, hexbit[31]); + strcat(binary_string, hexbit[31]); if (debug) printf("UL "); newtable = UPPER; break; case DIGIT: /* US */ - concat(binary_string, pentbit[15]); + strcat(binary_string, pentbit[15]); if (debug) printf("US "); break; } @@ -333,26 +333,26 @@ int aztec_text_process(unsigned char source[], const unsigned int src_len, char case (64 + LOWER): /* To LOWER */ switch (curtable) { case UPPER: /* LL */ - concat(binary_string, hexbit[28]); + strcat(binary_string, hexbit[28]); if (debug) printf("LL "); newtable = LOWER; break; case MIXED: /* LL */ - concat(binary_string, hexbit[28]); + strcat(binary_string, hexbit[28]); if (debug) printf("LL "); newtable = LOWER; break; case PUNC: /* UL LL */ - concat(binary_string, hexbit[31]); + strcat(binary_string, hexbit[31]); if (debug) printf("UL "); - concat(binary_string, hexbit[28]); + strcat(binary_string, hexbit[28]); if (debug) printf("LL "); newtable = LOWER; break; case DIGIT: /* UL LL */ - concat(binary_string, pentbit[14]); + strcat(binary_string, pentbit[14]); if (debug) printf("UL "); - concat(binary_string, hexbit[28]); + strcat(binary_string, hexbit[28]); if (debug) printf("LL "); newtable = LOWER; break; @@ -361,26 +361,26 @@ int aztec_text_process(unsigned char source[], const unsigned int src_len, char case (64 + MIXED): /* To MIXED */ switch (curtable) { case UPPER: /* ML */ - concat(binary_string, hexbit[29]); + strcat(binary_string, hexbit[29]); if (debug) printf("ML "); newtable = MIXED; break; case LOWER: /* ML */ - concat(binary_string, hexbit[29]); + strcat(binary_string, hexbit[29]); if (debug) printf("ML "); newtable = MIXED; break; case PUNC: /* UL ML */ - concat(binary_string, hexbit[31]); + strcat(binary_string, hexbit[31]); if (debug) printf("UL "); - concat(binary_string, hexbit[29]); + strcat(binary_string, hexbit[29]); if (debug) printf("ML "); newtable = MIXED; break; case DIGIT: /* UL ML */ - concat(binary_string, pentbit[14]); + strcat(binary_string, pentbit[14]); if (debug) printf("UL "); - concat(binary_string, hexbit[29]); + strcat(binary_string, hexbit[29]); if (debug) printf("ML "); newtable = MIXED; break; @@ -389,19 +389,19 @@ int aztec_text_process(unsigned char source[], const unsigned int src_len, char case (64 + PUNC): /* To PUNC */ switch (curtable) { case UPPER: /* PS */ - concat(binary_string, hexbit[0]); + strcat(binary_string, hexbit[0]); if (debug) printf("PS "); break; case LOWER: /* PS */ - concat(binary_string, hexbit[0]); + strcat(binary_string, hexbit[0]); if (debug) printf("PS "); break; case MIXED: /* PS */ - concat(binary_string, hexbit[0]); + strcat(binary_string, hexbit[0]); if (debug) printf("PS "); break; case DIGIT: /* PS */ - concat(binary_string, pentbit[0]); + strcat(binary_string, pentbit[0]); if (debug) printf("PS "); break; } @@ -409,26 +409,26 @@ int aztec_text_process(unsigned char source[], const unsigned int src_len, char case (64 + DIGIT): /* To DIGIT */ switch (curtable) { case UPPER: /* DL */ - concat(binary_string, hexbit[30]); + strcat(binary_string, hexbit[30]); if (debug) printf("DL "); newtable = DIGIT; break; case LOWER: /* DL */ - concat(binary_string, hexbit[30]); + strcat(binary_string, hexbit[30]); if (debug) printf("DL "); newtable = DIGIT; break; case MIXED: /* UL DL */ - concat(binary_string, hexbit[29]); + strcat(binary_string, hexbit[29]); if (debug) printf("UL "); - concat(binary_string, hexbit[30]); + strcat(binary_string, hexbit[30]); if (debug) printf("DL "); newtable = DIGIT; break; case PUNC: /* UL DL */ - concat(binary_string, hexbit[31]); + strcat(binary_string, hexbit[31]); if (debug) printf("UL "); - concat(binary_string, hexbit[30]); + strcat(binary_string, hexbit[30]); if (debug) printf("DL "); newtable = DIGIT; break; @@ -441,24 +441,24 @@ int aztec_text_process(unsigned char source[], const unsigned int src_len, char case UPPER: /* To UPPER */ switch (curtable) { case LOWER: /* ML UL */ - concat(binary_string, hexbit[29]); + strcat(binary_string, hexbit[29]); if (debug) printf("ML "); - concat(binary_string, hexbit[29]); + strcat(binary_string, hexbit[29]); if (debug) printf("UL "); newtable = UPPER; break; case MIXED: /* UL */ - concat(binary_string, hexbit[29]); + strcat(binary_string, hexbit[29]); if (debug) printf("UL "); newtable = UPPER; break; case PUNC: /* UL */ - concat(binary_string, hexbit[31]); + strcat(binary_string, hexbit[31]); if (debug) printf("UL "); newtable = UPPER; break; case DIGIT: /* UL */ - concat(binary_string, pentbit[14]); + strcat(binary_string, pentbit[14]); if (debug) printf("UL "); newtable = UPPER; break; @@ -467,26 +467,26 @@ int aztec_text_process(unsigned char source[], const unsigned int src_len, char case LOWER: /* To LOWER */ switch (curtable) { case UPPER: /* LL */ - concat(binary_string, hexbit[28]); + strcat(binary_string, hexbit[28]); if (debug) printf("LL "); newtable = LOWER; break; case MIXED: /* LL */ - concat(binary_string, hexbit[28]); + strcat(binary_string, hexbit[28]); if (debug) printf("LL "); newtable = LOWER; break; case PUNC: /* UL LL */ - concat(binary_string, hexbit[31]); + strcat(binary_string, hexbit[31]); if (debug) printf("UL "); - concat(binary_string, hexbit[28]); + strcat(binary_string, hexbit[28]); if (debug) printf("LL "); newtable = LOWER; break; case DIGIT: /* UL LL */ - concat(binary_string, pentbit[14]); + strcat(binary_string, pentbit[14]); if (debug) printf("UL "); - concat(binary_string, hexbit[28]); + strcat(binary_string, hexbit[28]); if (debug) printf("LL "); newtable = LOWER; break; @@ -495,26 +495,26 @@ int aztec_text_process(unsigned char source[], const unsigned int src_len, char case MIXED: /* To MIXED */ switch (curtable) { case UPPER: /* ML */ - concat(binary_string, hexbit[29]); + strcat(binary_string, hexbit[29]); if (debug) printf("ML "); newtable = MIXED; break; case LOWER: /* ML */ - concat(binary_string, hexbit[29]); + strcat(binary_string, hexbit[29]); if (debug) printf("ML "); newtable = MIXED; break; case PUNC: /* UL ML */ - concat(binary_string, hexbit[31]); + strcat(binary_string, hexbit[31]); if (debug) printf("UL "); - concat(binary_string, hexbit[29]); + strcat(binary_string, hexbit[29]); if (debug) printf("ML "); newtable = MIXED; break; case DIGIT: /* UL ML */ - concat(binary_string, pentbit[14]); + strcat(binary_string, pentbit[14]); if (debug) printf("UL "); - concat(binary_string, hexbit[29]); + strcat(binary_string, hexbit[29]); if (debug) printf("ML "); newtable = MIXED; break; @@ -523,30 +523,30 @@ int aztec_text_process(unsigned char source[], const unsigned int src_len, char case PUNC: /* To PUNC */ switch (curtable) { case UPPER: /* ML PL */ - concat(binary_string, hexbit[29]); + strcat(binary_string, hexbit[29]); if (debug) printf("ML "); - concat(binary_string, hexbit[30]); + strcat(binary_string, hexbit[30]); if (debug) printf("PL "); newtable = PUNC; break; case LOWER: /* ML PL */ - concat(binary_string, hexbit[29]); + strcat(binary_string, hexbit[29]); if (debug) printf("ML "); - concat(binary_string, hexbit[30]); + strcat(binary_string, hexbit[30]); if (debug) printf("PL "); newtable = PUNC; break; case MIXED: /* PL */ - concat(binary_string, hexbit[30]); + strcat(binary_string, hexbit[30]); if (debug) printf("PL "); newtable = PUNC; break; case DIGIT: /* UL ML PL */ - concat(binary_string, pentbit[14]); + strcat(binary_string, pentbit[14]); if (debug) printf("UL "); - concat(binary_string, hexbit[29]); + strcat(binary_string, hexbit[29]); if (debug) printf("ML "); - concat(binary_string, hexbit[30]); + strcat(binary_string, hexbit[30]); if (debug) printf("PL "); newtable = PUNC; break; @@ -555,26 +555,26 @@ int aztec_text_process(unsigned char source[], const unsigned int src_len, char case DIGIT: /* To DIGIT */ switch (curtable) { case UPPER: /* DL */ - concat(binary_string, hexbit[30]); + strcat(binary_string, hexbit[30]); if (debug) printf("DL "); newtable = DIGIT; break; case LOWER: /* DL */ - concat(binary_string, hexbit[30]); + strcat(binary_string, hexbit[30]); if (debug) printf("DL "); newtable = DIGIT; break; case MIXED: /* UL DL */ - concat(binary_string, hexbit[29]); + strcat(binary_string, hexbit[29]); if (debug) printf("UL "); - concat(binary_string, hexbit[30]); + strcat(binary_string, hexbit[30]); if (debug) printf("DL "); newtable = DIGIT; break; case PUNC: /* UL DL */ - concat(binary_string, hexbit[31]); + strcat(binary_string, hexbit[31]); if (debug) printf("UL "); - concat(binary_string, hexbit[30]); + strcat(binary_string, hexbit[30]); if (debug) printf("DL "); newtable = DIGIT; break; @@ -584,32 +584,32 @@ int aztec_text_process(unsigned char source[], const unsigned int src_len, char lasttable = curtable; switch (curtable) { case UPPER: /* BS */ - concat(binary_string, hexbit[31]); + strcat(binary_string, hexbit[31]); if (debug) printf("BS "); newtable = BINARY; break; case LOWER: /* BS */ - concat(binary_string, hexbit[31]); + strcat(binary_string, hexbit[31]); if (debug) printf("BS "); newtable = BINARY; break; case MIXED: /* BS */ - concat(binary_string, hexbit[31]); + strcat(binary_string, hexbit[31]); if (debug) printf("BS "); newtable = BINARY; break; case PUNC: /* UL BS */ - concat(binary_string, hexbit[31]); + strcat(binary_string, hexbit[31]); if (debug) printf("UL "); - concat(binary_string, hexbit[31]); + strcat(binary_string, hexbit[31]); if (debug) printf("BS "); lasttable = UPPER; newtable = BINARY; break; case DIGIT: /* UL BS */ - concat(binary_string, pentbit[14]); + strcat(binary_string, pentbit[14]); if (debug) printf("UL "); - concat(binary_string, hexbit[31]); + strcat(binary_string, hexbit[31]); if (debug) printf("BS "); lasttable = UPPER; newtable = BINARY; @@ -628,22 +628,22 @@ int aztec_text_process(unsigned char source[], const unsigned int src_len, char if (bytes > 31) { /* Put 00000 followed by 11-bit number of bytes less 31 */ - concat(binary_string, "00000"); + strcat(binary_string, "00000"); for (p = 0; p < 11; p++) { if ((bytes - 31) & (0x400 >> p)) { - concat(binary_string, "1"); + strcat(binary_string, "1"); } else { - concat(binary_string, "0"); + strcat(binary_string, "0"); } } } else { /* Put 5-bit number of bytes */ for (p = 0; p < 5; p++) { if (bytes & (0x10 >> p)) { - concat(binary_string, "1"); + strcat(binary_string, "1"); } else { - concat(binary_string, "0"); + strcat(binary_string, "0"); } } } @@ -665,24 +665,24 @@ int aztec_text_process(unsigned char source[], const unsigned int src_len, char case MIXED: case PUNC: if (charmap[i] >= 400) { - concat(binary_string, tribit[charmap[i] - 400]); + strcat(binary_string, tribit[charmap[i] - 400]); if (debug) printf("FLG(%d) ", charmap[i] - 400); } else { - concat(binary_string, hexbit[charmap[i]]); + strcat(binary_string, hexbit[charmap[i]]); if (!((chartype == PUNC) && (charmap[i] == 0))) if (debug) printf("%d ", charmap[i]); } break; case DIGIT: - concat(binary_string, pentbit[charmap[i]]); + strcat(binary_string, pentbit[charmap[i]]); if (debug) printf("%d ", charmap[i]); break; case BINARY: for (p = 0; p < 8; p++) { if (charmap[i] & (0x80 >> p)) { - concat(binary_string, "1"); + strcat(binary_string, "1"); } else { - concat(binary_string, "0"); + strcat(binary_string, "0"); } } if (debug) printf("%d ", charmap[i]); @@ -1065,7 +1065,7 @@ int aztec(struct zint_symbol *symbol, unsigned char source[], int length) { } for (i = 0; i < padbits; i++) { - concat(adjusted_string, "1"); + strcat(adjusted_string, "1"); } adjusted_length = strlen(adjusted_string); @@ -1171,7 +1171,7 @@ int aztec(struct zint_symbol *symbol, unsigned char source[], int length) { } for (i = 0; i < padbits; i++) { - concat(adjusted_string, "1"); + strcat(adjusted_string, "1"); } adjusted_length = strlen(adjusted_string); @@ -1266,9 +1266,9 @@ int aztec(struct zint_symbol *symbol, unsigned char source[], int length) { for (i = (ecc_blocks - 1); i >= 0; i--) { for (p = 0; p < 6; p++) { if (ecc_part[i] & (0x20 >> p)) { - concat(adjusted_string, "1"); + strcat(adjusted_string, "1"); } else { - concat(adjusted_string, "0"); + strcat(adjusted_string, "0"); } } } @@ -1288,9 +1288,9 @@ int aztec(struct zint_symbol *symbol, unsigned char source[], int length) { for (i = (ecc_blocks - 1); i >= 0; i--) { for (p = 0; p < 8; p++) { if (ecc_part[i] & (0x80 >> p)) { - concat(adjusted_string, "1"); + strcat(adjusted_string, "1"); } else { - concat(adjusted_string, "0"); + strcat(adjusted_string, "0"); } } } @@ -1310,9 +1310,9 @@ int aztec(struct zint_symbol *symbol, unsigned char source[], int length) { for (i = (ecc_blocks - 1); i >= 0; i--) { for (p = 0; p < 10; p++) { if (ecc_part[i] & (0x200 >> p)) { - concat(adjusted_string, "1"); + strcat(adjusted_string, "1"); } else { - concat(adjusted_string, "0"); + strcat(adjusted_string, "0"); } } } @@ -1332,9 +1332,9 @@ int aztec(struct zint_symbol *symbol, unsigned char source[], int length) { for (i = (ecc_blocks - 1); i >= 0; i--) { for (p = 0; p < 12; p++) { if (ecc_part[i] & (0x800 >> p)) { - concat(adjusted_string, "1"); + strcat(adjusted_string, "1"); } else { - concat(adjusted_string, "0"); + strcat(adjusted_string, "0"); } } } @@ -1654,9 +1654,9 @@ int aztec_runes(struct zint_symbol *symbol, unsigned char source[], int length) strcpy(binary_string, ""); for (p = 0; p < 8; p++) { if (input_value & (0x80 >> p)) { - concat(binary_string, "1"); + strcat(binary_string, "1"); } else { - concat(binary_string, "0"); + strcat(binary_string, "0"); } } diff --git a/backend/code.c b/backend/code.c index 53766a23..5561ff85 100644 --- a/backend/code.c +++ b/backend/code.c @@ -177,12 +177,12 @@ int code_11(struct zint_symbol *symbol, unsigned char source[], int length) { /* lookup(SODIUM, C11Table, checkstr[1], dest); /* Stop character */ - concat(dest, "11221"); + strcat(dest, "11221"); expand(symbol, dest); ustrcpy(symbol->text, source); - uconcat(symbol->text, (unsigned char*) checkstr); + strcat((char*) symbol->text, checkstr); return error_number; } @@ -265,7 +265,7 @@ int c39(struct zint_symbol *symbol, unsigned char source[], int length) { } /* Stop character */ - concat(dest, "121121211"); + strcat(dest, "121121211"); if ((symbol->symbology == BARCODE_LOGMARS) || (symbol->symbology == BARCODE_HIBC_39)) { /* LOGMARS uses wider 'wide' bars than normal Code 39 */ @@ -280,13 +280,13 @@ int c39(struct zint_symbol *symbol, unsigned char source[], int length) { expand(symbol, dest); if (symbol->symbology == BARCODE_CODE39) { - ustrcpy(symbol->text, (unsigned char*) "*"); - uconcat(symbol->text, source); - uconcat(symbol->text, (unsigned char*) localstr); - uconcat(symbol->text, (unsigned char*) "*"); + strcpy((char*) symbol->text, "*"); + strcat((char*) symbol->text, (char*) source); + strcat((char*) symbol->text, localstr); + strcat((char*) symbol->text, "*"); } else { - ustrcpy(symbol->text, source); - uconcat(symbol->text, (unsigned char*) localstr); + strcpy((char*) symbol->text, (char*) source); + strcat((char*) symbol->text, localstr); } return error_number; } @@ -333,7 +333,7 @@ int pharmazentral(struct zint_symbol *symbol, unsigned char source[], int length } error_number = c39(symbol, (unsigned char *) localstr, strlen(localstr)); ustrcpy(symbol->text, (unsigned char *) "PZN"); - uconcat(symbol->text, (unsigned char *) localstr); + strcat((char*) symbol->text, localstr); return error_number; } @@ -358,7 +358,7 @@ int ec39(struct zint_symbol *symbol, unsigned char source[], int length) { strcpy(symbol->errtxt, "Invalid characters in input data"); return ZINT_ERROR_INVALID_DATA; } - concat((char*) buffer, EC39Ctrl[source[i]]); + strcat((char*) buffer, EC39Ctrl[source[i]]); } /* Then sends the buffer to the C39 function */ @@ -399,7 +399,7 @@ int c93(struct zint_symbol *symbol, unsigned char source[], int length) { strcpy(symbol->errtxt, "Invalid characters in input data"); return ZINT_ERROR_INVALID_DATA; } - concat(buffer, C93Ctrl[source[i]]); + strcat(buffer, C93Ctrl[source[i]]); symbol->text[i] = source[i] ? source[i] : ' '; } @@ -450,7 +450,7 @@ int c93(struct zint_symbol *symbol, unsigned char source[], int length) { } /* Stop character */ - concat(dest, "1111411"); + strcat(dest, "1111411"); expand(symbol, dest); symbol->text[length] = set_copy[c]; @@ -482,7 +482,7 @@ void CheckCharacter() { part[0] = itoc(S[i]); part[1] = itoc(B[i]); part[2] = '\0'; - concat(pattern, part); + strcat(pattern, part); } } } diff --git a/backend/code1.c b/backend/code1.c index 31fb3958..0bd97f4c 100644 --- a/backend/code1.c +++ b/backend/code1.c @@ -36,6 +36,7 @@ #include "large.h" #include #include +#include #ifdef __APPLE__ #include #else @@ -187,7 +188,7 @@ int c1_look_ahead_test(unsigned char source[], int sourcelen, int position, int if ((source[sp] >= '0') && (source[sp] <= '9')) { ascii_count += 0.5; } else { - ascii_count = froundup(ascii_count); + ascii_count = ceil(ascii_count); if (source[sp] > 127) { ascii_count += 2.0; } else { @@ -280,34 +281,34 @@ int c1_look_ahead_test(unsigned char source[], int sourcelen, int position, int } - ascii_count = froundup(ascii_count); - c40_count = froundup(c40_count); - text_count = froundup(text_count); - edi_count = froundup(edi_count); - byte_count = froundup(byte_count); + ascii_count = ceil(ascii_count); + c40_count = ceil(c40_count); + text_count = ceil(text_count); + edi_count = ceil(edi_count); + byte_count = ceil(byte_count); best_scheme = C1_ASCII; if (sp == sourcelen) { /* Step K */ - best_count = (int)edi_count; + best_count = (int) edi_count; if (text_count <= best_count) { - best_count = (int)text_count; + best_count = (int) text_count; best_scheme = C1_TEXT; } if (c40_count <= best_count) { - best_count = (int)c40_count; + best_count = (int) c40_count; best_scheme = C1_C40; } if (ascii_count <= best_count) { - best_count = (int)ascii_count; + best_count = (int) ascii_count; best_scheme = C1_ASCII; } if (byte_count <= best_count) { - best_count = (int)byte_count; + best_count = (int) byte_count; best_scheme = C1_BYTE; } } else { @@ -382,7 +383,7 @@ int c1_encode(struct zint_symbol *symbol, unsigned char source[], unsigned int t /* FNC1 */ target[tp] = 232; tp++; - } + } /* Step A */ current_mode = C1_ASCII; @@ -518,7 +519,7 @@ int c1_encode(struct zint_symbol *symbol, unsigned char source[], unsigned int t if (source[sp] > 127) { /* Step B7 */ target[tp] = 235; /* FNC4 */ - tp++; + tp++; target[tp] = (source[sp] - 128) + 1; tp++; sp++; @@ -527,7 +528,7 @@ int c1_encode(struct zint_symbol *symbol, unsigned char source[], unsigned int t if ((gs1) && (source[sp] == '[')) { target[tp] = 232; /* FNC1 */ tp++; - sp++; + sp++; } else { target[tp] = source[sp] + 1; tp++; @@ -594,13 +595,13 @@ int c1_encode(struct zint_symbol *symbol, unsigned char source[], unsigned int t if (next_mode != C1_C40) { target[tp] = 255; /* Unlatch */ - tp++; + tp++; } else { if (source[sp] > 127) { c40_buffer[c40_p] = 1; c40_p++; c40_buffer[c40_p] = 30; /* Upper Shift */ - c40_p++; + c40_p++; shift_set = c40_shift[source[sp] - 128]; value = c40_value[source[sp] - 128]; } else { @@ -794,7 +795,7 @@ int c1_encode(struct zint_symbol *symbol, unsigned char source[], unsigned int t if (next_mode != C1_EDI) { target[tp] = 255; /* Unlatch */ - tp++; + tp++; } else { if (source[sp] == 13) { value = 0; @@ -869,7 +870,7 @@ int c1_encode(struct zint_symbol *symbol, unsigned char source[], unsigned int t int sub_target; /* Finish Decimal mode and go back to ASCII */ - concat(decimal_binary, "111111"); /* Unlatch */ + strcat(decimal_binary, "111111"); /* Unlatch */ target_count = 3; if (strlen(decimal_binary) <= 16) { @@ -884,7 +885,7 @@ int c1_encode(struct zint_symbol *symbol, unsigned char source[], unsigned int t } if (bits_left_in_byte == 2) { - concat(decimal_binary, "01"); + strcat(decimal_binary, "01"); } if ((bits_left_in_byte == 4) || (bits_left_in_byte == 6)) { @@ -892,33 +893,33 @@ int c1_encode(struct zint_symbol *symbol, unsigned char source[], unsigned int t int sub_value = ctoi(source[sp]) + 1; if (sub_value & 0x08) { - concat(decimal_binary, "1"); + strcat(decimal_binary, "1"); } else { - concat(decimal_binary, "0"); + strcat(decimal_binary, "0"); } if (sub_value & 0x04) { - concat(decimal_binary, "1"); + strcat(decimal_binary, "1"); } else { - concat(decimal_binary, "0"); + strcat(decimal_binary, "0"); } if (sub_value & 0x02) { - concat(decimal_binary, "1"); + strcat(decimal_binary, "1"); } else { - concat(decimal_binary, "0"); + strcat(decimal_binary, "0"); } if (sub_value & 0x01) { - concat(decimal_binary, "1"); + strcat(decimal_binary, "1"); } else { - concat(decimal_binary, "0"); + strcat(decimal_binary, "0"); } sp++; } else { - concat(decimal_binary, "1111"); + strcat(decimal_binary, "1111"); } } if (bits_left_in_byte == 6) { - concat(decimal_binary, "01"); + strcat(decimal_binary, "01"); } /* Binary buffer is full - transfer to target */ @@ -1017,9 +1018,9 @@ int c1_encode(struct zint_symbol *symbol, unsigned char source[], unsigned int t for (p = 0; p < 10; p++) { if (value & (0x200 >> p)) { - concat(decimal_binary, "1"); + strcat(decimal_binary, "1"); } else { - concat(decimal_binary, "0"); + strcat(decimal_binary, "0"); } } @@ -1031,7 +1032,7 @@ int c1_encode(struct zint_symbol *symbol, unsigned char source[], unsigned int t char temp_binary[40]; /* Binary buffer is full - transfer to target */ - + for (p = 0; p < 8; p++) { if (decimal_binary[p] == '1') { target1 += (0x80 >> p); @@ -1052,7 +1053,7 @@ int c1_encode(struct zint_symbol *symbol, unsigned char source[], unsigned int t strcpy(temp_binary, ""); if (strlen(decimal_binary) > 24) { - for(i = 0; i <= (int)(strlen(decimal_binary) - 24); i++) { + for (i = 0; i <= (int) (strlen(decimal_binary) - 24); i++) { temp_binary[i] = decimal_binary[i + 24]; } strcpy(decimal_binary, temp_binary); @@ -1158,7 +1159,7 @@ int c1_encode(struct zint_symbol *symbol, unsigned char source[], unsigned int t int sub_target; /* Finish Decimal mode and go back to ASCII */ - concat(decimal_binary, "111111"); /* Unlatch */ + strcat(decimal_binary, "111111"); /* Unlatch */ target_count = 3; if (strlen(decimal_binary) <= 16) { @@ -1173,15 +1174,15 @@ int c1_encode(struct zint_symbol *symbol, unsigned char source[], unsigned int t } if (bits_left_in_byte == 2) { - concat(decimal_binary, "01"); + strcat(decimal_binary, "01"); } if ((bits_left_in_byte == 4) || (bits_left_in_byte == 6)) { - concat(decimal_binary, "1111"); + strcat(decimal_binary, "1111"); } if (bits_left_in_byte == 6) { - concat(decimal_binary, "01"); + strcat(decimal_binary, "01"); } /* Binary buffer is full - transfer to target */ @@ -1357,13 +1358,13 @@ int code_one(struct zint_symbol *symbol, unsigned char source[], int length) { sub_version = 2; codewords = 8; block_width = 4; - } + } if (length <= 6) { /* Version S-10 */ sub_version = 1; codewords = 4; block_width = 2; - } + } binary_load(elreg, (char *) source, length); diff --git a/backend/code128.c b/backend/code128.c index c0b90404..1c0ce2d1 100644 --- a/backend/code128.c +++ b/backend/code128.c @@ -244,18 +244,18 @@ void c128_set_a(unsigned char source, char dest[], int values[], int *bar_chars) if (source > 127) { if (source < 160) { - concat(dest, C128Table[(source - 128) + 64]); + strcat(dest, C128Table[(source - 128) + 64]); values[(*bar_chars)] = (source - 128) + 64; } else { - concat(dest, C128Table[(source - 128) - 32]); + strcat(dest, C128Table[(source - 128) - 32]); values[(*bar_chars)] = (source - 128) - 32; } } else { if (source < 32) { - concat(dest, C128Table[source + 64]); + strcat(dest, C128Table[source + 64]); values[(*bar_chars)] = source + 64; } else { - concat(dest, C128Table[source - 32]); + strcat(dest, C128Table[source - 32]); values[(*bar_chars)] = source - 32; } } @@ -269,10 +269,10 @@ void c128_set_a(unsigned char source, char dest[], int values[], int *bar_chars) */ void c128_set_b(unsigned char source, char dest[], int values[], int *bar_chars) { if (source > 127) { - concat(dest, C128Table[source - 32 - 128]); + strcat(dest, C128Table[source - 32 - 128]); values[(*bar_chars)] = source - 32 - 128; } else { - concat(dest, C128Table[source - 32]); + strcat(dest, C128Table[source - 32]); values[(*bar_chars)] = source - 32; } (*bar_chars)++; @@ -285,7 +285,7 @@ void c128_set_c(unsigned char source_a, unsigned char source_b, char dest[], int int weight; weight = (10 * ctoi(source_a)) + ctoi(source_b); - concat(dest, C128Table[weight]); + strcat(dest, C128Table[weight]); values[(*bar_chars)] = weight; (*bar_chars)++; } @@ -491,27 +491,27 @@ int code_128(struct zint_symbol *symbol, unsigned char source[], int length) { /* Reader Initialisation mode */ switch (set[0]) { case 'A': /* Start A */ - concat(dest, C128Table[103]); + strcat(dest, C128Table[103]); values[0] = 103; current_set = 'A'; - concat(dest, C128Table[96]); /* FNC3 */ + strcat(dest, C128Table[96]); /* FNC3 */ values[1] = 96; bar_characters++; break; case 'B': /* Start B */ - concat(dest, C128Table[104]); + strcat(dest, C128Table[104]); values[0] = 104; current_set = 'B'; - concat(dest, C128Table[96]); /* FNC3 */ + strcat(dest, C128Table[96]); /* FNC3 */ values[1] = 96; bar_characters++; break; case 'C': /* Start C */ - concat(dest, C128Table[104]); /* Start B */ + strcat(dest, C128Table[104]); /* Start B */ values[0] = 105; - concat(dest, C128Table[96]); /* FNC3 */ + strcat(dest, C128Table[96]); /* FNC3 */ values[1] = 96; - concat(dest, C128Table[99]); /* Code C */ + strcat(dest, C128Table[99]); /* Code C */ values[2] = 99; bar_characters += 2; current_set = 'C'; @@ -521,17 +521,17 @@ int code_128(struct zint_symbol *symbol, unsigned char source[], int length) { /* Normal mode */ switch (set[0]) { case 'A': /* Start A */ - concat(dest, C128Table[103]); + strcat(dest, C128Table[103]); values[0] = 103; current_set = 'A'; break; case 'B': /* Start B */ - concat(dest, C128Table[104]); + strcat(dest, C128Table[104]); values[0] = 104; current_set = 'B'; break; case 'C': /* Start C */ - concat(dest, C128Table[105]); + strcat(dest, C128Table[105]); values[0] = 105; current_set = 'C'; break; @@ -543,14 +543,14 @@ int code_128(struct zint_symbol *symbol, unsigned char source[], int length) { if (fset[0] == 'F') { switch (current_set) { case 'A': - concat(dest, C128Table[101]); - concat(dest, C128Table[101]); + strcat(dest, C128Table[101]); + strcat(dest, C128Table[101]); values[bar_characters] = 101; values[bar_characters + 1] = 101; break; case 'B': - concat(dest, C128Table[100]); - concat(dest, C128Table[100]); + strcat(dest, C128Table[100]); + strcat(dest, C128Table[100]); values[bar_characters] = 100; values[bar_characters + 1] = 100; break; @@ -566,17 +566,17 @@ int code_128(struct zint_symbol *symbol, unsigned char source[], int length) { if ((read != 0) && (set[read] != current_set)) { /* Latch different code set */ switch (set[read]) { - case 'A': concat(dest, C128Table[101]); + case 'A': strcat(dest, C128Table[101]); values[bar_characters] = 101; bar_characters++; current_set = 'A'; break; - case 'B': concat(dest, C128Table[100]); + case 'B': strcat(dest, C128Table[100]); values[bar_characters] = 100; bar_characters++; current_set = 'B'; break; - case 'C': concat(dest, C128Table[99]); + case 'C': strcat(dest, C128Table[99]); values[bar_characters] = 99; bar_characters++; current_set = 'C'; @@ -589,14 +589,14 @@ int code_128(struct zint_symbol *symbol, unsigned char source[], int length) { /* Latch beginning of extended mode */ switch (current_set) { case 'A': - concat(dest, C128Table[101]); - concat(dest, C128Table[101]); + strcat(dest, C128Table[101]); + strcat(dest, C128Table[101]); values[bar_characters] = 101; values[bar_characters + 1] = 101; break; case 'B': - concat(dest, C128Table[100]); - concat(dest, C128Table[100]); + strcat(dest, C128Table[100]); + strcat(dest, C128Table[100]); values[bar_characters] = 100; values[bar_characters + 1] = 100; break; @@ -608,14 +608,14 @@ int code_128(struct zint_symbol *symbol, unsigned char source[], int length) { /* Latch end of extended mode */ switch (current_set) { case 'A': - concat(dest, C128Table[101]); - concat(dest, C128Table[101]); + strcat(dest, C128Table[101]); + strcat(dest, C128Table[101]); values[bar_characters] = 101; values[bar_characters + 1] = 101; break; case 'B': - concat(dest, C128Table[100]); - concat(dest, C128Table[100]); + strcat(dest, C128Table[100]); + strcat(dest, C128Table[100]); values[bar_characters] = 100; values[bar_characters + 1] = 100; break; @@ -629,11 +629,11 @@ int code_128(struct zint_symbol *symbol, unsigned char source[], int length) { /* Shift to or from extended mode */ switch (current_set) { case 'A': - concat(dest, C128Table[101]); /* FNC 4 */ + strcat(dest, C128Table[101]); /* FNC 4 */ values[bar_characters] = 101; break; case 'B': - concat(dest, C128Table[100]); /* FNC 4 */ + strcat(dest, C128Table[100]); /* FNC 4 */ values[bar_characters] = 100; break; } @@ -642,7 +642,7 @@ int code_128(struct zint_symbol *symbol, unsigned char source[], int length) { if ((set[read] == 'a') || (set[read] == 'b')) { /* Insert shift character */ - concat(dest, C128Table[98]); + strcat(dest, C128Table[98]); values[bar_characters] = 98; bar_characters++; } @@ -672,10 +672,10 @@ int code_128(struct zint_symbol *symbol, unsigned char source[], int length) { } total_sum += values[i]; } - concat(dest, C128Table[total_sum % 103]); + strcat(dest, C128Table[total_sum % 103]); /* Stop character */ - concat(dest, C128Table[106]); + strcat(dest, C128Table[106]); expand(symbol, dest); return error_number; } @@ -850,21 +850,21 @@ int ean_128(struct zint_symbol *symbol, unsigned char source[], int length) { /* So now we know what start character to use - we can get on with it! */ switch (set[0]) { case 'A': /* Start A */ - concat(dest, C128Table[103]); + strcat(dest, C128Table[103]); values[0] = 103; break; case 'B': /* Start B */ - concat(dest, C128Table[104]); + strcat(dest, C128Table[104]); values[0] = 104; break; case 'C': /* Start C */ - concat(dest, C128Table[105]); + strcat(dest, C128Table[105]); values[0] = 105; break; } bar_characters++; - concat(dest, C128Table[102]); + strcat(dest, C128Table[102]); values[1] = 102; bar_characters++; @@ -874,15 +874,15 @@ int ean_128(struct zint_symbol *symbol, unsigned char source[], int length) { if ((read != 0) && (set[read] != set[read - 1])) { /* Latch different code set */ switch (set[read]) { - case 'A': concat(dest, C128Table[101]); + case 'A': strcat(dest, C128Table[101]); values[bar_characters] = 101; bar_characters++; break; - case 'B': concat(dest, C128Table[100]); + case 'B': strcat(dest, C128Table[100]); values[bar_characters] = 100; bar_characters++; break; - case 'C': concat(dest, C128Table[99]); + case 'C': strcat(dest, C128Table[99]); values[bar_characters] = 99; bar_characters++; break; @@ -891,7 +891,7 @@ int ean_128(struct zint_symbol *symbol, unsigned char source[], int length) { if ((set[read] == 'a') || (set[read] == 'b')) { /* Insert shift character */ - concat(dest, C128Table[98]); + strcat(dest, C128Table[98]); values[bar_characters] = 98; bar_characters++; } @@ -914,7 +914,7 @@ int ean_128(struct zint_symbol *symbol, unsigned char source[], int length) { break; } } else { - concat(dest, C128Table[102]); + strcat(dest, C128Table[102]); values[bar_characters] = 102; bar_characters++; read++; @@ -953,7 +953,7 @@ int ean_128(struct zint_symbol *symbol, unsigned char source[], int length) { } if (linkage_flag != 0) { - concat(dest, C128Table[linkage_flag]); + strcat(dest, C128Table[linkage_flag]); values[bar_characters] = linkage_flag; bar_characters++; } @@ -967,12 +967,12 @@ int ean_128(struct zint_symbol *symbol, unsigned char source[], int length) { } total_sum += values[i]; } - concat(dest, C128Table[total_sum % 103]); + strcat(dest, C128Table[total_sum % 103]); values[bar_characters] = total_sum % 103; bar_characters++; /* Stop character */ - concat(dest, C128Table[106]); + strcat(dest, C128Table[106]); values[bar_characters] = 106; bar_characters++; expand(symbol, dest); diff --git a/backend/code16k.c b/backend/code16k.c index 90708b54..1db0cb54 100644 --- a/backend/code16k.c +++ b/backend/code16k.c @@ -695,12 +695,12 @@ int code16k(struct zint_symbol *symbol, unsigned char source[], int length) { for (current_row = 0; current_row < rows_needed; current_row++) { strcpy(width_pattern, ""); - concat(width_pattern, C16KStartStop[C16KStartValues[current_row]]); - concat(width_pattern, "1"); + strcat(width_pattern, C16KStartStop[C16KStartValues[current_row]]); + strcat(width_pattern, "1"); for (i = 0; i < 5; i++) { - concat(width_pattern, C16KTable[values[(current_row * 5) + i]]); + strcat(width_pattern, C16KTable[values[(current_row * 5) + i]]); } - concat(width_pattern, C16KStartStop[C16KStopValues[current_row]]); + strcat(width_pattern, C16KStartStop[C16KStopValues[current_row]]); /* Write the information into the symbol */ writer = 0; diff --git a/backend/code49.c b/backend/code49.c index 386204b5..9b83ed4e 100644 --- a/backend/code49.c +++ b/backend/code49.c @@ -40,8 +40,8 @@ /* "!" represents Shift 1 and "&" represents Shift 2, "*" represents FNC1 */ -int code_49(struct zint_symbol *symbol, unsigned char source[], int length) { - int i, j, rows, M, x_count, y_count, z_count, posn_val, local_value, h; +int code_49(struct zint_symbol *symbol, unsigned char source[], const int length) { + int i, j, rows, M, x_count, y_count, z_count, posn_val, local_value; char intermediate[170] = ""; int codewords[170], codeword_count; int c_grid[8][8]; /* Refers to table 3 */ @@ -49,6 +49,7 @@ int code_49(struct zint_symbol *symbol, unsigned char source[], int length) { int pad_count = 0; char pattern[40]; int gs1; + size_t h; if (length > 81) { strcpy(symbol->errtxt, "Input too long"); @@ -67,9 +68,9 @@ int code_49(struct zint_symbol *symbol, unsigned char source[], int length) { return ZINT_ERROR_INVALID_DATA; } if (gs1 && (source[i] == '[')) - concat(intermediate, "*"); /* FNC1 */ + strcat(intermediate, "*"); /* FNC1 */ else - concat(intermediate, c49_table7[source[i]]); + strcat(intermediate, c49_table7[source[i]]); } codeword_count = 0; @@ -310,17 +311,17 @@ int code_49(struct zint_symbol *symbol, unsigned char source[], int length) { if (i != (rows - 1)) { if (c49_table4[i][j] == 'E') { /* Even Parity */ - concat(pattern, c49_appxe_even[w_grid[i][j]]); + strcat(pattern, c49_appxe_even[w_grid[i][j]]); } else { /* Odd Parity */ - concat(pattern, c49_appxe_odd[w_grid[i][j]]); + strcat(pattern, c49_appxe_odd[w_grid[i][j]]); } } else { /* Last row uses all even parity */ - concat(pattern, c49_appxe_even[w_grid[i][j]]); + strcat(pattern, c49_appxe_even[w_grid[i][j]]); } } - concat(pattern, "4"); /* Stop character */ + strcat(pattern, "4"); /* Stop character */ /* Expand into symbol */ symbol->row_height[i] = 10; diff --git a/backend/common.c b/backend/common.c index c9e86d6b..d9c7606f 100644 --- a/backend/common.c +++ b/backend/common.c @@ -36,42 +36,13 @@ /* Local replacement for strlen() with unsigned char strings */ int ustrlen(const unsigned char data[]) { - int i; - for (i = 0; data[i]; i++); - - return i; + return strlen((const char*) data); } /* Local replacement for strcpy() with unsigned char strings */ + void ustrcpy(unsigned char target[], const unsigned char source[]) { - int i, len; - - len = ustrlen(source); - for (i = 0; i < len; i++) { - target[i] = source[i]; - } - target[i] = '\0'; -} - -/* Concatinates dest[] with the contents of source[], copying /0 as well */ -void concat(char dest[], const char source[]) { - size_t i, j, n; - - j = strlen(dest); - n = strlen(source); - for (i = 0; i <= n; i++) { - dest[i + j] = source[i]; - } -} - -/* Concatinates dest[] with the contents of source[], copying /0 as well */ -void uconcat(unsigned char dest[], const unsigned char source[]) { - unsigned int i, j; - - j = ustrlen(dest); - for (i = 0; i <= ustrlen(source); i++) { - dest[i + j] = source[i]; - } + strcpy((char *) target, (const char*) source); } /* Converts a character 0-9 to its equivalent integer value */ @@ -140,7 +111,7 @@ void lookup(char set_string[], const char *table[], const char data, char dest[] for (i = 0; i < n; i++) { if (data == set_string[i]) { - concat(dest, table[i]); + strcat(dest, table[i]); } } } @@ -195,7 +166,7 @@ void expand(struct zint_symbol *symbol, char data[]) { } /* Indicates which symbologies can have row binding */ -int is_stackable(int symbology) { +int is_stackable(const int symbology) { if (symbology < BARCODE_PDF417) { return 1; } @@ -257,20 +228,6 @@ int is_extendable(const int symbology) { return 0; } -int roundup(const float input) { - float remainder; - int integer_part; - - integer_part = (int) input; - remainder = input - integer_part; - - if (remainder > 0.1F) { - integer_part++; - } - - return integer_part; -} - int istwodigits(const unsigned char source[], const int position) { if ((source[position] >= '0') && (source[position] <= '9')) { if ((source[position + 1] >= '0') && (source[position + 1] <= '9')) { @@ -281,19 +238,6 @@ int istwodigits(const unsigned char source[], const int position) { return 0; } -double froundup(const double input) { - double fraction, output = 0.0; - - fraction = input - (int) input; - if (fraction > 0.01) { - output = (input - fraction) + 1.0; - } else { - output = input; - } - - return output; -} - /* Convert Unicode to Latin-1 for those symbologies which only support Latin-1 */ int latin1_process(struct zint_symbol *symbol, const unsigned char source[], unsigned char preprocessed[], int *length) { int j, i, next; diff --git a/backend/common.h b/backend/common.h index 97e586f5..f748a872 100644 --- a/backend/common.h +++ b/backend/common.h @@ -53,8 +53,6 @@ extern "C" { extern int ustrlen(const unsigned char source[]); extern void ustrcpy(unsigned char target[], const unsigned char source[]); - extern void concat(char dest[], const char source[]); - extern void uconcat(unsigned char dest[], const unsigned char source[]); extern int ctoi(const char source); extern char itoc(const int source); extern void to_upper(unsigned char source[]); diff --git a/backend/composite.c b/backend/composite.c index 9b045b48..c71981e3 100644 --- a/backend/composite.c +++ b/backend/composite.c @@ -274,33 +274,33 @@ int cc_a(struct zint_symbol *symbol, char source[], int cc_width) { dummy[j + 1] = codeWords[i * cc_width + j]; } /* Copy the data into codebarre */ - concat(codebarre, RAPLR[LeftRAP]); - concat(codebarre, "1"); - concat(codebarre, codagemc[offset + dummy[1]]); - concat(codebarre, "1"); + strcat(codebarre, RAPLR[LeftRAP]); + strcat(codebarre, "1"); + strcat(codebarre, codagemc[offset + dummy[1]]); + strcat(codebarre, "1"); if (cc_width == 3) { - concat(codebarre, RAPC[CentreRAP]); + strcat(codebarre, RAPC[CentreRAP]); } if (cc_width >= 2) { - concat(codebarre, "1"); - concat(codebarre, codagemc[offset + dummy[2]]); - concat(codebarre, "1"); + strcat(codebarre, "1"); + strcat(codebarre, codagemc[offset + dummy[2]]); + strcat(codebarre, "1"); } if (cc_width == 4) { - concat(codebarre, RAPC[CentreRAP]); + strcat(codebarre, RAPC[CentreRAP]); } if (cc_width >= 3) { - concat(codebarre, "1"); - concat(codebarre, codagemc[offset + dummy[3]]); - concat(codebarre, "1"); + strcat(codebarre, "1"); + strcat(codebarre, codagemc[offset + dummy[3]]); + strcat(codebarre, "1"); } if (cc_width == 4) { - concat(codebarre, "1"); - concat(codebarre, codagemc[offset + dummy[4]]); - concat(codebarre, "1"); + strcat(codebarre, "1"); + strcat(codebarre, codagemc[offset + dummy[4]]); + strcat(codebarre, "1"); } - concat(codebarre, RAPLR[RightRAP]); - concat(codebarre, "1"); /* stop */ + strcat(codebarre, RAPLR[RightRAP]); + strcat(codebarre, "1"); /* stop */ /* Now codebarre is a mixture of letters and numbers */ @@ -558,33 +558,33 @@ int cc_b(struct zint_symbol *symbol, char source[], int cc_width) { dummy[j + 1] = chainemc[i * symbol->option_2 + j]; } /* Copy the data into codebarre */ - concat(codebarre, RAPLR[LeftRAP]); - concat(codebarre, "1"); - concat(codebarre, codagemc[offset + dummy[1]]); - concat(codebarre, "1"); + strcat(codebarre, RAPLR[LeftRAP]); + strcat(codebarre, "1"); + strcat(codebarre, codagemc[offset + dummy[1]]); + strcat(codebarre, "1"); if (cc_width == 3) { - concat(codebarre, RAPC[CentreRAP]); + strcat(codebarre, RAPC[CentreRAP]); } if (cc_width >= 2) { - concat(codebarre, "1"); - concat(codebarre, codagemc[offset + dummy[2]]); - concat(codebarre, "1"); + strcat(codebarre, "1"); + strcat(codebarre, codagemc[offset + dummy[2]]); + strcat(codebarre, "1"); } if (cc_width == 4) { - concat(codebarre, RAPC[CentreRAP]); + strcat(codebarre, RAPC[CentreRAP]); } if (cc_width >= 3) { - concat(codebarre, "1"); - concat(codebarre, codagemc[offset + dummy[3]]); - concat(codebarre, "1"); + strcat(codebarre, "1"); + strcat(codebarre, codagemc[offset + dummy[3]]); + strcat(codebarre, "1"); } if (cc_width == 4) { - concat(codebarre, "1"); - concat(codebarre, codagemc[offset + dummy[4]]); - concat(codebarre, "1"); + strcat(codebarre, "1"); + strcat(codebarre, codagemc[offset + dummy[4]]); + strcat(codebarre, "1"); } - concat(codebarre, RAPLR[RightRAP]); - concat(codebarre, "1"); /* stop */ + strcat(codebarre, RAPLR[RightRAP]); + strcat(codebarre, "1"); /* stop */ /* Now codebarre is a mixture of letters and numbers */ @@ -772,10 +772,10 @@ int cc_c(struct zint_symbol *symbol, char source[], int cc_width, int ecc_level) default: offset = 0; /* cluster(0) */ break; } - concat(codebarre, codagemc[offset + dummy[j]]); - concat(codebarre, "*"); + strcat(codebarre, codagemc[offset + dummy[j]]); + strcat(codebarre, "*"); } - concat(codebarre, "-"); + strcat(codebarre, "-"); strcpy(pattern, ""); for (loop = 0; loop < (int) strlen(codebarre); loop++) { @@ -829,17 +829,17 @@ int cc_binary_string(struct zint_symbol *symbol, const char source[], char binar } if (encoding_method == 1) { - concat(binary_string, "0"); + strcat(binary_string, "0"); } if (encoding_method == 2) { /* Encoding Method field "10" - date and lot number */ - concat(binary_string, "10"); + strcat(binary_string, "10"); if (source[1] == '0') { /* No date data */ - concat(binary_string, "11"); + strcat(binary_string, "11"); read_posn = 2; } else { /* Production Date (11) or Expiration Date (17) */ @@ -859,19 +859,19 @@ int cc_binary_string(struct zint_symbol *symbol, const char source[], char binar mask = 0x8000; for (j = 0; j < 16; j++) { if ((group_val & mask) == 0x00) { - concat(binary_string, "0"); + strcat(binary_string, "0"); } else { - concat(binary_string, "1"); + strcat(binary_string, "1"); } mask = mask >> 1; } if (source[1] == '1') { /* Production Date AI 11 */ - concat(binary_string, "0"); + strcat(binary_string, "0"); } else { /* Expiration Date AI 17 */ - concat(binary_string, "1"); + strcat(binary_string, "1"); } read_posn = 8; } @@ -967,7 +967,7 @@ int cc_binary_string(struct zint_symbol *symbol, const char source[], char binar if ((test1 != -1) && (test2 != 1) && (test3 == 0)) { /* Encodation method "11" can be used */ - concat(binary_string, "11"); + strcat(binary_string, "11"); numeric -= test1; alpha--; @@ -977,16 +977,16 @@ int cc_binary_string(struct zint_symbol *symbol, const char source[], char binar if (alphanum > 0) { /* Alphanumeric mode */ - concat(binary_string, "0"); + strcat(binary_string, "0"); ai90_mode = 1; } else { if (alpha > numeric) { /* Alphabetic mode */ - concat(binary_string, "11"); + strcat(binary_string, "11"); ai90_mode = 2; } else { /* Numeric mode */ - concat(binary_string, "10"); + strcat(binary_string, "10"); ai90_mode = 3; } } @@ -1007,11 +1007,11 @@ int cc_binary_string(struct zint_symbol *symbol, const char source[], char binar } switch (ai_crop) { - case 0: concat(binary_string, "0"); + case 0: strcat(binary_string, "0"); break; - case 1: concat(binary_string, "10"); + case 1: strcat(binary_string, "10"); break; - case 2: concat(binary_string, "11"); + case 2: strcat(binary_string, "11"); break; } @@ -1070,9 +1070,9 @@ int cc_binary_string(struct zint_symbol *symbol, const char source[], char binar mask = 0x10; for (j = 0; j < 5; j++) { if ((numeric_value & mask) == 0x00) { - concat(binary_string, "0"); + strcat(binary_string, "0"); } else { - concat(binary_string, "1"); + strcat(binary_string, "1"); } mask = mask >> 1; } @@ -1081,22 +1081,22 @@ int cc_binary_string(struct zint_symbol *symbol, const char source[], char binar mask = 0x08; for (j = 0; j < 4; j++) { if ((table3_letter & mask) == 0x00) { - concat(binary_string, "0"); + strcat(binary_string, "0"); } else { - concat(binary_string, "1"); + strcat(binary_string, "1"); } mask = mask >> 1; } } else { /* Encoding is done according to 5.2.2 c) 3) */ - concat(binary_string, "11111"); + strcat(binary_string, "11111"); /* ten bit representation of number */ mask = 0x200; for (j = 0; j < 10; j++) { if ((numeric_value & mask) == 0x00) { - concat(binary_string, "0"); + strcat(binary_string, "0"); } else { - concat(binary_string, "1"); + strcat(binary_string, "1"); } mask = mask >> 1; } @@ -1105,9 +1105,9 @@ int cc_binary_string(struct zint_symbol *symbol, const char source[], char binar mask = 0x10; for (j = 0; j < 5; j++) { if (((ninety[test1] - 65) & mask) == 0x00) { - concat(binary_string, "0"); + strcat(binary_string, "0"); } else { - concat(binary_string, "1"); + strcat(binary_string, "1"); } mask = mask >> 1; } @@ -1116,7 +1116,7 @@ int cc_binary_string(struct zint_symbol *symbol, const char source[], char binar read_posn = test1 + 3; } else { /* Use general field encodation instead */ - concat(binary_string, "0"); + strcat(binary_string, "0"); read_posn = 0; } } @@ -1129,9 +1129,9 @@ int cc_binary_string(struct zint_symbol *symbol, const char source[], char binar mask = 0x10; for (j = 0; j < 5; j++) { if (((source[read_posn] + 4) & mask) == 0x00) { - concat(binary_string, "0"); + strcat(binary_string, "0"); } else { - concat(binary_string, "1"); + strcat(binary_string, "1"); } mask = mask >> 1; } @@ -1141,16 +1141,16 @@ int cc_binary_string(struct zint_symbol *symbol, const char source[], char binar mask = 0x20; for (j = 0; j < 6; j++) { if (((source[read_posn] - 65) & mask) == 0x00) { - concat(binary_string, "0"); + strcat(binary_string, "0"); } else { - concat(binary_string, "1"); + strcat(binary_string, "1"); } mask = mask >> 1; } } if (source[read_posn] == '[') { - concat(binary_string, "11111"); + strcat(binary_string, "11111"); } read_posn++; @@ -1165,9 +1165,9 @@ int cc_binary_string(struct zint_symbol *symbol, const char source[], char binar mask = 0x10; for (j = 0; j < 5; j++) { if (((source[read_posn] - 43) & mask) == 0x00) { - concat(binary_string, "0"); + strcat(binary_string, "0"); } else { - concat(binary_string, "1"); + strcat(binary_string, "1"); } mask = mask >> 1; } @@ -1177,26 +1177,26 @@ int cc_binary_string(struct zint_symbol *symbol, const char source[], char binar mask = 0x20; for (j = 0; j < 6; j++) { if (((source[read_posn] - 33) & mask) == 0x00) { - concat(binary_string, "0"); + strcat(binary_string, "0"); } else { - concat(binary_string, "1"); + strcat(binary_string, "1"); } mask = mask >> 1; } } switch (source[read_posn]) { - case '[': concat(binary_string, "01111"); + case '[': strcat(binary_string, "01111"); break; - case '*': concat(binary_string, "111010"); + case '*': strcat(binary_string, "111010"); break; - case ',': concat(binary_string, "111011"); + case ',': strcat(binary_string, "111011"); break; - case '-': concat(binary_string, "111100"); + case '-': strcat(binary_string, "111100"); break; - case '.': concat(binary_string, "111101"); + case '.': strcat(binary_string, "111101"); break; - case '/': concat(binary_string, "111110"); + case '/': strcat(binary_string, "111110"); break; } @@ -1322,7 +1322,7 @@ int cc_binary_string(struct zint_symbol *symbol, const char source[], char binar if (i != 0) { if ((general_field_type[i - 1] != NUMERIC) && (general_field[i - 1] != '[')) { - concat(binary_string, "000"); /* Numeric latch */ + strcat(binary_string, "000"); /* Numeric latch */ } } @@ -1343,9 +1343,9 @@ int cc_binary_string(struct zint_symbol *symbol, const char source[], char binar mask = 0x40; for (j = 0; j < 7; j++) { if ((value & mask) == 0x00) { - concat(binary_string, "0"); + strcat(binary_string, "0"); } else { - concat(binary_string, "1"); + strcat(binary_string, "1"); } mask = mask >> 1; } @@ -1357,10 +1357,10 @@ int cc_binary_string(struct zint_symbol *symbol, const char source[], char binar if (i != 0) { if ((general_field_type[i - 1] == NUMERIC) || (general_field[i - 1] == '[')) { - concat(binary_string, "0000"); /* Alphanumeric latch */ + strcat(binary_string, "0000"); /* Alphanumeric latch */ } if (general_field_type[i - 1] == ISOIEC) { - concat(binary_string, "00100"); /* ISO/IEC 646 latch */ + strcat(binary_string, "00100"); /* ISO/IEC 646 latch */ } } @@ -1371,9 +1371,9 @@ int cc_binary_string(struct zint_symbol *symbol, const char source[], char binar mask = 0x10; for (j = 0; j < 5; j++) { if ((value & mask) == 0x00) { - concat(binary_string, "0"); + strcat(binary_string, "0"); } else { - concat(binary_string, "1"); + strcat(binary_string, "1"); } mask = mask >> 1; } @@ -1386,20 +1386,20 @@ int cc_binary_string(struct zint_symbol *symbol, const char source[], char binar mask = 0x20; for (j = 0; j < 6; j++) { if ((value & mask) == 0x00) { - concat(binary_string, "0"); + strcat(binary_string, "0"); } else { - concat(binary_string, "1"); + strcat(binary_string, "1"); } mask = mask >> 1; } } - if (general_field[i] == '[') concat(binary_string, "01111"); /* FNC1/Numeric latch */ - if (general_field[i] == '*') concat(binary_string, "111010"); /* asterisk */ - if (general_field[i] == ',') concat(binary_string, "111011"); /* comma */ - if (general_field[i] == '-') concat(binary_string, "111100"); /* minus or hyphen */ - if (general_field[i] == '.') concat(binary_string, "111101"); /* period or full stop */ - if (general_field[i] == '/') concat(binary_string, "111110"); /* slash or solidus */ + if (general_field[i] == '[') strcat(binary_string, "01111"); /* FNC1/Numeric latch */ + if (general_field[i] == '*') strcat(binary_string, "111010"); /* asterisk */ + if (general_field[i] == ',') strcat(binary_string, "111011"); /* comma */ + if (general_field[i] == '-') strcat(binary_string, "111100"); /* minus or hyphen */ + if (general_field[i] == '.') strcat(binary_string, "111101"); /* period or full stop */ + if (general_field[i] == '/') strcat(binary_string, "111110"); /* slash or solidus */ i++; break; @@ -1408,11 +1408,11 @@ int cc_binary_string(struct zint_symbol *symbol, const char source[], char binar if (i != 0) { if ((general_field_type[i - 1] == NUMERIC) || (general_field[i - 1] == '[')) { - concat(binary_string, "0000"); /* Alphanumeric latch */ - concat(binary_string, "00100"); /* ISO/IEC 646 latch */ + strcat(binary_string, "0000"); /* Alphanumeric latch */ + strcat(binary_string, "00100"); /* ISO/IEC 646 latch */ } if (general_field_type[i - 1] == ALPHA) { - concat(binary_string, "00100"); /* ISO/IEC 646 latch */ + strcat(binary_string, "00100"); /* ISO/IEC 646 latch */ } } @@ -1423,9 +1423,9 @@ int cc_binary_string(struct zint_symbol *symbol, const char source[], char binar mask = 0x10; for (j = 0; j < 5; j++) { if ((value & mask) == 0x00) { - concat(binary_string, "0"); + strcat(binary_string, "0"); } else { - concat(binary_string, "1"); + strcat(binary_string, "1"); } mask = mask >> 1; } @@ -1438,9 +1438,9 @@ int cc_binary_string(struct zint_symbol *symbol, const char source[], char binar mask = 0x40; for (j = 0; j < 7; j++) { if ((value & mask) == 0x00) { - concat(binary_string, "0"); + strcat(binary_string, "0"); } else { - concat(binary_string, "1"); + strcat(binary_string, "1"); } mask = mask >> 1; } @@ -1453,36 +1453,36 @@ int cc_binary_string(struct zint_symbol *symbol, const char source[], char binar mask = 0x40; for (j = 0; j < 7; j++) { if ((value & mask) == 0x00) { - concat(binary_string, "0"); + strcat(binary_string, "0"); } else { - concat(binary_string, "1"); + strcat(binary_string, "1"); } mask = mask >> 1; } } - if (general_field[i] == '[') concat(binary_string, "01111"); /* FNC1/Numeric latch */ - if (general_field[i] == '!') concat(binary_string, "11101000"); /* exclamation mark */ - if (general_field[i] == 34) concat(binary_string, "11101001"); /* quotation mark */ - if (general_field[i] == 37) concat(binary_string, "11101010"); /* percent sign */ - if (general_field[i] == '&') concat(binary_string, "11101011"); /* ampersand */ - if (general_field[i] == 39) concat(binary_string, "11101100"); /* apostrophe */ - if (general_field[i] == '(') concat(binary_string, "11101101"); /* left parenthesis */ - if (general_field[i] == ')') concat(binary_string, "11101110"); /* right parenthesis */ - if (general_field[i] == '*') concat(binary_string, "11101111"); /* asterisk */ - if (general_field[i] == '+') concat(binary_string, "11110000"); /* plus sign */ - if (general_field[i] == ',') concat(binary_string, "11110001"); /* comma */ - if (general_field[i] == '-') concat(binary_string, "11110010"); /* minus or hyphen */ - if (general_field[i] == '.') concat(binary_string, "11110011"); /* period or full stop */ - if (general_field[i] == '/') concat(binary_string, "11110100"); /* slash or solidus */ - if (general_field[i] == ':') concat(binary_string, "11110101"); /* colon */ - if (general_field[i] == ';') concat(binary_string, "11110110"); /* semicolon */ - if (general_field[i] == '<') concat(binary_string, "11110111"); /* less-than sign */ - if (general_field[i] == '=') concat(binary_string, "11111000"); /* equals sign */ - if (general_field[i] == '>') concat(binary_string, "11111001"); /* greater-than sign */ - if (general_field[i] == '?') concat(binary_string, "11111010"); /* question mark */ - if (general_field[i] == '_') concat(binary_string, "11111011"); /* underline or low line */ - if (general_field[i] == ' ') concat(binary_string, "11111100"); /* space */ + if (general_field[i] == '[') strcat(binary_string, "01111"); /* FNC1/Numeric latch */ + if (general_field[i] == '!') strcat(binary_string, "11101000"); /* exclamation mark */ + if (general_field[i] == 34) strcat(binary_string, "11101001"); /* quotation mark */ + if (general_field[i] == 37) strcat(binary_string, "11101010"); /* percent sign */ + if (general_field[i] == '&') strcat(binary_string, "11101011"); /* ampersand */ + if (general_field[i] == 39) strcat(binary_string, "11101100"); /* apostrophe */ + if (general_field[i] == '(') strcat(binary_string, "11101101"); /* left parenthesis */ + if (general_field[i] == ')') strcat(binary_string, "11101110"); /* right parenthesis */ + if (general_field[i] == '*') strcat(binary_string, "11101111"); /* asterisk */ + if (general_field[i] == '+') strcat(binary_string, "11110000"); /* plus sign */ + if (general_field[i] == ',') strcat(binary_string, "11110001"); /* comma */ + if (general_field[i] == '-') strcat(binary_string, "11110010"); /* minus or hyphen */ + if (general_field[i] == '.') strcat(binary_string, "11110011"); /* period or full stop */ + if (general_field[i] == '/') strcat(binary_string, "11110100"); /* slash or solidus */ + if (general_field[i] == ':') strcat(binary_string, "11110101"); /* colon */ + if (general_field[i] == ';') strcat(binary_string, "11110110"); /* semicolon */ + if (general_field[i] == '<') strcat(binary_string, "11110111"); /* less-than sign */ + if (general_field[i] == '=') strcat(binary_string, "11111000"); /* equals sign */ + if (general_field[i] == '>') strcat(binary_string, "11111001"); /* greater-than sign */ + if (general_field[i] == '?') strcat(binary_string, "11111010"); /* question mark */ + if (general_field[i] == '_') strcat(binary_string, "11111011"); /* underline or low line */ + if (general_field[i] == ' ') strcat(binary_string, "11111100"); /* space */ i++; break; @@ -1744,9 +1744,9 @@ int cc_binary_string(struct zint_symbol *symbol, const char source[], char binar mask = 0x08; for (j = 0; j < 4; j++) { if ((value & mask) == 0x00) { - concat(binary_string, "0"); + strcat(binary_string, "0"); } else { - concat(binary_string, "1"); + strcat(binary_string, "1"); } mask = mask >> 1; } @@ -1759,9 +1759,9 @@ int cc_binary_string(struct zint_symbol *symbol, const char source[], char binar mask = 0x40; for (j = 0; j < 7; j++) { if ((value & mask) == 0x00) { - concat(binary_string, "0"); + strcat(binary_string, "0"); } else { - concat(binary_string, "1"); + strcat(binary_string, "1"); } mask = mask >> 1; } @@ -2022,17 +2022,17 @@ int cc_binary_string(struct zint_symbol *symbol, const char source[], char binar if (binary_length < target_bitsize) { /* Now add padding to binary string */ if (alpha_pad == 1) { - concat(binary_string, "11111"); + strcat(binary_string, "11111"); alpha_pad = 0; /* Extra FNC1 character required after Alpha encodation (section 5.2.3) */ } if ((strlen(general_field) != 0) && (general_field_type[strlen(general_field) - 1] == NUMERIC)) { - concat(binary_string, "0000"); + strcat(binary_string, "0000"); } while (strlen(binary_string) < (unsigned int) target_bitsize) { - concat(binary_string, "00100"); + strcat(binary_string, "00100"); } if (strlen(binary_string) > (unsigned int) target_bitsize) { @@ -2170,7 +2170,7 @@ int composite(struct zint_symbol *symbol, unsigned char source[], int length) { if (error_number != 0) { strcpy(symbol->errtxt, linear->errtxt); - concat(symbol->errtxt, " in linear component"); + strcat(symbol->errtxt, " in linear component"); return error_number; } diff --git a/backend/dmatrix.c b/backend/dmatrix.c old mode 100755 new mode 100644 index 04361018..b6ef5d22 --- a/backend/dmatrix.c +++ b/backend/dmatrix.c @@ -258,10 +258,10 @@ static void insert_value(unsigned char binary_stream[], const int posn, const in for (i = streamlen; i > posn; i--) { binary_stream[i] = binary_stream[i - 1]; } - binary_stream[posn] = newbit; + binary_stream[posn] = (unsigned char) newbit; } -int p_r_6_2_1(const unsigned char inputData[], int position, const int sourcelen) { +static int p_r_6_2_1(const unsigned char inputData[], const int position, const int sourcelen) { /* Annex P section (r)(6)(ii)(I) "If one of the three X12 terminator/separator characters first occurs in the yet to be processed data before a non-X12 character..." @@ -522,8 +522,7 @@ static int look_ahead_test(const unsigned char inputData[], const int sourcelen, /* Encodes data using ASCII, C40, Text, X12, EDIFACT or Base 256 modes as appropriate Supports encoding FNC1 in supporting systems */ -int dm200encode(struct zint_symbol *symbol, unsigned char source[], unsigned char target[], int *last_mode, int *length_p, int process_buffer[], int *process_p) { - +static int dm200encode(struct zint_symbol *symbol, const unsigned char source[], unsigned char target[], int *last_mode, int *length_p, int process_buffer[], int *process_p) { int sp, tp, i, gs1; int current_mode, next_mode; @@ -554,7 +553,7 @@ int dm200encode(struct zint_symbol *symbol, unsigned char source[], unsigned cha if (gs1) { target[tp] = 232; tp++; - concat(binary, " "); + strcat(binary, " "); if (debug) printf("FN1 "); } /* FNC1 */ @@ -565,7 +564,7 @@ int dm200encode(struct zint_symbol *symbol, unsigned char source[], unsigned cha } else { target[tp] = 234; tp++; /* Reader Programming */ - concat(binary, " "); + strcat(binary, " "); if (debug) printf("RP "); } } @@ -588,7 +587,7 @@ int dm200encode(struct zint_symbol *symbol, unsigned char source[], unsigned cha if (debug) printf("Macro06 "); } tp++; - concat(binary, " "); + strcat(binary, " "); /* Remove macro characters from input string */ sp = 7; inputlen -= 2; @@ -605,10 +604,10 @@ int dm200encode(struct zint_symbol *symbol, unsigned char source[], unsigned cha next_mode = DM_ASCII; if (istwodigits(source, sp) && ((sp + 1) != inputlen)) { - target[tp] = (10 * ctoi(source[sp])) + ctoi(source[sp + 1]) + 130; + target[tp] = (unsigned char) ((10 * ctoi(source[sp])) + ctoi(source[sp + 1]) + 130); if (debug) printf("N%d ", target[tp] - 130); tp++; - concat(binary, " "); + strcat(binary, " "); sp += 2; } else { next_mode = look_ahead_test(source, inputlen, sp, current_mode, gs1); @@ -617,27 +616,27 @@ int dm200encode(struct zint_symbol *symbol, unsigned char source[], unsigned cha switch (next_mode) { case DM_C40: target[tp] = 230; tp++; - concat(binary, " "); + strcat(binary, " "); if (debug) printf("C40 "); break; case DM_TEXT: target[tp] = 239; tp++; - concat(binary, " "); + strcat(binary, " "); if (debug) printf("TEX "); break; case DM_X12: target[tp] = 238; tp++; - concat(binary, " "); + strcat(binary, " "); if (debug) printf("X12 "); break; case DM_EDIFACT: target[tp] = 240; tp++; - concat(binary, " "); + strcat(binary, " "); if (debug) printf("EDI "); break; case DM_BASE256: target[tp] = 231; tp++; - concat(binary, " "); + strcat(binary, " "); if (debug) printf("BAS "); break; } @@ -649,7 +648,7 @@ int dm200encode(struct zint_symbol *symbol, unsigned char source[], unsigned cha target[tp] = (source[sp] - 128) + 1; if (debug) printf("A%02X ", target[tp] - 1); tp++; - concat(binary, " "); + strcat(binary, " "); } else { if (gs1 && (source[sp] == '[')) { target[tp] = 232; /* FNC1 */ @@ -659,7 +658,7 @@ int dm200encode(struct zint_symbol *symbol, unsigned char source[], unsigned cha if (debug) printf("A%02X ", target[tp] - 1); } tp++; - concat(binary, " "); + strcat(binary, " "); } sp++; } @@ -679,7 +678,7 @@ int dm200encode(struct zint_symbol *symbol, unsigned char source[], unsigned cha if (next_mode != DM_C40) { target[tp] = 254; tp++; - concat(binary, " "); /* Unlatch */ + strcat(binary, " "); /* Unlatch */ next_mode = DM_ASCII; if (debug) printf("ASC "); } else { @@ -715,7 +714,7 @@ int dm200encode(struct zint_symbol *symbol, unsigned char source[], unsigned cha tp++; target[tp] = iv % 256; tp++; - concat(binary, " "); + strcat(binary, " "); if (debug) printf("[%d %d %d] ", process_buffer[0], process_buffer[1], process_buffer[2]); process_buffer[0] = process_buffer[3]; @@ -742,7 +741,7 @@ int dm200encode(struct zint_symbol *symbol, unsigned char source[], unsigned cha if (next_mode != DM_TEXT) { target[tp] = 254; tp++; - concat(binary, " "); /* Unlatch */ + strcat(binary, " "); /* Unlatch */ next_mode = DM_ASCII; if (debug) printf("ASC "); } else { @@ -778,7 +777,7 @@ int dm200encode(struct zint_symbol *symbol, unsigned char source[], unsigned cha tp++; target[tp] = iv % 256; tp++; - concat(binary, " "); + strcat(binary, " "); if (debug) printf("[%d %d %d] ", process_buffer[0], process_buffer[1], process_buffer[2]); process_buffer[0] = process_buffer[3]; @@ -805,7 +804,7 @@ int dm200encode(struct zint_symbol *symbol, unsigned char source[], unsigned cha if (next_mode != DM_X12) { target[tp] = 254; tp++; - concat(binary, " "); /* Unlatch */ + strcat(binary, " "); /* Unlatch */ next_mode = DM_ASCII; if (debug) printf("ASC "); } else { @@ -839,7 +838,7 @@ int dm200encode(struct zint_symbol *symbol, unsigned char source[], unsigned cha tp++; target[tp] = iv % 256; tp++; - concat(binary, " "); + strcat(binary, " "); if (debug) printf("[%d %d %d] ", process_buffer[0], process_buffer[1], process_buffer[2]); process_buffer[0] = process_buffer[3]; @@ -888,7 +887,7 @@ int dm200encode(struct zint_symbol *symbol, unsigned char source[], unsigned cha tp++; target[tp] = ((process_buffer[2] & 0x03) << 6) + process_buffer[3]; tp++; - concat(binary, " "); + strcat(binary, " "); if (debug) printf("[%d %d %d %d] ", process_buffer[0], process_buffer[1], process_buffer[2], process_buffer[3]); process_buffer[0] = process_buffer[4]; @@ -912,7 +911,7 @@ int dm200encode(struct zint_symbol *symbol, unsigned char source[], unsigned cha if (debug) printf("B%02X ", target[tp]); tp++; sp++; - concat(binary, "b"); + strcat(binary, "b"); } else { next_mode = DM_ASCII; if (debug) printf("ASC "); @@ -970,7 +969,7 @@ int dm200encode(struct zint_symbol *symbol, unsigned char source[], unsigned cha return tp; } -int dm200encode_remainder(unsigned char target[], int target_length, unsigned char source[], int inputlen, int last_mode, int process_buffer[], int process_p, int symbols_left) { +static int dm200encode_remainder(unsigned char target[], int target_length, const unsigned char source[], const int inputlen, const int last_mode, const int process_buffer[], const int process_p, const int symbols_left) { int debug = 0; switch (last_mode) { @@ -1120,7 +1119,7 @@ int dm200encode_remainder(unsigned char target[], int target_length, unsigned ch } /* add pad bits */ -void add_tail(unsigned char target[], int tp, int tail_length) { +static void add_tail(unsigned char target[], int tp, const int tail_length) { int i, prn, temp; for (i = tail_length; i > 0; i--) { @@ -1141,7 +1140,7 @@ void add_tail(unsigned char target[], int tp, int tail_length) { } } -int data_matrix_200(struct zint_symbol *symbol, unsigned char source[], int length) { +int data_matrix_200(struct zint_symbol *symbol, unsigned char source[], const int length) { int inputlen, i, skew = 0; unsigned char binary[2200]; int binlen; diff --git a/backend/dmatrix.h b/backend/dmatrix.h index 75ebffa2..ae9fb4f2 100644 --- a/backend/dmatrix.h +++ b/backend/dmatrix.h @@ -44,7 +44,7 @@ extern "C" { #endif /* __cplusplus */ - extern int data_matrix_200(struct zint_symbol *symbol, unsigned char source[], int length); + extern int data_matrix_200(struct zint_symbol *symbol, unsigned char source[], const int length); #ifdef __cplusplus } @@ -105,45 +105,45 @@ static const int intsymbol[] = { 26, /* 41: 26x48 , 90*/ 29, /* 42: 26x64 ,118*/ 0 }; - + // Number of DM Sizes #define DMSIZESCOUNT 42 // Number of 144x144 for special interlace #define INTSYMBOL144 41 -// Is the current code a DMRE code ? -// This is the case, if intsymbol index >= 30 - -static const int isDMRE[] = { - /*0*/ 0, /* 10x10 ,3 */ 0, /* 12x12 ,5 */ 0, /* 8x18 ,5 */ 0, /* 14x14 , 8 */ - /*4*/ 0, /* 8x32 ,10 */ 0, /* 16x16 ,12 */ 0, /* 12x26 ,16 */ 0, /* 18x18 ,18 */ - /*8*/ 1, /* 8x48 ,18 */ 0, /* 20x20 ,22 */ 0, /* 12x36 ,22 */ 1, /* 8x64 ,24 */ - /*12*/ 0, /* 22x22 ,30 */ 0, /* 16x36 ,32 */ 0, /* 24x24 ,36 */ 1, /* 12x64 ,43 */ - /*16*/ 0, /* 26x26 ,44 */ 0, /* 16x48 ,49 */ 1, /* 24x32 ,49 */ 1, /* 26x32 ,52 */ - /*20*/ 1, /* 24x36 ,55 */ 0, /* 32x32 ,62 */ 1, /* 16x64 ,62 */ 1, /* 26x40 ,70 */ - /*24*/ 1, /* 24x48 ,80 */ 0, /* 36x36 ,86 */ 1, /* 26x48 ,90 */ 1, /* 24x64 ,108*/ - /*28*/ 0, /* 40x40 ,114*/ 1, /* 26x64 ,118*/ 0, /* 44x44 ,144*/ 0, /* 48x48,174 */ - /*32*/ 0, /* 52x52,204 */ 0, /* 64x64,280 */ 0, /* 72x72,368 */ 0, /* 80x80,456 */ - /*36*/ 0, /* 88x88,576 */ 0, /* 96x96,696 */ 0, /*104x104,816*/ 0, /*120x120,1050*/ - /*40*/ 0, /*132x132,1304*/0 /*144x144,1558*/ -}; - -// Horizontal matrix size - -static const int matrixH[] = { - /*0*/ 10, /* 10x10 ,3 */ 12, /* 12x12 ,5 */ 8, /* 8x18 ,5 */ 14, /* 14x14 , 8 */ - /*4*/ 8, /* 8x32 ,10 */ 16, /* 16x16 ,12 */ 12, /* 12x26 ,16 */ 18, /* 18x18 ,18 */ - /*8*/ 8, /* 8x48 ,18 */ 20, /* 20x20 ,22 */ 12, /* 12x36 ,22 */ 8, /* 8x64 ,24 */ - /*12*/ 22, /* 22x22 ,30 */ 16, /* 16x36 ,32 */ 24, /* 24x24 ,36 */ 12, /* 12x64 ,43 */ - /*16*/ 26, /* 26x26 ,44 */ 16, /* 16x48 ,49 */ 24, /* 24x32 ,49 */ 26, /* 26x32 ,52 */ - /*20*/ 24, /* 24x36 ,55 */ 32, /* 32x32 ,62 */ 16, /* 16x64 ,62 */ 26, /* 26x40 ,70 */ - /*24*/ 24, /* 24x48 ,80 */ 36, /* 36x36 ,86 */ 26, /* 26x48 ,90 */ 24, /* 24x64 ,108*/ - /*28*/ 40, /* 40x40 ,114*/ 26, /* 26x64 ,118*/ 44, /* 44x44 ,144*/ 48, /* 48x48,174 */ - /*32*/ 52, /* 52x52,204 */ 64, /* 64x64,280 */ 72, /* 72x72,368 */ 80, /* 80x80,456 */ - /*36*/ 88, /* 88x88,576 */ 96, /* 96x96,696 */ 104, /*104x104,816*/ 120, /*120x120,1050*/ - /*40*/ 132, /*132x132,1304*/144/*144x144,1558*/ -}; - +// Is the current code a DMRE code ? +// This is the case, if intsymbol index >= 30 + +static const int isDMRE[] = { + /*0*/ 0, /* 10x10 ,3 */ 0, /* 12x12 ,5 */ 0, /* 8x18 ,5 */ 0, /* 14x14 , 8 */ + /*4*/ 0, /* 8x32 ,10 */ 0, /* 16x16 ,12 */ 0, /* 12x26 ,16 */ 0, /* 18x18 ,18 */ + /*8*/ 1, /* 8x48 ,18 */ 0, /* 20x20 ,22 */ 0, /* 12x36 ,22 */ 1, /* 8x64 ,24 */ + /*12*/ 0, /* 22x22 ,30 */ 0, /* 16x36 ,32 */ 0, /* 24x24 ,36 */ 1, /* 12x64 ,43 */ + /*16*/ 0, /* 26x26 ,44 */ 0, /* 16x48 ,49 */ 1, /* 24x32 ,49 */ 1, /* 26x32 ,52 */ + /*20*/ 1, /* 24x36 ,55 */ 0, /* 32x32 ,62 */ 1, /* 16x64 ,62 */ 1, /* 26x40 ,70 */ + /*24*/ 1, /* 24x48 ,80 */ 0, /* 36x36 ,86 */ 1, /* 26x48 ,90 */ 1, /* 24x64 ,108*/ + /*28*/ 0, /* 40x40 ,114*/ 1, /* 26x64 ,118*/ 0, /* 44x44 ,144*/ 0, /* 48x48,174 */ + /*32*/ 0, /* 52x52,204 */ 0, /* 64x64,280 */ 0, /* 72x72,368 */ 0, /* 80x80,456 */ + /*36*/ 0, /* 88x88,576 */ 0, /* 96x96,696 */ 0, /*104x104,816*/ 0, /*120x120,1050*/ + /*40*/ 0, /*132x132,1304*/0 /*144x144,1558*/ +}; + +// Horizontal matrix size + +static const int matrixH[] = { + /*0*/ 10, /* 10x10 ,3 */ 12, /* 12x12 ,5 */ 8, /* 8x18 ,5 */ 14, /* 14x14 , 8 */ + /*4*/ 8, /* 8x32 ,10 */ 16, /* 16x16 ,12 */ 12, /* 12x26 ,16 */ 18, /* 18x18 ,18 */ + /*8*/ 8, /* 8x48 ,18 */ 20, /* 20x20 ,22 */ 12, /* 12x36 ,22 */ 8, /* 8x64 ,24 */ + /*12*/ 22, /* 22x22 ,30 */ 16, /* 16x36 ,32 */ 24, /* 24x24 ,36 */ 12, /* 12x64 ,43 */ + /*16*/ 26, /* 26x26 ,44 */ 16, /* 16x48 ,49 */ 24, /* 24x32 ,49 */ 26, /* 26x32 ,52 */ + /*20*/ 24, /* 24x36 ,55 */ 32, /* 32x32 ,62 */ 16, /* 16x64 ,62 */ 26, /* 26x40 ,70 */ + /*24*/ 24, /* 24x48 ,80 */ 36, /* 36x36 ,86 */ 26, /* 26x48 ,90 */ 24, /* 24x64 ,108*/ + /*28*/ 40, /* 40x40 ,114*/ 26, /* 26x64 ,118*/ 44, /* 44x44 ,144*/ 48, /* 48x48,174 */ + /*32*/ 52, /* 52x52,204 */ 64, /* 64x64,280 */ 72, /* 72x72,368 */ 80, /* 80x80,456 */ + /*36*/ 88, /* 88x88,576 */ 96, /* 96x96,696 */ 104, /*104x104,816*/ 120, /*120x120,1050*/ + /*40*/ 132, /*132x132,1304*/144/*144x144,1558*/ +}; + // Vertical matrix sizes static const int matrixW[] = { diff --git a/backend/gridmtx.c b/backend/gridmtx.c index 4b0f0893..f40e858c 100644 --- a/backend/gridmtx.c +++ b/backend/gridmtx.c @@ -341,9 +341,9 @@ void add_shift_char(char binary[], int shifty) { for (p = 0; p < 6; p++) { if (glyph & (0x20 >> p)) { - concat(binary, "1"); + strcat(binary, "1"); } else { - concat(binary, "0"); + strcat(binary, "0"); } } } @@ -368,7 +368,7 @@ int gm_encode(int gbdata[], int length, char binary[], int reader) { number_pad_posn = 0; if (reader) { - concat(binary, "1010"); /* FNC3 - Reader Initialisation */ + strcat(binary, "1010"); /* FNC3 - Reader Initialisation */ } do { @@ -378,31 +378,31 @@ int gm_encode(int gbdata[], int length, char binary[], int reader) { switch (current_mode) { case 0: switch (next_mode) { - case GM_CHINESE: concat(binary, "0001"); + case GM_CHINESE: strcat(binary, "0001"); break; - case GM_NUMBER: concat(binary, "0010"); + case GM_NUMBER: strcat(binary, "0010"); break; - case GM_LOWER: concat(binary, "0011"); + case GM_LOWER: strcat(binary, "0011"); break; - case GM_UPPER: concat(binary, "0100"); + case GM_UPPER: strcat(binary, "0100"); break; - case GM_MIXED: concat(binary, "0101"); + case GM_MIXED: strcat(binary, "0101"); break; - case GM_BYTE: concat(binary, "0111"); + case GM_BYTE: strcat(binary, "0111"); break; } break; case GM_CHINESE: switch (next_mode) { - case GM_NUMBER: concat(binary, "1111111100001"); + case GM_NUMBER: strcat(binary, "1111111100001"); break; // 8161 - case GM_LOWER: concat(binary, "1111111100010"); + case GM_LOWER: strcat(binary, "1111111100010"); break; // 8162 - case GM_UPPER: concat(binary, "1111111100011"); + case GM_UPPER: strcat(binary, "1111111100011"); break; // 8163 - case GM_MIXED: concat(binary, "1111111100100"); + case GM_MIXED: strcat(binary, "1111111100100"); break; // 8164 - case GM_BYTE: concat(binary, "1111111100101"); + case GM_BYTE: strcat(binary, "1111111100101"); break; // 8165 } break; @@ -420,45 +420,45 @@ int gm_encode(int gbdata[], int length, char binary[], int reader) { break; // 0 pad digits } switch (next_mode) { - case GM_CHINESE: concat(binary, "1111111011"); + case GM_CHINESE: strcat(binary, "1111111011"); break; // 1019 - case GM_LOWER: concat(binary, "1111111100"); + case GM_LOWER: strcat(binary, "1111111100"); break; // 1020 - case GM_UPPER: concat(binary, "1111111101"); + case GM_UPPER: strcat(binary, "1111111101"); break; // 1021 - case GM_MIXED: concat(binary, "1111111110"); + case GM_MIXED: strcat(binary, "1111111110"); break; // 1022 - case GM_BYTE: concat(binary, "1111111111"); + case GM_BYTE: strcat(binary, "1111111111"); break; // 1023 } break; case GM_LOWER: case GM_UPPER: switch (next_mode) { - case GM_CHINESE: concat(binary, "11100"); + case GM_CHINESE: strcat(binary, "11100"); break; // 28 - case GM_NUMBER: concat(binary, "11101"); + case GM_NUMBER: strcat(binary, "11101"); break; // 29 case GM_LOWER: - case GM_UPPER: concat(binary, "11110"); + case GM_UPPER: strcat(binary, "11110"); break; // 30 - case GM_MIXED: concat(binary, "1111100"); + case GM_MIXED: strcat(binary, "1111100"); break; // 124 - case GM_BYTE: concat(binary, "1111110"); + case GM_BYTE: strcat(binary, "1111110"); break; // 126 } break; case GM_MIXED: switch (next_mode) { - case GM_CHINESE: concat(binary, "1111110001"); + case GM_CHINESE: strcat(binary, "1111110001"); break; // 1009 - case GM_NUMBER: concat(binary, "1111110010"); + case GM_NUMBER: strcat(binary, "1111110010"); break; // 1010 - case GM_LOWER: concat(binary, "1111110011"); + case GM_LOWER: strcat(binary, "1111110011"); break; // 1011 - case GM_UPPER: concat(binary, "1111110100"); + case GM_UPPER: strcat(binary, "1111110100"); break; // 1012 - case GM_BYTE: concat(binary, "1111110111"); + case GM_BYTE: strcat(binary, "1111110111"); break; // 1015 } break; @@ -467,15 +467,15 @@ int gm_encode(int gbdata[], int length, char binary[], int reader) { add_byte_count(binary, byte_count_posn, byte_count); byte_count = 0; switch (next_mode) { - case GM_CHINESE: concat(binary, "0001"); + case GM_CHINESE: strcat(binary, "0001"); break; // 1 - case GM_NUMBER: concat(binary, "0010"); + case GM_NUMBER: strcat(binary, "0010"); break; // 2 - case GM_LOWER: concat(binary, "0011"); + case GM_LOWER: strcat(binary, "0011"); break; // 3 - case GM_UPPER: concat(binary, "0100"); + case GM_UPPER: strcat(binary, "0100"); break; // 4 - case GM_MIXED: concat(binary, "0101"); + case GM_MIXED: strcat(binary, "0101"); break; // 5 } break; @@ -547,9 +547,9 @@ int gm_encode(int gbdata[], int length, char binary[], int reader) { for (q = 0; q < 13; q++) { if (glyph & (0x1000 >> q)) { - concat(binary, "1"); + strcat(binary, "1"); } else { - concat(binary, "0"); + strcat(binary, "0"); } } sp++; @@ -559,7 +559,7 @@ int gm_encode(int gbdata[], int length, char binary[], int reader) { if (last_mode != current_mode) { /* Reserve a space for numeric digit padding value (2 bits) */ number_pad_posn = strlen(binary); - concat(binary, "XX"); + strcat(binary, "XX"); } p = 0; ppos = -1; @@ -621,9 +621,9 @@ int gm_encode(int gbdata[], int length, char binary[], int reader) { for (q = 0; q < 10; q++) { if (glyph & (0x200 >> q)) { - concat(binary, "1"); + strcat(binary, "1"); } else { - concat(binary, "0"); + strcat(binary, "0"); } } } @@ -635,9 +635,9 @@ int gm_encode(int gbdata[], int length, char binary[], int reader) { for (q = 0; q < 10; q++) { if (glyph & (0x200 >> q)) { - concat(binary, "1"); + strcat(binary, "1"); } else { - concat(binary, "0"); + strcat(binary, "0"); } } break; @@ -646,14 +646,14 @@ int gm_encode(int gbdata[], int length, char binary[], int reader) { if (last_mode != current_mode) { /* Reserve space for byte block length indicator (9 bits) */ byte_count_posn = strlen(binary); - concat(binary, "LLLLLLLLL"); + strcat(binary, "LLLLLLLLL"); } if (byte_count == 512) { /* Maximum byte block size is 512 bytes. If longer is needed then start a new block */ add_byte_count(binary, byte_count_posn, byte_count); - concat(binary, "0111"); + strcat(binary, "0111"); byte_count_posn = strlen(binary); - concat(binary, "LLLLLLLLL"); + strcat(binary, "LLLLLLLLL"); byte_count = 0; } @@ -663,9 +663,9 @@ int gm_encode(int gbdata[], int length, char binary[], int reader) { } for (q = 0; q < 8; q++) { if (glyph & (0x80 >> q)) { - concat(binary, "1"); + strcat(binary, "1"); } else { - concat(binary, "0"); + strcat(binary, "0"); } } sp++; @@ -696,14 +696,14 @@ int gm_encode(int gbdata[], int length, char binary[], int reader) { for (q = 0; q < 6; q++) { if (glyph & (0x20 >> q)) { - concat(binary, "1"); + strcat(binary, "1"); } else { - concat(binary, "0"); + strcat(binary, "0"); } } } else { /* Shift Mode character */ - concat(binary, "1111110110"); /* 1014 - shift indicator */ + strcat(binary, "1111110110"); /* 1014 - shift indicator */ add_shift_char(binary, gbdata[sp]); } @@ -728,14 +728,14 @@ int gm_encode(int gbdata[], int length, char binary[], int reader) { for (q = 0; q < 5; q++) { if (glyph & (0x10 >> q)) { - concat(binary, "1"); + strcat(binary, "1"); } else { - concat(binary, "0"); + strcat(binary, "0"); } } } else { /* Shift Mode character */ - concat(binary, "1111101"); /* 127 - shift indicator */ + strcat(binary, "1111101"); /* 127 - shift indicator */ add_shift_char(binary, gbdata[sp]); } @@ -760,14 +760,14 @@ int gm_encode(int gbdata[], int length, char binary[], int reader) { for (q = 0; q < 5; q++) { if (glyph & (0x10 >> q)) { - concat(binary, "1"); + strcat(binary, "1"); } else { - concat(binary, "0"); + strcat(binary, "0"); } } } else { /* Shift Mode character */ - concat(binary, "1111101"); /* 127 - shift indicator */ + strcat(binary, "1111101"); /* 127 - shift indicator */ add_shift_char(binary, gbdata[sp]); } @@ -802,16 +802,16 @@ int gm_encode(int gbdata[], int length, char binary[], int reader) { /* Add "end of data" character */ switch (current_mode) { - case GM_CHINESE: concat(binary, "1111111100000"); + case GM_CHINESE: strcat(binary, "1111111100000"); break; // 8160 - case GM_NUMBER: concat(binary, "1111111010"); + case GM_NUMBER: strcat(binary, "1111111010"); break; // 1018 case GM_LOWER: - case GM_UPPER: concat(binary, "11011"); + case GM_UPPER: strcat(binary, "11011"); break; // 27 - case GM_MIXED: concat(binary, "1111110000"); + case GM_MIXED: strcat(binary, "1111110000"); break; // 1008 - case GM_BYTE: concat(binary, "0000"); + case GM_BYTE: strcat(binary, "0000"); break; // 0 } @@ -821,7 +821,7 @@ int gm_encode(int gbdata[], int length, char binary[], int reader) { p = 0; } for (i = 0; i < p; i++) { - concat(binary, "0"); + strcat(binary, "0"); } if (strlen(binary) > 9191) { diff --git a/backend/gs1.c b/backend/gs1.c index 7bbad9f2..af70d1f7 100644 --- a/backend/gs1.c +++ b/backend/gs1.c @@ -56,17 +56,17 @@ void itostr(char ai_string[], int ai_value) { temp[1] = '\0'; if (ai_value >= 1000) { temp[0] = itoc(thou); - concat(ai_string, temp); + strcat(ai_string, temp); } if (ai_value >= 100) { temp[0] = itoc(hund); - concat(ai_string, temp); + strcat(ai_string, temp); } temp[0] = itoc(ten); - concat(ai_string, temp); + strcat(ai_string, temp); temp[0] = itoc(unit); - concat(ai_string, temp); - concat(ai_string, ")"); + strcat(ai_string, temp); + strcat(ai_string, ")"); } int gs1_verify(struct zint_symbol *symbol, const unsigned char source[], const unsigned int src_len, char reduced[]) { @@ -287,13 +287,13 @@ int gs1_verify(struct zint_symbol *symbol, const unsigned char source[], const u if (error_latch == 5) { strcpy(symbol->errtxt, "Invalid data length for AI "); - concat(symbol->errtxt, ai_string); + strcat(symbol->errtxt, ai_string); return ZINT_ERROR_INVALID_DATA; } if (error_latch == 6) { strcpy(symbol->errtxt, "Invalid AI value "); - concat(symbol->errtxt, ai_string); + strcat(symbol->errtxt, ai_string); return ZINT_ERROR_INVALID_DATA; } diff --git a/backend/imail.c b/backend/imail.c index ede7fc88..a946cacd 100644 --- a/backend/imail.c +++ b/backend/imail.c @@ -652,7 +652,7 @@ int imail(struct zint_symbol *symbol, unsigned char source[], int length) { if (bar_map[i + 65] == 0) j += 2; temp[0] = itoc(j); - concat(data_pattern, temp); + strcat(data_pattern, temp); } /* Translate 4-state data pattern to symbol */ diff --git a/backend/library.c b/backend/library.c old mode 100755 new mode 100644 index 846cab31..03340f44 --- a/backend/library.c +++ b/backend/library.c @@ -204,7 +204,7 @@ void error_tag(char error_string[], int error_number) { strcpy(error_string, "warning: "); } - concat(error_string, error_buffer); + strcat(error_string, error_buffer); } } @@ -315,23 +315,23 @@ int hibc(struct zint_symbol *symbol, unsigned char source[], int length) { temp[0] = check_digit; temp[1] = '\0'; - concat(to_process, (char *) source); - concat(to_process, temp); + strcat(to_process, (char *) source); + strcat(to_process, temp); length = strlen(to_process); switch (symbol->symbology) { case BARCODE_HIBC_128: error_number = code_128(symbol, (unsigned char *) to_process, length); ustrcpy(symbol->text, (unsigned char*) "*"); - uconcat(symbol->text, (unsigned char*) to_process); - uconcat(symbol->text, (unsigned char*) "*"); + strcat((char*) symbol->text, to_process); + strcat((char*) symbol->text, "*"); break; case BARCODE_HIBC_39: symbol->option_2 = 0; error_number = c39(symbol, (unsigned char *) to_process, length); ustrcpy(symbol->text, (unsigned char*) "*"); - uconcat(symbol->text, (unsigned char*) to_process); - uconcat(symbol->text, (unsigned char*) "*"); + strcat((char*) symbol->text, to_process); + strcat((char*) symbol->text, "*"); break; case BARCODE_HIBC_DM: error_number = dmatrix(symbol, (unsigned char *) to_process, length); diff --git a/backend/medical.c b/backend/medical.c index 1f7a2a37..dbe484d7 100644 --- a/backend/medical.c +++ b/backend/medical.c @@ -85,10 +85,10 @@ int pharma_one(struct zint_symbol *symbol, unsigned char source[], int length) { do { if (!(tester & 1)) { - concat(inter, "W"); + strcat(inter, "W"); tester = (tester - 2) / 2; } else { - concat(inter, "N"); + strcat(inter, "N"); tester = (tester - 1) / 2; } } while (tester != 0); @@ -97,9 +97,9 @@ int pharma_one(struct zint_symbol *symbol, unsigned char source[], int length) { *dest = '\0'; for (counter = h; counter >= 0; counter--) { if (inter[counter] == 'W') { - concat(dest, "32"); + strcat(dest, "32"); } else { - concat(dest, "12"); + strcat(dest, "12"); } } @@ -130,15 +130,15 @@ int pharma_two_calc(struct zint_symbol *symbol, unsigned char source[], char des do { switch (tester % 3) { case 0: - concat(inter, "3"); + strcat(inter, "3"); tester = (tester - 3) / 3; break; case 1: - concat(inter, "1"); + strcat(inter, "1"); tester = (tester - 1) / 3; break; case 2: - concat(inter, "2"); + strcat(inter, "2"); tester = (tester - 2) / 3; break; } @@ -194,7 +194,7 @@ int pharma_two(struct zint_symbol *symbol, unsigned char source[], int length) { } /* The Codabar system consisting of simple substitution */ -int codabar(struct zint_symbol *symbol, unsigned char source[], int length) { +int codabar(struct zint_symbol *symbol, unsigned char source[], int length) { int i, error_number; char dest[512]; @@ -213,7 +213,7 @@ int codabar(struct zint_symbol *symbol, unsigned char source[], int length) { return error_number; } /* Codabar must begin and end with the characters A, B, C or D */ - if ((source[0] != 'A') && (source[0] != 'B') && (source[0] != 'C') + if ((source[0] != 'A') && (source[0] != 'B') && (source[0] != 'C') && (source[0] != 'D')) { strcpy(symbol->errtxt, "Invalid characters in data"); return ZINT_ERROR_INVALID_DATA; @@ -235,7 +235,7 @@ int codabar(struct zint_symbol *symbol, unsigned char source[], int length) { } /* Italian Pharmacode */ -int code32(struct zint_symbol *symbol, unsigned char source[], int length) { +int code32(struct zint_symbol *symbol, unsigned char source[], int length) { int i, zeroes, error_number, checksum, checkpart, checkdigit; char localstr[10], risultante[7]; long int pharmacode, remainder, devisor; @@ -302,8 +302,8 @@ int code32(struct zint_symbol *symbol, unsigned char source[], int length) { } /* Override the normal text output with the Pharmacode number */ - ustrcpy(symbol->text, (unsigned char*) "A"); - uconcat(symbol->text, (unsigned char*) localstr); + strcpy((char*) symbol->text, "A"); + strcat((char*) symbol->text, (char*) localstr); return error_number; } diff --git a/backend/pdf417.c b/backend/pdf417.c index f76d7c0b..0ed73a75 100644 --- a/backend/pdf417.c +++ b/backend/pdf417.c @@ -78,7 +78,7 @@ static const int asciiy[95] = { /* Automatic sizing table */ -static const int MicroAutosize[56] ={ +static const int MicroAutosize[56] = { 4, 6, 7, 8, 10, 12, 13, 14, 16, 18, 19, 20, 24, 29, 30, 33, 34, 37, 39, 46, 54, 58, 70, 72, 82, 90, 108, 126, 1, 14, 2, 7, 3, 25, 8, 16, 5, 17, 9, 6, 10, 11, 28, 12, 19, 13, 29, 20, 30, 21, 22, 31, 23, 32, 33, 34 }; @@ -510,7 +510,7 @@ void numbprocess(int *chainemc, int *mclength, char chaine[], int start, int len if (longueur > 44) { longueur = 44; } - concat(chainemod, "1"); + strcat(chainemod, "1"); for (loop = 1; loop <= longueur; loop++) { chainemod[loop] = chaine[start + loop + j - 1]; } @@ -529,7 +529,7 @@ void numbprocess(int *chainemc, int *mclength, char chaine[], int start, int len } if (nombre < diviseur) { if (strlen(chainemult) != 0) { - concat(chainemult, "0"); + strcat(chainemult, "0"); } } else { temp = (nombre / diviseur) + '0'; @@ -777,8 +777,8 @@ int pdf417(struct zint_symbol *symbol, unsigned char chaine[], int length) { default: offset = 0; break; } - concat(codebarre, codagemc[offset + dummy[j]]); - concat(codebarre, "*"); + strcat(codebarre, codagemc[offset + dummy[j]]); + strcat(codebarre, "*"); } } else { /* normal PDF417 symbol */ @@ -791,10 +791,10 @@ int pdf417(struct zint_symbol *symbol, unsigned char chaine[], int length) { default: offset = 0; /* cluster(0) */ break; } - concat(codebarre, codagemc[offset + dummy[j]]); - concat(codebarre, "*"); + strcat(codebarre, codagemc[offset + dummy[j]]); + strcat(codebarre, "*"); } - concat(codebarre, "-"); + strcat(codebarre, "-"); } strcpy(pattern, ""); @@ -1194,33 +1194,33 @@ int micro_pdf417(struct zint_symbol *symbol, unsigned char chaine[], int length) } /* Copy the data into codebarre */ - concat(codebarre, RAPLR[LeftRAP]); - concat(codebarre, "1"); - concat(codebarre, codagemc[offset + dummy[1]]); - concat(codebarre, "1"); + strcat(codebarre, RAPLR[LeftRAP]); + strcat(codebarre, "1"); + strcat(codebarre, codagemc[offset + dummy[1]]); + strcat(codebarre, "1"); if (symbol->option_2 == 3) { - concat(codebarre, RAPC[CentreRAP]); + strcat(codebarre, RAPC[CentreRAP]); } if (symbol->option_2 >= 2) { - concat(codebarre, "1"); - concat(codebarre, codagemc[offset + dummy[2]]); - concat(codebarre, "1"); + strcat(codebarre, "1"); + strcat(codebarre, codagemc[offset + dummy[2]]); + strcat(codebarre, "1"); } if (symbol->option_2 == 4) { - concat(codebarre, RAPC[CentreRAP]); + strcat(codebarre, RAPC[CentreRAP]); } if (symbol->option_2 >= 3) { - concat(codebarre, "1"); - concat(codebarre, codagemc[offset + dummy[3]]); - concat(codebarre, "1"); + strcat(codebarre, "1"); + strcat(codebarre, codagemc[offset + dummy[3]]); + strcat(codebarre, "1"); } if (symbol->option_2 == 4) { - concat(codebarre, "1"); - concat(codebarre, codagemc[offset + dummy[4]]); - concat(codebarre, "1"); + strcat(codebarre, "1"); + strcat(codebarre, codagemc[offset + dummy[4]]); + strcat(codebarre, "1"); } - concat(codebarre, RAPLR[RightRAP]); - concat(codebarre, "1"); /* stop */ + strcat(codebarre, RAPLR[RightRAP]); + strcat(codebarre, "1"); /* stop */ if (debug) printf("%s\n", codebarre); /* Now codebarre is a mixture of letters and numbers */ diff --git a/backend/plessey.c b/backend/plessey.c index 1082207f..20610d7d 100644 --- a/backend/plessey.c +++ b/backend/plessey.c @@ -49,7 +49,7 @@ static const char *MSITable[10] = { }; /* Not MSI/Plessey but the older Plessey standard */ -int plessey(struct zint_symbol *symbol, unsigned char source[], int length) { +int plessey(struct zint_symbol *symbol, unsigned char source[], int length) { unsigned int i, check; unsigned char *checkptr; @@ -95,15 +95,15 @@ int plessey(struct zint_symbol *symbol, unsigned char source[], int length) { for (i = 0; i < 8; i++) { switch (checkptr[length * 4 + i]) { - case 0: concat(dest, "13"); + case 0: strcat(dest, "13"); break; - case 1: concat(dest, "31"); + case 1: strcat(dest, "31"); break; } } /* Stop character */ - concat(dest, "331311313"); + strcat(dest, "331311313"); expand(symbol, dest); ustrcpy(symbol->text, source); @@ -112,7 +112,7 @@ int plessey(struct zint_symbol *symbol, unsigned char source[], int length) { } /* Plain MSI Plessey - does not calculate any check character */ -int msi_plessey(struct zint_symbol *symbol, unsigned char source[], int length) { +int msi_plessey(struct zint_symbol *symbol, unsigned char source[], int length) { unsigned int i; char dest[512]; /* 2 + 55 * 8 + 3 + 1 ~ 512 */ @@ -130,7 +130,7 @@ int msi_plessey(struct zint_symbol *symbol, unsigned char source[], int length) } /* Stop character */ - concat(dest, "121"); + strcat(dest, "121"); expand(symbol, dest); ustrcpy(symbol->text, source); @@ -139,8 +139,8 @@ int msi_plessey(struct zint_symbol *symbol, unsigned char source[], int length) /* MSI Plessey with Modulo 10 check digit - algorithm from Barcode Island * http://www.barcodeisland.com/ */ -int msi_plessey_mod10(struct zint_symbol *symbol, unsigned char source[], int length) { - +int msi_plessey_mod10(struct zint_symbol *symbol, unsigned char source[], int length) { + unsigned long i, wright, dau, pedwar, pump, n; char un[200], tri[32]; @@ -195,7 +195,7 @@ int msi_plessey_mod10(struct zint_symbol *symbol, unsigned char source[], int le lookup(NEON, MSITable, itoc(pump), dest); /* Stop character */ - concat(dest, "121"); + strcat(dest, "121"); expand(symbol, dest); ustrcpy(symbol->text, source); @@ -206,8 +206,8 @@ int msi_plessey_mod10(struct zint_symbol *symbol, unsigned char source[], int le /* MSI Plessey with two Modulo 10 check digits - algorithm from * Barcode Island http://www.barcodeisland.com/ */ -int msi_plessey_mod1010(struct zint_symbol *symbol, unsigned char source[], const unsigned int src_len) { - +int msi_plessey_mod1010(struct zint_symbol *symbol, unsigned char source[], const unsigned int src_len) { + unsigned long i, n, wright, dau, pedwar, pump, chwech; char un[16], tri[32]; @@ -296,7 +296,7 @@ int msi_plessey_mod1010(struct zint_symbol *symbol, unsigned char source[], cons lookup(NEON, MSITable, itoc(chwech), dest); /* Stop character */ - concat(dest, "121"); + strcat(dest, "121"); expand(symbol, dest); @@ -351,13 +351,13 @@ int msi_plessey_mod11(struct zint_symbol *symbol, unsigned char source[], const } /* stop character */ - concat(dest, "121"); + strcat(dest, "121"); expand(symbol, dest); ustrcpy(symbol->text, source); if (check == 10) { - concat((char*) symbol->text, "10"); + strcat((char*) symbol->text, "10"); } else { symbol->text[src_len] = itoc(check); symbol->text[src_len + 1] = '\0'; @@ -410,7 +410,7 @@ int msi_plessey_mod1110(struct zint_symbol *symbol, unsigned char source[], cons if (check == 10) { lookup(NEON, MSITable, '1', dest); lookup(NEON, MSITable, '0', dest); - uconcat(temp, (unsigned char *) "10"); + strcat((char*) temp, "10"); temp_len += 2; } else { lookup(NEON, MSITable, itoc(check), dest); @@ -451,7 +451,7 @@ int msi_plessey_mod1110(struct zint_symbol *symbol, unsigned char source[], cons lookup(NEON, MSITable, itoc(pump), dest); /* stop character */ - concat(dest, "121"); + strcat(dest, "121"); expand(symbol, dest); temp[temp_len++] = itoc(pump); diff --git a/backend/postal.c b/backend/postal.c index 9ac7c84e..4be548eb 100644 --- a/backend/postal.c +++ b/backend/postal.c @@ -111,10 +111,10 @@ int postnet(struct zint_symbol *symbol, unsigned char source[], char dest[], int } check_digit = (10 - (sum % 10)) % 10; - concat(dest, PNTable[check_digit]); + strcat(dest, PNTable[check_digit]); /* stop character */ - concat(dest, "L"); + strcat(dest, "L"); return error_number; } @@ -177,10 +177,10 @@ int planet(struct zint_symbol *symbol, unsigned char source[], char dest[], int } check_digit = (10 - (sum % 10)) % 10; - concat(dest, PLTable[check_digit]); + strcat(dest, PLTable[check_digit]); /* stop character */ - concat(dest, "L"); + strcat(dest, "L"); return error_number; } @@ -216,7 +216,7 @@ int planet_plot(struct zint_symbol *symbol, unsigned char source[], int length) } /* Korean Postal Authority */ -int korea_post(struct zint_symbol *symbol, unsigned char source[], int length) { +int korea_post(struct zint_symbol *symbol, unsigned char source[], int length) { int total, loop, check, zeroes, error_number; char localstr[8], dest[80]; @@ -257,7 +257,7 @@ int korea_post(struct zint_symbol *symbol, unsigned char source[], int length) { /* The simplest barcode symbology ever! Supported by MS Word, so here it is! glyphs from http://en.wikipedia.org/wiki/Facing_Identification_Mark */ int fim(struct zint_symbol *symbol, unsigned char source[], int length) { - + char dest[16] = {0}; @@ -322,10 +322,10 @@ char rm4scc(char source[], unsigned char dest[], int length) { column = 5; } check_digit = (6 * row) + column; - concat((char*) dest, RoyalTable[check_digit]); + strcat((char*) dest, RoyalTable[check_digit]); /* stop character */ - concat((char*) dest, "0"); + strcat((char*) dest, "0"); return set_copy[check_digit]; } @@ -448,16 +448,16 @@ int daft_code(struct zint_symbol *symbol, unsigned char source[], int length) { for (i = 0; i < length; i++) { if (source[i] == 'D') { - concat(height_pattern, "2"); + strcat(height_pattern, "2"); } if (source[i] == 'A') { - concat(height_pattern, "1"); + strcat(height_pattern, "1"); } if (source[i] == 'F') { - concat(height_pattern, "0"); + strcat(height_pattern, "0"); } if (source[i] == 'T') { - concat(height_pattern, "3"); + strcat(height_pattern, "3"); } } @@ -484,7 +484,7 @@ int daft_code(struct zint_symbol *symbol, unsigned char source[], int length) { } /* Flattermarken - Not really a barcode symbology! */ -int flattermarken(struct zint_symbol *symbol, unsigned char source[], int length) { +int flattermarken(struct zint_symbol *symbol, unsigned char source[], int length) { int loop, error_number; char dest[512]; /* 90 * 4 + 1 ~ */ @@ -509,7 +509,7 @@ int flattermarken(struct zint_symbol *symbol, unsigned char source[], int length } /* Japanese Postal Code (Kasutama Barcode) */ -int japan_post(struct zint_symbol *symbol, unsigned char source[], int length) { +int japan_post(struct zint_symbol *symbol, unsigned char source[], int length) { int error_number, h; char pattern[69]; int writer, loopey, inter_posn, i, sum, check; @@ -570,7 +570,7 @@ int japan_post(struct zint_symbol *symbol, unsigned char source[], int length) { sum = 0; for (i = 0; i < 20; i++) { - concat(pattern, JapanTable[posn(KASUTSET, inter[i])]); + strcat(pattern, JapanTable[posn(KASUTSET, inter[i])]); sum += posn(CHKASUTSET, inter[i]); } @@ -588,9 +588,9 @@ int japan_post(struct zint_symbol *symbol, unsigned char source[], int length) { if (check >= 11) { check_char = (check - 11) + 'a'; } - concat(pattern, JapanTable[posn(KASUTSET, check_char)]); + strcat(pattern, JapanTable[posn(KASUTSET, check_char)]); - concat(pattern, "31"); /* Stop */ + strcat(pattern, "31"); /* Stop */ /* Resolve pattern to 4-state symbols */ writer = 0; diff --git a/backend/ps.c b/backend/ps.c index 0ea642cf..dfc863f2 100644 --- a/backend/ps.c +++ b/backend/ps.c @@ -34,6 +34,7 @@ #include #include #include +#include #include "common.h" #define SSET "0123456789ABCDEF" @@ -198,9 +199,9 @@ int ps_plot(struct zint_symbol *symbol) { } fprintf(feps, "%%%%Pages: 0\n"); if (symbol->symbology != BARCODE_MAXICODE) { - fprintf(feps, "%%%%BoundingBox: 0 0 %d %d\n", roundup((symbol->width + xoffset + xoffset) * scaler), roundup((symbol->height + textoffset + yoffset + yoffset) * scaler)); + fprintf(feps, "%%%%BoundingBox: 0 0 %d %d\n", (int)ceil((symbol->width + xoffset + xoffset) * scaler), (int)ceil((symbol->height + textoffset + yoffset + yoffset) * scaler)); } else { - fprintf(feps, "%%%%BoundingBox: 0 0 %d %d\n", roundup((74.0 + xoffset + xoffset) * scaler), roundup((72.0 + yoffset + yoffset) * scaler)); + fprintf(feps, "%%%%BoundingBox: 0 0 %d %d\n", (int)ceil((74.0F + xoffset + xoffset) * scaler), (int)ceil((72.0F + yoffset + yoffset) * scaler)); } fprintf(feps, "%%%%EndComments\n"); diff --git a/backend/qr.c b/backend/qr.c index b46c369b..eeaf1aeb 100644 --- a/backend/qr.c +++ b/backend/qr.c @@ -188,7 +188,7 @@ int estimate_binary_length(char mode[], int length, int gs1) { static void qr_bscan(char *binary, int data, int h) { for (; h; h >>= 1) { - concat(binary, data & h ? "1" : "0"); + strcat(binary, data & h ? "1" : "0"); } } @@ -208,7 +208,7 @@ void qr_binary(int datastream[], int version, int target_binlen, char mode[], in strcpy(binary, ""); if (gs1) { - concat(binary, "0101"); /* FNC1 */ + strcat(binary, "0101"); /* FNC1 */ } if (version <= 9) { @@ -233,14 +233,14 @@ void qr_binary(int datastream[], int version, int target_binlen, char mode[], in short_data_block_length = 0; do { short_data_block_length++; - } while (((short_data_block_length + position) < length) + } while (((short_data_block_length + position) < length) && (mode[position + short_data_block_length] == data_block)); switch (data_block) { case 'K': /* Kanji mode */ /* Mode indicator */ - concat(binary, "1000"); + strcat(binary, "1000"); /* Character count indicator */ qr_bscan(binary, short_data_block_length, 0x20 << (scheme * 2)); /* scheme = 1..3 */ @@ -276,7 +276,7 @@ void qr_binary(int datastream[], int version, int target_binlen, char mode[], in case 'B': /* Byte mode */ /* Mode indicator */ - concat(binary, "0100"); + strcat(binary, "0100"); /* Character count indicator */ qr_bscan(binary, short_data_block_length, scheme > 1 ? 0x8000 : 0x80); /* scheme = 1..3 */ @@ -308,7 +308,7 @@ void qr_binary(int datastream[], int version, int target_binlen, char mode[], in case 'A': /* Alphanumeric mode */ /* Mode indicator */ - concat(binary, "0010"); + strcat(binary, "0010"); /* Character count indicator */ qr_bscan(binary, short_data_block_length, 0x40 << (2 * scheme)); /* scheme = 1..3 */ @@ -399,7 +399,7 @@ void qr_binary(int datastream[], int version, int target_binlen, char mode[], in case 'N': /* Numeric mode */ /* Mode indicator */ - concat(binary, "0001"); + strcat(binary, "0001"); /* Character count indicator */ qr_bscan(binary, short_data_block_length, 0x80 << (2 * scheme)); /* scheme = 1..3 */ @@ -450,7 +450,7 @@ void qr_binary(int datastream[], int version, int target_binlen, char mode[], in } while (position < length); /* Terminator */ - concat(binary, "0000"); + strcat(binary, "0000"); current_binlen = strlen(binary); padbits = 8 - (current_binlen % 8); @@ -461,7 +461,7 @@ void qr_binary(int datastream[], int version, int target_binlen, char mode[], in /* Padding bits */ for (i = 0; i < padbits; i++) { - concat(binary, "0"); + strcat(binary, "0"); } /* Put data into 8-bit codewords */ @@ -1138,8 +1138,7 @@ int apply_bitmask(unsigned char *grid, int size, int ecc_level) { for (y = 0; y < size; y++) { if (grid[(y * size) + x] & 0x01) { p = 0xff; - } - else { + } else { p = 0x00; } @@ -1296,12 +1295,12 @@ int tribus(int version, int a, int b, int c) { /* Implements a custom optimisation algorithm, more efficient than that given in Annex J. */ void applyOptimisation(int version, char inputMode[], int inputLength) { - + int blockCount = 0, block; int i, j; char currentMode = ' '; // Null - int *blockLength; + int *blockLength; char *blockMode; for (i = 0; i < inputLength; i++) { @@ -1311,13 +1310,12 @@ void applyOptimisation(int version, char inputMode[], int inputLength) { } } - blockLength=(int*)malloc(sizeof(int)*blockCount); + blockLength = (int*) malloc(sizeof (int)*blockCount); assert(blockLength); if (!blockLength) return; - blockMode=(char*)malloc(sizeof(char)*blockCount); + blockMode = (char*) malloc(sizeof (char)*blockCount); assert(blockMode); - if (!blockMode) - { + if (!blockMode) { free(blockLength); return; } @@ -1773,13 +1771,13 @@ int micro_qr_intermediate(char binary[], int jisdata[], char mode[], int length, case 'K': /* Kanji mode */ /* Mode indicator */ - concat(binary, "K"); + strcat(binary, "K"); *kanji_used = 1; /* Character count indicator */ buffer[0] = short_data_block_length; buffer[1] = '\0'; - concat(binary, buffer); + strcat(binary, buffer); if (debug) { printf("Kanji block (length %d)\n\t", short_data_block_length); @@ -1816,13 +1814,13 @@ int micro_qr_intermediate(char binary[], int jisdata[], char mode[], int length, case 'B': /* Byte mode */ /* Mode indicator */ - concat(binary, "B"); + strcat(binary, "B"); *byte_used = 1; /* Character count indicator */ buffer[0] = short_data_block_length; buffer[1] = '\0'; - concat(binary, buffer); + strcat(binary, buffer); if (debug) { printf("Byte block (length %d)\n\t", short_data_block_length); @@ -1851,13 +1849,13 @@ int micro_qr_intermediate(char binary[], int jisdata[], char mode[], int length, case 'A': /* Alphanumeric mode */ /* Mode indicator */ - concat(binary, "A"); + strcat(binary, "A"); *alphanum_used = 1; /* Character count indicator */ buffer[0] = short_data_block_length; buffer[1] = '\0'; - concat(binary, buffer); + strcat(binary, buffer); if (debug) { printf("Alpha block (length %d)\n\t", short_data_block_length); @@ -1900,12 +1898,12 @@ int micro_qr_intermediate(char binary[], int jisdata[], char mode[], int length, case 'N': /* Numeric mode */ /* Mode indicator */ - concat(binary, "N"); + strcat(binary, "N"); /* Character count indicator */ buffer[0] = short_data_block_length; buffer[1] = '\0'; - concat(binary, buffer); + strcat(binary, buffer); if (debug) { printf("Number block (length %d)\n\t", short_data_block_length); @@ -2014,21 +2012,21 @@ void microqr_expand_binary(char binary_stream[], char full_stream[], int version i = 0; do { switch (binary_stream[i]) { - case '1': concat(full_stream, "1"); + case '1': strcat(full_stream, "1"); i++; break; - case '0': concat(full_stream, "0"); + case '0': strcat(full_stream, "0"); i++; break; case 'N': /* Numeric Mode */ /* Mode indicator */ switch (version) { - case 1: concat(full_stream, "0"); + case 1: strcat(full_stream, "0"); break; - case 2: concat(full_stream, "00"); + case 2: strcat(full_stream, "00"); break; - case 3: concat(full_stream, "000"); + case 3: strcat(full_stream, "000"); break; } @@ -2041,11 +2039,11 @@ void microqr_expand_binary(char binary_stream[], char full_stream[], int version /* Alphanumeric Mode */ /* Mode indicator */ switch (version) { - case 1: concat(full_stream, "1"); + case 1: strcat(full_stream, "1"); break; - case 2: concat(full_stream, "01"); + case 2: strcat(full_stream, "01"); break; - case 3: concat(full_stream, "001"); + case 3: strcat(full_stream, "001"); break; } @@ -2058,9 +2056,9 @@ void microqr_expand_binary(char binary_stream[], char full_stream[], int version /* Byte Mode */ /* Mode indicator */ switch (version) { - case 2: concat(full_stream, "10"); + case 2: strcat(full_stream, "10"); break; - case 3: concat(full_stream, "010"); + case 3: strcat(full_stream, "010"); break; } @@ -2073,9 +2071,9 @@ void microqr_expand_binary(char binary_stream[], char full_stream[], int version /* Kanji Mode */ /* Mode indicator */ switch (version) { - case 2: concat(full_stream, "11"); + case 2: strcat(full_stream, "11"); break; - case 3: concat(full_stream, "011"); + case 3: strcat(full_stream, "011"); break; } @@ -2102,11 +2100,11 @@ void micro_qr_m1(char binary_data[]) { bits_left = bits_total - strlen(binary_data); if (bits_left <= 3) { for (i = 0; i < bits_left; i++) { - concat(binary_data, "0"); + strcat(binary_data, "0"); } latch = 1; } else { - concat(binary_data, "000"); + strcat(binary_data, "000"); } if (latch == 0) { @@ -2114,7 +2112,7 @@ void micro_qr_m1(char binary_data[]) { bits_left = bits_total - strlen(binary_data); if (bits_left <= 4) { for (i = 0; i < bits_left; i++) { - concat(binary_data, "0"); + strcat(binary_data, "0"); } latch = 1; } @@ -2127,7 +2125,7 @@ void micro_qr_m1(char binary_data[]) { remainder = 0; } for (i = 0; i < remainder; i++) { - concat(binary_data, "0"); + strcat(binary_data, "0"); } /* Add padding */ @@ -2135,10 +2133,10 @@ void micro_qr_m1(char binary_data[]) { if (bits_left > 4) { remainder = (bits_left - 4) / 8; for (i = 0; i < remainder; i++) { - concat(binary_data, i & 1 ? "00010001" : "11101100"); + strcat(binary_data, i & 1 ? "00010001" : "11101100"); } } - concat(binary_data, "0000"); + strcat(binary_data, "0000"); } data_codewords = 3; @@ -2217,11 +2215,11 @@ void micro_qr_m2(char binary_data[], int ecc_mode) { bits_left = bits_total - strlen(binary_data); if (bits_left <= 5) { for (i = 0; i < bits_left; i++) { - concat(binary_data, "0"); + strcat(binary_data, "0"); } latch = 1; } else { - concat(binary_data, "00000"); + strcat(binary_data, "00000"); } if (latch == 0) { @@ -2231,14 +2229,14 @@ void micro_qr_m2(char binary_data[], int ecc_mode) { remainder = 0; } for (i = 0; i < remainder; i++) { - concat(binary_data, "0"); + strcat(binary_data, "0"); } /* Add padding */ bits_left = bits_total - strlen(binary_data); remainder = bits_left / 8; for (i = 0; i < remainder; i++) { - concat(binary_data, i & 1 ? "00010001" : "11101100"); + strcat(binary_data, i & 1 ? "00010001" : "11101100"); } } @@ -2313,11 +2311,11 @@ void micro_qr_m3(char binary_data[], int ecc_mode) { bits_left = bits_total - strlen(binary_data); if (bits_left <= 7) { for (i = 0; i < bits_left; i++) { - concat(binary_data, "0"); + strcat(binary_data, "0"); } latch = 1; } else { - concat(binary_data, "0000000"); + strcat(binary_data, "0000000"); } if (latch == 0) { @@ -2325,7 +2323,7 @@ void micro_qr_m3(char binary_data[], int ecc_mode) { bits_left = bits_total - strlen(binary_data); if (bits_left <= 4) { for (i = 0; i < bits_left; i++) { - concat(binary_data, "0"); + strcat(binary_data, "0"); } latch = 1; } @@ -2338,7 +2336,7 @@ void micro_qr_m3(char binary_data[], int ecc_mode) { remainder = 0; } for (i = 0; i < remainder; i++) { - concat(binary_data, "0"); + strcat(binary_data, "0"); } /* Add padding */ @@ -2346,10 +2344,10 @@ void micro_qr_m3(char binary_data[], int ecc_mode) { if (bits_left > 4) { remainder = (bits_left - 4) / 8; for (i = 0; i < remainder; i++) { - concat(binary_data, i & 1 ? "00010001" : "11101100"); + strcat(binary_data, i & 1 ? "00010001" : "11101100"); } } - concat(binary_data, "0000"); + strcat(binary_data, "0000"); } if (ecc_mode == LEVEL_L) { @@ -2458,11 +2456,11 @@ void micro_qr_m4(char binary_data[], int ecc_mode) { bits_left = bits_total - strlen(binary_data); if (bits_left <= 9) { for (i = 0; i < bits_left; i++) { - concat(binary_data, "0"); + strcat(binary_data, "0"); } latch = 1; } else { - concat(binary_data, "000000000"); + strcat(binary_data, "000000000"); } if (latch == 0) { @@ -2472,14 +2470,14 @@ void micro_qr_m4(char binary_data[], int ecc_mode) { remainder = 0; } for (i = 0; i < remainder; i++) { - concat(binary_data, "0"); + strcat(binary_data, "0"); } /* Add padding */ bits_left = bits_total - strlen(binary_data); remainder = bits_left / 8; for (i = 0; i < remainder; i++) { - concat(binary_data, i & 1 ? "00010001" : "11101100"); + strcat(binary_data, i & 1 ? "00010001" : "11101100"); } } diff --git a/backend/reedsol.c b/backend/reedsol.c index 09ad9da5..baefd614 100644 --- a/backend/reedsol.c +++ b/backend/reedsol.c @@ -51,8 +51,6 @@ #include // only needed for debug (main) #include // only needed for malloc/free #include "reedsol.h" -static int gfpoly; -static int symsize; // in bits static int logmod; // 2**symsize - 1 static int rlen; @@ -76,8 +74,6 @@ void rs_init_gf(const int poly) { m++; b >>= 1; m--; - gfpoly = poly; - symsize = m; // Calculate the log/alog tables logmod = (1 << m) - 1; @@ -100,7 +96,7 @@ void rs_init_gf(const int poly) { // (x + 2**i)*(x + 2**(i+1))*... [nsym terms] // For ECC200, index is 1. -void rs_init_code(const int nsym,int index) { +void rs_init_code(const int nsym, int index) { int i, k; rspoly = (int *) malloc(sizeof (int) * (nsym + 1)); @@ -120,7 +116,7 @@ void rs_init_code(const int nsym,int index) { } } -void rs_encode(const int len,const unsigned char *data, unsigned char *res) { +void rs_encode(const int len, const unsigned char *data, unsigned char *res) { int i, k, m; for (i = 0; i < rlen; i++) res[i] = 0; @@ -128,19 +124,19 @@ void rs_encode(const int len,const unsigned char *data, unsigned char *res) { m = res[rlen - 1] ^ data[i]; for (k = rlen - 1; k > 0; k--) { if (m && rspoly[k]) - res[k] = res[k - 1] ^ alog[(logt[m] + logt[rspoly[k]]) % logmod]; + res[k] = (unsigned char) (res[k - 1] ^ alog[(logt[m] + logt[rspoly[k]]) % logmod]); else res[k] = res[k - 1]; } if (m && rspoly[0]) - res[0] = alog[(logt[m] + logt[rspoly[0]]) % logmod]; + res[0] = (unsigned char) (alog[(logt[m] + logt[rspoly[0]]) % logmod]); else res[0] = 0; } } /* The same as above but for larger bitlengths - Aztec code compatible */ -void rs_encode_long(const int len,const unsigned int *data, unsigned int *res) { +void rs_encode_long(const int len, const unsigned int *data, unsigned int *res) { int i, k, m; for (i = 0; i < rlen; i++) res[i] = 0; @@ -160,7 +156,7 @@ void rs_encode_long(const int len,const unsigned int *data, unsigned int *res) { } /* Free memory */ -void rs_free(void) { +void rs_free(void) { free(logt); free(alog); free(rspoly); diff --git a/backend/render.c b/backend/render.c index 33659da5..aa5d7de4 100644 --- a/backend/render.c +++ b/backend/render.c @@ -56,7 +56,7 @@ int render_plot_add_hexagon(struct zint_symbol *symbol, struct zint_render_hexag int render_plot_add_string(struct zint_symbol *symbol, unsigned char *text, float x, float y, float fsize, float width, struct zint_render_string **last_string); -int render_plot(struct zint_symbol *symbol,const float width,const float height) { +int render_plot(struct zint_symbol *symbol, const float width, const float height) { struct zint_render *render; struct zint_render_line *line, *last_line = NULL; struct zint_render_string *last_string = NULL; @@ -81,6 +81,7 @@ int render_plot(struct zint_symbol *symbol,const float width,const float height // Allocate memory for the rendered version render = symbol->rendered = (struct zint_render *) malloc(sizeof (struct zint_render)); + if (!symbol->rendered) return ZINT_ERROR_MEMORY; render->lines = NULL; render->strings = NULL; render->rings = NULL; @@ -172,8 +173,7 @@ int render_plot(struct zint_symbol *symbol,const float width,const float height break; } } - - else if (((symbol->symbology == BARCODE_UPCA) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_UPCA_CC)) { + else if (((symbol->symbology == BARCODE_UPCA) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_UPCA_CC)) { upceanflag = 12; if (symbol->whitespace_width < 10) { symbol->whitespace_width = 10; @@ -190,8 +190,7 @@ int render_plot(struct zint_symbol *symbol,const float width,const float height break; } } - - else if (((symbol->symbology == BARCODE_UPCE) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_UPCE_CC)) { + else if (((symbol->symbology == BARCODE_UPCE) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_UPCE_CC)) { upceanflag = 6; if (symbol->whitespace_width == 0) { symbol->whitespace_width = 10; @@ -228,7 +227,7 @@ int render_plot(struct zint_symbol *symbol,const float width,const float height if (large_bar_count == 0) { required_aspect = width / height; symbol_aspect = (total_symbol_width_x + (2 * xoffset)) / (preset_height + (2 * yoffset) + text_offset + text_height); - symbol->height = (int)preset_height; + symbol->height = (int) preset_height; if (required_aspect > symbol_aspect) { /* the area is too wide */ scaler = height / (preset_height + (2 * yoffset) + text_offset + text_height); @@ -242,7 +241,7 @@ int render_plot(struct zint_symbol *symbol,const float width,const float height } } else { scaler = width / (total_symbol_width_x + (2 * xoffset)); - symbol->height = (int)((height / scaler) - ((2 * yoffset) + text_offset + text_height)); + symbol->height = (int) ((height / scaler) - ((2 * yoffset) + text_offset + text_height)); render->width = width; render->height = height; @@ -276,8 +275,7 @@ int render_plot(struct zint_symbol *symbol,const float width,const float height render->height = ((x_dimension * ((2 * symbol->border_width) + text_offset + text_height)) + 5.0) * GL_CONST; } } - - else if(symbol->symbology == BARCODE_CODE49) { + else if (symbol->symbology == BARCODE_CODE49) { /* The minimum X-dimension of Code 49 is 0.191mm */ if (x_dimension < 0.191) { render->width = 0.191 * GL_CONST * total_area_width_x; @@ -315,21 +313,18 @@ int render_plot(struct zint_symbol *symbol,const float width,const float height render->width = 0.508 * GL_CONST * total_area_width_x; render->height = 4.064 * GL_CONST; } - - else if((symbol->symbology == BARCODE_POSTNET) || (symbol->symbology == BARCODE_PLANET)) { + else if ((symbol->symbology == BARCODE_POSTNET) || (symbol->symbology == BARCODE_PLANET)) { /* The size of PostNet and PLANET are fized */ render->width = 0.508 * GL_CONST * total_area_width_x; render->height = 2.921 * GL_CONST; } - - else if(((symbol->symbology == BARCODE_AUSPOST) || (symbol->symbology == BARCODE_AUSREPLY)) || + else if (((symbol->symbology == BARCODE_AUSPOST) || (symbol->symbology == BARCODE_AUSREPLY)) || ((symbol->symbology == BARCODE_AUSROUTE) || (symbol->symbology == BARCODE_AUSREDIRECT))) { /* Australia Post use the same sizes as USPS */ render->width = 0.508 * GL_CONST * total_area_width_x; render->height = 4.064 * GL_CONST; } - - else if((symbol->symbology == BARCODE_RM4SCC) || (symbol->symbology == BARCODE_KIX)) { + else if ((symbol->symbology == BARCODE_RM4SCC) || (symbol->symbology == BARCODE_KIX)) { /* Royal Mail and KIX Code uses 22 bars per inch */ render->width = 0.577 * GL_CONST * total_area_width_x; render->height = 5.22 * GL_CONST; @@ -696,7 +691,7 @@ struct zint_render_line *render_plot_create_line(float x, float y, float width, * next value. */ int render_plot_add_line(struct zint_symbol *symbol, struct zint_render_line *line, struct zint_render_line **last_line) { - if (!line) return ZINT_ERROR_MEMORY; + if (!line) return ZINT_ERROR_MEMORY; if (*last_line) (*last_line)->next = line; else @@ -721,7 +716,7 @@ struct zint_render_ring *render_plot_create_ring(float x, float y, float radius, } int render_plot_add_ring(struct zint_symbol *symbol, struct zint_render_ring *ring, struct zint_render_ring **last_ring) { - if (!ring) return ZINT_ERROR_MEMORY; + if (!ring) return ZINT_ERROR_MEMORY; if (*last_ring) (*last_ring)->next = ring; else @@ -744,7 +739,7 @@ struct zint_render_hexagon *render_plot_create_hexagon(float x, float y) { } int render_plot_add_hexagon(struct zint_symbol *symbol, struct zint_render_hexagon *hexagon, struct zint_render_hexagon **last_hexagon) { - if (!hexagon) return ZINT_ERROR_MEMORY; + if (!hexagon) return ZINT_ERROR_MEMORY; if (*last_hexagon) (*last_hexagon)->next = hexagon; else diff --git a/backend/rss.c b/backend/rss.c index cc1f9181..c7edac6d 100644 --- a/backend/rss.c +++ b/backend/rss.c @@ -159,7 +159,7 @@ void getRSSwidths(int val, int n, int elements, int maxWidth, int noNarrow) { } /* GS1 DataBar-14 */ -int rss14(struct zint_symbol *symbol, unsigned char source[], int src_len) { +int rss14(struct zint_symbol *symbol, unsigned char source[], int src_len) { int error_number = 0, i, j, mask; short int accum[112], left_reg[112], right_reg[112], x_reg[112], y_reg[112]; int data_character[4], data_group[4], v_odd[4], v_even[4]; @@ -513,7 +513,7 @@ int rss14(struct zint_symbol *symbol, unsigned char source[], int src_len) { } hrt[13] = itoc(check_digit); - uconcat(symbol->text, (unsigned char*) hrt); + strcat((char*) symbol->text, hrt); } if ((symbol->symbology == BARCODE_RSS14STACK) || (symbol->symbology == BARCODE_RSS14STACK_CC)) { @@ -723,7 +723,7 @@ int rss14(struct zint_symbol *symbol, unsigned char source[], int src_len) { } /* GS1 DataBar Limited */ -int rsslimited(struct zint_symbol *symbol, unsigned char source[], int src_len) { +int rsslimited(struct zint_symbol *symbol, unsigned char source[], int src_len) { int error_number = 0, i, mask; short int accum[112], left_reg[112], right_reg[112], x_reg[112], y_reg[112]; int left_group, right_group, left_odd, left_even, right_odd, right_even; @@ -1041,15 +1041,15 @@ int rsslimited(struct zint_symbol *symbol, unsigned char source[], int src_len) hrt[13] = itoc(check_digit); hrt[14] = '\0'; - uconcat(symbol->text, (unsigned char*) hrt); + strcat((char*) symbol->text, hrt); return error_number; } /* Attempts to apply encoding rules from secions 7.2.5.5.1 to 7.2.5.5.3 * of ISO/IEC 24724:2006 */ -int general_rules(char field[], char type[]) { - +int general_rules(char field[], char type[]) { + int block[2][200], block_count, i, j, k; char current, next, last; @@ -1165,7 +1165,7 @@ int general_rules(char field[], char type[]) { } /* Handles all data encodation from section 7.2.5 of ISO/IEC 24724 */ -int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_string[]) { +int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_string[]) { int encoding_method, i, mask, j, read_posn, latch, debug = 0, last_mode = ISOIEC; #ifndef _MSC_VER char general_field[strlen(source) + 1], general_field_type[strlen(source) + 1]; @@ -1270,12 +1270,12 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str /* (01) and (3202)/(3203) */ if (source[19] == '3') { - weight = atof(weight_str) / 1000.0; + weight = (float) (atof(weight_str) / 1000.0F); if (weight <= 22.767) { encoding_method = 4; } } else { - weight = atof(weight_str) / 100.0; + weight = (float) (atof(weight_str) / 100.0F); if (weight <= 99.99) { encoding_method = 4; } @@ -1325,46 +1325,46 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str } switch (encoding_method) { /* Encoding method - Table 10 */ - case 1: concat(binary_string, "1XX"); + case 1: strcat(binary_string, "1XX"); read_posn = 16; break; - case 2: concat(binary_string, "00XX"); + case 2: strcat(binary_string, "00XX"); read_posn = 0; break; - case 3: concat(binary_string, "0100"); + case 3: strcat(binary_string, "0100"); read_posn = strlen(source); break; - case 4: concat(binary_string, "0101"); + case 4: strcat(binary_string, "0101"); read_posn = strlen(source); break; - case 5: concat(binary_string, "01100XX"); + case 5: strcat(binary_string, "01100XX"); read_posn = 20; break; - case 6: concat(binary_string, "01101XX"); + case 6: strcat(binary_string, "01101XX"); read_posn = 23; break; - case 7: concat(binary_string, "0111000"); + case 7: strcat(binary_string, "0111000"); read_posn = strlen(source); break; - case 8: concat(binary_string, "0111001"); + case 8: strcat(binary_string, "0111001"); read_posn = strlen(source); break; - case 9: concat(binary_string, "0111010"); + case 9: strcat(binary_string, "0111010"); read_posn = strlen(source); break; - case 10: concat(binary_string, "0111011"); + case 10: strcat(binary_string, "0111011"); read_posn = strlen(source); break; - case 11: concat(binary_string, "0111100"); + case 11: strcat(binary_string, "0111100"); read_posn = strlen(source); break; - case 12: concat(binary_string, "0111101"); + case 12: strcat(binary_string, "0111101"); read_posn = strlen(source); break; - case 13: concat(binary_string, "0111110"); + case 13: strcat(binary_string, "0111110"); read_posn = strlen(source); break; - case 14: concat(binary_string, "0111111"); + case 14: strcat(binary_string, "0111111"); read_posn = strlen(source); break; } @@ -1399,7 +1399,7 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str mask = 0x08; for (j = 0; j < 4; j++) { - concat(binary_string, (group_val & mask) ? "1" : "0"); + strcat(binary_string, (group_val & mask) ? "1" : "0"); mask = mask >> 1; } @@ -1412,7 +1412,7 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str mask = 0x200; for (j = 0; j < 10; j++) { - concat(binary_string, (group_val & mask) ? "1" : "0"); + strcat(binary_string, (group_val & mask) ? "1" : "0"); mask = mask >> 1; } } @@ -1435,7 +1435,7 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str mask = 0x200; for (j = 0; j < 10; j++) { - concat(binary_string, (group_val & mask) ? "1" : "0"); + strcat(binary_string, (group_val & mask) ? "1" : "0"); mask = mask >> 1; } } @@ -1448,7 +1448,7 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str mask = 0x4000; for (j = 0; j < 15; j++) { - concat(binary_string, (group_val & mask) ? "1" : "0"); + strcat(binary_string, (group_val & mask) ? "1" : "0"); mask = mask >> 1; } } @@ -1469,7 +1469,7 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str mask = 0x200; for (j = 0; j < 10; j++) { - concat(binary_string, (group_val & mask) ? "1" : "0"); + strcat(binary_string, (group_val & mask) ? "1" : "0"); mask = mask >> 1; } } @@ -1486,7 +1486,7 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str mask = 0x4000; for (j = 0; j < 15; j++) { - concat(binary_string, (group_val & mask) ? "1" : "0"); + strcat(binary_string, (group_val & mask) ? "1" : "0"); mask = mask >> 1; } } @@ -1509,7 +1509,7 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str mask = 0x200; for (j = 0; j < 10; j++) { - concat(binary_string, (group_val & mask) ? "1" : "0"); + strcat(binary_string, (group_val & mask) ? "1" : "0"); mask = mask >> 1; } } @@ -1524,7 +1524,7 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str mask = 0x80000; for (j = 0; j < 20; j++) { - concat(binary_string, (group_val & mask) ? "1" : "0"); + strcat(binary_string, (group_val & mask) ? "1" : "0"); mask = mask >> 1; } @@ -1548,7 +1548,7 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str mask = 0x8000; for (j = 0; j < 16; j++) { - concat(binary_string, (group_val & mask) ? "1" : "0"); + strcat(binary_string, (group_val & mask) ? "1" : "0"); mask = mask >> 1; } } @@ -1567,19 +1567,19 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str mask = 0x200; for (j = 0; j < 10; j++) { - concat(binary_string, (group_val & mask) ? "1" : "0"); + strcat(binary_string, (group_val & mask) ? "1" : "0"); mask = mask >> 1; } } switch (source[19]) { - case '0': concat(binary_string, "00"); + case '0': strcat(binary_string, "00"); break; - case '1': concat(binary_string, "01"); + case '1': strcat(binary_string, "01"); break; - case '2': concat(binary_string, "10"); + case '2': strcat(binary_string, "10"); break; - case '3': concat(binary_string, "11"); + case '3': strcat(binary_string, "11"); break; } } @@ -1601,19 +1601,19 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str mask = 0x200; for (j = 0; j < 10; j++) { - concat(binary_string, (group_val & mask) ? "1" : "0"); + strcat(binary_string, (group_val & mask) ? "1" : "0"); mask = mask >> 1; } } switch (source[19]) { - case '0': concat(binary_string, "00"); + case '0': strcat(binary_string, "00"); break; - case '1': concat(binary_string, "01"); + case '1': strcat(binary_string, "01"); break; - case '2': concat(binary_string, "10"); + case '2': strcat(binary_string, "10"); break; - case '3': concat(binary_string, "11"); + case '3': strcat(binary_string, "11"); break; } @@ -1625,7 +1625,7 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str mask = 0x200; for (j = 0; j < 10; j++) { - concat(binary_string, (group_val & mask) ? "1" : "0"); + strcat(binary_string, (group_val & mask) ? "1" : "0"); mask = mask >> 1; } } @@ -1734,12 +1734,12 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str /* Set initial mode if not NUMERIC */ if (general_field_type[0] == ALPHA) { - concat(binary_string, "0000"); /* Alphanumeric latch */ + strcat(binary_string, "0000"); /* Alphanumeric latch */ last_mode = ALPHA; } if (general_field_type[0] == ISOIEC) { - concat(binary_string, "0000"); /* Alphanumeric latch */ - concat(binary_string, "00100"); /* ISO/IEC 646 latch */ + strcat(binary_string, "0000"); /* Alphanumeric latch */ + strcat(binary_string, "00100"); /* ISO/IEC 646 latch */ last_mode = ISOIEC; } @@ -1751,7 +1751,7 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str if (debug) printf("as NUMERIC:"); if (last_mode != NUMERIC) { - concat(binary_string, "000"); /* Numeric latch */ + strcat(binary_string, "000"); /* Numeric latch */ if (debug) printf("\n"); } @@ -1772,7 +1772,7 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str mask = 0x40; for (j = 0; j < 7; j++) { - concat(binary_string, (value & mask) ? "1" : "0"); + strcat(binary_string, (value & mask) ? "1" : "0"); if (debug) { printf("%d", !!(value & mask)); } @@ -1788,10 +1788,10 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str if (debug) printf("as ALPHA\n"); if (i != 0) { if (last_mode == NUMERIC) { - concat(binary_string, "0000"); /* Alphanumeric latch */ + strcat(binary_string, "0000"); /* Alphanumeric latch */ } if (last_mode == ISOIEC) { - concat(binary_string, "00100"); /* Alphanumeric latch */ + strcat(binary_string, "00100"); /* Alphanumeric latch */ } } @@ -1801,7 +1801,7 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str mask = 0x10; for (j = 0; j < 5; j++) { - concat(binary_string, (value & mask) ? "1" : "0"); + strcat(binary_string, (value & mask) ? "1" : "0"); mask = mask >> 1; } } @@ -1812,21 +1812,21 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str mask = 0x20; for (j = 0; j < 6; j++) { - concat(binary_string, (value & mask) ? "1" : "0"); + strcat(binary_string, (value & mask) ? "1" : "0"); mask = mask >> 1; } } last_mode = ALPHA; if (general_field[i] == '[') { - concat(binary_string, "01111"); + strcat(binary_string, "01111"); last_mode = NUMERIC; } /* FNC1/Numeric latch */ - if (general_field[i] == '*') concat(binary_string, "111010"); /* asterisk */ - if (general_field[i] == ',') concat(binary_string, "111011"); /* comma */ - if (general_field[i] == '-') concat(binary_string, "111100"); /* minus or hyphen */ - if (general_field[i] == '.') concat(binary_string, "111101"); /* period or full stop */ - if (general_field[i] == '/') concat(binary_string, "111110"); /* slash or solidus */ + if (general_field[i] == '*') strcat(binary_string, "111010"); /* asterisk */ + if (general_field[i] == ',') strcat(binary_string, "111011"); /* comma */ + if (general_field[i] == '-') strcat(binary_string, "111100"); /* minus or hyphen */ + if (general_field[i] == '.') strcat(binary_string, "111101"); /* period or full stop */ + if (general_field[i] == '/') strcat(binary_string, "111110"); /* slash or solidus */ i++; break; @@ -1835,11 +1835,11 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str if (debug) printf("as ISOIEC\n"); if (i != 0) { if (last_mode == NUMERIC) { - concat(binary_string, "0000"); /* Alphanumeric latch */ - concat(binary_string, "00100"); /* ISO/IEC 646 latch */ + strcat(binary_string, "0000"); /* Alphanumeric latch */ + strcat(binary_string, "00100"); /* ISO/IEC 646 latch */ } if (last_mode == ALPHA) { - concat(binary_string, "00100"); /* ISO/IEC 646 latch */ + strcat(binary_string, "00100"); /* ISO/IEC 646 latch */ } } @@ -1849,7 +1849,7 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str mask = 0x10; for (j = 0; j < 5; j++) { - concat(binary_string, (value & mask) ? "1" : "0"); + strcat(binary_string, (value & mask) ? "1" : "0"); mask = mask >> 1; } } @@ -1860,7 +1860,7 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str mask = 0x40; for (j = 0; j < 7; j++) { - concat(binary_string, (value & mask) ? "1" : "0"); + strcat(binary_string, (value & mask) ? "1" : "0"); mask = mask >> 1; } } @@ -1871,37 +1871,37 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str mask = 0x40; for (j = 0; j < 7; j++) { - concat(binary_string, (value & mask) ? "1" : "0"); + strcat(binary_string, (value & mask) ? "1" : "0"); mask = mask >> 1; } } last_mode = ISOIEC; if (general_field[i] == '[') { - concat(binary_string, "01111"); + strcat(binary_string, "01111"); last_mode = NUMERIC; } /* FNC1/Numeric latch */ - if (general_field[i] == '!') concat(binary_string, "11101000"); /* exclamation mark */ - if (general_field[i] == 34) concat(binary_string, "11101001"); /* quotation mark */ - if (general_field[i] == 37) concat(binary_string, "11101010"); /* percent sign */ - if (general_field[i] == '&') concat(binary_string, "11101011"); /* ampersand */ - if (general_field[i] == 39) concat(binary_string, "11101100"); /* apostrophe */ - if (general_field[i] == '(') concat(binary_string, "11101101"); /* left parenthesis */ - if (general_field[i] == ')') concat(binary_string, "11101110"); /* right parenthesis */ - if (general_field[i] == '*') concat(binary_string, "11101111"); /* asterisk */ - if (general_field[i] == '+') concat(binary_string, "11110000"); /* plus sign */ - if (general_field[i] == ',') concat(binary_string, "11110001"); /* comma */ - if (general_field[i] == '-') concat(binary_string, "11110010"); /* minus or hyphen */ - if (general_field[i] == '.') concat(binary_string, "11110011"); /* period or full stop */ - if (general_field[i] == '/') concat(binary_string, "11110100"); /* slash or solidus */ - if (general_field[i] == ':') concat(binary_string, "11110101"); /* colon */ - if (general_field[i] == ';') concat(binary_string, "11110110"); /* semicolon */ - if (general_field[i] == '<') concat(binary_string, "11110111"); /* less-than sign */ - if (general_field[i] == '=') concat(binary_string, "11111000"); /* equals sign */ - if (general_field[i] == '>') concat(binary_string, "11111001"); /* greater-than sign */ - if (general_field[i] == '?') concat(binary_string, "11111010"); /* question mark */ - if (general_field[i] == '_') concat(binary_string, "11111011"); /* underline or low line */ - if (general_field[i] == ' ') concat(binary_string, "11111100"); /* space */ + if (general_field[i] == '!') strcat(binary_string, "11101000"); /* exclamation mark */ + if (general_field[i] == 34) strcat(binary_string, "11101001"); /* quotation mark */ + if (general_field[i] == 37) strcat(binary_string, "11101010"); /* percent sign */ + if (general_field[i] == '&') strcat(binary_string, "11101011"); /* ampersand */ + if (general_field[i] == 39) strcat(binary_string, "11101100"); /* apostrophe */ + if (general_field[i] == '(') strcat(binary_string, "11101101"); /* left parenthesis */ + if (general_field[i] == ')') strcat(binary_string, "11101110"); /* right parenthesis */ + if (general_field[i] == '*') strcat(binary_string, "11101111"); /* asterisk */ + if (general_field[i] == '+') strcat(binary_string, "11110000"); /* plus sign */ + if (general_field[i] == ',') strcat(binary_string, "11110001"); /* comma */ + if (general_field[i] == '-') strcat(binary_string, "11110010"); /* minus or hyphen */ + if (general_field[i] == '.') strcat(binary_string, "11110011"); /* period or full stop */ + if (general_field[i] == '/') strcat(binary_string, "11110100"); /* slash or solidus */ + if (general_field[i] == ':') strcat(binary_string, "11110101"); /* colon */ + if (general_field[i] == ';') strcat(binary_string, "11110110"); /* semicolon */ + if (general_field[i] == '<') strcat(binary_string, "11110111"); /* less-than sign */ + if (general_field[i] == '=') strcat(binary_string, "11111000"); /* equals sign */ + if (general_field[i] == '>') strcat(binary_string, "11111001"); /* greater-than sign */ + if (general_field[i] == '?') strcat(binary_string, "11111010"); /* question mark */ + if (general_field[i] == '_') strcat(binary_string, "11111011"); /* underline or low line */ + if (general_field[i] == ' ') strcat(binary_string, "11111100"); /* space */ i++; break; @@ -1929,7 +1929,7 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str mask = 0x08; for (j = 0; j < 4; j++) { - concat(binary_string, (value & mask) ? "1" : "0"); + strcat(binary_string, (value & mask) ? "1" : "0"); mask = mask >> 1; } } else { @@ -1940,7 +1940,7 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str mask = 0x40; for (j = 0; j < 7; j++) { - concat(binary_string, (value & mask) ? "1" : "0"); + strcat(binary_string, (value & mask) ? "1" : "0"); mask = mask >> 1; } } @@ -1949,7 +1949,7 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str mask = 0x10; for (j = 0; j < 5; j++) { - concat(binary_string, (value & mask) ? "1" : "0"); + strcat(binary_string, (value & mask) ? "1" : "0"); mask = mask >> 1; } } @@ -1979,11 +1979,11 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str strcpy(padstring, ""); } for (; i > 0; i -= 5) { - concat(padstring, "00100"); + strcat(padstring, "00100"); } padstring[remainder] = '\0'; - concat(binary_string, padstring); + strcat(binary_string, padstring); /* Patch variable length symbol bit field */ d1 = ((strlen(binary_string) / 12) + 1) & 1; @@ -2011,7 +2011,7 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str } /* GS1 DataBar Expanded */ -int rssexpanded(struct zint_symbol *symbol, unsigned char source[], int src_len) { +int rssexpanded(struct zint_symbol *symbol, unsigned char source[], int src_len) { int i, j, k, l, p, data_chars, vs[21], group[21], v_odd[21], v_even[21]; char substring[21][14], latch; int char_widths[21][8], checksum, check_widths[8], c_group; @@ -2047,9 +2047,9 @@ int rssexpanded(struct zint_symbol *symbol, unsigned char source[], int src_len) strcpy(binary_string, ""); if (symbol->option_1 == 2) { - concat(binary_string, "1"); + strcat(binary_string, "1"); } else { - concat(binary_string, "0"); + strcat(binary_string, "0"); } i = rss_binary_string(symbol, reduced, binary_string); diff --git a/backend/svg.c b/backend/svg.c index 85dc7cf8..02af747d 100644 --- a/backend/svg.c +++ b/backend/svg.c @@ -34,6 +34,7 @@ #include #include #include +#include #include "common.h" #define SSET "0123456789ABCDEF" @@ -178,9 +179,9 @@ int svg_plot(struct zint_symbol *symbol) { fprintf(fsvg, "\n"); if (symbol->symbology != BARCODE_MAXICODE) { - fprintf(fsvg, "width + xoffset + xoffset) * scaler), roundup((symbol->height + textoffset + yoffset + yoffset) * scaler)); + fprintf(fsvg, "width + xoffset + xoffset) * scaler), (int)ceil((symbol->height + textoffset + yoffset + yoffset) * scaler)); } else { - fprintf(fsvg, "\n"); if (ustrlen(symbol->text) != 0) { @@ -192,9 +193,9 @@ int svg_plot(struct zint_symbol *symbol) { fprintf(fsvg, "\n \n", symbol->fgcolour); if (symbol->symbology != BARCODE_MAXICODE) { - fprintf(fsvg, " \n", roundup((symbol->width + xoffset + xoffset) * scaler), roundup((symbol->height + textoffset + yoffset + yoffset) * scaler), symbol->bgcolour); + fprintf(fsvg, " \n", (int)ceil((symbol->width + xoffset + xoffset) * scaler), (int)ceil((symbol->height + textoffset + yoffset + yoffset) * scaler), symbol->bgcolour); } else { - fprintf(fsvg, " \n", roundup((74.0 + xoffset + xoffset) * scaler), roundup((72.0 + yoffset + yoffset) * scaler), symbol->bgcolour); + fprintf(fsvg, " \n", (int)ceil((74.0F + xoffset + xoffset) * scaler), (int)ceil((72.0F + yoffset + yoffset) * scaler), symbol->bgcolour); } if (((symbol->output_options & BARCODE_BOX) != 0) || ((symbol->output_options & BARCODE_BIND) != 0)) { diff --git a/backend/telepen.c b/backend/telepen.c index 02b2b0ca..8a5b375f 100644 --- a/backend/telepen.c +++ b/backend/telepen.c @@ -37,7 +37,7 @@ #include #include "common.h" -static char *TeleTable[] ={ +static char *TeleTable[] = { "1111111111111111", "1131313111", "33313111", "1111313131", "3111313111", "11333131", "13133131", "111111313111", "31333111", "1131113131", "33113131", "1111333111", "3111113131", "1113133111", "1311133111", "111111113131", "3131113111", "11313331", "333331", "111131113111", "31113331", "1133113111", "1313113111", "1111113331", @@ -78,7 +78,7 @@ int telepen(struct zint_symbol *symbol, unsigned char source[], int src_len) { strcpy(symbol->errtxt, "Invalid characters in input data"); return ZINT_ERROR_INVALID_DATA; } - concat(dest, TeleTable[source[i]]); + strcat(dest, TeleTable[source[i]]); count += source[i]; } @@ -86,10 +86,10 @@ int telepen(struct zint_symbol *symbol, unsigned char source[], int src_len) { if (check_digit == 127) { check_digit = 0; } - concat(dest, TeleTable[check_digit]); + strcat(dest, TeleTable[check_digit]); /* Stop character */ - concat(dest, TeleTable['z']); + strcat(dest, TeleTable['z']); expand(symbol, dest); for (i = 0; i < src_len; i++) { @@ -149,17 +149,17 @@ int telepen_num(struct zint_symbol *symbol, unsigned char source[], int src_len) glyph += 27; count += glyph; } - concat(dest, TeleTable[glyph]); + strcat(dest, TeleTable[glyph]); } check_digit = 127 - (count % 127); if (check_digit == 127) { check_digit = 0; } - concat(dest, TeleTable[check_digit]); + strcat(dest, TeleTable[check_digit]); /* Stop character */ - concat(dest, TeleTable['z']); + strcat(dest, TeleTable['z']); expand(symbol, dest); ustrcpy(symbol->text, temp); diff --git a/backend/upcean.c b/backend/upcean.c index fd163d28..bf5c447e 100644 --- a/backend/upcean.c +++ b/backend/upcean.c @@ -50,7 +50,7 @@ static const char *UPCParity1[10] = { /* Not covered by BS EN 797:1995 */ "AAABBB", "AABABB", "AABBAB", "AABBBA", "ABAABB", "ABBAAB", "ABBBAA", "ABABAB", "ABABBA", "ABBABA" -}; +}; static const char *EAN2Parity[4] = { /* Number sets for 2-digit add-on (EN Table 6) */ @@ -71,16 +71,16 @@ static const char *EAN13Parity[10] = { static const char *EANsetA[10] = { /* Representation set A and C (EN Table 1) */ - "3211", "2221", "2122", "1411", "1132", "1231", "1114", "1312", "1213","3112" + "3211", "2221", "2122", "1411", "1132", "1231", "1114", "1312", "1213", "3112" }; static const char *EANsetB[10] = { /* Representation set B (EN Table 1) */ "1123", "1222", "2212", "1141", "2311", "1321", "4111", "2131", "3121", "2113" -}; +}; /* Calculate the correct check digit for a UPC barcode */ -char upc_check(char source[]) { +char upc_check(char source[]) { unsigned int i, count, check_digit; count = 0; @@ -101,30 +101,30 @@ char upc_check(char source[]) { } /* UPC A is usually used for 12 digit numbers, but this function takes a source of any length */ -void upca_draw(char source[], char dest[]) { +void upca_draw(char source[], char dest[]) { unsigned int i, half_way; half_way = strlen(source) / 2; /* start character */ - concat(dest, "111"); + strcat(dest, "111"); for (i = 0; i <= strlen(source); i++) { if (i == half_way) { /* middle character - separates manufacturer no. from product no. */ /* also inverts right hand characters */ - concat(dest, "11111"); + strcat(dest, "11111"); } lookup(NEON, EANsetA, source[i], dest); } /* stop character */ - concat(dest, "111"); + strcat(dest, "111"); } /* Make a UPC A barcode when we haven't been given the check digit */ -void upca(struct zint_symbol *symbol, unsigned char source[], char dest[]) { +void upca(struct zint_symbol *symbol, unsigned char source[], char dest[]) { int length; char gtin[15]; @@ -137,7 +137,7 @@ void upca(struct zint_symbol *symbol, unsigned char source[], char dest[]) { } /* UPC E is a zero-compressed version of UPC A */ -void upce(struct zint_symbol *symbol, unsigned char source[], char dest[]) { +void upce(struct zint_symbol *symbol, unsigned char source[], char dest[]) { unsigned int i, num_system; char emode, equivalent[12], check_digit, parity[8], temp[8]; char hrt[9]; @@ -162,7 +162,7 @@ void upce(struct zint_symbol *symbol, unsigned char source[], char dest[]) { num_system = 0; hrt[0] = '0'; hrt[1] = '\0'; - concat(hrt, (char*) source); + strcat(hrt, (char*) source); } /* Expand the zero-compressed UPCE code to make a UPCA equivalent (EN Table 5) */ @@ -234,7 +234,7 @@ void upce(struct zint_symbol *symbol, unsigned char source[], char dest[]) { /* Take all this information and make the barcode pattern */ /* start character */ - concat(dest, "111"); + strcat(dest, "111"); for (i = 0; i <= ustrlen(source); i++) { switch (parity[i]) { @@ -246,7 +246,7 @@ void upce(struct zint_symbol *symbol, unsigned char source[], char dest[]) { } /* stop character */ - concat(dest, "111111"); + strcat(dest, "111111"); hrt[7] = check_digit; hrt[8] = '\0'; @@ -254,17 +254,17 @@ void upce(struct zint_symbol *symbol, unsigned char source[], char dest[]) { } /* EAN-2 and EAN-5 add-on codes */ -void add_on(unsigned char source[], char dest[], int mode) { +void add_on(unsigned char source[], char dest[], int mode) { char parity[6]; unsigned int i, code_type; /* If an add-on then append with space */ if (mode != 0) { - concat(dest, "9"); + strcat(dest, "9"); } /* Start character */ - concat(dest, "112"); + strcat(dest, "112"); /* Determine EAN2 or EAN5 add-on */ if (ustrlen(source) == 2) { @@ -306,14 +306,15 @@ void add_on(unsigned char source[], char dest[], int mode) { /* Glyph separator */ if (i != (ustrlen(source) - 1)) { - concat(dest, "11"); + strcat(dest, "11"); } } } /* ************************ EAN-13 ****************** */ + /* Calculate the correct check digit for a EAN-13 barcode */ -char ean_check(char source[]) { +char ean_check(char source[]) { int i; unsigned int h, count, check_digit; @@ -354,13 +355,13 @@ void ean13(struct zint_symbol *symbol, unsigned char source[], char dest[]) { half_way = 7; /* start character */ - concat(dest, "111"); + strcat(dest, "111"); length = strlen(gtin); for (i = 1; i <= length; i++) { if (i == half_way) { /* middle character - separates manufacturer no. from product no. */ /* also inverses right hand characters */ - concat(dest, "11111"); + strcat(dest, "11111"); } if (((i > 1) && (i < 7)) && (parity[i - 2] == 'B')) { @@ -371,13 +372,13 @@ void ean13(struct zint_symbol *symbol, unsigned char source[], char dest[]) { } /* stop character */ - concat(dest, "111"); + strcat(dest, "111"); ustrcpy(symbol->text, (unsigned char*) gtin); } /* Make an EAN-8 barcode when we haven't been given the check digit */ -void ean8(struct zint_symbol *symbol, unsigned char source[], char dest[]) { +void ean8(struct zint_symbol *symbol, unsigned char source[], char dest[]) { /* EAN-8 is basically the same as UPC-A but with fewer digits */ int length; char gtin[10]; @@ -599,19 +600,19 @@ void ean_leading_zeroes(struct zint_symbol *symbol, unsigned char source[], unsi /* Add leading zeroes */ for (i = 0; i < (zfirst_len - first_len); i++) { - uconcat(zfirst_part, (unsigned char *) "0"); + strcat((char*) zfirst_part, "0"); } - uconcat(zfirst_part, first_part); + strcat((char*) zfirst_part, (char*) first_part); for (i = 0; i < (zsecond_len - second_len); i++) { - uconcat(zsecond_part, (unsigned char *) "0"); + strcat((char*) zsecond_part, "0"); } - uconcat(zsecond_part, second_part); + strcat((char*) zsecond_part, (char*) second_part); /* Copy adjusted data back to local_source */ - uconcat(local_source, zfirst_part); + strcat((char*) local_source, (char*) zfirst_part); if (zsecond_len != 0) { - uconcat(local_source, (unsigned char *) "+"); - uconcat(local_source, zsecond_part); + strcat((char*) local_source, "+"); + strcat((char*) local_source, (char*) zsecond_part); } } @@ -794,13 +795,13 @@ int eanx(struct zint_symbol *symbol, unsigned char source[], int src_len) { case 0: break; case 2: add_on(second_part, (char*) dest, 1); - uconcat(symbol->text, (unsigned char*) "+"); - uconcat(symbol->text, second_part); + strcat((char*) symbol->text, "+"); + strcat((char*) symbol->text, (char*) second_part); break; case 5: add_on(second_part, (char*) dest, 1); - uconcat(symbol->text, (unsigned char*) "+"); - uconcat(symbol->text, second_part); + strcat((char*) symbol->text, "+"); + strcat((char*) symbol->text, (char*) second_part); break; default: strcpy(symbol->errtxt, "Invalid length input");