diff --git a/backend/dotcode.c b/backend/dotcode.c index da16ced5..5a2d5f5d 100644 --- a/backend/dotcode.c +++ b/backend/dotcode.c @@ -455,7 +455,7 @@ static int dotcode_encode_message(struct zint_symbol *symbol, const unsigned cha int input_position, array_length, i; char encoding_mode; int inside_macro; - int debug = symbol->debug; + int debug = (symbol->debug & ZINT_DEBUG_PRINT); int binary_buffer_size = 0; int lawrencium[6]; // Reversed radix 103 values diff --git a/backend/eci.c b/backend/eci.c index 73c4bf80..42277904 100644 --- a/backend/eci.c +++ b/backend/eci.c @@ -1,7 +1,7 @@ /* eci.c - Extended Channel Interpretations libzint - the open source barcode library - Copyright (C) 2009-2017 Robin Stuart + Copyright (C) 2009 - 2020 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -32,7 +32,6 @@ #include #include -#include #include "eci.h" #include "common.h" #ifdef _MSC_VER @@ -70,7 +69,7 @@ INTERNAL int utf_to_eci(const int eci, const unsigned char source[], unsigned ch bytelen = 2; glyph = (source[in_posn] & 0x1f) << 6; - if (*length < (in_posn + 2)) { + if ((int) *length < (in_posn + 2)) { return ZINT_ERROR_INVALID_DATA; } @@ -86,11 +85,11 @@ INTERNAL int utf_to_eci(const int eci, const unsigned char source[], unsigned ch bytelen = 3; glyph = (source[in_posn] & 0x0f) << 12; - if (*length < (in_posn + 2)) { + if ((int) *length < (in_posn + 2)) { return ZINT_ERROR_INVALID_DATA; } - if (*length < (in_posn + 3)) { + if ((int) *length < (in_posn + 3)) { return ZINT_ERROR_INVALID_DATA; } @@ -246,7 +245,7 @@ INTERNAL int utf_to_eci(const int eci, const unsigned char source[], unsigned ch in_posn += bytelen; out_posn++; - } while (in_posn < *length); + } while (in_posn < (int) *length); dest[out_posn] = '\0'; *length = out_posn; diff --git a/backend/emf.c b/backend/emf.c index 3f0a7638..50aa9e66 100644 --- a/backend/emf.c +++ b/backend/emf.c @@ -1,7 +1,7 @@ /* emf.c - Support for Microsoft Enhanced Metafile Format libzint - the open source barcode library - Copyright (C) 2016-2018 Robin Stuart + Copyright (C) 2016 - 2020 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -181,10 +181,10 @@ INTERNAL int emf_plot(struct zint_symbol *symbol) { string_count = count_strings(symbol); #ifndef _MSC_VER - emr_rectangle_t rectangle[rectangle_count]; - emr_ellipse_t circle[circle_count]; - emr_polygon_t hexagon[hexagon_count]; - emr_exttextoutw_t text[string_count]; + emr_rectangle_t rectangle[rectangle_count ? rectangle_count : 1]; // Avoid sanitize runtime error by making always non-zero + emr_ellipse_t circle[circle_count ? circle_count : 1]; + emr_polygon_t hexagon[hexagon_count ? hexagon_count : 1]; + emr_exttextoutw_t text[string_count ? string_count: 1]; #else rectangle = (emr_rectangle_t*) _alloca(rectangle_count * sizeof (emr_rectangle_t)); circle = (emr_ellipse_t*) _alloca(circle_count * sizeof (emr_ellipse_t)); @@ -509,6 +509,7 @@ INTERNAL int emf_plot(struct zint_symbol *symbol) { fwrite(&emr_selectobject_font, sizeof (emr_selectobject_t), 1, emf_file); fwrite(&text[i], sizeof (emr_exttextoutw_t), 1, emf_file); fwrite(this_string[i], bump_up(text[i].w_emr_text.chars + 1) * 2, 1, emf_file); + free(this_string[i]); for (j = 0; j < bump_up(text[i].w_emr_text.chars + 1); j++) { fwrite(&spacing, 4, 1, emf_file); } diff --git a/backend/gs1.c b/backend/gs1.c index 469f1c60..9e7b4ba6 100644 --- a/backend/gs1.c +++ b/backend/gs1.c @@ -2,7 +2,7 @@ /* libzint - the open source barcode library - Copyright (C) 2009-2017 Robin Stuart + Copyright (C) 2009 - 2020 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -32,7 +32,6 @@ /* vim: set ts=4 sw=4 et : */ #include -#include #include #ifdef _MSC_VER #include @@ -93,7 +92,7 @@ INTERNAL int gs1_verify(struct zint_symbol *symbol, const unsigned char source[] #endif /* Detect extended ASCII characters */ - for (i = 0; i < src_len; i++) { + for (i = 0; i < (int) src_len; i++) { if (source[i] >= 128) { strcpy(symbol->errtxt, "250: Extended ASCII characters are not supported by GS1"); return ZINT_ERROR_INVALID_DATA; @@ -121,7 +120,7 @@ INTERNAL int gs1_verify(struct zint_symbol *symbol, const unsigned char source[] min_ai_length = 5; j = 0; ai_latch = 0; - for (i = 0; i < src_len; i++) { + for (i = 0; i < (int) src_len; i++) { ai_length += j; if (((j == 1) && (source[i] != ']')) && ((source[i] < '0') || (source[i] > '9'))) { ai_latch = 1; @@ -178,7 +177,7 @@ INTERNAL int gs1_verify(struct zint_symbol *symbol, const unsigned char source[] } ai_count = 0; - for (i = 1; i < src_len; i++) { + for (i = 1; i < (int) src_len; i++) { if (source[i - 1] == '[') { ai_location[ai_count] = i; j = 0; @@ -203,7 +202,7 @@ INTERNAL int gs1_verify(struct zint_symbol *symbol, const unsigned char source[] data_length[i] = 0; do { data_length[i]++; - } while ((source[data_location[i] + data_length[i] - 1] != '[') && (data_location[i] + data_length[i] <= src_len)); + } while ((source[data_location[i] + data_length[i] - 1] != '[') && (data_location[i] + data_length[i] <= (int) src_len)); data_length[i]--; } @@ -662,7 +661,7 @@ INTERNAL int gs1_verify(struct zint_symbol *symbol, const unsigned char source[] j = 0; last_ai = 0; ai_latch = 1; - for (i = 0; i < src_len; i++) { + for (i = 0; i < (int) src_len; i++) { if ((source[i] != '[') && (source[i] != ']')) { reduced[j++] = source[i]; } diff --git a/backend/reedsol.c b/backend/reedsol.c index fb5273f7..6d908e48 100644 --- a/backend/reedsol.c +++ b/backend/reedsol.c @@ -124,11 +124,11 @@ INTERNAL void rs_init_code(const int nsym, int index) { } } -INTERNAL void rs_encode(const size_t len,const unsigned char *data, unsigned char *res) { +INTERNAL void rs_encode(const size_t len, const unsigned char *data, unsigned char *res) { int i, k; for (i = 0; i < rlen; i++) res[i] = 0; - for (i = 0; i < len; i++) { + for (i = 0; i < (int) len; i++) { int m = res[rlen - 1] ^ data[i]; for (k = rlen - 1; k > 0; k--) { if (m && rspoly[k]) diff --git a/backend/svg.c b/backend/svg.c index 2d1e9ffa..35d5b526 100644 --- a/backend/svg.c +++ b/backend/svg.c @@ -2,7 +2,7 @@ /* libzint - the open source barcode library - Copyright (C) 2009-2019 Robin Stuart + Copyright (C) 2009 - 2020 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -33,7 +33,6 @@ #include #include -#include #include #include #ifdef _MSC_VER @@ -50,7 +49,7 @@ static void make_html_friendly(unsigned char * string, char * html_version) { html_pos = 0; html_version[html_pos] = '\0'; - for (i = 0; i < ustrlen(string); i++) { + for (i = 0; i < (int) ustrlen(string); i++) { switch(string[i]) { case '>': strcat(html_version, ">"); @@ -105,7 +104,7 @@ INTERNAL int svg_plot(struct zint_symbol *symbol) { int html_len = strlen((char *)symbol->text) + 1; - for (i = 0; i < strlen((char *)symbol->text); i++) { + for (i = 0; i < (int) strlen((char *)symbol->text); i++) { switch(symbol->text[i]) { case '>': case '<': diff --git a/backend/tests/CMakeLists.txt b/backend/tests/CMakeLists.txt index a6858590..2d408e1a 100644 --- a/backend/tests/CMakeLists.txt +++ b/backend/tests/CMakeLists.txt @@ -73,6 +73,7 @@ zint_add_test(maxicode, test_maxicode) zint_add_test(pdf417, test_pdf417) zint_add_test(png, test_png) zint_add_test(postal, test_postal) +zint_add_test(print, test_print) zint_add_test(qr, test_qr) zint_add_test(raster, test_raster) zint_add_test(rss, test_rss) diff --git a/backend/tests/data/print/bmp/code128_aim.bmp b/backend/tests/data/print/bmp/code128_aim.bmp new file mode 100644 index 00000000..61b0206e Binary files /dev/null and b/backend/tests/data/print/bmp/code128_aim.bmp differ diff --git a/backend/tests/data/print/bmp/dotcode_aim_fig7.bmp b/backend/tests/data/print/bmp/dotcode_aim_fig7.bmp new file mode 100644 index 00000000..d67bd14f Binary files /dev/null and b/backend/tests/data/print/bmp/dotcode_aim_fig7.bmp differ diff --git a/backend/tests/data/print/bmp/qr_v1_m.bmp b/backend/tests/data/print/bmp/qr_v1_m.bmp new file mode 100644 index 00000000..731d8d5a Binary files /dev/null and b/backend/tests/data/print/bmp/qr_v1_m.bmp differ diff --git a/backend/tests/data/print/emf/code128_aim.emf b/backend/tests/data/print/emf/code128_aim.emf new file mode 100644 index 00000000..f1aa5a16 Binary files /dev/null and b/backend/tests/data/print/emf/code128_aim.emf differ diff --git a/backend/tests/data/print/emf/dotcode_aim_fig7.emf b/backend/tests/data/print/emf/dotcode_aim_fig7.emf new file mode 100644 index 00000000..a836388f Binary files /dev/null and b/backend/tests/data/print/emf/dotcode_aim_fig7.emf differ diff --git a/backend/tests/data/print/emf/qr_v1_m.emf b/backend/tests/data/print/emf/qr_v1_m.emf new file mode 100644 index 00000000..ab2e90c6 Binary files /dev/null and b/backend/tests/data/print/emf/qr_v1_m.emf differ diff --git a/backend/tests/data/print/eps/code128_aim.eps b/backend/tests/data/print/eps/code128_aim.eps new file mode 100644 index 00000000..5d65ec70 --- /dev/null +++ b/backend/tests/data/print/eps/code128_aim.eps @@ -0,0 +1,64 @@ +%!PS-Adobe-3.0 EPSF-3.0 +%%Creator: Zint 2.7.1 +%%Title: Zint Generated Symbol +%%Pages: 0 +%%BoundingBox: 0 0 136 118 +%%EndComments +/TL { setlinewidth moveto lineto stroke } bind def +/TD { newpath 0 360 arc fill } bind def +/TH { 0 setlinewidth moveto lineto lineto lineto lineto lineto closepath fill } bind def +/TB { 2 copy } bind def +/TR { newpath 4 1 roll exch moveto 1 index 0 rlineto 0 exch rlineto neg 0 rlineto closepath fill } bind def +/TE { pop pop } bind def +newpath +1.00 1.00 1.00 setrgbcolor +118.00 0.00 TB 0.00 136.00 TR +TE +0.00 0.00 0.00 setrgbcolor +100.00 18.00 TB 0.00 4.00 TR +TE +100.00 18.00 TB 6.00 2.00 TR +TE +100.00 18.00 TB 12.00 2.00 TR +TE +100.00 18.00 TB 22.00 2.00 TR +TE +100.00 18.00 TB 26.00 2.00 TR +TE +100.00 18.00 TB 34.00 4.00 TR +TE +100.00 18.00 TB 44.00 4.00 TR +TE +100.00 18.00 TB 54.00 2.00 TR +TE +100.00 18.00 TB 62.00 2.00 TR +TE +100.00 18.00 TB 66.00 2.00 TR +TE +100.00 18.00 TB 70.00 6.00 TR +TE +100.00 18.00 TB 78.00 4.00 TR +TE +100.00 18.00 TB 88.00 2.00 TR +TE +100.00 18.00 TB 92.00 6.00 TR +TE +100.00 18.00 TB 100.00 4.00 TR +TE +100.00 18.00 TB 110.00 4.00 TR +TE +100.00 18.00 TB 120.00 6.00 TR +TE +100.00 18.00 TB 128.00 2.00 TR +TE +100.00 18.00 TB 132.00 4.00 TR +TE +matrix currentmatrix +/Helvetica findfont +18.00 scalefont setfont + 0 0 moveto 68.00 0.00 translate 0.00 rotate 0 0 moveto + (AIM) stringwidth +pop +-2 div 0 rmoveto + (AIM) show +setmatrix diff --git a/backend/tests/data/print/eps/dotcode_aim_fig7.eps b/backend/tests/data/print/eps/dotcode_aim_fig7.eps new file mode 100644 index 00000000..af59ba97 --- /dev/null +++ b/backend/tests/data/print/eps/dotcode_aim_fig7.eps @@ -0,0 +1,56 @@ +%!PS-Adobe-3.0 EPSF-3.0 +%%Creator: Zint 2.7.1 +%%Title: Zint Generated Symbol +%%Pages: 0 +%%BoundingBox: 0 0 26 20 +%%EndComments +/TL { setlinewidth moveto lineto stroke } bind def +/TD { newpath 0 360 arc fill } bind def +/TH { 0 setlinewidth moveto lineto lineto lineto lineto lineto closepath fill } bind def +/TB { 2 copy } bind def +/TR { newpath 4 1 roll exch moveto 1 index 0 rlineto 0 exch rlineto neg 0 rlineto closepath fill } bind def +/TE { pop pop } bind def +newpath +1.00 1.00 1.00 setrgbcolor +20.00 0.00 TB 0.00 26.00 TR +TE +0.00 0.00 0.00 setrgbcolor +1.00 19.00 1.00 TD +5.00 19.00 1.00 TD +13.00 19.00 1.00 TD +17.00 19.00 1.00 TD +21.00 19.00 1.00 TD +25.00 19.00 1.00 TD +7.00 17.00 1.00 TD +1.00 15.00 1.00 TD +9.00 15.00 1.00 TD +17.00 15.00 1.00 TD +21.00 15.00 1.00 TD +25.00 15.00 1.00 TD +3.00 13.00 1.00 TD +15.00 13.00 1.00 TD +19.00 13.00 1.00 TD +9.00 11.00 1.00 TD +13.00 11.00 1.00 TD +21.00 11.00 1.00 TD +3.00 9.00 1.00 TD +11.00 9.00 1.00 TD +23.00 9.00 1.00 TD +1.00 7.00 1.00 TD +9.00 7.00 1.00 TD +13.00 7.00 1.00 TD +17.00 7.00 1.00 TD +25.00 7.00 1.00 TD +3.00 5.00 1.00 TD +7.00 5.00 1.00 TD +11.00 5.00 1.00 TD +19.00 5.00 1.00 TD +1.00 3.00 1.00 TD +9.00 3.00 1.00 TD +17.00 3.00 1.00 TD +21.00 3.00 1.00 TD +25.00 3.00 1.00 TD +3.00 1.00 1.00 TD +7.00 1.00 1.00 TD +15.00 1.00 1.00 TD +23.00 1.00 1.00 TD diff --git a/backend/tests/data/print/eps/qr_v1_m.eps b/backend/tests/data/print/eps/qr_v1_m.eps new file mode 100644 index 00000000..361fae1a --- /dev/null +++ b/backend/tests/data/print/eps/qr_v1_m.eps @@ -0,0 +1,181 @@ +%!PS-Adobe-3.0 EPSF-3.0 +%%Creator: Zint 2.7.1 +%%Title: Zint Generated Symbol +%%Pages: 0 +%%BoundingBox: 0 0 42 42 +%%EndComments +/TL { setlinewidth moveto lineto stroke } bind def +/TD { newpath 0 360 arc fill } bind def +/TH { 0 setlinewidth moveto lineto lineto lineto lineto lineto closepath fill } bind def +/TB { 2 copy } bind def +/TR { newpath 4 1 roll exch moveto 1 index 0 rlineto 0 exch rlineto neg 0 rlineto closepath fill } bind def +/TE { pop pop } bind def +newpath +1.00 1.00 1.00 setrgbcolor +42.00 0.00 TB 0.00 42.00 TR +TE +0.00 0.00 0.00 setrgbcolor +2.00 40.00 TB 0.00 14.00 TR +TE +2.00 40.00 TB 18.00 2.00 TR +TE +2.00 40.00 TB 24.00 2.00 TR +TE +2.00 40.00 TB 28.00 14.00 TR +TE +10.00 30.00 TB 0.00 2.00 TR +TE +10.00 30.00 TB 12.00 2.00 TR +TE +2.00 38.00 TB 16.00 2.00 TR +TE +2.00 38.00 TB 22.00 4.00 TR +TE +10.00 30.00 TB 28.00 2.00 TR +TE +10.00 30.00 TB 40.00 2.00 TR +TE +6.00 32.00 TB 4.00 6.00 TR +TE +2.00 36.00 TB 18.00 2.00 TR +TE +6.00 32.00 TB 32.00 6.00 TR +TE +8.00 28.00 TB 24.00 2.00 TR +TE +2.00 32.00 TB 16.00 4.00 TR +TE +2.00 28.00 TB 0.00 14.00 TR +TE +2.00 28.00 TB 16.00 2.00 TR +TE +2.00 28.00 TB 20.00 2.00 TR +TE +2.00 28.00 TB 28.00 14.00 TR +TE +2.00 26.00 TB 18.00 2.00 TR +TE +2.00 26.00 TB 22.00 4.00 TR +TE +2.00 24.00 TB 0.00 2.00 TR +TE +2.00 24.00 TB 4.00 2.00 TR +TE +2.00 24.00 TB 8.00 2.00 TR +TE +2.00 24.00 TB 12.00 2.00 TR +TE +2.00 24.00 TB 18.00 6.00 TR +TE +2.00 24.00 TB 32.00 2.00 TR +TE +2.00 24.00 TB 38.00 2.00 TR +TE +2.00 22.00 TB 0.00 12.00 TR +TE +2.00 22.00 TB 14.00 4.00 TR +TE +2.00 22.00 TB 20.00 2.00 TR +TE +2.00 22.00 TB 28.00 2.00 TR +TE +2.00 22.00 TB 40.00 2.00 TR +TE +6.00 16.00 TB 0.00 2.00 TR +TE +2.00 20.00 TB 4.00 14.00 TR +TE +2.00 20.00 TB 24.00 2.00 TR +TE +2.00 20.00 TB 32.00 4.00 TR +TE +4.00 16.00 TB 8.00 2.00 TR +TE +4.00 16.00 TB 28.00 2.00 TR +TE +2.00 18.00 TB 34.00 2.00 TR +TE +2.00 18.00 TB 40.00 2.00 TR +TE +2.00 16.00 TB 12.00 2.00 TR +TE +2.00 16.00 TB 24.00 2.00 TR +TE +2.00 16.00 TB 32.00 2.00 TR +TE +2.00 16.00 TB 38.00 4.00 TR +TE +2.00 14.00 TB 16.00 8.00 TR +TE +2.00 14.00 TB 26.00 2.00 TR +TE +2.00 14.00 TB 30.00 2.00 TR +TE +4.00 12.00 TB 34.00 2.00 TR +TE +2.00 14.00 TB 38.00 2.00 TR +TE +2.00 12.00 TB 0.00 14.00 TR +TE +2.00 12.00 TB 20.00 4.00 TR +TE +2.00 12.00 TB 26.00 6.00 TR +TE +10.00 2.00 TB 0.00 2.00 TR +TE +10.00 2.00 TB 12.00 2.00 TR +TE +2.00 10.00 TB 18.00 2.00 TR +TE +2.00 10.00 TB 22.00 6.00 TR +TE +2.00 10.00 TB 30.00 6.00 TR +TE +2.00 10.00 TB 38.00 4.00 TR +TE +6.00 4.00 TB 4.00 6.00 TR +TE +2.00 8.00 TB 16.00 2.00 TR +TE +2.00 8.00 TB 20.00 4.00 TR +TE +2.00 8.00 TB 26.00 6.00 TR +TE +2.00 8.00 TB 34.00 4.00 TR +TE +2.00 8.00 TB 40.00 2.00 TR +TE +2.00 6.00 TB 20.00 2.00 TR +TE +2.00 6.00 TB 28.00 4.00 TR +TE +2.00 6.00 TB 38.00 2.00 TR +TE +2.00 4.00 TB 16.00 2.00 TR +TE +2.00 4.00 TB 24.00 2.00 TR +TE +2.00 4.00 TB 32.00 6.00 TR +TE +2.00 4.00 TB 40.00 2.00 TR +TE +2.00 2.00 TB 18.00 2.00 TR +TE +2.00 2.00 TB 28.00 4.00 TR +TE +2.00 2.00 TB 34.00 2.00 TR +TE +2.00 0.00 TB 0.00 14.00 TR +TE +2.00 0.00 TB 16.00 6.00 TR +TE +2.00 0.00 TB 24.00 2.00 TR +TE +2.00 0.00 TB 28.00 2.00 TR +TE +2.00 0.00 TB 32.00 2.00 TR +TE +2.00 0.00 TB 36.00 2.00 TR +TE +2.00 0.00 TB 40.00 2.00 TR +TE diff --git a/backend/tests/data/print/gif/code128_aim.gif b/backend/tests/data/print/gif/code128_aim.gif new file mode 100644 index 00000000..e2f87bf9 Binary files /dev/null and b/backend/tests/data/print/gif/code128_aim.gif differ diff --git a/backend/tests/data/print/gif/dotcode_aim_fig7.gif b/backend/tests/data/print/gif/dotcode_aim_fig7.gif new file mode 100644 index 00000000..a61fee6a Binary files /dev/null and b/backend/tests/data/print/gif/dotcode_aim_fig7.gif differ diff --git a/backend/tests/data/print/gif/qr_v1_m.gif b/backend/tests/data/print/gif/qr_v1_m.gif new file mode 100644 index 00000000..2d3b5d6e Binary files /dev/null and b/backend/tests/data/print/gif/qr_v1_m.gif differ diff --git a/backend/tests/data/print/pcx/code128_aim.pcx b/backend/tests/data/print/pcx/code128_aim.pcx new file mode 100644 index 00000000..0050e1ea Binary files /dev/null and b/backend/tests/data/print/pcx/code128_aim.pcx differ diff --git a/backend/tests/data/print/pcx/dotcode_aim_fig7.pcx b/backend/tests/data/print/pcx/dotcode_aim_fig7.pcx new file mode 100644 index 00000000..dc3efc8e Binary files /dev/null and b/backend/tests/data/print/pcx/dotcode_aim_fig7.pcx differ diff --git a/backend/tests/data/print/pcx/qr_v1_m.pcx b/backend/tests/data/print/pcx/qr_v1_m.pcx new file mode 100644 index 00000000..79338148 Binary files /dev/null and b/backend/tests/data/print/pcx/qr_v1_m.pcx differ diff --git a/backend/tests/data/png/code128_aim.png b/backend/tests/data/print/png/code128_aim.png similarity index 100% rename from backend/tests/data/png/code128_aim.png rename to backend/tests/data/print/png/code128_aim.png diff --git a/backend/tests/data/print/png/dotcode_aim_fig7.png b/backend/tests/data/print/png/dotcode_aim_fig7.png new file mode 100644 index 00000000..3d7b7119 Binary files /dev/null and b/backend/tests/data/print/png/dotcode_aim_fig7.png differ diff --git a/backend/tests/data/print/png/qr_v1_m.png b/backend/tests/data/print/png/qr_v1_m.png new file mode 100644 index 00000000..0892287b Binary files /dev/null and b/backend/tests/data/print/png/qr_v1_m.png differ diff --git a/backend/tests/data/print/svg/code128_aim.svg b/backend/tests/data/print/svg/code128_aim.svg new file mode 100644 index 00000000..c552746e --- /dev/null +++ b/backend/tests/data/print/svg/code128_aim.svg @@ -0,0 +1,35 @@ + + + + Zint Generated Symbol + + + + + + + + + + + + + + + + + + + + + + + + + AIM + + + diff --git a/backend/tests/data/print/svg/dotcode_aim_fig7.svg b/backend/tests/data/print/svg/dotcode_aim_fig7.svg new file mode 100644 index 00000000..f07c2d59 --- /dev/null +++ b/backend/tests/data/print/svg/dotcode_aim_fig7.svg @@ -0,0 +1,51 @@ + + + + Zint Generated Symbol + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/backend/tests/data/print/svg/qr_v1_m.svg b/backend/tests/data/print/svg/qr_v1_m.svg new file mode 100644 index 00000000..41a6e3c9 --- /dev/null +++ b/backend/tests/data/print/svg/qr_v1_m.svg @@ -0,0 +1,94 @@ + + + + Zint Generated Symbol + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/backend/tests/data/print/tif/code128_aim.tif b/backend/tests/data/print/tif/code128_aim.tif new file mode 100644 index 00000000..17820791 Binary files /dev/null and b/backend/tests/data/print/tif/code128_aim.tif differ diff --git a/backend/tests/data/print/tif/dotcode_aim_fig7.tif b/backend/tests/data/print/tif/dotcode_aim_fig7.tif new file mode 100644 index 00000000..680d1bda Binary files /dev/null and b/backend/tests/data/print/tif/dotcode_aim_fig7.tif differ diff --git a/backend/tests/data/print/tif/qr_v1_m.tif b/backend/tests/data/print/tif/qr_v1_m.tif new file mode 100644 index 00000000..1c54d936 Binary files /dev/null and b/backend/tests/data/print/tif/qr_v1_m.tif differ diff --git a/backend/tests/data/print/txt/code128_aim.txt b/backend/tests/data/print/txt/code128_aim.txt new file mode 100644 index 00000000..e0349487 --- /dev/null +++ b/backend/tests/data/print/txt/code128_aim.txt @@ -0,0 +1 @@ +D2 14 63 11 5D 8B B1 8E B diff --git a/backend/tests/data/print/txt/dotcode_aim_fig7.txt b/backend/tests/data/print/txt/dotcode_aim_fig7.txt new file mode 100644 index 00000000..4a367cbc --- /dev/null +++ b/backend/tests/data/print/txt/dotcode_aim_fig7.txt @@ -0,0 +1,10 @@ +A2 A8 +10 00 +88 A8 +41 40 +0A 20 +44 10 +8A 88 +54 40 +88 A8 +51 10 diff --git a/backend/tests/data/print/txt/qr_v1_m.txt b/backend/tests/data/print/txt/qr_v1_m.txt new file mode 100644 index 00000000..5b7bec81 --- /dev/null +++ b/backend/tests/data/print/txt/qr_v1_m.txt @@ -0,0 +1,21 @@ +FE 4B F8 +82 9A 08 +BA 42 E8 +BA 0A E8 +BA CA E8 +82 0A 08 +FE AB F8 +00 58 00 +AA 70 90 +FD A2 08 +BF 88 C0 +88 02 48 +8A 0A 98 +00 F5 50 +FE 37 40 +82 5D D8 +BA B7 68 +BA 23 10 +BA 88 E8 +82 43 40 +FE EA A8 diff --git a/backend/tests/test_code128.c b/backend/tests/test_code128.c index 7534d285..081bde9b 100644 --- a/backend/tests/test_code128.c +++ b/backend/tests/test_code128.c @@ -52,8 +52,9 @@ static void test_input(void) /* 2*/ { BARCODE_CODE128, UNICODE_MODE, "éAéAéAéAéAéAéAéAéAéAéAéAéAéAéAéAéAéAéAé", -1, 0 }, // 39 chars /* 3*/ { BARCODE_CODE128, UNICODE_MODE, "éAéAéAéAéAéAéAéAéAéAéAéAéAéAéAéAéAéAéAéA", -1, ZINT_ERROR_TOO_LONG }, // 40 chars (+ 20 shifts) /* 4*/ { BARCODE_CODE128, UNICODE_MODE, "\302\200", -1, ZINT_ERROR_INVALID_DATA }, // PAD U+0080, not in ISO 8859-1 although encodable in CODE128 - /* 5*/ { BARCODE_CODE128, UNICODE_MODE, "\000\037é", 4, 0 }, - /* 6*/ { BARCODE_CODE128B, UNICODE_MODE, "\000\037é", 4, 0 }, + /* 5*/ { BARCODE_CODE128, DATA_MODE, "\302\200", -1, 0 }, // PAD U+0080, use binary + /* 6*/ { BARCODE_CODE128, UNICODE_MODE, "\000\037é", 4, 0 }, + /* 7*/ { BARCODE_CODE128B, UNICODE_MODE, "\000\037é", 4, 0 }, }; int data_size = sizeof(data) / sizeof(struct item); @@ -67,7 +68,7 @@ static void test_input(void) symbol->symbology = data[i].symbology; symbol->input_mode = data[i].input_mode; - int length = data[i].length == -1 ? strlen(data[i].data) : data[i].length; + int length = data[i].length == -1 ? (int) strlen(data[i].data) : data[i].length; ret = ZBarcode_Encode(symbol, data[i].data, length); assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt); diff --git a/backend/tests/test_common.c b/backend/tests/test_common.c index 8ca42a8f..94b6639d 100644 --- a/backend/tests/test_common.c +++ b/backend/tests/test_common.c @@ -1,6 +1,6 @@ /* libzint - the open source barcode library - Copyright (C) 2008-2019 Robin Stuart + Copyright (C) 2019 - 2020 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -60,15 +60,15 @@ static void test_utf8_to_unicode(void) for (int i = 0; i < data_size; i++) { - int length = data[i].length == -1 ? strlen(data[i].data) : data[i].length; + int length = data[i].length == -1 ? (int) strlen(data[i].data) : data[i].length; size_t ret_length = length; ret = utf8_to_unicode(&symbol, data[i].data, vals, &ret_length, data[i].disallow_4byte); assert_equal(ret, data[i].ret, "i:%d ret %d != %d\n", i, ret, data[i].ret); if (ret == 0) { assert_equal(ret_length, data[i].ret_length, "i:%d ret_length %ld != %ld\n", i, ret_length, data[i].ret_length); - for (int j = 0; j < ret_length; j++) { - assert_equal(vals[j], data[i].expected_vals[j], "i:%d vals[%d] %04X != %04X\n", i, j, vals[j], data[i].expected_vals[j]); + for (size_t j = 0; j < ret_length; j++) { + assert_equal(vals[j], data[i].expected_vals[j], "i:%d vals[%zu] %04X != %04X\n", i, j, vals[j], data[i].expected_vals[j]); } } } diff --git a/backend/tests/test_dotcode.c b/backend/tests/test_dotcode.c index 86d84f7e..d8ad0931 100644 --- a/backend/tests/test_dotcode.c +++ b/backend/tests/test_dotcode.c @@ -1,6 +1,6 @@ /* libzint - the open source barcode library - Copyright (C) 2008-2020 Robin Stuart + Copyright (C) 2019 - 2020 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -31,6 +31,85 @@ #include "testcommon.h" +#define TEST_ENCODE_GENERATE_EXPECTED 1 + +// TODO: Verify against AIM standard +static void test_encode(void) +{ + testStart(""); + + int ret; + struct item { + int input_mode; + int option_2; + unsigned char* data; + int ret; + + int expected_rows; + int expected_width; + char* comment; + char* expected; + }; + struct item data[] = { + /* 0*/ { UNICODE_MODE, -1, "2741", 0, 10, 13, "Verified manually againt bwipp (tec-it differs)", + "1010001010101" + "0001000000000" + "1000100010101" + "0100000101000" + "0000101000100" + "0100010000010" + "1000101010001" + "0101010001000" + "1000100010101" + "0101000100010" + }, + }; + int data_size = sizeof(data) / sizeof(struct item); + + char escaped[1024]; + + for (int i = 0; i < data_size; i++) { + + struct zint_symbol* symbol = ZBarcode_Create(); + assert_nonnull(symbol, "Symbol not created\n"); + + symbol->symbology = BARCODE_DOTCODE; + symbol->input_mode = data[i].input_mode; + if (data[i].option_2 != -1) { + symbol->option_2 = data[i].option_2; + } + symbol->debug = ZINT_DEBUG_PRINT; + + int length = strlen(data[i].data); + + ret = ZBarcode_Encode(symbol, data[i].data, length); + assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt); + + #ifdef TEST_ENCODE_GENERATE_EXPECTED + printf(" /*%3d*/ { %s, %d, \"%s\", %s, %d, %d, \"%s\",\n", + i, testUtilInputModeName(data[i].input_mode), data[i].option_2, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), + testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment); + testUtilModulesDump(symbol, " ", "\n"); + printf(" },\n"); + #else + if (ret < 5) { + assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data); + assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data); + + if (ret == 0) { + int width, row; + ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row); + assert_zero(ret, "i:%d testUtilModulesCmp ret %d != 0 width %d row %d (%s)\n", i, ret, width, row, data[i].data); + } + } + #endif + + ZBarcode_Delete(symbol); + } + + testFinish(); +} + // #181 Christian Hartlage / Nico Gunkel OSS-Fuzz static void test_fuzz(void) { @@ -95,6 +174,7 @@ static void test_fuzz(void) int main() { + test_encode(); test_fuzz(); testReport(); diff --git a/backend/tests/test_library.c b/backend/tests/test_library.c index d0528f27..695d315f 100644 --- a/backend/tests/test_library.c +++ b/backend/tests/test_library.c @@ -84,7 +84,7 @@ static void test_checks(void) if (data[i].dot_size != -1) { symbol->dot_size = data[i].dot_size; } - int length = data[i].length == -1 ? strlen(data[i].data) : data[i].length; + int length = data[i].length == -1 ? (int) strlen(data[i].data) : data[i].length; ret = ZBarcode_Encode(symbol, data[i].data, length); assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode(%d) ret %d != %d (%s)\n", i, data[i].symbology, ret, data[i].ret, symbol->errtxt); diff --git a/backend/tests/test_png.c b/backend/tests/test_png.c index 412d9aa5..52f643ae 100644 --- a/backend/tests/test_png.c +++ b/backend/tests/test_png.c @@ -47,8 +47,7 @@ static void test_print(void) char* expected_file; }; struct item data[] = { - /* 0*/ { BARCODE_CODE128, -1, -1, "AIM", "../data/png/code128_aim.png" }, - /* 1*/ { BARCODE_CODABLOCKF, 3, -1, "AAAAAAAAA", "../data/png/codablockf_3rows.png" }, + /* 0*/ { BARCODE_CODABLOCKF, 3, -1, "AAAAAAAAA", "../data/png/codablockf_3rows.png"}, }; int data_size = sizeof(data) / sizeof(struct item); @@ -88,13 +87,15 @@ static void test_print(void) #ifdef TEST_PRINT_GENERATE_EXPECTED - printf(" /*%2d*/ { %s, \"%s\", \"%s\"},\n", i, testUtilBarcodeName(data[i].symbology), testUtilEscape(data[i].data, length, escaped, escaped_size), data[i].expected_file); + printf(" /*%3d*/ { %s, %d, %d, \"%s\", \"%s\"},\n", + i, testUtilBarcodeName(data[i].symbology), data[i].option_1, data[i].option_2, testUtilEscape(data[i].data, length, escaped, escaped_size), data[i].expected_file); ret = rename(symbol->outfile, data[i].expected_file); assert_zero(ret, "i:%d rename(%s, %s) ret %d != 0\n", i, symbol->outfile, data[i].expected_file, ret); #else assert_nonzero(testUtilExists(symbol->outfile), "i:%d testUtilExists(%s) == 0\n", i, symbol->outfile); + assert_nonzero(testUtilExists(data[i].expected_file), "i:%d testUtilExists(%s) == 0\n", i, data[i].expected_file); ret = testUtilCmpPngs(symbol->outfile, data[i].expected_file); assert_zero(ret, "i:%d %s testUtilCmpPngs(%s, %s) %d != 0\n", i, testUtilBarcodeName(data[i].symbology), symbol->outfile, data[i].expected_file, ret); diff --git a/backend/tests/test_print.c b/backend/tests/test_print.c new file mode 100644 index 00000000..d92f899e --- /dev/null +++ b/backend/tests/test_print.c @@ -0,0 +1,167 @@ +/* + libzint - the open source barcode library + Copyright (C) 2020 Robin Stuart + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 3. Neither the name of the project nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + SUCH DAMAGE. + */ +/* vim: set ts=4 sw=4 et : */ + +#include "testcommon.h" +#include + +//#define TEST_PRINT_GENERATE_EXPECTED 1 + +static void test_print(void) +{ + testStart(""); + + int ret; + struct item { + int symbology; + int option_1; + int option_2; + unsigned char* data; + char* expected_file; + }; + struct item data[] = { + /* 0*/ { BARCODE_CODE128, -1, -1, "AIM", "code128_aim"}, + /* 1*/ { BARCODE_QRCODE, 2, 1, "1234567890", "qr_v1_m"}, + /* 2*/ { BARCODE_DOTCODE, -1, -1, "2741", "dotcode_aim_fig7"}, + }; + int data_size = sizeof(data) / sizeof(struct item); + + char* exts[] = { "bmp", "emf", "eps", "gif", "pcx", "png", "svg", "tif", "txt" }; + int exts_len = sizeof(exts) / sizeof(char*); + + char data_dir[1024]; + char expected_file[1024]; + + char escaped[1024]; + int escaped_size = 1024; + + #ifdef TEST_PRINT_GENERATE_EXPECTED + strcpy(data_dir, "../data"); + if (!testUtilExists(data_dir)) { + ret = mkdir(data_dir, 0755); + assert_zero(ret, "mkdir(%s) ret %d != 0\n", data_dir, ret); + } + strcat(data_dir, "/print"); + if (!testUtilExists(data_dir)) { + ret = mkdir(data_dir, 0755); + assert_zero(ret, "mkdir(%s) ret %d != 0\n", data_dir, ret); + } + #endif + + for (int j = 0; j < exts_len; j++) { + strcpy(data_dir, "../data/print/"); + strcat(data_dir, exts[j]); + + #ifdef TEST_PRINT_GENERATE_EXPECTED + if (!testUtilExists(data_dir)) { + ret = mkdir(data_dir, 0755); + assert_zero(ret, "mkdir(%s) ret %d != 0\n", data_dir, ret); + } + #endif + + for (int i = 0; i < data_size; i++) { + + struct zint_symbol* symbol = ZBarcode_Create(); + assert_nonnull(symbol, "Symbol not created\n"); + + symbol->symbology = data[i].symbology; + if (data[i].option_1 != -1) { + symbol->option_1 = data[i].option_1; + } + if (data[i].option_2 != -1) { + symbol->option_2 = data[i].option_2; + } + + int length = strlen(data[i].data); + + ret = ZBarcode_Encode(symbol, data[i].data, length); + assert_zero(ret, "i:%d %s ZBarcode_Encode ret %d != 0 %s\n", i, testUtilBarcodeName(data[i].symbology), ret, symbol->errtxt); + + strcpy(symbol->outfile, "out."); + strcat(symbol->outfile, exts[j]); + + strcpy(expected_file, data_dir); + strcat(expected_file, "/"); + strcat(expected_file, data[i].expected_file); + strcat(expected_file, "."); + strcat(expected_file, exts[j]); + + ret = ZBarcode_Print(symbol, 0); + assert_zero(ret, "i:%d j:%d %s %s ZBarcode_Print %s ret %d != 0\n", i, j, exts[j], testUtilBarcodeName(data[i].symbology), symbol->outfile, ret); + + #ifdef TEST_PRINT_GENERATE_EXPECTED + + if (j == 0) { + printf(" /*%3d*/ { %s, %d, %d, \"%s\", \"%s\"},\n", + i, testUtilBarcodeName(data[i].symbology), data[i].option_1, data[i].option_2, testUtilEscape(data[i].data, length, escaped, escaped_size), data[i].expected_file); + } + ret = rename(symbol->outfile, expected_file); + assert_zero(ret, "i:%d rename(%s, %s) ret %d != 0\n", i, symbol->outfile, expected_file, ret); + + #else + + assert_nonzero(testUtilExists(symbol->outfile), "i:%d j:%d %s testUtilExists(%s) == 0\n", i, j, exts[j], symbol->outfile); + + if (strcmp(exts[j], "eps") == 0) { + ret = testUtilCmpEpss(symbol->outfile, expected_file); + assert_zero(ret, "i:%d %s testUtilCmpEpss(%s, %s) %d != 0\n", i, testUtilBarcodeName(data[i].symbology), symbol->outfile, expected_file, ret); + } else if (strcmp(exts[j], "png") == 0) { + ret = testUtilCmpPngs(symbol->outfile, expected_file); + assert_zero(ret, "i:%d %s testUtilCmpPngs(%s, %s) %d != 0\n", i, testUtilBarcodeName(data[i].symbology), symbol->outfile, expected_file, ret); + } else if (strcmp(exts[j], "svg") == 0) { + ret = testUtilCmpSvgs(symbol->outfile, expected_file); + assert_zero(ret, "i:%d %s testUtilCmpSvgs(%s, %s) %d != 0\n", i, testUtilBarcodeName(data[i].symbology), symbol->outfile, expected_file, ret); + } else if (strcmp(exts[j], "txt") == 0) { + ret = testUtilCmpTxts(symbol->outfile, expected_file); + assert_zero(ret, "i:%d %s testUtilCmpTxts(%s, %s) %d != 0\n", i, testUtilBarcodeName(data[i].symbology), symbol->outfile, expected_file, ret); + } else { + ret = testUtilCmpBins(symbol->outfile, expected_file); + assert_zero(ret, "i:%d %s testUtilCmpBins(%s, %s) %d != 0\n", i, testUtilBarcodeName(data[i].symbology), symbol->outfile, expected_file, ret); + } + + assert_zero(remove(symbol->outfile), "i:%d remove(%s) != 0\n", i, symbol->outfile); + + #endif + + ZBarcode_Delete(symbol); + } + } + + testFinish(); +} + +int main() +{ + test_print(); + + testReport(); + + return 0; +} diff --git a/backend/tests/test_svg.c b/backend/tests/test_svg.c index 0e13dbe2..093327e2 100644 --- a/backend/tests/test_svg.c +++ b/backend/tests/test_svg.c @@ -47,8 +47,8 @@ static void test_print(void) char* expected_file; }; struct item data[] = { - /* 0*/ { BARCODE_CODE128, -1, -1, "<>\"&'", "../data/svg/code128_amperands.svg" }, - /* 1*/ { BARCODE_CODABLOCKF, 3, -1, "AAAAAAAAA", "../data/svg/codablockf_3rows.svg" }, + /* 0*/ { BARCODE_CODE128, -1, -1, "<>\"&'", "../data/svg/code128_amperands.svg" }, + /* 1*/ { BARCODE_CODABLOCKF, 3, -1, "AAAAAAAAA", "../data/svg/codablockf_3rows.svg"}, }; int data_size = sizeof(data) / sizeof(struct item); @@ -88,13 +88,15 @@ static void test_print(void) #ifdef TEST_PRINT_GENERATE_EXPECTED - printf(" /*%2d*/ { %s, \"%s\", \"%s\"},\n", i, testUtilBarcodeName(data[i].symbology), testUtilEscape(data[i].data, length, escaped, escaped_size), data[i].expected_file); + printf(" /*%3d*/ { %s, %d, %d, \"%s\", \"%s\"},\n", + i, testUtilBarcodeName(data[i].symbology), data[i].option_1, data[i].option_2, testUtilEscape(data[i].data, length, escaped, escaped_size), data[i].expected_file); ret = rename(symbol->outfile, data[i].expected_file); assert_zero(ret, "i:%d rename(%s, %s) ret %d != 0\n", i, symbol->outfile, data[i].expected_file, ret); #else assert_nonzero(testUtilExists(symbol->outfile), "i:%d testUtilExists(%s) == 0\n", i, symbol->outfile); + assert_nonzero(testUtilExists(data[i].expected_file), "i:%d testUtilExists(%s) == 0\n", i, data[i].expected_file); ret = testUtilCmpSvgs(symbol->outfile, data[i].expected_file); assert_zero(ret, "i:%d %s testUtilCmpSvgs(%s, %s) %d != 0\n", i, testUtilBarcodeName(data[i].symbology), symbol->outfile, data[i].expected_file, ret); diff --git a/backend/tests/testcommon.c b/backend/tests/testcommon.c index 50e3e78f..000772b1 100644 --- a/backend/tests/testcommon.c +++ b/backend/tests/testcommon.c @@ -1,6 +1,6 @@ /* libzint - the open source barcode library - Copyright (C) 2008-2019 Robin Stuart + Copyright (C) 2019 - 2020 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -33,8 +33,6 @@ * Copyright (C) 2006-2017 Kentaro Fukuchi */ -#include -#include #include "testcommon.h" #ifndef NO_PNG #include @@ -354,7 +352,7 @@ int testUtilDAFTConvert(const struct zint_symbol* symbol, char* buffer, int buff /* Is string valid UTF-8? */ int testUtilIsValidUTF8(const unsigned char str[], const size_t length) { - int i; + size_t i; unsigned int codepoint, state = 0; for (i = 0; i < length; i++) { @@ -954,7 +952,7 @@ int testUtilCmpPngs(char* png1, char* png2) return ret; } -static int testUtilCmpTxts(char* txt1, char* txt2) +int testUtilCmpTxts(char* txt1, char* txt2) { int ret = -1; FILE* fp1; @@ -1005,7 +1003,7 @@ static int testUtilCmpTxts(char* txt1, char* txt2) return ret; } -static int testUtilCmpBins(char* bin1, char* bin2) +int testUtilCmpBins(char* bin1, char* bin2) { int ret = -1; FILE* fp1; @@ -1114,23 +1112,3 @@ int testUtilCmpEpss(char* eps1, char* eps2) return ret; } - -int testUtilCmpEmfs(char* emf1, char* emf2) -{ - return testUtilCmpBins(emf1, emf2); -} - -int testUtilCmpGifs(char* gif1, char* gif2) -{ - return testUtilCmpBins(gif1, gif2); -} - -int testUtilCmpBmps(char* bmp1, char* bmp2) -{ - return testUtilCmpBins(bmp1, bmp2); -} - -int testUtilCmpPcxs(char* pcx1, char* pcx2) -{ - return testUtilCmpBins(pcx1, pcx2); -} diff --git a/backend/tests/testcommon.h b/backend/tests/testcommon.h index 276c3e1e..fb5655d8 100644 --- a/backend/tests/testcommon.h +++ b/backend/tests/testcommon.h @@ -1,6 +1,6 @@ /* libzint - the open source barcode library - Copyright (C) 2008-2019 Robin Stuart + Copyright (C) 2019 - 2020 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -79,11 +79,9 @@ int testUtilModulesCmp(const struct zint_symbol* symbol, const char* expected, i int testUtilModulesDumpHex(const struct zint_symbol* symbol, char dump[], int dump_size); int testUtilExists(char* filename); int testUtilCmpPngs(char* file1, char* file2); +int testUtilCmpTxts(char* txt1, char* txt2); +int testUtilCmpBins(char* bin1, char* bin2); int testUtilCmpSvgs(char* svg1, char* svg2); int testUtilCmpEpss(char* eps1, char* eps2); -int testUtilCmpEmfs(char* emf1, char* emf2); -int testUtilCmpGifs(char* gif1, char* gif2); -int testUtilCmpBmps(char* bmp1, char* bmp2); -int testUtilCmpPcxs(char* pcx1, char* pcx2); #endif /* TESTCOMMON_H */ diff --git a/backend/tif.c b/backend/tif.c index ff21a1cf..9c9afe36 100644 --- a/backend/tif.c +++ b/backend/tif.c @@ -2,7 +2,7 @@ /* libzint - the open source barcode library - Copyright (C) 2016-2017 Robin Stuart + Copyright (C) 2016 - 2020 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -32,7 +32,6 @@ /* vim: set ts=4 sw=4 et : */ #include -#include #include #include #include "common.h" @@ -47,8 +46,9 @@ INTERNAL int tif_pixel_plot(struct zint_symbol *symbol, char *pixelbuf) { int fgred, fggrn, fgblu, bgred, bggrn, bgblu; int i; int rows_per_strip, strip_count; - int free_memory; - int row, column, strip, bytes_put; + unsigned int free_memory; + int row, column, strip; + unsigned int bytes_put; FILE *tif_file; #ifdef _MSC_VER uint32_t* strip_offset; @@ -113,10 +113,6 @@ INTERNAL int tif_pixel_plot(struct zint_symbol *symbol, char *pixelbuf) { } if (free_memory > 0xffff0000) { -#ifdef _MSC_VER - free(strip_offset); - free(strip_bytes); -#endif strcpy(symbol->errtxt, "670: Output file size too big"); return ZINT_ERROR_MEMORY; }