mirror of
https://github.com/zint/zint
synced 2024-11-16 20:57:25 +13:00
Change height and row_height array to floats: VC6, CodeQL fixes
This commit is contained in:
parent
c693482aa1
commit
e5115bad07
@ -640,7 +640,7 @@ INTERNAL int codablock(struct zint_symbol *symbol, unsigned char source[], int l
|
|||||||
int emptyColumns;
|
int emptyColumns;
|
||||||
char dest[1000];
|
char dest[1000];
|
||||||
int r, c;
|
int r, c;
|
||||||
float min_row_height;
|
float min_row_height = 0.0f;
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
CharacterSetTable *T;
|
CharacterSetTable *T;
|
||||||
unsigned char *data;
|
unsigned char *data;
|
||||||
@ -997,8 +997,7 @@ INTERNAL int codablock(struct zint_symbol *symbol, unsigned char source[], int l
|
|||||||
error_number = set_height(symbol, min_row_height, (min_row_height > 10.0f ? min_row_height : 10.0f) * rows, 0.0f,
|
error_number = set_height(symbol, min_row_height, (min_row_height > 10.0f ? min_row_height : 10.0f) * rows, 0.0f,
|
||||||
0 /*no_errtxt*/);
|
0 /*no_errtxt*/);
|
||||||
#else
|
#else
|
||||||
(void)min_row_height;
|
(void) set_height(symbol, min_row_height, 10.0f * rows, 0.0f, 1 /*no_errtxt*/);
|
||||||
(void) set_height(symbol, 0.0f, 10.0f * rows, 0.0f, 1 /*no_errtxt*/);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
symbol->output_options |= BARCODE_BIND;
|
symbol->output_options |= BARCODE_BIND;
|
||||||
|
@ -861,7 +861,7 @@ static int c1_encode(struct zint_symbol *symbol, unsigned char source[], unsigne
|
|||||||
db_p = bin_append_posn(1, 2, decimal_binary, db_p);
|
db_p = bin_append_posn(1, 2, decimal_binary, db_p);
|
||||||
}
|
}
|
||||||
|
|
||||||
(void)decimal_binary_transfer(decimal_binary, db_p, target, &tp);
|
(void) decimal_binary_transfer(decimal_binary, db_p, target, &tp);
|
||||||
}
|
}
|
||||||
current_mode = C1_ASCII;
|
current_mode = C1_ASCII;
|
||||||
|
|
||||||
|
@ -120,7 +120,7 @@ INTERNAL int code16k(struct zint_symbol *symbol, unsigned char source[], int len
|
|||||||
int input_length;
|
int input_length;
|
||||||
int gs1, c_count;
|
int gs1, c_count;
|
||||||
int separator;
|
int separator;
|
||||||
float min_row_height;
|
float min_row_height = 0.0f;
|
||||||
|
|
||||||
/* Suppresses clang-analyzer-core.UndefinedBinaryOperatorResult warning on fset which is fully set */
|
/* Suppresses clang-analyzer-core.UndefinedBinaryOperatorResult warning on fset which is fully set */
|
||||||
assert(length > 0);
|
assert(length > 0);
|
||||||
@ -500,8 +500,8 @@ INTERNAL int code16k(struct zint_symbol *symbol, unsigned char source[], int len
|
|||||||
error_number = set_height(symbol, min_row_height, (min_row_height > 10.0f ? min_row_height : 10.0f) * rows, 0.0f,
|
error_number = set_height(symbol, min_row_height, (min_row_height > 10.0f ? min_row_height : 10.0f) * rows, 0.0f,
|
||||||
0 /*no_errtxt*/);
|
0 /*no_errtxt*/);
|
||||||
#else
|
#else
|
||||||
(void)min_row_height; (void)separator;
|
(void)&separator;
|
||||||
(void) set_height(symbol, 0.0f, 10.0f * rows, 0.0f, 1 /*no_errtxt*/);
|
(void) set_height(symbol, min_row_height, 10.0f * rows, 0.0f, 1 /*no_errtxt*/);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
symbol->output_options |= BARCODE_BIND;
|
symbol->output_options |= BARCODE_BIND;
|
||||||
|
@ -50,7 +50,7 @@ INTERNAL int code_49(struct zint_symbol *symbol, unsigned char source[], int len
|
|||||||
int gs1;
|
int gs1;
|
||||||
int h, len;
|
int h, len;
|
||||||
int separator;
|
int separator;
|
||||||
float min_row_height;
|
float min_row_height = 0.0f;
|
||||||
int error_number = 0;
|
int error_number = 0;
|
||||||
|
|
||||||
if (length > 81) {
|
if (length > 81) {
|
||||||
@ -358,8 +358,8 @@ INTERNAL int code_49(struct zint_symbol *symbol, unsigned char source[], int len
|
|||||||
error_number = set_height(symbol, min_row_height, (min_row_height > 10.0f ? min_row_height : 10.0f) * rows, 0.0f,
|
error_number = set_height(symbol, min_row_height, (min_row_height > 10.0f ? min_row_height : 10.0f) * rows, 0.0f,
|
||||||
0 /*no_errtxt*/);
|
0 /*no_errtxt*/);
|
||||||
#else
|
#else
|
||||||
(void)min_row_height; (void)separator;
|
(void)&separator;
|
||||||
(void) set_height(symbol, 0.0f, 10.0f * rows, 0.0f, 1 /*no_errtxt*/);
|
(void) set_height(symbol, min_row_height, 10.0f * rows, 0.0f, 1 /*no_errtxt*/);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
symbol->output_options |= BARCODE_BIND;
|
symbol->output_options |= BARCODE_BIND;
|
||||||
|
@ -64,6 +64,9 @@
|
|||||||
# define ceilf (float) ceil
|
# define ceilf (float) ceil
|
||||||
# define floorf (float) floor
|
# define floorf (float) floor
|
||||||
# define roundf(arg) ((float) floor((arg) + 0.5f))
|
# define roundf(arg) ((float) floor((arg) + 0.5f))
|
||||||
|
# if _MSC_VER == 1200 /* VC6 */
|
||||||
|
# define round(arg) floor((arg) + 0.5f)
|
||||||
|
# endif
|
||||||
# endif
|
# endif
|
||||||
# pragma warning(disable: 4244) /* conversion from int to float */
|
# pragma warning(disable: 4244) /* conversion from int to float */
|
||||||
# if _MSC_VER >= 1900 /* MSVC 2015 */
|
# if _MSC_VER >= 1900 /* MSVC 2015 */
|
||||||
|
@ -1243,7 +1243,7 @@ int ZBarcode_Encode(struct zint_symbol *symbol, const unsigned char *source, int
|
|||||||
if (error_number == 0) {
|
if (error_number == 0) {
|
||||||
error_number = warn_number;
|
error_number = warn_number;
|
||||||
}
|
}
|
||||||
(void)error_tag(symbol->errtxt, error_number);
|
(void) error_tag(symbol->errtxt, error_number);
|
||||||
|
|
||||||
if (error_number < ZINT_ERROR) {
|
if (error_number < ZINT_ERROR) {
|
||||||
if (symbol->height < 0.5f) { /* Absolute minimum */
|
if (symbol->height < 0.5f) { /* Absolute minimum */
|
||||||
|
@ -555,7 +555,7 @@ INTERNAL float output_large_bar_height(struct zint_symbol *symbol, int si) {
|
|||||||
symbol->height = large_bar_height * zero_count + fixed_height;
|
symbol->height = large_bar_height * zero_count + fixed_height;
|
||||||
}
|
}
|
||||||
if (si && large_bar_height * si != (int) (large_bar_height * si)) {
|
if (si && large_bar_height * si != (int) (large_bar_height * si)) {
|
||||||
large_bar_height = (float) (round(large_bar_height * si) / si);
|
large_bar_height = roundf(large_bar_height * si) / si;
|
||||||
symbol->height = large_bar_height * zero_count + fixed_height;
|
symbol->height = large_bar_height * zero_count + fixed_height;
|
||||||
}
|
}
|
||||||
/* Note should never happen that have both zero_count and round_rows */
|
/* Note should never happen that have both zero_count and round_rows */
|
||||||
@ -565,7 +565,7 @@ INTERNAL float output_large_bar_height(struct zint_symbol *symbol, int si) {
|
|||||||
fixed_height = 0.0f;
|
fixed_height = 0.0f;
|
||||||
for (i = 0; i < symbol->rows; i++) {
|
for (i = 0; i < symbol->rows; i++) {
|
||||||
if (symbol->row_height[i] * si != (int) (symbol->row_height[i] * si)) {
|
if (symbol->row_height[i] * si != (int) (symbol->row_height[i] * si)) {
|
||||||
symbol->row_height[i] = (float) (round(symbol->row_height[i] * si) / si);
|
symbol->row_height[i] = roundf(symbol->row_height[i] * si) / si;
|
||||||
}
|
}
|
||||||
fixed_height += symbol->row_height[i];
|
fixed_height += symbol->row_height[i];
|
||||||
}
|
}
|
||||||
|
@ -35,10 +35,6 @@
|
|||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
/* For Visual C++ 6 suppress conversion from int to float warning */
|
|
||||||
#if _MSC_VER == 1200
|
|
||||||
#pragma warning(disable: 4244)
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
Loading…
Reference in New Issue
Block a user