From d8330f5d9621e294550a7dc9e766d4098a41fce8 Mon Sep 17 00:00:00 2001 From: oxygenic Date: Tue, 13 Jun 2017 21:05:35 +0200 Subject: [PATCH] back-merged --- backend/codablock.c | 11 +++++------ backend/common.c | 4 ++-- backend/common.h | 2 +- backend/composite.c | 2 +- backend/dmatrix.c | 8 ++++---- backend/dotcode.c | 4 +++- backend/eci.c | 4 ++-- backend/hanxin.c | 4 ++-- backend/large.c | 3 ++- backend/library.c | 13 +++++++------ backend/qr.c | 10 +++++----- backend/qr.h | 2 +- win32/libzint.vcxproj | 4 ++-- 13 files changed, 37 insertions(+), 34 deletions(-) diff --git a/backend/codablock.c b/backend/codablock.c index 465eba14..2a565d60 100644 --- a/backend/codablock.c +++ b/backend/codablock.c @@ -115,7 +115,7 @@ int GetPossibleCharacterSet(unsigned char C) * int CFollowing The number of characters encodable in CodeC if we * start here. */ -void CreateCharacterSetTable(CharacterSetTable T[], unsigned char *data, int dataLength) +static void CreateCharacterSetTable(CharacterSetTable T[], unsigned char *data,const size_t dataLength) { int charCur; int runChar; @@ -205,7 +205,7 @@ int RemainingDigits(CharacterSetTable *T, int charCur,int emptyColumns) * Return value Resulting row count */ -int Columns2Rows(CharacterSetTable *T, unsigned char *data, int dataLength, +static int Columns2Rows(CharacterSetTable *T, unsigned char *data, const size_t dataLength, int * pRows, int * pUseColumns, int * pSet, int * pFillings) { int useColumns; /* Usable Characters per line */ @@ -430,7 +430,7 @@ int Columns2Rows(CharacterSetTable *T, unsigned char *data, int dataLength, } /* Find columns if row count is given. */ -int Rows2Columns(CharacterSetTable *T, unsigned char *data, int dataLength, +static int Rows2Columns(CharacterSetTable *T, unsigned char *data, const size_t dataLength, int * pRows, int * pUseColumns, int * pSet, int * pFillings) { int errorCur; @@ -630,8 +630,7 @@ void SumASCII(uchar **ppOutPos, int Sum, int CharacterSet) /* Main function called by zint framework */ int codablock(struct zint_symbol *symbol,const unsigned char source[], const size_t length) { - int charCur; - int dataLength; + size_t charCur,dataLength; int Error; int rows, columns, useColumns; int fillings; @@ -733,7 +732,7 @@ int codablock(struct zint_symbol *symbol,const unsigned char source[], const siz Sum1=Sum2=0; if (rows>1) { - int charCur; + size_t charCur; for (charCur=0 ; charCur= '0') && (source[position] <= '9')) { if ((source[position + 1] >= '0') && (source[position + 1] <= '9')) { return 1; diff --git a/backend/common.h b/backend/common.h index 9053f3d4..73b87218 100644 --- a/backend/common.h +++ b/backend/common.h @@ -64,7 +64,7 @@ extern "C" { extern int posn(const char set_string[], const char data); extern int module_is_set(const struct zint_symbol *symbol, const int y_coord, const int x_coord); extern void set_module(struct zint_symbol *symbol, const int y_coord, const int x_coord); - extern int istwodigits(const unsigned char source[], const int position); + extern int istwodigits(const unsigned char source[], const size_t position); extern int parunmodd(const unsigned char llyth); extern void expand(struct zint_symbol *symbol, const char data[]); extern void unset_module(struct zint_symbol *symbol, const int y_coord, const int x_coord); diff --git a/backend/composite.c b/backend/composite.c index 3d174b5c..d69427a6 100644 --- a/backend/composite.c +++ b/backend/composite.c @@ -150,7 +150,7 @@ static int cc_a(struct zint_symbol *symbol, char source[], int cc_width) { codeWords[i] = 0; } - bitlen = strlen(source); + bitlen = (int)strlen(source); for (i = 0; i < 208; i++) { local_source[i] = '0'; diff --git a/backend/dmatrix.c b/backend/dmatrix.c index 4c009668..78df9398 100644 --- a/backend/dmatrix.c +++ b/backend/dmatrix.c @@ -256,7 +256,7 @@ static void dminsert(char binary_string[], const int posn, const char newbit) { binary_string[posn] = newbit; } -static void insert_value(unsigned char binary_stream[], const int posn, const size_t streamlen, const int newbit) { +static void insert_value(unsigned char binary_stream[], const int posn, const int streamlen, const int newbit) { int i; for(i = (int)streamlen; i > posn; i--) { @@ -265,15 +265,15 @@ static void insert_value(unsigned char binary_stream[], const int posn, const si binary_stream[posn] = (unsigned char) newbit; } -static int p_r_6_2_1(const unsigned char inputData[], const int position, const size_t sourcelen) { +static int p_r_6_2_1(const unsigned char inputData[], const size_t position, const size_t 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..." */ size_t i; - int nonX12Position = 0; - int specialX12Position = 0; + size_t nonX12Position = 0; + size_t specialX12Position = 0; int retval = 0; for (i = position; i < sourcelen; i++) { diff --git a/backend/dotcode.c b/backend/dotcode.c index 0175d6a7..c0fb7681 100644 --- a/backend/dotcode.c +++ b/backend/dotcode.c @@ -1203,13 +1203,15 @@ int dotcode(struct zint_symbol *symbol, const unsigned char source[], int length int binary_finish = 0; int debug = 0; int padding_dots, is_first; +#ifdef _MSC_VER + unsigned char* masked_codeword_array; +#endif #ifndef _MSC_VER unsigned char codeword_array[length * 3]; #else char* dot_stream; char* dot_array; - unsigned char* masked_codeword_array; unsigned char* codeword_array = (unsigned char *) _alloca(length * 3 * sizeof (unsigned char)); #endif /* _MSC_VER */ diff --git a/backend/eci.c b/backend/eci.c index 495273cc..4545613d 100644 --- a/backend/eci.c +++ b/backend/eci.c @@ -39,7 +39,7 @@ #endif /* Convert Unicode to other character encodings */ -int utf_to_eci(int eci, const unsigned char source[], unsigned char dest[], int *length) { +int utf_to_eci(const int eci, const unsigned char source[], unsigned char dest[], size_t *length) { int glyph; int bytelen; int in_posn; @@ -288,7 +288,7 @@ int utf_to_eci(int eci, const unsigned char source[], unsigned char dest[], int } /* Find the lowest ECI mode which will encode a given set of Unicode text */ -int get_best_eci(unsigned char source[], int length) { +int get_best_eci(unsigned char source[], size_t length) { int eci = 3; #ifndef _MSC_VER diff --git a/backend/hanxin.c b/backend/hanxin.c index 000f9b35..9585facd 100644 --- a/backend/hanxin.c +++ b/backend/hanxin.c @@ -65,7 +65,7 @@ int getsubmode(char input) { /* Calculate the approximate length of the binary string */ static int calculate_binlength(char mode[], int source[], const size_t length, int eci) { - int i; + size_t i; char lastmode = 't'; int est_binlen = 0; int submode = 1; @@ -226,7 +226,7 @@ int isFourByte(int glyph, int glyph2) { /* Calculate mode switching */ static void hx_define_mode(char mode[], int source[], const size_t length) { - int i; + size_t i; char lastmode = 't'; int done; diff --git a/backend/large.c b/backend/large.c index d7fe2082..a0bdc5c2 100644 --- a/backend/large.c +++ b/backend/large.c @@ -172,7 +172,8 @@ short int islarger(short int accum[], short int reg[]) { } void binary_load(short int reg[], char data[], const size_t src_len) { - int read, i; + size_t read; + int i; short int temp[112] = {0}; for (i = 0; i < 112; i++) { diff --git a/backend/library.c b/backend/library.c index a084beae..00c973ea 100644 --- a/backend/library.c +++ b/backend/library.c @@ -145,8 +145,9 @@ void ZBarcode_Delete(struct zint_symbol *symbol) { free(symbol); } -extern int get_best_eci(unsigned char source[], int length); /* Calculate suitable ECI mode */ -extern int utf_to_eci(int eci, const unsigned char source[], unsigned char dest[], int *length); /* Convert Unicode to other encodings */ +extern int get_best_eci(unsigned char source[], size_t length); /* Calculate suitable ECI mode */ +extern int utf_to_eci(const int eci, const unsigned char source[], unsigned char dest[], size_t *length); /* Convert Unicode to other encodings */ + extern int eanx(struct zint_symbol *symbol, unsigned char source[], int length); /* EAN system barcodes */ extern int c39(struct zint_symbol *symbol, unsigned char source[], const size_t length); /* Code 3 from 9 (or Code 39) */ @@ -203,7 +204,7 @@ extern int grid_matrix(struct zint_symbol *symbol, const unsigned char source[], extern int han_xin(struct zint_symbol * symbol, const unsigned char source[], size_t length); /* Han Xin */ extern int dotcode(struct zint_symbol * symbol, const unsigned char source[], int length); /* DotCode */ extern int codablock(struct zint_symbol * symbol, const unsigned char source[], const size_t length); /* Codablock */ -extern int upnqr(struct zint_symbol *symbol, const unsigned char source[], int length); /* UPNQR */ +extern int upnqr(struct zint_symbol *symbol, const unsigned char source[], size_t length); /* UPNQR */ extern int qr_code(struct zint_symbol *symbol, const unsigned char source[], size_t length); /* Data Matrix (IEC16022) */ extern int dmatrix(struct zint_symbol *symbol, const unsigned char source[], const size_t in_length); /* QR Code */ @@ -615,7 +616,7 @@ static int extended_charset(struct zint_symbol *symbol, const unsigned char *sou return error_number; } -static int reduced_charset(struct zint_symbol *symbol, const unsigned char *source, int in_length) { +static int reduced_charset(struct zint_symbol *symbol, const unsigned char *source, size_t in_length) { /* These are the "norm" standards which only support Latin-1 at most */ int error_number = 0; @@ -1049,7 +1050,7 @@ int ZBarcode_Encode(struct zint_symbol *symbol, const unsigned char *source,int case BARCODE_MICROQR: case BARCODE_GRIDMATRIX: case BARCODE_HANXIN: - error_number = utf_to_eci(symbol->eci, source, local_source, &in_length); + error_number = utf_to_eci(symbol->eci, source, local_source, (size_t*)&in_length); error_number = extended_charset(symbol, local_source, in_length); break; default: @@ -1310,4 +1311,4 @@ int ZBarcode_Render(struct zint_symbol *symbol, const float width, const float h int ZBarcode_Version() { return (ZINT_VERSION_MAJOR * 10000) + (ZINT_VERSION_MINOR * 100) + ZINT_VERSION_RELEASE; -} \ No newline at end of file +} diff --git a/backend/qr.c b/backend/qr.c index 09aad516..cf0364a0 100644 --- a/backend/qr.c +++ b/backend/qr.c @@ -42,7 +42,7 @@ #include /* abs */ #include -extern int utf_to_eci(int eci, const unsigned char source[], unsigned char dest[], int *length); /* Convert Unicode to other encodings */ +extern int utf_to_eci(const int eci, const unsigned char source[], unsigned char dest[], size_t *length); /* Convert Unicode to other encodings */ /* Returns true if input glyph is in the Alphanumeric set */ static int in_alpha(const int glyph) { @@ -147,7 +147,7 @@ static int tribus(const int version,const int a,const int b,const int c) { } /* Convert input data to a binary stream and add padding */ -static void qr_binary(int datastream[], const int version, const int target_binlen, const char mode[], const int jisdata[], const size_t length, const int gs1, const int eci, const int est_binlen, int debug) { +static void qr_binary(int datastream[], const int version, const int target_binlen, const char mode[], const int jisdata[], const size_t length, const int gs1, const int eci, const int est_binlen,const int debug) { int position = 0; int short_data_block_length, i; char data_block, padbits; @@ -1313,7 +1313,7 @@ static void applyOptimisation(const int version,char inputMode[], const size_t i free(blockMode); } -static int blockLength(const int start,const char inputMode[],const size_t inputLength) { +static int blockLength(const size_t start,const char inputMode[],const size_t inputLength) { /* Find the length of the block starting from 'start' */ size_t i; int count; @@ -1648,7 +1648,7 @@ int qr_code(struct zint_symbol *symbol, const unsigned char source[], size_t len /* NOTE: From this point forward concerns Micro QR Code only */ -static int micro_qr_intermediate(char binary[], const int jisdata[], const char mode[], const size_t length, int *kanji_used, int *alphanum_used, int *byte_used, int debug) { +static int micro_qr_intermediate(char binary[], const int jisdata[], const char mode[], const size_t length, int *kanji_used, int *alphanum_used, int *byte_used,const int debug) { /* Convert input data to an "intermediate stage" where data is binary encoded but control information is not */ int position = 0; @@ -2888,7 +2888,7 @@ int microqr(struct zint_symbol *symbol, const unsigned char source[], size_t len } /* For UPNQR the symbol size and error correction capacity is fixed */ -int upnqr(struct zint_symbol *symbol, const unsigned char source[], int length) { +int upnqr(struct zint_symbol *symbol, const unsigned char source[], size_t length) { int i, j, est_binlen; int ecc_level, version, target_binlen, blocks, size; int bitmask, error_number; diff --git a/backend/qr.h b/backend/qr.h index f2790e16..d1c248f5 100644 --- a/backend/qr.h +++ b/backend/qr.h @@ -164,4 +164,4 @@ static const unsigned int qr_annex_c1[] = { 0x4445, 0x4172, 0x4e2b, 0x4b1c, 0x55ae, 0x5099, 0x5fc0, 0x5af7, 0x6793, 0x62a4, 0x6dfd, 0x68ca, 0x7678, 0x734f, 0x7c16, 0x7921, 0x06de, 0x03e9, 0x0cb0, 0x0987, 0x1735, 0x1202, 0x1d5b, 0x186c, 0x2508, 0x203f, 0x2f66, 0x2a51, 0x34e3, 0x31d4, 0x3e8d, 0x3bba -}; \ No newline at end of file +}; diff --git a/win32/libzint.vcxproj b/win32/libzint.vcxproj index afa2ee2c..c3436c36 100644 --- a/win32/libzint.vcxproj +++ b/win32/libzint.vcxproj @@ -135,7 +135,7 @@ false - libpng16d.lib;zlibd.lib;%(AdditionalDependencies) + %(AdditionalDependencies) $(OutDir)zintd.dll ..\extern\libpng\lib\x86;..\extern\zlib\lib\x86;%(AdditionalLibraryDirectories) libcmtd.lib;%(IgnoreSpecificDefaultLibraries) @@ -169,7 +169,7 @@ false - libpng16d.lib;zlibd.lib;%(AdditionalDependencies) + zlibd.lib;%(AdditionalDependencies) $(OutDir)zintd.dll ..\extern\libpng\lib\x64;..\extern\zlib\lib\x64;%(AdditionalLibraryDirectories) libcmtd.lib;%(IgnoreSpecificDefaultLibraries)