1
0
mirror of https://git.code.sf.net/p/zint/code synced 2026-06-10 07:33:43 +00:00

general: add -Wshorten-64-to-32 compiler flag & suppress warnings

(ticket #351, props Axel Waggershauser)
This commit is contained in:
gitlost
2026-02-26 18:23:21 +00:00
parent 9ef5bc7298
commit bd33953fc1
24 changed files with 106 additions and 102 deletions
+4
View File
@@ -72,6 +72,10 @@ if(NOT MSVC) # Use default warnings if MSVC otherwise inundated
if(C_COMPILER_FLAG_WSHADOW) if(C_COMPILER_FLAG_WSHADOW)
add_compile_options("-Wshadow") add_compile_options("-Wshadow")
endif() endif()
check_c_compiler_flag("-Wshorten-64-to-32" C_COMPILER_FLAG_WSHORTEN64TO32)
if(C_COMPILER_FLAG_WSHORTEN64TO32)
add_compile_options("-Wshorten-64-to-32")
endif()
check_c_compiler_flag("-Wundef" C_COMPILER_FLAG_WUNDEF) check_c_compiler_flag("-Wundef" C_COMPILER_FLAG_WUNDEF)
if(C_COMPILER_FLAG_WUNDEF) if(C_COMPILER_FLAG_WUNDEF)
add_compile_options("-Wundef") add_compile_options("-Wundef")
+2 -2
View File
@@ -1,7 +1,7 @@
/* 2of5.c - Handles non-interleaved Code 2 of 5 barcodes */ /* 2of5.c - Handles non-interleaved Code 2 of 5 barcodes */
/* /*
libzint - the open source barcode library libzint - the open source barcode library
Copyright (C) 2008-2025 Robin Stuart <rstuart114@gmail.com> Copyright (C) 2008-2026 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions modification, are permitted provided that the following conditions
@@ -103,7 +103,7 @@ static int c25_common(struct zint_symbol *symbol, const unsigned char source[],
memcpy(d, start_stop[1], start_length - 1); memcpy(d, start_stop[1], start_length - 1);
d += start_length - 1; d += start_length - 1;
z_expand(symbol, dest, d - dest); z_expand(symbol, dest, (int) (d - dest));
/* Exclude check digit from HRT if hidden */ /* Exclude check digit from HRT if hidden */
z_hrt_cpy_nochk(symbol, local_source, length - (symbol->option_2 == 2)); z_hrt_cpy_nochk(symbol, local_source, length - (symbol->option_2 == 2));
+2 -2
View File
@@ -1,7 +1,7 @@
/* 2of5inter.c - Handles Code 2 of 5 Interleaved */ /* 2of5inter.c - Handles Code 2 of 5 Interleaved */
/* /*
libzint - the open source barcode library libzint - the open source barcode library
Copyright (C) 2008-2025 Robin Stuart <rstuart114@gmail.com> Copyright (C) 2008-2026 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions modification, are permitted provided that the following conditions
@@ -96,7 +96,7 @@ INTERNAL int zint_c25_inter_common(struct zint_symbol *symbol, unsigned char sou
memcpy(d, "311", 3); memcpy(d, "311", 3);
d += 3; d += 3;
z_expand(symbol, dest, d - dest); z_expand(symbol, dest, (int) (d - dest));
if (!dont_set_height) { if (!dont_set_height) {
if (symbol->output_options & COMPLIANT_HEIGHT) { if (symbol->output_options & COMPLIANT_HEIGHT) {
+4 -4
View File
@@ -1,7 +1,7 @@
/* auspost.c - Handles Australia Post 4-State Barcode */ /* auspost.c - Handles Australia Post 4-State Barcode */
/* /*
libzint - the open source barcode library libzint - the open source barcode library
Copyright (C) 2008-2025 Robin Stuart <rstuart114@gmail.com> Copyright (C) 2008-2026 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions modification, are permitted provided that the following conditions
@@ -76,7 +76,7 @@ static unsigned char aus_convert_pattern(const char data, const int shift) {
/* Adds Reed-Solomon error correction to auspost */ /* Adds Reed-Solomon error correction to auspost */
static char *aus_rs_error(const char data_pattern[], char *d) { static char *aus_rs_error(const char data_pattern[], char *d) {
const int length = d - data_pattern; const int length = (int) (d - data_pattern);
int reader, triple_writer; int reader, triple_writer;
unsigned char triple[31]; unsigned char triple[31];
unsigned char result[5]; unsigned char result[5];
@@ -228,7 +228,7 @@ INTERNAL int zint_auspost(struct zint_symbol *symbol, unsigned char source[], in
} }
/* Filler bar */ /* Filler bar */
h = d - data_pattern; h = (int) (d - data_pattern);
switch (h) { switch (h) {
case 22: case 22:
case 37: case 37:
@@ -248,7 +248,7 @@ INTERNAL int zint_auspost(struct zint_symbol *symbol, unsigned char source[], in
/* Turn the symbol into a bar pattern ready for plotting */ /* Turn the symbol into a bar pattern ready for plotting */
writer = 0; writer = 0;
h = d - data_pattern; h = (int) (d - data_pattern);
for (loopey = 0; loopey < h; loopey++) { for (loopey = 0; loopey < h; loopey++) {
if (data_pattern[loopey] == '1' || data_pattern[loopey] == '0') { if (data_pattern[loopey] == '1' || data_pattern[loopey] == '0') {
z_set_module(symbol, 0, writer); z_set_module(symbol, 0, writer);
+2 -2
View File
@@ -1,7 +1,7 @@
/* bc412.c - Handles IBM BC412 (SEMI T1-95) symbology */ /* bc412.c - Handles IBM BC412 (SEMI T1-95) symbology */
/* /*
libzint - the open source barcode library libzint - the open source barcode library
Copyright (C) 2022-2025 Robin Stuart <rstuart114@gmail.com> Copyright (C) 2022-2026 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions modification, are permitted provided that the following conditions
@@ -130,7 +130,7 @@ INTERNAL int zint_bc412(struct zint_symbol *symbol, unsigned char source[], int
memcpy(d, "111", 3); memcpy(d, "111", 3);
d += 3; d += 3;
z_expand(symbol, dest, d - dest); z_expand(symbol, dest, (int) (d - dest));
if (symbol->output_options & COMPLIANT_HEIGHT) { if (symbol->output_options & COMPLIANT_HEIGHT) {
/* SEMI T1-95 Table 1 "Module" (Character) Height 2mm ± 0.025mm, using Module Spacing 0.12mm ± 0.025mm as /* SEMI T1-95 Table 1 "Module" (Character) Height 2mm ± 0.025mm, using Module Spacing 0.12mm ± 0.025mm as
+1 -1
View File
@@ -240,7 +240,7 @@ INTERNAL int zint_channel(struct zint_symbol *symbol, unsigned char source[], in
*d++ = z_itoc(B[i]); *d++ = z_itoc(B[i]);
} }
z_expand(symbol, dest, d - dest); z_expand(symbol, dest, (int) (d - dest));
if (symbol->output_options & COMPLIANT_HEIGHT) { if (symbol->output_options & COMPLIANT_HEIGHT) {
/* ANSI/AIM BC12-1998 gives min height as 5mm or 15% of length; X left as application specification so use /* ANSI/AIM BC12-1998 gives min height as 5mm or 15% of length; X left as application specification so use
+2 -2
View File
@@ -1,7 +1,7 @@
/* codabar.c - Handles Codabar */ /* codabar.c - Handles Codabar */
/* /*
libzint - the open source barcode library libzint - the open source barcode library
Copyright (C) 2008-2025 Robin Stuart <rstuart114@gmail.com> Copyright (C) 2008-2026 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions modification, are permitted provided that the following conditions
@@ -115,7 +115,7 @@ INTERNAL int zint_codabar(struct zint_symbol *symbol, unsigned char source[], in
} }
} }
z_expand(symbol, dest, d - dest); z_expand(symbol, dest, (int) (d - dest));
if (symbol->output_options & COMPLIANT_HEIGHT) { if (symbol->output_options & COMPLIANT_HEIGHT) {
/* BS EN 798:1995 4.4.1 (d) max of 5mm / 0.43mm (X max) ~ 11.628 or 15% of width where (taking N = /* BS EN 798:1995 4.4.1 (d) max of 5mm / 0.43mm (X max) ~ 11.628 or 15% of width where (taking N =
+2 -2
View File
@@ -1,7 +1,7 @@
/* codablock.c - Handles Codablock-F */ /* codablock.c - Handles Codablock-F */
/* /*
libzint - the open source barcode library libzint - the open source barcode library
Copyright (C) 2016-2025 Harald Oehlmann Copyright (C) 2016-2026 Harald Oehlmann
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions modification, are permitted provided that the following conditions
@@ -861,7 +861,7 @@ INTERNAL int zint_codablockf(struct zint_symbol *symbol, unsigned char source[],
} }
memcpy(d, "2331112", 7); /* Stop character (106, not in `zint_C128Table[]`) */ memcpy(d, "2331112", 7); /* Stop character (106, not in `zint_C128Table[]`) */
d += 7; d += 7;
z_expand(symbol, dest, d - dest); z_expand(symbol, dest, (int) (d - dest));
} }
if (symbol->output_options & COMPLIANT_HEIGHT) { if (symbol->output_options & COMPLIANT_HEIGHT) {
+8 -8
View File
@@ -1,7 +1,7 @@
/* code.c - Handles Code 39, 39+, 93 and VIN */ /* code.c - Handles Code 39, 39+, 93 and VIN */
/* /*
libzint - the open source barcode library libzint - the open source barcode library
Copyright (C) 2008-2025 Robin Stuart <rstuart114@gmail.com> Copyright (C) 2008-2026 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions modification, are permitted provided that the following conditions
@@ -174,7 +174,7 @@ INTERNAL int zint_code39(struct zint_symbol *symbol, unsigned char source[], int
if (symbol->symbology == BARCODE_LOGMARS || symbol->symbology == BARCODE_HIBC_39) { if (symbol->symbology == BARCODE_LOGMARS || symbol->symbology == BARCODE_HIBC_39) {
/* LOGMARS and HIBC use wider 'wide' bars than normal Code 39 */ /* LOGMARS and HIBC use wider 'wide' bars than normal Code 39 */
counter = d - dest; counter = (int) (d - dest);
for (i = 0; i < counter; i++) { for (i = 0; i < counter; i++) {
if (dest[i] == '2') { if (dest[i] == '2') {
dest[i] = '3'; dest[i] = '3';
@@ -186,7 +186,7 @@ INTERNAL int zint_code39(struct zint_symbol *symbol, unsigned char source[], int
printf("Barspaces: %.*s\n", (int) (d - dest), dest); printf("Barspaces: %.*s\n", (int) (d - dest), dest);
} }
z_expand(symbol, dest, d - dest); z_expand(symbol, dest, (int) (d - dest));
if (symbol->output_options & COMPLIANT_HEIGHT) { if (symbol->output_options & COMPLIANT_HEIGHT) {
if (symbol->symbology == BARCODE_LOGMARS) { if (symbol->symbology == BARCODE_LOGMARS) {
@@ -261,7 +261,7 @@ INTERNAL int zint_excode39(struct zint_symbol *symbol, unsigned char source[], i
memcpy(b, EC39Ctrl[source[i]], 2); memcpy(b, EC39Ctrl[source[i]], 2);
b += EC39Ctrl[source[i]][1] ? 2 : 1; b += EC39Ctrl[source[i]][1] ? 2 : 1;
} }
if (b - buffer > 86) { if ((int) (b - buffer) > 86) {
return z_errtxtf(ZINT_ERROR_TOO_LONG, symbol, 317, return z_errtxtf(ZINT_ERROR_TOO_LONG, symbol, 317,
"Input too long, requires %d symbol characters (maximum 86)", (int) (b - buffer)); "Input too long, requires %d symbol characters (maximum 86)", (int) (b - buffer));
} }
@@ -275,7 +275,7 @@ INTERNAL int zint_excode39(struct zint_symbol *symbol, unsigned char source[], i
} }
/* Then send the buffer to the C39 function */ /* Then send the buffer to the C39 function */
if ((error_number = zint_code39(symbol, buffer, b - buffer)) >= ZINT_ERROR) { if ((error_number = zint_code39(symbol, buffer, (int) (b - buffer))) >= ZINT_ERROR) {
return error_number; return error_number;
} }
@@ -341,7 +341,7 @@ INTERNAL int zint_code93(struct zint_symbol *symbol, unsigned char source[], int
} }
/* Now we can check the true length of the barcode */ /* Now we can check the true length of the barcode */
h = b - buffer; h = (int) (b - buffer);
if (h > 123) { if (h > 123) {
return z_errtxtf(ZINT_ERROR_TOO_LONG, symbol, 332, return z_errtxtf(ZINT_ERROR_TOO_LONG, symbol, 332,
"Input too long, requires %d symbol characters (maximum 123)", h); "Input too long, requires %d symbol characters (maximum 123)", h);
@@ -394,7 +394,7 @@ INTERNAL int zint_code93(struct zint_symbol *symbol, unsigned char source[], int
memcpy(d, "1111411", 7); memcpy(d, "1111411", 7);
d += 7; d += 7;
z_expand(symbol, dest, d - dest); z_expand(symbol, dest, (int) (d - dest));
if (symbol->output_options & COMPLIANT_HEIGHT) { if (symbol->output_options & COMPLIANT_HEIGHT) {
/* ANSI/AIM BC5-1995 Section 2.6 minimum height 0.2" or 15% of symbol length, whichever is greater /* ANSI/AIM BC5-1995 Section 2.6 minimum height 0.2" or 15% of symbol length, whichever is greater
@@ -504,7 +504,7 @@ INTERNAL int zint_vin(struct zint_symbol *symbol, unsigned char source[], int le
memcpy(d, C39Table[43], 9); memcpy(d, C39Table[43], 9);
d += 9; d += 9;
z_expand(symbol, dest, d - dest); z_expand(symbol, dest, (int) (d - dest));
z_hrt_cpy_nochk(symbol, source, length); z_hrt_cpy_nochk(symbol, source, length);
+2 -2
View File
@@ -1,7 +1,7 @@
/* code11.c - Handles Code 11 */ /* code11.c - Handles Code 11 */
/* /*
libzint - the open source barcode library libzint - the open source barcode library
Copyright (C) 2008-2025 Robin Stuart <rstuart114@gmail.com> Copyright (C) 2008-2026 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions modification, are permitted provided that the following conditions
@@ -142,7 +142,7 @@ INTERNAL int zint_code11(struct zint_symbol *symbol, unsigned char source[], int
memcpy(d, C11Table[11], 5); memcpy(d, C11Table[11], 5);
d += 5; d += 5;
z_expand(symbol, dest, d - dest); z_expand(symbol, dest, (int) (d - dest));
/* TODO: Find documentation on BARCODE_CODE11 dimensions/height */ /* TODO: Find documentation on BARCODE_CODE11 dimensions/height */
+1 -1
View File
@@ -336,7 +336,7 @@ static void c128_expand(struct zint_symbol *symbol, int values[C128_VALUES_MAX],
} }
#endif #endif
z_expand(symbol, dest, d - dest); z_expand(symbol, dest, (int) (d - dest));
} }
/* Helper to set `priority` array based on flags */ /* Helper to set `priority` array based on flags */
+2 -2
View File
@@ -1,7 +1,7 @@
/* code16k.c - Handles Code 16k stacked symbology */ /* code16k.c - Handles Code 16k stacked symbology */
/* /*
libzint - the open source barcode library libzint - the open source barcode library
Copyright (C) 2008-2025 Robin Stuart <rstuart114@gmail.com> Copyright (C) 2008-2026 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions modification, are permitted provided that the following conditions
@@ -560,7 +560,7 @@ INTERNAL int zint_code16k(struct zint_symbol *symbol, unsigned char source[], in
/* Write the information into the symbol */ /* Write the information into the symbol */
writer = 0; writer = 0;
flip_flop = 1; flip_flop = 1;
for (mx_reader = 0, len = d - width_pattern; mx_reader < len; mx_reader++) { for (mx_reader = 0, len = (int) (d - width_pattern); mx_reader < len; mx_reader++) {
for (looper = 0; looper < z_ctoi(width_pattern[mx_reader]); looper++) { for (looper = 0; looper < z_ctoi(width_pattern[mx_reader]); looper++) {
if (flip_flop == 1) { if (flip_flop == 1) {
z_set_module(symbol, current_row, writer); z_set_module(symbol, current_row, writer);
+2 -2
View File
@@ -1,7 +1,7 @@
/* code49.c - Handles Code 49 */ /* code49.c - Handles Code 49 */
/* /*
libzint - the open source barcode library libzint - the open source barcode library
Copyright (C) 2009-2025 Robin Stuart <rstuart114@gmail.com> Copyright (C) 2009-2026 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions modification, are permitted provided that the following conditions
@@ -79,7 +79,7 @@ INTERNAL int zint_code49(struct zint_symbol *symbol, unsigned char source[], int
codeword_count = 0; codeword_count = 0;
i = 0; i = 0;
h = d - intermediate; h = (int) (d - intermediate);
do { do {
if (z_isdigit(intermediate[i])) { if (z_isdigit(intermediate[i])) {
/* Numeric data */ /* Numeric data */
+1 -1
View File
@@ -161,7 +161,7 @@ INTERNAL int z_posn(const char set_string[], const char data) {
for (s = set_string; *s; s++) { for (s = set_string; *s; s++) {
if (data == *s) { if (data == *s) {
return s - set_string; return (int) (s - set_string);
} }
} }
return -1; return -1;
+40 -40
View File
@@ -86,7 +86,7 @@ static int gs1_numeric(const unsigned char *data, int data_len, int offset, int
for (; d < de; d++) { for (; d < de; d++) {
if (!z_isdigit(*d)) { if (!z_isdigit(*d)) {
*p_err_no = 3; *p_err_no = 3;
*p_err_posn = d - data + 1; *p_err_posn = (int) (d - data) + 1;
return gs1_err_msg_printf_nochk(err_msg, "Non-numeric character '%c'", *d); return gs1_err_msg_printf_nochk(err_msg, "Non-numeric character '%c'", *d);
} }
} }
@@ -136,7 +136,7 @@ static int gs1_cset82(const unsigned char *data, int data_len, int offset, int m
for (; d < de; d++) { for (; d < de; d++) {
if (*d < '!' || *d > 'z' || gs1_c82[*d - '!'] == 82) { if (*d < '!' || *d > 'z' || gs1_c82[*d - '!'] == 82) {
*p_err_no = 3; *p_err_no = 3;
*p_err_posn = d - data + 1; *p_err_posn = (int) (d - data) + 1;
return gs1_err_msg_printf_nochk(err_msg, "Invalid CSET 82 character '%c'", *d); return gs1_err_msg_printf_nochk(err_msg, "Invalid CSET 82 character '%c'", *d);
} }
} }
@@ -164,7 +164,7 @@ static int gs1_cset39(const unsigned char *data, int data_len, int offset, int m
/* 0-9, A-Z and "#", "-", "/" */ /* 0-9, A-Z and "#", "-", "/" */
if ((*d < '0' && *d != '#' && *d != '-' && *d != '/') || (*d > '9' && *d < 'A') || *d > 'Z') { if ((*d < '0' && *d != '#' && *d != '-' && *d != '/') || (*d > '9' && *d < 'A') || *d > 'Z') {
*p_err_no = 3; *p_err_no = 3;
*p_err_posn = d - data + 1; *p_err_posn = (int) (d - data) + 1;
return gs1_err_msg_printf_nochk(err_msg, "Invalid CSET 39 character '%c'", *d); return gs1_err_msg_printf_nochk(err_msg, "Invalid CSET 39 character '%c'", *d);
} }
} }
@@ -196,7 +196,7 @@ static int gs1_cset64(const unsigned char *data, int data_len, int offset, int m
break; break;
} }
*p_err_no = 3; *p_err_no = 3;
*p_err_posn = d - data + 1; *p_err_posn = (int) (d - data) + 1;
return gs1_err_msg_printf_nochk(err_msg, "Invalid CSET 64 character '%c'", *d); return gs1_err_msg_printf_nochk(err_msg, "Invalid CSET 64 character '%c'", *d);
} }
} }
@@ -232,7 +232,7 @@ static int gs1_csum(const unsigned char *data, int data_len, int offset, int min
} }
if (checksum != *d - '0') { if (checksum != *d - '0') {
*p_err_no = 3; *p_err_no = 3;
*p_err_posn = d - data + 1; *p_err_posn = (int) (d - data) + 1;
return gs1_err_msg_printf_nochk(err_msg, "Bad checksum '%c', expected '%c'", *d, checksum + '0'); return gs1_err_msg_printf_nochk(err_msg, "Bad checksum '%c', expected '%c'", *d, checksum + '0');
} }
} }
@@ -274,7 +274,7 @@ static int gs1_csumalpha(const unsigned char *data, int data_len, int offset, in
if (de[0] != c1 || de[1] != c2) { if (de[0] != c1 || de[1] != c2) {
*p_err_no = 3; *p_err_no = 3;
*p_err_posn = (de - data) + 1; *p_err_posn = (int) (de - data) + 1;
return gs1_err_msg_printf_nochk(err_msg, "Bad checksum '%.2s', expected '%c%c'", de, c1, c2); return gs1_err_msg_printf_nochk(err_msg, "Bad checksum '%.2s', expected '%c%c'", de, c1, c2);
} }
} }
@@ -665,12 +665,12 @@ static int gs1_pcenc(const unsigned char *data, int data_len, int offset, int mi
if (*d == '%') { if (*d == '%') {
if (de - d < 3) { if (de - d < 3) {
*p_err_no = 3; *p_err_no = 3;
*p_err_posn = d - data + 1; *p_err_posn = (int) (d - data) + 1;
return gs1_err_msg_cpy_nochk(err_msg, "Invalid % escape"); return gs1_err_msg_cpy_nochk(err_msg, "Invalid % escape");
} }
if (strchr(hex_chars, *(++d)) == NULL || strchr(hex_chars, *(++d)) == NULL) { if (strchr(hex_chars, *(++d)) == NULL || strchr(hex_chars, *(++d)) == NULL) {
*p_err_no = 3; *p_err_no = 3;
*p_err_posn = d - data + 1; *p_err_posn = (int) (d - data) + 1;
return gs1_err_msg_cpy_nochk(err_msg, "Invalid character for percent encoding"); return gs1_err_msg_cpy_nochk(err_msg, "Invalid character for percent encoding");
} }
} }
@@ -858,19 +858,19 @@ static int gs1_iban(const unsigned char *data, int data_len, int offset, int min
/* 1st 2 chars alphabetic country code */ /* 1st 2 chars alphabetic country code */
if (!z_isupper(d[0]) || !z_isupper(d[1])) { if (!z_isupper(d[0]) || !z_isupper(d[1])) {
*p_err_no = 3; *p_err_no = 3;
*p_err_posn = d - data + 1; *p_err_posn = (int) (d - data) + 1;
return gs1_err_msg_printf_nochk(err_msg, "Non-alphabetic IBAN country code '%.2s'", d); return gs1_err_msg_printf_nochk(err_msg, "Non-alphabetic IBAN country code '%.2s'", d);
} }
if (!iso3166_alpha2((const char *) d)) { if (!iso3166_alpha2((const char *) d)) {
*p_err_no = 3; *p_err_no = 3;
*p_err_posn = d - data + 1; *p_err_posn = (int) (d - data) + 1;
return gs1_err_msg_printf_nochk(err_msg, "Invalid IBAN country code '%.2s'", d); return gs1_err_msg_printf_nochk(err_msg, "Invalid IBAN country code '%.2s'", d);
} }
d += 2; d += 2;
/* 2nd 2 chars numeric checksum */ /* 2nd 2 chars numeric checksum */
if (!z_isdigit(d[0]) || !z_isdigit(d[1])) { if (!z_isdigit(d[0]) || !z_isdigit(d[1])) {
*p_err_no = 3; *p_err_no = 3;
*p_err_posn = d - data + 1; *p_err_posn = (int) (d - data) + 1;
return gs1_err_msg_printf_nochk(err_msg, "Non-numeric IBAN checksum '%.2s'", d); return gs1_err_msg_printf_nochk(err_msg, "Non-numeric IBAN checksum '%.2s'", d);
} }
given_checksum = z_to_int(d, 2); given_checksum = z_to_int(d, 2);
@@ -879,7 +879,7 @@ static int gs1_iban(const unsigned char *data, int data_len, int offset, int min
/* 0-9, A-Z */ /* 0-9, A-Z */
if (*d < '0' || (*d > '9' && *d < 'A') || *d > 'Z') { if (*d < '0' || (*d > '9' && *d < 'A') || *d > 'Z') {
*p_err_no = 3; *p_err_no = 3;
*p_err_posn = d - data + 1; *p_err_posn = (int) (d - data) + 1;
return gs1_err_msg_printf_nochk(err_msg, "Invalid IBAN character '%c'", *d); return gs1_err_msg_printf_nochk(err_msg, "Invalid IBAN character '%c'", *d);
} }
if (*d >= 'A') { if (*d >= 'A') {
@@ -944,14 +944,14 @@ static const unsigned char *gs1_coupon_vli(const unsigned char *data, const int
if (d - data + 1 > data_len) { if (d - data + 1 > data_len) {
*p_err_no = 3; *p_err_no = 3;
*p_err_posn = d - data + 1; *p_err_posn = (int) (d - data) + 1;
(void) gs1_err_msg_printf_nochk(err_msg, "%s VLI missing", name); (void) gs1_err_msg_printf_nochk(err_msg, "%s VLI missing", name);
return NULL; return NULL;
} }
vli = z_to_int(d, 1); vli = z_to_int(d, 1);
if ((vli < vli_min || vli > vli_max) && (vli != 9 || !vli_nine)) { if ((vli < vli_min || vli > vli_max) && (vli != 9 || !vli_nine)) {
*p_err_no = 3; *p_err_no = 3;
*p_err_posn = d - data + 1; *p_err_posn = (int) (d - data) + 1;
if (vli < 0) { if (vli < 0) {
(void) gs1_err_msg_printf_nochk(err_msg, "Non-numeric %s VLI '%c'", name, *d); (void) gs1_err_msg_printf_nochk(err_msg, "Non-numeric %s VLI '%c'", name, *d);
} else { } else {
@@ -963,7 +963,7 @@ static const unsigned char *gs1_coupon_vli(const unsigned char *data, const int
if (vli != 9 || !vli_nine) { if (vli != 9 || !vli_nine) {
if (d - data + vli + vli_offset > data_len) { if (d - data + vli + vli_offset > data_len) {
*p_err_no = 3; *p_err_no = 3;
*p_err_posn = d - data + 1; *p_err_posn = (int) (d - data) + 1;
(void) gs1_err_msg_printf_nochk(err_msg, "%s incomplete", name); (void) gs1_err_msg_printf_nochk(err_msg, "%s incomplete", name);
return NULL; return NULL;
} }
@@ -971,7 +971,7 @@ static const unsigned char *gs1_coupon_vli(const unsigned char *data, const int
for (; d < de; d++) { for (; d < de; d++) {
if (!z_isdigit(*d)) { if (!z_isdigit(*d)) {
*p_err_no = 3; *p_err_no = 3;
*p_err_posn = d - data + 1; *p_err_posn = (int) (d - data) + 1;
(void) gs1_err_msg_printf_nochk(err_msg, "Non-numeric %s '%c'", name, *d); (void) gs1_err_msg_printf_nochk(err_msg, "Non-numeric %s '%c'", name, *d);
return NULL; return NULL;
} }
@@ -988,14 +988,14 @@ static const unsigned char *gs1_coupon_val(const unsigned char *data, const int
if (d - data + val_len > data_len) { if (d - data + val_len > data_len) {
*p_err_no = 3; *p_err_no = 3;
*p_err_posn = d - data + 1; *p_err_posn = (int) (d - data) + 1;
(void) gs1_err_msg_printf_nochk(err_msg, "%s incomplete", name); (void) gs1_err_msg_printf_nochk(err_msg, "%s incomplete", name);
return NULL; return NULL;
} }
val = z_to_int(d, val_len); val = z_to_int(d, val_len);
if (val < 0) { if (val < 0) {
*p_err_no = 3; *p_err_no = 3;
*p_err_posn = d - data + 1; *p_err_posn = (int) (d - data) + 1;
(void) gs1_err_msg_printf_nochk(err_msg, "Non-numeric %s", name); (void) gs1_err_msg_printf_nochk(err_msg, "Non-numeric %s", name);
return NULL; return NULL;
} }
@@ -1059,7 +1059,7 @@ static int gs1_couponcode(const unsigned char *data, int data_len, int offset, i
} }
if (val > 5 && val < 9) { if (val > 5 && val < 9) {
*p_err_no = 3; *p_err_no = 3;
*p_err_posn = d - 1 - data + 1; *p_err_posn = (int) (d - 1 - data) + 1;
return gs1_err_msg_printf_nochk(err_msg, "Invalid Primary Purch. Req. Code '%c'", *(d - 1)); return gs1_err_msg_printf_nochk(err_msg, "Invalid Primary Purch. Req. Code '%c'", *(d - 1));
} }
if (!(d = gs1_coupon_val(data, data_len, d, "Primary Purch. Family Code", 3, NULL, p_err_no, p_err_posn, if (!(d = gs1_coupon_val(data, data_len, d, "Primary Purch. Family Code", 3, NULL, p_err_no, p_err_posn,
@@ -1080,7 +1080,7 @@ static int gs1_couponcode(const unsigned char *data, int data_len, int offset, i
} }
if (val > 3) { if (val > 3) {
*p_err_no = 3; *p_err_no = 3;
*p_err_posn = d - 1 - data + 1; *p_err_posn = (int) (d - 1 - data) + 1;
return gs1_err_msg_printf_nochk(err_msg, "Invalid Add. Purch. Rules Code '%c'", *(d - 1)); return gs1_err_msg_printf_nochk(err_msg, "Invalid Add. Purch. Rules Code '%c'", *(d - 1));
} }
if (!(d = gs1_coupon_vli(data, data_len, d, "2nd Purch. Req.", 0, 1, 5, 0, p_err_no, p_err_posn, if (!(d = gs1_coupon_vli(data, data_len, d, "2nd Purch. Req.", 0, 1, 5, 0, p_err_no, p_err_posn,
@@ -1093,7 +1093,7 @@ static int gs1_couponcode(const unsigned char *data, int data_len, int offset, i
} }
if (val > 4 && val < 9) { if (val > 4 && val < 9) {
*p_err_no = 3; *p_err_no = 3;
*p_err_posn = d - 1 - data + 1; *p_err_posn = (int) (d - 1 - data) + 1;
return gs1_err_msg_printf_nochk(err_msg, "Invalid 2nd Purch. Req. Code '%c'", *(d - 1)); return gs1_err_msg_printf_nochk(err_msg, "Invalid 2nd Purch. Req. Code '%c'", *(d - 1));
} }
if (!(d = gs1_coupon_val(data, data_len, d, "2nd Purch. Family Code", 3, NULL, p_err_no, p_err_posn, if (!(d = gs1_coupon_val(data, data_len, d, "2nd Purch. Family Code", 3, NULL, p_err_no, p_err_posn,
@@ -1117,7 +1117,7 @@ static int gs1_couponcode(const unsigned char *data, int data_len, int offset, i
} }
if (val > 4 && val < 9) { if (val > 4 && val < 9) {
*p_err_no = 3; *p_err_no = 3;
*p_err_posn = d - 1 - data + 1; *p_err_posn = (int) (d - 1 - data) + 1;
return gs1_err_msg_printf_nochk(err_msg, "Invalid 3rd Purch. Req. Code '%c'", *(d - 1)); return gs1_err_msg_printf_nochk(err_msg, "Invalid 3rd Purch. Req. Code '%c'", *(d - 1));
} }
if (!(d = gs1_coupon_val(data, data_len, d, "3rd Purch. Family Code", 3, NULL, p_err_no, p_err_posn, if (!(d = gs1_coupon_val(data, data_len, d, "3rd Purch. Family Code", 3, NULL, p_err_no, p_err_posn,
@@ -1135,7 +1135,7 @@ static int gs1_couponcode(const unsigned char *data, int data_len, int offset, i
err_msg))) { err_msg))) {
return 0; return 0;
} }
if (!gs1_yymmd0(data, data_len, d - 6 - data, 6, 6, p_err_no, p_err_posn, err_msg, 0)) { if (!gs1_yymmd0(data, data_len, (int) (d - 6 - data), 6, 6, p_err_no, p_err_posn, err_msg, 0)) {
return 0; return 0;
} }
@@ -1144,7 +1144,7 @@ static int gs1_couponcode(const unsigned char *data, int data_len, int offset, i
if (!(d = gs1_coupon_val(data, data_len, d, "Start Date", 6, NULL, p_err_no, p_err_posn, err_msg))) { if (!(d = gs1_coupon_val(data, data_len, d, "Start Date", 6, NULL, p_err_no, p_err_posn, err_msg))) {
return 0; return 0;
} }
if (!gs1_yymmd0(data, data_len, d - 6 - data, 6, 6, p_err_no, p_err_posn, err_msg, 0)) { if (!gs1_yymmd0(data, data_len, (int) (d - 6 - data), 6, 6, p_err_no, p_err_posn, err_msg, 0)) {
return 0; return 0;
} }
@@ -1170,7 +1170,7 @@ static int gs1_couponcode(const unsigned char *data, int data_len, int offset, i
} }
if ((val > 2 && val < 5) || val > 6) { if ((val > 2 && val < 5) || val > 6) {
*p_err_no = 3; *p_err_no = 3;
*p_err_posn = d - 1 - data + 1; *p_err_posn = (int) (d - 1 - data) + 1;
return gs1_err_msg_printf_nochk(err_msg, "Invalid Save Value Code '%c'", *(d - 1)); return gs1_err_msg_printf_nochk(err_msg, "Invalid Save Value Code '%c'", *(d - 1));
} }
if (!(d = gs1_coupon_val(data, data_len, d, "Save Value Applies To", 1, &val, p_err_no, p_err_posn, if (!(d = gs1_coupon_val(data, data_len, d, "Save Value Applies To", 1, &val, p_err_no, p_err_posn,
@@ -1179,7 +1179,7 @@ static int gs1_couponcode(const unsigned char *data, int data_len, int offset, i
} }
if (val > 2) { if (val > 2) {
*p_err_no = 3; *p_err_no = 3;
*p_err_posn = d - 1 - data + 1; *p_err_posn = (int) (d - 1 - data) + 1;
return gs1_err_msg_printf_nochk(err_msg, "Invalid Save Value Applies To '%c'", *(d - 1)); return gs1_err_msg_printf_nochk(err_msg, "Invalid Save Value Applies To '%c'", *(d - 1));
} }
if (!(d = gs1_coupon_val(data, data_len, d, "Store Coupon Flag", 1, NULL, p_err_no, p_err_posn, if (!(d = gs1_coupon_val(data, data_len, d, "Store Coupon Flag", 1, NULL, p_err_no, p_err_posn,
@@ -1192,14 +1192,14 @@ static int gs1_couponcode(const unsigned char *data, int data_len, int offset, i
} }
if (val > 1) { if (val > 1) {
*p_err_no = 3; *p_err_no = 3;
*p_err_posn = d - 1 - data + 1; *p_err_posn = (int) (d - 1 - data) + 1;
return gs1_err_msg_printf_nochk(err_msg, "Invalid Don't Multiply Flag '%c'", *(d - 1)); return gs1_err_msg_printf_nochk(err_msg, "Invalid Don't Multiply Flag '%c'", *(d - 1));
} }
} else { } else {
*p_err_no = 3; *p_err_no = 3;
*p_err_posn = d - 1 - data + 1; *p_err_posn = (int) (d - 1 - data) + 1;
if (data_field < 0) { if (data_field < 0) {
(void) gs1_err_msg_printf_nochk(err_msg, "Non-numeric Data Field '%c'", *(d - 1)); (void) gs1_err_msg_printf_nochk(err_msg, "Non-numeric Data Field '%c'", *(d - 1));
} else { } else {
@@ -1247,7 +1247,7 @@ static int gs1_couponposoffer(const unsigned char *data, int data_len, int offse
} }
if (val != 0 && val != 1) { if (val != 0 && val != 1) {
*p_err_no = 3; *p_err_no = 3;
*p_err_posn = d - 1 - data + 1; *p_err_posn = (int) (d - 1 - data) + 1;
return gs1_err_msg_cpy_nochk(err_msg, "Coupon Format must be 0 or 1"); return gs1_err_msg_cpy_nochk(err_msg, "Coupon Format must be 0 or 1");
} }
if (!(d = gs1_coupon_vli(data, data_len, d, "Coupon Funder ID", 6, 0, 6, 0, p_err_no, p_err_posn, err_msg))) { if (!(d = gs1_coupon_vli(data, data_len, d, "Coupon Funder ID", 6, 0, 6, 0, p_err_no, p_err_posn, err_msg))) {
@@ -1261,7 +1261,7 @@ static int gs1_couponposoffer(const unsigned char *data, int data_len, int offse
} }
if (d - data != data_len) { if (d - data != data_len) {
*p_err_no = 3; *p_err_no = 3;
*p_err_posn = d - data + 1; *p_err_posn = (int) (d - data) + 1;
return gs1_err_msg_cpy_nochk(err_msg, "Reserved trailing characters"); return gs1_err_msg_cpy_nochk(err_msg, "Reserved trailing characters");
} }
} }
@@ -1290,7 +1290,7 @@ static int gs1_latitude(const unsigned char *data, int data_len, int offset, int
} }
if (lat > 1800000000) { if (lat > 1800000000) {
*p_err_no = 3; *p_err_no = 3;
*p_err_posn = d - 1 - data + 1; *p_err_posn = (int) (d - 1 - data) + 1;
return gs1_err_msg_cpy_nochk(err_msg, "Invalid latitude"); return gs1_err_msg_cpy_nochk(err_msg, "Invalid latitude");
} }
} }
@@ -1319,7 +1319,7 @@ static int gs1_longitude(const unsigned char *data, int data_len, int offset, in
} }
if (lng > 3600000000) { if (lng > 3600000000) {
*p_err_no = 3; *p_err_no = 3;
*p_err_posn = d - 1 - data + 1; *p_err_posn = (int) (d - 1 - data) + 1;
return gs1_err_msg_cpy_nochk(err_msg, "Invalid longitude"); return gs1_err_msg_cpy_nochk(err_msg, "Invalid longitude");
} }
} }
@@ -1348,7 +1348,7 @@ static int gs1_mediatype(const unsigned char *data, int data_len, int offset, in
} }
if (val == 0 || (val > 10 && val < 80)) { if (val == 0 || (val > 10 && val < 80)) {
*p_err_no = 3; *p_err_no = 3;
*p_err_posn = d - data + 1; *p_err_posn = (int) (d - data) + 1;
return gs1_err_msg_cpy_nochk(err_msg, "Invalid AIDC media type"); return gs1_err_msg_cpy_nochk(err_msg, "Invalid AIDC media type");
} }
} }
@@ -1373,7 +1373,7 @@ static int gs1_hyphen(const unsigned char *data, int data_len, int offset, int m
for (; d < de; d++) { for (; d < de; d++) {
if (*d != '-') { if (*d != '-') {
*p_err_no = 3; *p_err_no = 3;
*p_err_posn = d - data + 1; *p_err_posn = (int) (d - data) + 1;
return gs1_err_msg_cpy_nochk(err_msg, "Invalid temperature indicator (hyphen only)"); return gs1_err_msg_cpy_nochk(err_msg, "Invalid temperature indicator (hyphen only)");
} }
} }
@@ -1425,17 +1425,17 @@ static int gs1_posinseqslash(const unsigned char *data, int data_len, int offset
if (!z_isdigit(*d)) { if (!z_isdigit(*d)) {
if (*d != '/') { if (*d != '/') {
*p_err_no = 3; *p_err_no = 3;
*p_err_posn = d - data + 1; *p_err_posn = (int) (d - data) + 1;
return gs1_err_msg_printf_nochk(err_msg, "Invalid character '%c' in sequence", *d); return gs1_err_msg_printf_nochk(err_msg, "Invalid character '%c' in sequence", *d);
} }
if (slash) { if (slash) {
*p_err_no = 3; *p_err_no = 3;
*p_err_posn = d - data + 1; *p_err_posn = (int) (d - data) + 1;
return gs1_err_msg_cpy_nochk(err_msg, "Single sequence separator ('/') only"); return gs1_err_msg_cpy_nochk(err_msg, "Single sequence separator ('/') only");
} }
if (d == data + offset || d + 1 == de) { if (d == data + offset || d + 1 == de) {
*p_err_no = 3; *p_err_no = 3;
*p_err_posn = d - data + 1; *p_err_posn = (int) (d - data) + 1;
return gs1_err_msg_cpy_nochk(err_msg, "Sequence separator '/' cannot start or end"); return gs1_err_msg_cpy_nochk(err_msg, "Sequence separator '/' cannot start or end");
} }
slash = d; slash = d;
@@ -1446,16 +1446,16 @@ static int gs1_posinseqslash(const unsigned char *data, int data_len, int offset
*p_err_posn = offset + 1; *p_err_posn = offset + 1;
return gs1_err_msg_cpy_nochk(err_msg, "No sequence separator ('/')"); return gs1_err_msg_cpy_nochk(err_msg, "No sequence separator ('/')");
} }
pos = z_to_int(data + offset, slash - (data + offset)); pos = z_to_int(data + offset, (int) (slash - (data + offset)));
if (pos == 0) { if (pos == 0) {
*p_err_no = 3; *p_err_no = 3;
*p_err_posn = offset + 1; *p_err_posn = offset + 1;
return gs1_err_msg_cpy_nochk(err_msg, "Sequence position cannot be zero"); return gs1_err_msg_cpy_nochk(err_msg, "Sequence position cannot be zero");
} }
tot = z_to_int(slash + 1, de - (slash + 1)); tot = z_to_int(slash + 1, (int) (de - (slash + 1)));
if (tot == 0) { if (tot == 0) {
*p_err_no = 3; *p_err_no = 3;
*p_err_posn = slash + 1 - data + 1; *p_err_posn = (int) (slash + 1 - data) + 1;
return gs1_err_msg_cpy_nochk(err_msg, "Sequence total cannot be zero"); return gs1_err_msg_cpy_nochk(err_msg, "Sequence total cannot be zero");
} }
if (pos > tot) { if (pos > tot) {
+2 -2
View File
@@ -1,7 +1,7 @@
/* mailmark.c - Royal Mail 4-state and 2D Mailmark barcodes */ /* mailmark.c - Royal Mail 4-state and 2D Mailmark barcodes */
/* /*
libzint - the open source barcode library libzint - the open source barcode library
Copyright (C) 2008-2025 Robin Stuart <rstuart114@gmail.com> Copyright (C) 2008-2026 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions modification, are permitted provided that the following conditions
@@ -467,7 +467,7 @@ INTERNAL int zint_mailmark_4s(struct zint_symbol *symbol, unsigned char source[]
/* Translate 4-state data pattern to symbol */ /* Translate 4-state data pattern to symbol */
j = 0; j = 0;
for (i = 0, len = d - bar; i < len; i++) { for (i = 0, len = (int) (d - bar); i < len; i++) {
if (bar[i] == 'F' || bar[i] == 'A') { if (bar[i] == 'F' || bar[i] == 'A') {
z_set_module(symbol, 0, j); z_set_module(symbol, 0, j);
} }
+3 -3
View File
@@ -83,14 +83,14 @@ INTERNAL int zint_pharma(struct zint_symbol *symbol, unsigned char source[], int
} }
} while (tester != 0); } while (tester != 0);
h = in - inter; h = (int) (in - inter);
for (counter = h - 1; counter >= 0; counter--) { for (counter = h - 1; counter >= 0; counter--) {
*d++ = inter[counter] == 'W' ? '3' : '1'; *d++ = inter[counter] == 'W' ? '3' : '1';
*d++ = '2'; *d++ = '2';
} }
*--d = '\0'; /* Chop off final bar */ *--d = '\0'; /* Chop off final bar */
z_expand(symbol, dest, d - dest); z_expand(symbol, dest, (int) (d - dest));
if (symbol->output_options & COMPLIANT_HEIGHT) { if (symbol->output_options & COMPLIANT_HEIGHT) {
/* Laetus Pharmacode Guide 1.2 Standard one-track height 8mm / 0.5mm (X) */ /* Laetus Pharmacode Guide 1.2 Standard one-track height 8mm / 0.5mm (X) */
@@ -133,7 +133,7 @@ static int pharma_two_calc(int tester, char *d) {
} }
} while (tester != 0); } while (tester != 0);
h = in - inter; h = (int) (in - inter);
for (counter = h - 1; counter >= 0; counter--) { for (counter = h - 1; counter >= 0; counter--) {
*d++ = inter[counter]; *d++ = inter[counter];
} }
+3 -3
View File
@@ -1,7 +1,7 @@
/* plessey.c - Handles Plessey and MSI Plessey */ /* plessey.c - Handles Plessey and MSI Plessey */
/* /*
libzint - the open source barcode library libzint - the open source barcode library
Copyright (C) 2008-2025 Robin Stuart <rstuart114@gmail.com> Copyright (C) 2008-2026 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions modification, are permitted provided that the following conditions
@@ -116,7 +116,7 @@ INTERNAL int zint_plessey(struct zint_symbol *symbol, unsigned char source[], in
memcpy(d, "331311313", 9); memcpy(d, "331311313", 9);
d += 9; d += 9;
z_expand(symbol, dest, d - dest); z_expand(symbol, dest, (int) (d - dest));
/* TODO: Find documentation on BARCODE_PLESSEY dimensions/height */ /* TODO: Find documentation on BARCODE_PLESSEY dimensions/height */
@@ -375,7 +375,7 @@ INTERNAL int zint_msi_plessey(struct zint_symbol *symbol, unsigned char source[]
memcpy(d, "121", 3); memcpy(d, "121", 3);
d += 3; d += 3;
z_expand(symbol, dest, d - dest); z_expand(symbol, dest, (int) (d - dest));
/* TODO: Find documentation on BARCODE_MSI_PLESSEY dimensions/height */ /* TODO: Find documentation on BARCODE_MSI_PLESSEY dimensions/height */
+5 -5
View File
@@ -1,7 +1,7 @@
/* postal.c - Handles POSTNET, PLANET, CEPNet, FIM. RM4SCC and Flattermarken */ /* postal.c - Handles POSTNET, PLANET, CEPNet, FIM. RM4SCC and Flattermarken */
/* /*
libzint - the open source barcode library libzint - the open source barcode library
Copyright (C) 2008-2025 Robin Stuart <rstuart114@gmail.com> Copyright (C) 2008-2026 Robin Stuart <rstuart114@gmail.com>
Including bug fixes by Bryan Hatton Including bug fixes by Bryan Hatton
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
@@ -330,7 +330,7 @@ INTERNAL int zint_koreapost(struct zint_symbol *symbol, unsigned char source[],
memcpy(d, KoreaTable[check], 10); memcpy(d, KoreaTable[check], 10);
d += KoreaTable[check][8] ? 10 : 8; d += KoreaTable[check][8] ? 10 : 8;
z_expand(symbol, dest, d - dest); z_expand(symbol, dest, (int) (d - dest));
/* TODO: Find documentation on BARCODE_KOREAPOST dimensions/height */ /* TODO: Find documentation on BARCODE_KOREAPOST dimensions/height */
@@ -557,7 +557,7 @@ INTERNAL int zint_kix(struct zint_symbol *symbol, unsigned char source[], int le
} }
writer = 0; writer = 0;
h = d - height_pattern; h = (int) (d - height_pattern);
for (loopey = 0; loopey < h; loopey++) { for (loopey = 0; loopey < h; loopey++) {
if (height_pattern[loopey] == '1' || height_pattern[loopey] == '0') { if (height_pattern[loopey] == '1' || height_pattern[loopey] == '0') {
z_set_module(symbol, 0, writer); z_set_module(symbol, 0, writer);
@@ -668,7 +668,7 @@ INTERNAL int zint_flat(struct zint_symbol *symbol, unsigned char source[], int l
d += entry[2] ? 4 : 2; d += entry[2] ? 4 : 2;
} }
z_expand(symbol, dest, d - dest); z_expand(symbol, dest, (int) (d - dest));
/* TODO: Find documentation on BARCODE_FLAT dimensions/height */ /* TODO: Find documentation on BARCODE_FLAT dimensions/height */
@@ -760,7 +760,7 @@ INTERNAL int zint_japanpost(struct zint_symbol *symbol, unsigned char source[],
/* Resolve pattern to 4-state symbols */ /* Resolve pattern to 4-state symbols */
writer = 0; writer = 0;
h = d - pattern; h = (int) (d - pattern);
for (loopey = 0; loopey < h; loopey++) { for (loopey = 0; loopey < h; loopey++) {
if (pattern[loopey] == '2' || pattern[loopey] == '1') { if (pattern[loopey] == '2' || pattern[loopey] == '1') {
z_set_module(symbol, 0, writer); z_set_module(symbol, 0, writer);
+3 -3
View File
@@ -1,7 +1,7 @@
/* telepen.c - Handles Telepen and Telepen numeric */ /* telepen.c - Handles Telepen and Telepen numeric */
/* /*
libzint - the open source barcode library libzint - the open source barcode library
Copyright (C) 2008-2025 Robin Stuart <rstuart114@gmail.com> Copyright (C) 2008-2026 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions modification, are permitted provided that the following conditions
@@ -128,7 +128,7 @@ INTERNAL int zint_telepen(struct zint_symbol *symbol, unsigned char source[], in
memcpy(d, TeleTable['z'], 12); memcpy(d, TeleTable['z'], 12);
d += 12; d += 12;
z_expand(symbol, dest, d - dest); z_expand(symbol, dest, (int) (d - dest));
if (symbol->output_options & COMPLIANT_HEIGHT) { if (symbol->output_options & COMPLIANT_HEIGHT) {
/* Default height from various Telepen docs is based on default 26pt at X 0.01125" /* Default height from various Telepen docs is based on default 26pt at X 0.01125"
@@ -210,7 +210,7 @@ INTERNAL int zint_telepen_num(struct zint_symbol *symbol, unsigned char source[]
memcpy(d, TeleTable['z'], 12); memcpy(d, TeleTable['z'], 12);
d += 12; d += 12;
z_expand(symbol, dest, d - dest); z_expand(symbol, dest, (int) (d - dest));
if (symbol->output_options & COMPLIANT_HEIGHT) { if (symbol->output_options & COMPLIANT_HEIGHT) {
(void) z_set_height(symbol, 0.0f, 32.0f, 0, 1 /*no_errtxt*/); /* Same as alphanumeric Telepen */ (void) z_set_height(symbol, 0.0f, 32.0f, 0, 1 /*no_errtxt*/); /* Same as alphanumeric Telepen */
+3 -3
View File
@@ -111,7 +111,7 @@ static void test_bwipp_random(const testCtx *const p_ctx, const struct random_it
bwipp_buf, sizeof(bwipp_buf), NULL); bwipp_buf, sizeof(bwipp_buf), NULL);
assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret);
bwipp_len = strlen(bwipp_buf); bwipp_len = (int) strlen(bwipp_buf);
assert_nonzero(bwipp_len, "i:%d bwipp_len %d = 0\n", i, bwipp_len); assert_nonzero(bwipp_len, "i:%d bwipp_len %d = 0\n", i, bwipp_len);
symbol->width = width_func ? width_func(rdata, bwipp_len) : bwipp_len; symbol->width = width_func ? width_func(rdata, bwipp_len) : bwipp_len;
@@ -405,7 +405,7 @@ static void test_aztec_bwipjs_354(const testCtx *const p_ctx) {
sizeof(bwipp_buf), NULL); sizeof(bwipp_buf), NULL);
assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret);
bwipp_len = strlen(bwipp_buf); bwipp_len = (int) strlen(bwipp_buf);
assert_nonzero(bwipp_len, "i:%d bwipp_len %d = 0\n", i, bwipp_len); assert_nonzero(bwipp_len, "i:%d bwipp_len %d = 0\n", i, bwipp_len);
symbol->width = sqrt_width_func(NULL /*rdata*/, bwipp_len); symbol->width = sqrt_width_func(NULL /*rdata*/, bwipp_len);
@@ -496,7 +496,7 @@ static void test_codablockf_fnc4_digit(const testCtx *const p_ctx) {
bwipp_buf, sizeof(bwipp_buf), NULL); bwipp_buf, sizeof(bwipp_buf), NULL);
assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret);
bwipp_len = strlen(bwipp_buf); bwipp_len = (int) strlen(bwipp_buf);
assert_nonzero(bwipp_len, "i:%d bwipp_len %d = 0\n", i, bwipp_len); assert_nonzero(bwipp_len, "i:%d bwipp_len %d = 0\n", i, bwipp_len);
symbol->width = codablockf_width_func(rdata, bwipp_len); symbol->width = codablockf_width_func(rdata, bwipp_len);
+1 -1
View File
@@ -1468,7 +1468,7 @@ static void test_encode_file_unreadable(const testCtx *const p_ctx) {
fd = creat(filename, S_IWUSR); fd = creat(filename, S_IWUSR);
assert_notequal(fd, -1, "Unreadable input file (%s) not created == -1 (%d: %s)\n", assert_notequal(fd, -1, "Unreadable input file (%s) not created == -1 (%d: %s)\n",
filename, errno, strerror(errno)); filename, errno, strerror(errno));
ret = write(fd, buf, 1); ret = (int) write(fd, buf, 1);
assert_equal(ret, 1, "Unreadable write ret %d != 1\n", ret); assert_equal(ret, 1, "Unreadable write ret %d != 1\n", ret);
ret = close(fd); ret = close(fd);
assert_zero(ret, "Unreadable close(%s) != 0(%d: %s)\n", filename, errno, strerror(errno)); assert_zero(ret, "Unreadable close(%s) != 0(%d: %s)\n", filename, errno, strerror(errno));
+9 -9
View File
@@ -1182,7 +1182,7 @@ int testUtilModulesDump(const struct zint_symbol *symbol, char dump[], int dump_
return -1; return -1;
} }
*d = '\0'; *d = '\0';
return d - dump; return (int) (d - dump);
} }
/* Print out module dump (for generate tests) */ /* Print out module dump (for generate tests) */
@@ -1492,24 +1492,24 @@ int testUtilDataPath(char *buffer, int buffer_size, const char *subdir, const ch
s = s2; s = s2;
} }
*s = '\0'; *s = '\0';
len = s - buffer; len = (int) (s - buffer);
} }
if ((s = strstr(buffer, "/backend")) != NULL) { if ((s = strstr(buffer, "/backend")) != NULL) {
while ((s2 = strstr(s + 1, "/backend")) != NULL) { /* Find rightmost */ while ((s2 = strstr(s + 1, "/backend")) != NULL) { /* Find rightmost */
s = s2; s = s2;
} }
*s = '\0'; *s = '\0';
len = s - buffer; len = (int) (s - buffer);
} else if ((s = strstr(buffer, "/frontend")) != NULL) { } else if ((s = strstr(buffer, "/frontend")) != NULL) {
while ((s2 = strstr(s + 1, "/frontend")) != NULL) { /* Find rightmost */ while ((s2 = strstr(s + 1, "/frontend")) != NULL) { /* Find rightmost */
s = s2; s = s2;
} }
*s = '\0'; *s = '\0';
len = s - buffer; len = (int) (s - buffer);
} }
if (cmake_src_dir == NULL && (s = strrchr(buffer, '/')) != NULL) { /* Remove "build" dir */ if (cmake_src_dir == NULL && (s = strrchr(buffer, '/')) != NULL) { /* Remove "build" dir */
*s = '\0'; *s = '\0';
len = s - buffer; len = (int) (s - buffer);
} }
if (subdir_len) { if (subdir_len) {
@@ -2196,7 +2196,7 @@ int testUtilVerifyLibreOffice(const char *filename, int debug) {
return -1; return -1;
} }
while (!feof(fp) && b < be) { while (!feof(fp) && b < be) {
if (fgets(b, be - b, fp) == NULL) { if (fgets(b, (int) (be - b), fp) == NULL) {
fprintf(stderr, "testUtilVerifyLibreOffice: failed to get line from '%s' (%s)\n", svg, cmd); fprintf(stderr, "testUtilVerifyLibreOffice: failed to get line from '%s' (%s)\n", svg, cmd);
fclose(fp); fclose(fp);
return -1; return -1;
@@ -2642,7 +2642,7 @@ static char *testUtilBwippCvtGS1Data(char *bwipp_data, const int bwipp_data_size
*b = ')'; *b = ')';
} else if ((*c == '+' || *c == ' ') && upcean && !pipe) { } else if ((*c == '+' || *c == ' ') && upcean && !pipe) {
*b = ' '; *b = ' ';
*addon_posn = b - bwipp_data; *addon_posn = (int) (b - bwipp_data);
} else { } else {
*b = *c; *b = *c;
} }
@@ -3780,7 +3780,7 @@ int testUtilBwippSegs(int index, struct zint_symbol *symbol, int option_1, int o
d += local_segs[i].length; d += local_segs[i].length;
} }
} }
total_len = d - data; total_len = (int) (d - data);
if (unicode_mode) { if (unicode_mode) {
symbol->input_mode = DATA_MODE; symbol->input_mode = DATA_MODE;
@@ -4273,7 +4273,7 @@ static int textUtilZXingCPPDX(const char *expected, const int expected_len, cons
static int textUtilZXingCPPEAN13AddOn(const char *expected, const int expected_len, char *out) { static int textUtilZXingCPPEAN13AddOn(const char *expected, const int expected_len, char *out) {
char *sep; char *sep;
if ((sep = strchr(expected, '+')) != NULL || (sep = strchr(expected, ' ')) != NULL) { if ((sep = strchr(expected, '+')) != NULL || (sep = strchr(expected, ' ')) != NULL) {
const int addon_len = expected_len - (sep + 1 - expected); const int addon_len = expected_len - (int) (sep + 1 - expected);
if (addon_len <= 2) { if (addon_len <= 2) {
memset(out + 13, '0', 2 - addon_len); memset(out + 13, '0', 2 - addon_len);
memcpy(out + 13 + (2 - addon_len), sep + 1, addon_len); memcpy(out + 13 + (2 - addon_len), sep + 1, addon_len);
+2 -2
View File
@@ -1,7 +1,7 @@
/* tif.c - Aldus Tagged Image File Format support */ /* tif.c - Aldus Tagged Image File Format support */
/* /*
libzint - the open source barcode library libzint - the open source barcode library
Copyright (C) 2016-2025 Robin Stuart <rstuart114@gmail.com> Copyright (C) 2016-2026 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions modification, are permitted provided that the following conditions
@@ -376,7 +376,7 @@ INTERNAL int zint_tif_pixel_plot(struct zint_symbol *symbol, const unsigned char
(void) zint_fm_close(fmp, symbol); (void) zint_fm_close(fmp, symbol);
return z_errtxt(ZINT_ERROR_MEMORY, symbol, 673, "Insufficient memory for TIF LZW hash table"); return z_errtxt(ZINT_ERROR_MEMORY, symbol, 673, "Insufficient memory for TIF LZW hash table");
} }
bytes_put = zint_fm_tell(fmp) - file_pos; bytes_put = (unsigned int) (zint_fm_tell(fmp) - file_pos);
if (bytes_put != strip_bytes[strip]) { if (bytes_put != strip_bytes[strip]) {
const int diff = bytes_put - strip_bytes[strip]; const int diff = bytes_put - strip_bytes[strip];
strip_bytes[strip] = bytes_put; strip_bytes[strip] = bytes_put;